From ba4d96644c831390cfbba5cc3035365d50f4d6de Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Tue, 14 May 2024 15:38:47 +0200 Subject: [PATCH] feat: change query previews for docker environment (#484) --- src/x-components/plugin.options.ts | 140 ++++++++++++++++------------- 1 file changed, 77 insertions(+), 63 deletions(-) diff --git a/src/x-components/plugin.options.ts b/src/x-components/plugin.options.ts index 13cae6c9..8490a599 100644 --- a/src/x-components/plugin.options.ts +++ b/src/x-components/plugin.options.ts @@ -13,13 +13,13 @@ import { mergeSemanticQueriesConfigWire } from './wiring/semantic-queries.wiring const device = useDevice(); const setSearchQueryFiltered = filter( - setSearchQuery, - ({ eventPayload }) => !eventPayload.startsWith('::') + setSearchQuery, + ({ eventPayload }) => !eventPayload.startsWith('::') ); const addQueryToHistoryQueriesFiltered = filter( - addQueryToHistoryQueries, - ({ eventPayload }) => !eventPayload.startsWith('::') + addQueryToHistoryQueries, + ({ eventPayload }) => !eventPayload.startsWith('::') ); const setUrlQueryFiltered = filter( @@ -33,70 +33,84 @@ const setUrlQueryFiltered = filter( * Returns - the InstallXOptions. */ export async function getInstallXOptions(): Promise { - if (process.env.VUE_APP_DEVELOPMENT_DOCKER) { - const { overrideAdapter } = await import('../adapter/docker.adapter'); - overrideAdapter(adapter); - } - return { - adapter, - store, - app: App, - domElement: getDomElement, - xModules: { - facets: { - config: { - filtersStrategyForRequest: 'leaves-only' - } - }, - semanticQueries: { - config: { - threshold: 50, - maxItemsToRequest: 10 - }, - wiring: { - SemanticQueriesConfigProvided: { - mergeSemanticQueriesConfigWire - } - } - }, - search: { - wiring: { - UserAcceptedAQuery: { - setSearchQuery: setSearchQueryFiltered - } + if (process.env.VUE_APP_DEVELOPMENT_DOCKER) { + const { overrideAdapter } = await import('../adapter/docker.adapter'); + overrideAdapter(adapter); + (window.initX as SnippetConfig)!.queriesPreview = [ + { + query: 'short', + title: 'Short' + }, + { + query: 'comedy', + title: 'Comedy' + }, + { + query: 'family', + title: 'Family' } - }, - historyQueries: { - wiring: { - UserAcceptedAQuery: { - addQueryToHistoryQueries: addQueryToHistoryQueriesFiltered + ]; + } + return { + adapter, + store, + app: App, + domElement: getDomElement, + xModules: { + facets: { + config: { + filtersStrategyForRequest: 'leaves-only' + } + }, + semanticQueries: { + config: { + threshold: 50, + maxItemsToRequest: 10 + }, + wiring: { + SemanticQueriesConfigProvided: { + mergeSemanticQueriesConfigWire + } + } + }, + search: { + wiring: { + UserAcceptedAQuery: { + setSearchQuery: setSearchQueryFiltered + } + } + }, + historyQueries: { + wiring: { + UserAcceptedAQuery: { + addQueryToHistoryQueries: addQueryToHistoryQueriesFiltered + } + } + }, + url: { + wiring: { + UserAcceptedAQuery: { + setUrlQuery: setUrlQueryFiltered + } } } }, - url: { - wiring: { - UserAcceptedAQuery: { - setUrlQuery: setUrlQueryFiltered - } - } - } - }, - async installExtraPlugins({ vue, snippet }) { - const i18n = await I18n.create({ - locale: snippet.uiLang, - device: (snippet.device as string) ?? device.deviceName.value, - fallbackLocale: 'en', - messages - }); - vue.use(i18n); - vue.prototype.$setLocale = i18n.setLocale.bind(i18n); - vue.prototype.$setLocaleDevice = i18n.setDevice.bind(i18n); + async installExtraPlugins({ vue, snippet }) { + const i18n = await I18n.create({ + locale: snippet.uiLang, + device: (snippet.device as string) ?? device.deviceName.value, + fallbackLocale: 'en', + messages + }); + vue.use(i18n); + vue.prototype.$setLocale = i18n.setLocale.bind(i18n); + vue.prototype.$setLocaleDevice = i18n.setDevice.bind(i18n); - return { - i18n: i18n.vueI18n - }; - } - }; + return { + i18n: i18n.vueI18n + }; + } + }; } /**