Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.15] [ResponseOps][Alerts] Fix Stack Alerts page filter controls error (#194785) #194942

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { URL_PARAM_ARRAY_EXCEPTION_MSG } from './translations';

export const FilterGroup = (props: PropsWithChildren<FilterGroupProps>) => {
const {
featureIds,
dataViewId,
onFiltersChange,
timeRange,
Expand All @@ -61,7 +62,7 @@ export const FilterGroup = (props: PropsWithChildren<FilterGroupProps>) => {
maxControls = Infinity,
ControlGroupRenderer,
Storage,
featureIds,
storageKey,
} = props;

const filterChangedSubscription = useRef<Subscription>();
Expand All @@ -82,8 +83,8 @@ export const FilterGroup = (props: PropsWithChildren<FilterGroupProps>) => {
const [controlGroup, setControlGroup] = useState<ControlGroupContainer>();

const localStoragePageFilterKey = useMemo(
() => `${featureIds.join(',')}.${spaceId}.${URL_PARAM_KEY}`,
[featureIds, spaceId]
() => storageKey ?? `${featureIds.join(',')}.${spaceId}.${URL_PARAM_KEY}`,
[featureIds, spaceId, storageKey]
);

const currentFiltersRef = useRef<Filter[]>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ export interface FilterGroupProps
*/
ControlGroupRenderer: typeof ControlGroupRenderer;
Storage: typeof Storage;
storageKey?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useCallback, useEffect, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { BoolQuery } from '@kbn/es-query';
import { AlertConsumers } from '@kbn/rule-data-utils';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -61,17 +61,23 @@ export const UrlSyncedAlertsSearchBar = ({
const [spaceId, setSpaceId] = useState<string>();

const {
// KQL bar query
kuery,
onKueryChange,
// KQL bar filters
filters,
onFiltersChange,
// Controls bar filters
controlFilters,
onControlFiltersChange,
// Time range
rangeFrom,
onRangeFromChange,
rangeTo,
onRangeToChange,
// Controls bar configuration
filterControls,
// Saved KQL query
savedQuery,
setSavedQuery,
clearSavedQuery,
Expand Down Expand Up @@ -131,6 +137,11 @@ export const UrlSyncedAlertsSearchBar = ({
[onKueryChange, onRangeFromChange, onRangeToChange, setSavedQuery, timeFilterService]
);

const filterControlsStorageKey = useMemo(
() => ['alertsSearchBar', spaceId, 'filterControls'].filter(Boolean).join('.'),
[spaceId]
);

return (
<>
<AlertsSearchBar
Expand All @@ -156,6 +167,7 @@ export const UrlSyncedAlertsSearchBar = ({
controlsUrlState={filterControls}
filters={controlFilters}
onFiltersChange={onControlFiltersChange}
storageKey={filterControlsStorageKey}
services={{
http,
notifications,
Expand Down