From a4aad0433f911ad81df95577f0cfe7a3f2b23dc0 Mon Sep 17 00:00:00 2001 From: Galen Date: Thu, 12 Dec 2024 10:13:12 -0600 Subject: [PATCH 1/7] chore: add case sensitive line filter state to local storage --- src/Components/ServiceScene/LineFilterScene.tsx | 13 +++++++++++-- src/services/store.ts | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Components/ServiceScene/LineFilterScene.tsx b/src/Components/ServiceScene/LineFilterScene.tsx index 64d49b37..c8279e67 100644 --- a/src/Components/ServiceScene/LineFilterScene.tsx +++ b/src/Components/ServiceScene/LineFilterScene.tsx @@ -8,10 +8,12 @@ import { reportAppInteraction, USER_EVENTS_ACTIONS, USER_EVENTS_PAGES } from 'se import { SearchInput } from './Breakdowns/SearchInput'; import { LineFilterIcon } from './LineFilterIcon'; import { getLineFilterVariable } from '../../services/variableGetters'; +import { getLineFilterCase, setLineFilterCase } from '../../services/store'; interface LineFilterState extends SceneObjectState { lineFilter: string; caseSensitive: boolean; + regex: boolean; } export class LineFilterScene extends SceneObjectBase { @@ -20,7 +22,8 @@ export class LineFilterScene extends SceneObjectBase { constructor(state?: Partial) { super({ lineFilter: state?.lineFilter || '', - caseSensitive: false, + caseSensitive: getLineFilterCase(false), + regex: false, ...state, }); this.addActivationHandler(this.onActivate); @@ -66,10 +69,16 @@ export class LineFilterScene extends SceneObjectBase { }; onCaseSensitiveToggle = (newState: 'sensitive' | 'insensitive') => { + const caseSensitive = newState === 'sensitive'; + + // Set value to scene state this.setState({ - caseSensitive: newState === 'sensitive', + caseSensitive, }); + // Set value in local storage + setLineFilterCase(caseSensitive); + this.updateFilter(this.state.lineFilter); }; diff --git a/src/services/store.ts b/src/services/store.ts index f3c19670..6197f2e2 100644 --- a/src/services/store.ts +++ b/src/services/store.ts @@ -236,6 +236,23 @@ export function setLogsVisualizationType(type: string) { localStorage.setItem(VISUALIZATION_TYPE_LOCALSTORAGE_KEY, type); } +// Line filter options + +const LINE_FILTER_OPTIONS_LOCALSTORAGE_KEY = `${pluginJson.id}.logs.option`; +export function setLineFilterCase(caseSensitive: boolean) { + let storedValue = caseSensitive.toString(); + if (typeof caseSensitive === 'boolean' && !caseSensitive) { + storedValue = ''; + } + + localStorage.setItem(`${LINE_FILTER_OPTIONS_LOCALSTORAGE_KEY}.caseSensitive`, storedValue); +} + +export function getLineFilterCase(defaultValue: boolean): boolean { + const storedValue = localStorage.getItem(`${LINE_FILTER_OPTIONS_LOCALSTORAGE_KEY}.caseSensitive`); + return storedValue === 'true' ? true : defaultValue; +} + // Panel options const PANEL_OPTIONS_LOCALSTORAGE_KEY = `${pluginJson.id}.panel.option`; export interface PanelOptions { From 516929b515acbb8ad747279b512cbb0c0e445db5 Mon Sep 17 00:00:00 2001 From: Galen Date: Thu, 12 Dec 2024 10:15:29 -0600 Subject: [PATCH 2/7] chore: cleanup --- src/services/store.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/store.ts b/src/services/store.ts index 6197f2e2..6f5c55ae 100644 --- a/src/services/store.ts +++ b/src/services/store.ts @@ -237,7 +237,6 @@ export function setLogsVisualizationType(type: string) { } // Line filter options - const LINE_FILTER_OPTIONS_LOCALSTORAGE_KEY = `${pluginJson.id}.logs.option`; export function setLineFilterCase(caseSensitive: boolean) { let storedValue = caseSensitive.toString(); From 423920621f19507365f9cf84d9f9e9b01a713472 Mon Sep 17 00:00:00 2001 From: Galen Date: Thu, 12 Dec 2024 10:19:08 -0600 Subject: [PATCH 3/7] chore: cleanuop --- src/Components/ServiceScene/LineFilterScene.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Components/ServiceScene/LineFilterScene.tsx b/src/Components/ServiceScene/LineFilterScene.tsx index c8279e67..32176823 100644 --- a/src/Components/ServiceScene/LineFilterScene.tsx +++ b/src/Components/ServiceScene/LineFilterScene.tsx @@ -13,7 +13,6 @@ import { getLineFilterCase, setLineFilterCase } from '../../services/store'; interface LineFilterState extends SceneObjectState { lineFilter: string; caseSensitive: boolean; - regex: boolean; } export class LineFilterScene extends SceneObjectBase { @@ -23,7 +22,6 @@ export class LineFilterScene extends SceneObjectBase { super({ lineFilter: state?.lineFilter || '', caseSensitive: getLineFilterCase(false), - regex: false, ...state, }); this.addActivationHandler(this.onActivate); From 0bb19d023918e179f3d691e046f461f5ef43f9fb Mon Sep 17 00:00:00 2001 From: Galen Date: Thu, 12 Dec 2024 10:47:19 -0600 Subject: [PATCH 4/7] chore: dont debounce case sensitive toggle --- src/Components/ServiceScene/LineFilterScene.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/ServiceScene/LineFilterScene.tsx b/src/Components/ServiceScene/LineFilterScene.tsx index 32176823..e007a339 100644 --- a/src/Components/ServiceScene/LineFilterScene.tsx +++ b/src/Components/ServiceScene/LineFilterScene.tsx @@ -77,7 +77,7 @@ export class LineFilterScene extends SceneObjectBase { // Set value in local storage setLineFilterCase(caseSensitive); - this.updateFilter(this.state.lineFilter); + this.updateFilter(this.state.lineFilter, false); }; updateVariableDebounced = debounce((search: string) => { From e381752dfe15c0ae4131a0861c272567dfd2f0fb Mon Sep 17 00:00:00 2001 From: Galen Date: Thu, 12 Dec 2024 10:47:55 -0600 Subject: [PATCH 5/7] chore: rename local storage --- src/services/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/store.ts b/src/services/store.ts index 6f5c55ae..e8fd8e27 100644 --- a/src/services/store.ts +++ b/src/services/store.ts @@ -237,7 +237,7 @@ export function setLogsVisualizationType(type: string) { } // Line filter options -const LINE_FILTER_OPTIONS_LOCALSTORAGE_KEY = `${pluginJson.id}.logs.option`; +const LINE_FILTER_OPTIONS_LOCALSTORAGE_KEY = `${pluginJson.id}.linefilter.option`; export function setLineFilterCase(caseSensitive: boolean) { let storedValue = caseSensitive.toString(); if (typeof caseSensitive === 'boolean' && !caseSensitive) { From 6c8bb6c4db58339205ab3f180a6e61ba5ee6d1db Mon Sep 17 00:00:00 2001 From: Galen Date: Thu, 12 Dec 2024 11:41:05 -0600 Subject: [PATCH 6/7] chore: spellcheck --- project-words.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/project-words.txt b/project-words.txt index a22e6154..a1538f2f 100644 --- a/project-words.txt +++ b/project-words.txt @@ -499,3 +499,4 @@ keycombo capslock pageup pagedown +linefilter From 656c1b9e2270a62ccd09f6a7cf38be1516f68cea Mon Sep 17 00:00:00 2001 From: Galen Date: Fri, 13 Dec 2024 08:14:38 -0600 Subject: [PATCH 7/7] chore: remove uncessary runtime check --- src/services/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/store.ts b/src/services/store.ts index e8fd8e27..7b0b9be6 100644 --- a/src/services/store.ts +++ b/src/services/store.ts @@ -240,7 +240,7 @@ export function setLogsVisualizationType(type: string) { const LINE_FILTER_OPTIONS_LOCALSTORAGE_KEY = `${pluginJson.id}.linefilter.option`; export function setLineFilterCase(caseSensitive: boolean) { let storedValue = caseSensitive.toString(); - if (typeof caseSensitive === 'boolean' && !caseSensitive) { + if (!caseSensitive) { storedValue = ''; }