mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 19:59:04 +08:00
fix: added logic to keep sections uncollapsed for all filtered items (#5371)
This commit is contained in:
parent
ddf5569ce9
commit
9844dcdfb7
@ -1,7 +1,14 @@
|
|||||||
import './Filter.styles.scss';
|
import './Filter.styles.scss';
|
||||||
|
|
||||||
import { Button, Collapse, Divider } from 'antd';
|
import { Button, Collapse, Divider } from 'antd';
|
||||||
import { Dispatch, MouseEvent, SetStateAction } from 'react';
|
import {
|
||||||
|
Dispatch,
|
||||||
|
MouseEvent,
|
||||||
|
SetStateAction,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
|
|
||||||
import { DurationSection } from './DurationSection';
|
import { DurationSection } from './DurationSection';
|
||||||
import {
|
import {
|
||||||
@ -18,9 +25,29 @@ interface SectionProps {
|
|||||||
setSelectedFilters: Dispatch<SetStateAction<FilterType | undefined>>;
|
setSelectedFilters: Dispatch<SetStateAction<FilterType | undefined>>;
|
||||||
handleRun: (props?: HandleRunProps) => void;
|
handleRun: (props?: HandleRunProps) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Section(props: SectionProps): JSX.Element {
|
export function Section(props: SectionProps): JSX.Element {
|
||||||
const { panelName, setSelectedFilters, selectedFilters, handleRun } = props;
|
const { panelName, setSelectedFilters, selectedFilters, handleRun } = props;
|
||||||
|
|
||||||
|
const defaultOpenPanes = useMemo(
|
||||||
|
() =>
|
||||||
|
Array.from(
|
||||||
|
new Set([
|
||||||
|
...Object.keys(selectedFilters || {}),
|
||||||
|
'hasError',
|
||||||
|
'durationNano',
|
||||||
|
'serviceName',
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
[selectedFilters],
|
||||||
|
);
|
||||||
|
|
||||||
|
const [activeKeys, setActiveKeys] = useState<string[]>(defaultOpenPanes);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActiveKeys(defaultOpenPanes);
|
||||||
|
}, [defaultOpenPanes]);
|
||||||
|
|
||||||
const onClearHandler = (e: MouseEvent): void => {
|
const onClearHandler = (e: MouseEvent): void => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -41,11 +68,8 @@ export function Section(props: SectionProps): JSX.Element {
|
|||||||
<Collapse
|
<Collapse
|
||||||
bordered={false}
|
bordered={false}
|
||||||
className="collapseContainer"
|
className="collapseContainer"
|
||||||
defaultActiveKey={
|
activeKey={activeKeys}
|
||||||
['hasError', 'durationNano', 'serviceName'].includes(panelName)
|
onChange={(keys): void => setActiveKeys(keys as string[])}
|
||||||
? panelName
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
items={[
|
items={[
|
||||||
panelName === 'durationNano'
|
panelName === 'durationNano'
|
||||||
? {
|
? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user