@fluid-topics/ft-search-context 2.1.18 → 2.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,8 +18,10 @@ export declare class FtSearchStateManager extends FtStateManager {
18
18
  constructor(store: FtReduxStore<FtSearchPageState, FtSearchPageStateReducers>, service?: FtSearchService);
19
19
  onNewNeededRequest: (neededRequest: string) => void;
20
20
  initService(): Promise<boolean>;
21
- addWindowListeners(): void;
22
- removeWindowListeners(): void;
21
+ addListeners(): void;
22
+ removeListeners(): void;
23
+ private get recentQueriesStorageKey();
24
+ private get taruqaConfigStorageKey();
23
25
  private onStorageEvent;
24
26
  private updateSearchRequest;
25
27
  setQuery(query: string): void;
@@ -56,6 +58,7 @@ export declare class FtSearchStateManager extends FtStateManager {
56
58
  setIgnoreEmptyQuery(ignoreEmptyQuery: boolean): void;
57
59
  setOpenExternalDocumentInNewTab(openExternalDocumentInNewTab: boolean): void;
58
60
  setCanUpdateUiLocale(canUpdateUiLocale: boolean): void;
61
+ private loadTaruqaTemplate;
59
62
  private loadRecentQueries;
60
63
  addRecentQuery(query: string): void;
61
64
  removeRecentQuery(query: string): void;
@@ -1,14 +1,13 @@
1
1
  import { FtSearchStateResourceRequest, } from "./model";
2
2
  import { cancelable, CanceledPromiseError, Debouncer, deepCopy, FtStateManager, minmax, watch, } from "@fluid-topics/ft-wc-utils";
3
3
  import { createSearchPageStore, } from "./redux";
4
- import { FtSearchKeywordMatch, FtSearchScope, FtVirtualField, } from "@fluid-topics/public-api";
4
+ import { FtSearchKeywordMatch, FtSearchScope, FtUserRole, FtVirtualField, userHasRole, } from "@fluid-topics/public-api";
5
5
  import { FtSearchService } from "./utils/FtSearchService";
6
6
  import { ClearAllFiltersEvent } from "../utils";
7
- import { ftAppStateManager } from "@fluid-topics/ft-app-context";
7
+ import { AuthenticationChangeEvent, ftAppInfoStore, ftAppStateManager, } from "@fluid-topics/ft-app-context";
8
8
  export const searchInDocumentTitlesOnlySelector = (s) => s.request.virtualField === FtVirtualField.TITLE_ONLY
9
9
  && s.request.scope === FtSearchScope.DOCUMENTS;
10
10
  export const keywordMatchSelector = (s) => s.request.keywordMatch == FtSearchKeywordMatch.MANDATORY;
11
- const recentQueriesStorageKey = "ft-recent-queries";
12
11
  const maxRecentQueries = 20;
13
12
  export class FtSearchStateManager extends FtStateManager {
14
13
  static build(id, service) {
@@ -27,9 +26,21 @@ export class FtSearchStateManager extends FtStateManager {
27
26
  };
28
27
  this.onStorageEvent = (e) => {
29
28
  // detect changes from any context
30
- if (e.key === recentQueriesStorageKey) {
29
+ if (e.key === this.recentQueriesStorageKey) {
31
30
  this.loadRecentQueries();
32
31
  }
32
+ else if (e.key === this.taruqaConfigStorageKey) {
33
+ this.loadTaruqaTemplate();
34
+ }
35
+ };
36
+ this.loadTaruqaTemplate = () => {
37
+ var _a;
38
+ let taruqaTemplateOverride;
39
+ if (userHasRole(ftAppInfoStore.getState().session, FtUserRole.DEBUG_USER)) {
40
+ const config = JSON.parse((_a = window.localStorage.getItem(this.taruqaConfigStorageKey)) !== null && _a !== void 0 ? _a : "{}");
41
+ taruqaTemplateOverride = config.overrideEnabled ? config.template : undefined;
42
+ }
43
+ this.updateSearchRequest({ taruqaTemplateOverride, changedByConfiguration: true });
33
44
  };
34
45
  this.localesDebouncer = new Debouncer(10);
35
46
  this.searchDebouncer = new Debouncer(100);
@@ -74,13 +85,22 @@ export class FtSearchStateManager extends FtStateManager {
74
85
  this.setSortId(this.store.getState().request.sortId);
75
86
  });
76
87
  this.loadRecentQueries();
88
+ this.loadTaruqaTemplate();
77
89
  return this.launchSearch();
78
90
  }
79
- addWindowListeners() {
91
+ addListeners() {
80
92
  window.addEventListener("storage", this.onStorageEvent);
93
+ ftAppInfoStore.addEventListener(AuthenticationChangeEvent.eventName, this.loadTaruqaTemplate);
81
94
  }
82
- removeWindowListeners() {
95
+ removeListeners() {
83
96
  window.removeEventListener("storage", this.onStorageEvent);
97
+ ftAppInfoStore.removeEventListener(AuthenticationChangeEvent.eventName, this.loadTaruqaTemplate);
98
+ }
99
+ get recentQueriesStorageKey() {
100
+ return ftAppInfoStore.getState().tenantId + "-ft-recent-queries";
101
+ }
102
+ get taruqaConfigStorageKey() {
103
+ return ftAppInfoStore.getState().tenantId + "-taruqa-experiment-conf";
84
104
  }
85
105
  updateSearchRequest(partialRequest, resetPaging = false) {
86
106
  const request = deepCopy(this.store.getState().request);
@@ -306,7 +326,7 @@ export class FtSearchStateManager extends FtStateManager {
306
326
  }
307
327
  loadRecentQueries() {
308
328
  var _a;
309
- this.store.actions.recentQueries(JSON.parse((_a = window.localStorage.getItem(recentQueriesStorageKey)) !== null && _a !== void 0 ? _a : "[]"));
329
+ this.store.actions.recentQueries(JSON.parse((_a = window.localStorage.getItem(this.recentQueriesStorageKey)) !== null && _a !== void 0 ? _a : "[]"));
310
330
  }
311
331
  addRecentQuery(query) {
312
332
  query = query.trim();
@@ -328,10 +348,10 @@ export class FtSearchStateManager extends FtStateManager {
328
348
  }
329
349
  setRecentQueries(queries) {
330
350
  const newValue = JSON.stringify(queries);
331
- window.localStorage.setItem(recentQueriesStorageKey, newValue);
351
+ window.localStorage.setItem(this.recentQueriesStorageKey, newValue);
332
352
  // notify all contexts
333
353
  window.dispatchEvent(new StorageEvent("storage", {
334
- key: recentQueriesStorageKey,
354
+ key: this.recentQueriesStorageKey,
335
355
  newValue,
336
356
  storageArea: window.localStorage,
337
357
  url: window.location.href,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-search-context",
3
- "version": "2.1.18",
3
+ "version": "2.1.19",
4
4
  "description": "Context block for integrated search components",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,12 +19,12 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-app-context": "2.1.18",
23
- "@fluid-topics/ft-wc-utils": "2.1.18",
22
+ "@fluid-topics/ft-app-context": "2.1.19",
23
+ "@fluid-topics/ft-wc-utils": "2.1.19",
24
24
  "lit": "3.1.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@fluid-topics/public-api": "1.0.132"
27
+ "@fluid-topics/public-api": "1.0.133"
28
28
  },
29
- "gitHead": "2effe252f9ab22ede85f961b8464ec8aa4d27870"
29
+ "gitHead": "c2c202986d05fbee1378d8dbb74fa609e89260ec"
30
30
  }