Add possibility to disable syncing controls with local storage

This commit is contained in:
Maryam Saeidi 2025-01-10 12:37:16 +01:00
parent bc0970e8ce
commit 24bab210b0
6 changed files with 8 additions and 1 deletions

View file

@ -60,6 +60,7 @@ export const FilterGroup = (props: PropsWithChildren<FilterGroupProps>) => {
Storage,
ruleTypeIds,
storageKey,
disableLocalStorageSync = false,
} = props;
const filterChangedSubscription = useRef<Subscription>();
@ -105,7 +106,7 @@ export const FilterGroup = (props: PropsWithChildren<FilterGroupProps>) => {
} = useControlGroupSyncToLocalStorage({
Storage,
storageKey: localStoragePageFilterKey,
shouldSync: isViewMode,
shouldSync: !disableLocalStorageSync && isViewMode,
});
useEffect(() => {

View file

@ -74,4 +74,5 @@ export interface FilterGroupProps extends Pick<ControlGroupRuntimeState, 'chaini
ControlGroupRenderer: typeof ControlGroupRenderer;
Storage: typeof Storage;
storageKey?: string;
disableLocalStorageSync?: boolean;
}

View file

@ -25,6 +25,7 @@ const toastTitle = i18n.translate('xpack.observability.alerts.searchBar.invalidQ
export function ObservabilityAlertSearchBar({
appName,
defaultFilters = EMPTY_FILTERS,
disableLocalStorageSync,
onEsQueryChange,
onKueryChange,
onRangeFromChange,
@ -168,6 +169,7 @@ export function ObservabilityAlertSearchBar({
filters={[...filters, ...defaultFilters]}
onFiltersChange={onFilterControlsChange}
storageKey={filterControlsStorageKey}
disableLocalStorageSync={disableLocalStorageSync}
services={{
http,
notifications,

View file

@ -63,6 +63,7 @@ export interface ObservabilityAlertSearchBarProps
onFilterControlsChange: (controlConfigs: Filter[]) => void;
savedQuery?: SavedQuery;
showFilterBar?: boolean;
disableLocalStorageSync?: boolean;
}
export interface AlertSearchBarContainerState {

View file

@ -129,6 +129,7 @@ export function InternalRelatedAlerts({ alert }: Props) {
onEsQueryChange={setEsQuery}
urlStorageKey={SEARCH_BAR_URL_STORAGE_KEY}
defaultFilters={defaultFilters.current}
disableLocalStorageSync={true}
defaultState={{
...defaultState,
kuery,

View file

@ -92,6 +92,7 @@ export function RuleDetailsTabs({
onEsQueryChange={onEsQueryChange}
urlStorageKey={RULE_DETAILS_SEARCH_BAR_URL_STORAGE_KEY}
defaultFilters={ruleFilters.current}
disableLocalStorageSync={true}
/>
<EuiSpacer size="s" />