From 0df2737e24a4150d43b39ecdcd98cf9742f09271 Mon Sep 17 00:00:00 2001 From: acondal Date: Wed, 11 Oct 2023 11:16:30 +0200 Subject: [PATCH] feat: use config utils in modules with state.config to enable using these mutations outside the modules EMP-2328 --- .../src/x-modules/empathize/store/module.ts | 4 +++- .../src/x-modules/empathize/store/types.ts | 6 ++++++ .../src/x-modules/history-queries/store/module.ts | 2 ++ .../src/x-modules/history-queries/store/types.ts | 6 ++++++ .../src/x-modules/identifier-results/store/module.ts | 4 +++- .../src/x-modules/identifier-results/store/types.ts | 6 ++++++ .../src/x-modules/next-queries/store/module.ts | 4 +++- .../src/x-modules/next-queries/store/types.ts | 10 +++++++--- .../src/x-modules/popular-searches/store/module.ts | 4 +++- .../src/x-modules/popular-searches/store/types.ts | 6 ++++++ .../src/x-modules/queries-preview/store/module.ts | 4 +++- .../src/x-modules/queries-preview/store/types.ts | 6 ++++++ .../src/x-modules/query-suggestions/store/module.ts | 4 +++- .../src/x-modules/query-suggestions/store/types.ts | 6 ++++++ .../src/x-modules/recommendations/store/module.ts | 4 +++- .../src/x-modules/recommendations/store/types.ts | 6 ++++++ .../src/x-modules/related-tags/store/module.ts | 4 +++- .../src/x-modules/related-tags/store/types.ts | 6 ++++++ .../src/x-modules/semantic-queries/store/module.ts | 4 +++- .../src/x-modules/semantic-queries/store/types.ts | 8 ++++++-- 20 files changed, 90 insertions(+), 14 deletions(-) diff --git a/packages/x-components/src/x-modules/empathize/store/module.ts b/packages/x-components/src/x-modules/empathize/store/module.ts index d53bb61691..f316f7449b 100644 --- a/packages/x-components/src/x-modules/empathize/store/module.ts +++ b/packages/x-components/src/x-modules/empathize/store/module.ts @@ -1,3 +1,4 @@ +import { setConfig } from '../../../store/utils/config-store.utils'; import { EmpathizeXStoreModule } from './types'; /** @@ -14,7 +15,8 @@ export const empathizeXStoreModule: EmpathizeXStoreModule = { mutations: { setIsOpen(state, isOpen) { state.isOpen = isOpen; - } + }, + setConfig }, actions: {} }; diff --git a/packages/x-components/src/x-modules/empathize/store/types.ts b/packages/x-components/src/x-modules/empathize/store/types.ts index 414cd5211e..6102470466 100644 --- a/packages/x-components/src/x-modules/empathize/store/types.ts +++ b/packages/x-components/src/x-modules/empathize/store/types.ts @@ -40,6 +40,12 @@ export interface EmpathizeMutations { * @param isOpen - The new isOpen state to save. */ setIsOpen(isOpen: boolean): void; + /** + * Sets the {@link EmpathizeState.config } config. + * + * @param config - The new config. + */ + setConfig(config: EmpathizeConfig): void; } /** diff --git a/packages/x-components/src/x-modules/history-queries/store/module.ts b/packages/x-components/src/x-modules/history-queries/store/module.ts index 86b7e31f60..09b4d4d2cf 100644 --- a/packages/x-components/src/x-modules/history-queries/store/module.ts +++ b/packages/x-components/src/x-modules/history-queries/store/module.ts @@ -1,5 +1,6 @@ import { setQuery } from '../../../store/utils/query.utils'; import { localStorageService } from '../../../utils/storage'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { addQueryToHistory } from './actions/add-query-to-history.action'; // eslint-disable-next-line max-len import { loadHistoryQueriesFromBrowserStorage } from './actions/load-history-queries-from-browser-storage.action'; @@ -51,6 +52,7 @@ export const historyQueriesXStoreModule: HistoryQueriesXStoreModule = { state.sessionTimeStampInMs = sessionTimeStamp; }, setQuery, + setConfig, setIsEnabled(state, isEnabled) { state.isEnabled = isEnabled; } diff --git a/packages/x-components/src/x-modules/history-queries/store/types.ts b/packages/x-components/src/x-modules/history-queries/store/types.ts index 43336898be..cd8199b2ee 100644 --- a/packages/x-components/src/x-modules/history-queries/store/types.ts +++ b/packages/x-components/src/x-modules/history-queries/store/types.ts @@ -87,6 +87,12 @@ export interface HistoryQueriesMutations extends QueryMutations { * @param query - The new {@link HistoryQueriesState.query }. */ setQuery(query: string): void; + /** + * Sets the {@link HistoryQueriesState.config } config. + * + * @param config - The new config. + */ + setConfig(config: HistoryQueriesConfig): void; /** * Sets the {@link HistoryQueriesState.isEnabled } property. * diff --git a/packages/x-components/src/x-modules/identifier-results/store/module.ts b/packages/x-components/src/x-modules/identifier-results/store/module.ts index 0ad6f3c0e5..ac6bb81877 100644 --- a/packages/x-components/src/x-modules/identifier-results/store/module.ts +++ b/packages/x-components/src/x-modules/identifier-results/store/module.ts @@ -1,5 +1,6 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveIdentifierResults, fetchAndSaveIdentifierResults @@ -47,7 +48,8 @@ export const identifierResultsXStoreModule: IdentifierResultsXStoreModule = { state.params = params; }, setQuery, - setStatus + setStatus, + setConfig }, actions: { cancelFetchAndSaveIdentifierResults, diff --git a/packages/x-components/src/x-modules/identifier-results/store/types.ts b/packages/x-components/src/x-modules/identifier-results/store/types.ts index e89b229086..351a8c991b 100644 --- a/packages/x-components/src/x-modules/identifier-results/store/types.ts +++ b/packages/x-components/src/x-modules/identifier-results/store/types.ts @@ -75,6 +75,12 @@ export interface IdentifierResultsMutations extends StatusMutations, QueryMutati * @param newQuery - The new query to save to the state. */ setQuery(newQuery: string): void; + /** + * Sets the {@link IdentifierResultsState.config } config. + * + * @param config - The new config. + */ + setConfig(config: IdentifierResultsConfig): void; } /** diff --git a/packages/x-components/src/x-modules/next-queries/store/module.ts b/packages/x-components/src/x-modules/next-queries/store/module.ts index e12a5e6b4c..ee31923eee 100644 --- a/packages/x-components/src/x-modules/next-queries/store/module.ts +++ b/packages/x-components/src/x-modules/next-queries/store/module.ts @@ -1,5 +1,6 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveNextQueries, fetchAndSaveNextQueries @@ -54,7 +55,8 @@ export const nextQueriesXStoreModule: NextQueriesXStoreModule = { }, resetResultsPreview(state) { state.resultsPreview = {}; - } + }, + setConfig }, actions: { cancelFetchAndSaveNextQueries, diff --git a/packages/x-components/src/x-modules/next-queries/store/types.ts b/packages/x-components/src/x-modules/next-queries/store/types.ts index 082c7c6a8a..9706442112 100644 --- a/packages/x-components/src/x-modules/next-queries/store/types.ts +++ b/packages/x-components/src/x-modules/next-queries/store/types.ts @@ -42,7 +42,7 @@ export interface NextQueriesState extends StatusState, QueryState { export interface NextQueriesGetters { /** * Request object to retrieve the next queries using the search adapter, or null if there is - * not valid data to conform a valid request. + * no valid data to conform a valid request. */ request: NextQueriesRequest | null; /** List of next queries that have not been searched before. */ @@ -79,7 +79,6 @@ export interface NextQueriesMutations extends StatusMutations, QueryMutations { * @param params - The new extra params. */ setParams(params: Dictionary): void; - /** * Adds a new entry to the result's dictionary. * @@ -87,11 +86,16 @@ export interface NextQueriesMutations extends StatusMutations, QueryMutations { * the totalResults and the results to add. */ setResultsPreview(resultsPreview: Dictionary): void; - /** * Resets the result's dictionary. */ resetResultsPreview(): void; + /** + * Sets the {@link NextQueriesState.config } config. + * + * @param config - The new config. + */ + setConfig(config: NextQueriesConfig): void; } /** diff --git a/packages/x-components/src/x-modules/popular-searches/store/module.ts b/packages/x-components/src/x-modules/popular-searches/store/module.ts index 92caeed7e4..a686201a3e 100644 --- a/packages/x-components/src/x-modules/popular-searches/store/module.ts +++ b/packages/x-components/src/x-modules/popular-searches/store/module.ts @@ -1,4 +1,5 @@ import { setStatus } from '../../../store/utils/status-store.utils'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveSuggestions, fetchAndSaveSuggestions @@ -38,7 +39,8 @@ export const popularSearchesXStoreModule: PopularSearchesXStoreModule = { setStatus, setParams(state, params) { state.params = params; - } + }, + setConfig }, actions: { cancelFetchAndSaveSuggestions, diff --git a/packages/x-components/src/x-modules/popular-searches/store/types.ts b/packages/x-components/src/x-modules/popular-searches/store/types.ts index bffb74824b..6b0df10ee8 100644 --- a/packages/x-components/src/x-modules/popular-searches/store/types.ts +++ b/packages/x-components/src/x-modules/popular-searches/store/types.ts @@ -57,6 +57,12 @@ export interface PopularSearchesMutations extends StatusMutations { * @param params - The new extra params. */ setParams(params: Dictionary): void; + /** + * Sets the {@link PopularSearchesState.config } config. + * + * @param config - The new config. + */ + setConfig(config: PopularSearchesConfig): void; } /** diff --git a/packages/x-components/src/x-modules/queries-preview/store/module.ts b/packages/x-components/src/x-modules/queries-preview/store/module.ts index 04f6fb377c..73264d3acc 100644 --- a/packages/x-components/src/x-modules/queries-preview/store/module.ts +++ b/packages/x-components/src/x-modules/queries-preview/store/module.ts @@ -1,4 +1,5 @@ import Vue from 'vue'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { QueriesPreviewXStoreModule } from './types'; import { fetchQueryPreview } from './actions/fetch-query-preview.action'; import { fetchAndSaveQueryPreview } from './actions/fetch-and-save-query-preview.action'; @@ -38,7 +39,8 @@ export const queriesPreviewXStoreModule: QueriesPreviewXStoreModule = { }, setSelectedQueryPreview(state, selectedQueryPreview) { state.selectedQueryPreview = selectedQueryPreview; - } + }, + setConfig }, actions: { fetchQueryPreview, diff --git a/packages/x-components/src/x-modules/queries-preview/store/types.ts b/packages/x-components/src/x-modules/queries-preview/store/types.ts index 7e562242f8..07aac90458 100644 --- a/packages/x-components/src/x-modules/queries-preview/store/types.ts +++ b/packages/x-components/src/x-modules/queries-preview/store/types.ts @@ -106,6 +106,12 @@ export interface QueriesPreviewMutations { * @param selectedQueryPreview - The selected query preview to save to the state. */ setSelectedQueryPreview(selectedQueryPreview: QueryPreviewInfo | null): void; + /** + * Sets the {@link QueriesPreviewState.config } config. + * + * @param config - The new config. + */ + setConfig(config: QueriesPreviewConfig): void; } /** diff --git a/packages/x-components/src/x-modules/query-suggestions/store/module.ts b/packages/x-components/src/x-modules/query-suggestions/store/module.ts index 39982eeecf..7bdd783389 100644 --- a/packages/x-components/src/x-modules/query-suggestions/store/module.ts +++ b/packages/x-components/src/x-modules/query-suggestions/store/module.ts @@ -1,5 +1,6 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveSuggestions, fetchAndSaveSuggestions @@ -41,7 +42,8 @@ export const querySuggestionsXStoreModule: QuerySuggestionsXStoreModule = { setStatus, setParams(state, params) { state.params = params; - } + }, + setConfig }, actions: { cancelFetchAndSaveSuggestions, diff --git a/packages/x-components/src/x-modules/query-suggestions/store/types.ts b/packages/x-components/src/x-modules/query-suggestions/store/types.ts index 9f2cfbc802..36eb53ee4f 100644 --- a/packages/x-components/src/x-modules/query-suggestions/store/types.ts +++ b/packages/x-components/src/x-modules/query-suggestions/store/types.ts @@ -63,6 +63,12 @@ export interface QuerySuggestionsMutations extends StatusMutations, QueryMutatio * @param params - The new extra params. */ setParams(params: Dictionary): void; + /** + * Sets the {@link QuerySuggestionsState.config } config. + * + * @param config - The new config. + */ + setConfig(config: QuerySuggestionsConfig): void; } /** diff --git a/packages/x-components/src/x-modules/recommendations/store/module.ts b/packages/x-components/src/x-modules/recommendations/store/module.ts index 9e32221408..b810030bef 100644 --- a/packages/x-components/src/x-modules/recommendations/store/module.ts +++ b/packages/x-components/src/x-modules/recommendations/store/module.ts @@ -1,4 +1,5 @@ import { setStatus } from '../../../store/utils/status-store.utils'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveRecommendations, fetchAndSaveRecommendations @@ -41,7 +42,8 @@ export const recommendationsXStoreModule: RecommendationsXStoreModule = { if (stateRecommendation) { Object.assign(stateRecommendation, recommendation); } - } + }, + setConfig }, actions: { cancelFetchAndSaveRecommendations, diff --git a/packages/x-components/src/x-modules/recommendations/store/types.ts b/packages/x-components/src/x-modules/recommendations/store/types.ts index bb65e7ffd3..8638f3db58 100644 --- a/packages/x-components/src/x-modules/recommendations/store/types.ts +++ b/packages/x-components/src/x-modules/recommendations/store/types.ts @@ -55,6 +55,12 @@ export interface RecommendationsMutations extends StatusMutations { * and the properties to modify. */ updateRecommendation(recommendation: Partial & Pick): void; + /** + * Sets the {@link RecommendationsState.config } config. + * + * @param config - The new config. + */ + setConfig(config: RecommendationsConfig): void; } /** diff --git a/packages/x-components/src/x-modules/related-tags/store/module.ts b/packages/x-components/src/x-modules/related-tags/store/module.ts index 1f6d793be5..b05c2117ef 100644 --- a/packages/x-components/src/x-modules/related-tags/store/module.ts +++ b/packages/x-components/src/x-modules/related-tags/store/module.ts @@ -1,5 +1,6 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; +import { setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveRelatedTags, fetchAndSaveRelatedTags @@ -45,7 +46,8 @@ export const relatedTagsXStoreModule: RelatedTagsXStoreModule = { setStatus, setParams(state, params) { state.params = params; - } + }, + setConfig }, actions: { cancelFetchAndSaveRelatedTags, diff --git a/packages/x-components/src/x-modules/related-tags/store/types.ts b/packages/x-components/src/x-modules/related-tags/store/types.ts index dbc83a9d8e..1a96a0f4db 100644 --- a/packages/x-components/src/x-modules/related-tags/store/types.ts +++ b/packages/x-components/src/x-modules/related-tags/store/types.ts @@ -64,6 +64,12 @@ export interface RelatedTagsMutations extends StatusMutations, QueryMutations { * @param params - The new extra params. */ setParams(params: Dictionary): void; + /** + * Sets the {@link RelatedTagsState.config } config. + * + * @param config - The new config. + */ + setConfig(config: RelatedTagsConfig): void; } /** * RelatedTags store actions. diff --git a/packages/x-components/src/x-modules/semantic-queries/store/module.ts b/packages/x-components/src/x-modules/semantic-queries/store/module.ts index 38e6108c4e..06316da24e 100644 --- a/packages/x-components/src/x-modules/semantic-queries/store/module.ts +++ b/packages/x-components/src/x-modules/semantic-queries/store/module.ts @@ -1,3 +1,4 @@ +import { setConfig } from '../../../store/utils/config-store.utils'; import { SemanticQueriesXStoreModule } from './types'; import { fetchSemanticQuery } from './actions/fetch-semantic-query.action'; import { fetchAndSaveSemanticQuery } from './actions/fetch-and-save-semantic-query.action'; @@ -36,7 +37,8 @@ export const semanticQueriesXStoreModule: SemanticQueriesXStoreModule = { }, setTotalResults(state, totalResults) { state.totalResults = totalResults; - } + }, + setConfig }, actions: { fetchSemanticQuery, diff --git a/packages/x-components/src/x-modules/semantic-queries/store/types.ts b/packages/x-components/src/x-modules/semantic-queries/store/types.ts index f86196b085..20693caad7 100644 --- a/packages/x-components/src/x-modules/semantic-queries/store/types.ts +++ b/packages/x-components/src/x-modules/semantic-queries/store/types.ts @@ -49,7 +49,6 @@ export interface SemanticQueriesMutations { * Sets the {@link SemanticQueriesState.query} property. */ setQuery(query: string): void; - /** * Sets the {@link SemanticQueriesState.totalResults} property. */ @@ -60,11 +59,16 @@ export interface SemanticQueriesMutations { * @param params - The new extra params. */ setParams(params: Dictionary): void; - /** * Sets the {@link SemanticQueriesState.semanticQueries} property. */ setSemanticQueries(semanticQueries: SemanticQuery[]): void; + /** + * Sets the {@link SemanticQueriesState.config } config. + * + * @param config - The new config. + */ + setConfig(config: SemanticQueriesConfig): void; } /**