Skip to content

Commit a56b31f

Browse files
committed
Move 'show duplicates' from query opts to display opts
1 parent 6475a88 commit a56b31f

File tree

10 files changed

+67
-66
lines changed

10 files changed

+67
-66
lines changed

web/locales/en/plugin__netobserv-plugin.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@
108108
"Datasource": "Datasource",
109109
"Only available when FlowCollector.prometheus.enable is true for Overview and Topology tabs": "Only available when FlowCollector.prometheus.enable is true for Overview and Topology tabs",
110110
"Only available when FlowCollector.loki.enable is true": "Only available when FlowCollector.loki.enable is true",
111-
"A flow might be reported from several interfaces, and from both source and destination nodes, making it appear several times. By default, duplicates are hidden. Showing duplicates is not possible in Overview and Topology tabs to avoid altering metric calculations. Use the Direction filter to switch between ingress, egress and inner-node traffic.": "A flow might be reported from several interfaces, and from both source and destination nodes, making it appear several times. By default, duplicates are hidden. Showing duplicates is not possible in Overview and Topology tabs to avoid altering metric calculations. Use the Direction filter to switch between ingress, egress and inner-node traffic.",
112-
"Duplicated flows": "Duplicated flows",
113-
"Show duplicates": "Show duplicates",
114111
"Whether each query result has to match all the filters or just any of them": "Whether each query result has to match all the filters or just any of them",
115112
"Match filters": "Match filters",
116113
"Filter flows by their drop status. Only packets dropped by the kernel are monitored here.": "Filter flows by their drop status. Only packets dropped by the kernel are monitored here.",
@@ -140,6 +137,9 @@
140137
"Large": "Large",
141138
"Force table rows to specific sizing.": "Force table rows to specific sizing.",
142139
"Row size": "Row size",
140+
"A flow might be reported from both source and destination nodes, making it appear several times. By default, duplicates are merged, but you can show them in order to get more granular data.": "A flow might be reported from both source and destination nodes, making it appear several times. By default, duplicates are merged, but you can show them in order to get more granular data.",
141+
"Duplicated flows": "Duplicated flows",
142+
"Show duplicates": "Show duplicates",
143143
"From": "From",
144144
"To": "To",
145145
"Measurement to show as edge labels.": "Measurement to show as edge labels.",
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Checkbox, Radio, Select } from '@patternfly/react-core';
1+
import { Radio, Select } from '@patternfly/react-core';
22
import { shallow } from 'enzyme';
33
import * as React from 'react';
44
import { act } from 'react-dom/test-utils';
@@ -9,12 +9,10 @@ describe('<QueryOptionsDropdown />', () => {
99
const props: QueryOptionsProps = {
1010
recordType: 'allConnections',
1111
dataSource: 'auto',
12-
showDuplicates: true,
1312
allowProm: true,
1413
allowLoki: true,
1514
allowFlow: true,
1615
allowConnection: true,
17-
allowShowDuplicates: true,
1816
allowPktDrops: true,
1917
useTopK: false,
2018
limit: 100,
@@ -23,7 +21,6 @@ describe('<QueryOptionsDropdown />', () => {
2321
setLimit: jest.fn(),
2422
setMatch: jest.fn(),
2523
setPacketLoss: jest.fn(),
26-
setShowDuplicates: jest.fn(),
2724
setRecordType: jest.fn(),
2825
setDataSource: jest.fn()
2926
};
@@ -38,12 +35,10 @@ describe('<QueryOptionsPanel />', () => {
3835
const props: QueryOptionsProps = {
3936
recordType: 'allConnections',
4037
dataSource: 'auto',
41-
showDuplicates: true,
4238
allowProm: true,
4339
allowLoki: true,
4440
allowFlow: true,
4541
allowConnection: true,
46-
allowShowDuplicates: true,
4742
allowPktDrops: true,
4843
useTopK: false,
4944
limit: 100,
@@ -52,55 +47,42 @@ describe('<QueryOptionsPanel />', () => {
5247
setLimit: jest.fn(),
5348
setMatch: jest.fn(),
5449
setPacketLoss: jest.fn(),
55-
setShowDuplicates: jest.fn(),
5650
setRecordType: jest.fn(),
5751
setDataSource: jest.fn()
5852
};
5953

6054
beforeEach(() => {
6155
props.setLimit = jest.fn();
62-
props.setShowDuplicates = jest.fn();
6356
props.setMatch = jest.fn();
6457
});
6558

6659
it('should render component', async () => {
6760
const wrapper = shallow(<QueryOptionsPanel {...props} />);
68-
expect(wrapper.find('.pf-v5-c-menu__group').length).toBe(6);
69-
expect(wrapper.find('.pf-v5-c-menu__group-title').length).toBe(6);
61+
expect(wrapper.find('.pf-v5-c-menu__group').length).toBe(5);
62+
expect(wrapper.find('.pf-v5-c-menu__group-title').length).toBe(5);
7063
expect(wrapper.find(Radio)).toHaveLength(15);
7164

7265
//setOptions should not be called at startup, because it is supposed to be already initialized from URL
7366
expect(props.setLimit).toHaveBeenCalledTimes(0);
74-
expect(props.setShowDuplicates).toHaveBeenCalledTimes(0);
7567
expect(props.setMatch).toHaveBeenCalledTimes(0);
7668
});
7769

7870
it('should set options', async () => {
7971
const wrapper = shallow(<QueryOptionsPanel {...props} />);
8072
expect(props.setLimit).toHaveBeenCalledTimes(0);
81-
expect(props.setShowDuplicates).toHaveBeenCalledTimes(0);
82-
expect(props.setMatch).toHaveBeenCalledTimes(0);
83-
84-
act(() => {
85-
wrapper.find('#show-duplicates').find(Checkbox).props().onChange!({} as React.FormEvent<HTMLInputElement>, true);
86-
});
87-
expect(props.setLimit).toHaveBeenCalledTimes(0);
88-
expect(props.setShowDuplicates).toHaveBeenNthCalledWith(1, false);
8973
expect(props.setMatch).toHaveBeenCalledTimes(0);
9074

9175
act(() => {
9276
wrapper.find('#limit-1000').find(Radio).props().onChange!({} as React.FormEvent<HTMLInputElement>, true);
9377
});
9478
expect(props.setLimit).toHaveBeenNthCalledWith(1, 1000);
95-
expect(props.setShowDuplicates).toHaveBeenNthCalledWith(1, false);
9679
expect(props.setMatch).toHaveBeenCalledTimes(0);
9780
wrapper.setProps({ ...props, limit: 1000 });
9881

9982
act(() => {
10083
wrapper.find('#match-any').find(Radio).props().onChange!({} as React.FormEvent<HTMLInputElement>, true);
10184
});
10285
expect(props.setLimit).toHaveBeenNthCalledWith(1, 1000);
103-
expect(props.setShowDuplicates).toHaveBeenNthCalledWith(1, false);
10486
expect(props.setMatch).toHaveBeenNthCalledWith(1, 'any');
10587
});
10688
});

web/src/components/dropdowns/__tests__/table-display-dropdown.spec.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { TableDisplayOptions } from '../table-display-options';
99
describe('<DisplayDropdown />', () => {
1010
const props = {
1111
size: 's' as Size,
12-
setSize: jest.fn()
12+
setSize: jest.fn(),
13+
showDuplicates: true,
14+
setShowDuplicates: jest.fn()
1315
};
1416

1517
it('should render component', async () => {

web/src/components/dropdowns/query-options-dropdown.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ export interface QueryOptionsProps {
1111
setRecordType: (recordType: RecordType) => void;
1212
dataSource: DataSource;
1313
setDataSource: (dataSource: DataSource) => void;
14-
showDuplicates: boolean;
15-
setShowDuplicates: (showDuplicates: boolean) => void;
1614
allowLoki: boolean;
1715
allowProm: boolean;
1816
allowFlow: boolean;
1917
allowConnection: boolean;
20-
allowShowDuplicates: boolean;
2118
allowPktDrops: boolean;
2219
useTopK: boolean;
2320
limit: number;

web/src/components/dropdowns/query-options-panel.tsx

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Checkbox, Radio, Text, TextContent, TextVariants, Tooltip } from '@patternfly/react-core';
1+
import { Radio, Text, TextContent, TextVariants, Tooltip } from '@patternfly/react-core';
22
import { InfoAltIcon } from '@patternfly/react-icons';
33
import * as React from 'react';
44
import { useTranslation } from 'react-i18next';
@@ -20,13 +20,10 @@ export const QueryOptionsPanel: React.FC<QueryOptionsProps> = ({
2020
setRecordType,
2121
dataSource,
2222
setDataSource,
23-
showDuplicates,
24-
setShowDuplicates,
2523
allowLoki,
2624
allowProm,
2725
allowFlow,
2826
allowConnection,
29-
allowShowDuplicates,
3027
allowPktDrops,
3128
useTopK,
3229
limit,
@@ -201,31 +198,6 @@ export const QueryOptionsPanel: React.FC<QueryOptionsProps> = ({
201198
);
202199
})}
203200
</div>
204-
<div className="pf-v5-c-menu__group">
205-
<Tooltip
206-
content={t(
207-
// eslint-disable-next-line max-len
208-
'A flow might be reported from several interfaces, and from both source and destination nodes, making it appear several times. By default, duplicates are hidden. Showing duplicates is not possible in Overview and Topology tabs to avoid altering metric calculations. Use the Direction filter to switch between ingress, egress and inner-node traffic.'
209-
)}
210-
>
211-
<div className="pf-v5-c-menu__group-title">
212-
<Text component={TextVariants.p}>
213-
{t('Duplicated flows')} <InfoAltIcon />
214-
</Text>
215-
</div>
216-
</Tooltip>
217-
<label className="display-dropdown-padding pf-v5-c-menu__menu-item">
218-
<Checkbox
219-
isChecked={allowShowDuplicates ? showDuplicates : false}
220-
isDisabled={!allowShowDuplicates}
221-
name={'show-duplicates'}
222-
onChange={() => setShowDuplicates(!showDuplicates)}
223-
label={t('Show duplicates')}
224-
data-test={'show-duplicates'}
225-
id={'show-duplicates'}
226-
/>
227-
</label>
228-
</div>
229201
<div className="pf-v5-c-menu__group">
230202
<Tooltip
231203
content={t(

web/src/components/dropdowns/table-display-dropdown.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ export type Size = 's' | 'm' | 'l';
1010
export interface TableDisplayDropdownProps {
1111
size: Size;
1212
setSize: (v: Size) => void;
13+
showDuplicates: boolean;
14+
setShowDuplicates: (showDuplicates: boolean) => void;
1315
}
1416

15-
export const TableDisplayDropdown: React.FC<TableDisplayDropdownProps> = ({ size, setSize }) => {
17+
export const TableDisplayDropdown: React.FC<TableDisplayDropdownProps> = ({
18+
size,
19+
setSize,
20+
showDuplicates,
21+
setShowDuplicates
22+
}) => {
1623
const { t } = useTranslation('plugin__netobserv-plugin');
1724
const ref = useOutsideClickEvent(() => setOpen(false));
1825
const [isOpen, setOpen] = React.useState<boolean>(false);
@@ -28,7 +35,12 @@ export const TableDisplayDropdown: React.FC<TableDisplayDropdownProps> = ({ size
2835
</MenuToggle>
2936
)}
3037
>
31-
<TableDisplayOptions size={size} setSize={setSize} />
38+
<TableDisplayOptions
39+
size={size}
40+
setSize={setSize}
41+
showDuplicates={showDuplicates}
42+
setShowDuplicates={setShowDuplicates}
43+
/>
3244
</Select>
3345
</div>
3446
);

web/src/components/dropdowns/table-display-options.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Radio, Text, TextVariants, Tooltip } from '@patternfly/react-core';
1+
import { Checkbox, Radio, Text, TextVariants, Tooltip } from '@patternfly/react-core';
22
import { InfoAltIcon } from '@patternfly/react-icons';
33
import * as _ from 'lodash';
44
import * as React from 'react';
@@ -9,9 +9,16 @@ export type Size = 's' | 'm' | 'l';
99
export interface TableDisplayOptionsProps {
1010
size: Size;
1111
setSize: (v: Size) => void;
12+
showDuplicates: boolean;
13+
setShowDuplicates: (showDuplicates: boolean) => void;
1214
}
1315

14-
export const TableDisplayOptions: React.FC<TableDisplayOptionsProps> = ({ size, setSize }) => {
16+
export const TableDisplayOptions: React.FC<TableDisplayOptionsProps> = ({
17+
size,
18+
setSize,
19+
showDuplicates,
20+
setShowDuplicates
21+
}) => {
1522
const { t } = useTranslation('plugin__netobserv-plugin');
1623

1724
const sizeOptions = {
@@ -48,6 +55,30 @@ export const TableDisplayOptions: React.FC<TableDisplayOptionsProps> = ({ size,
4855
);
4956
})}
5057
</div>
58+
<div className="pf-v5-c-menu__group">
59+
<Tooltip
60+
content={t(
61+
// eslint-disable-next-line max-len
62+
'A flow might be reported from both source and destination nodes, making it appear several times. By default, duplicates are merged, but you can show them in order to get more granular data.'
63+
)}
64+
>
65+
<div className="pf-v5-c-menu__group-title">
66+
<Text component={TextVariants.p}>
67+
{t('Duplicated flows')} <InfoAltIcon />
68+
</Text>
69+
</div>
70+
</Tooltip>
71+
<label className="display-dropdown-padding pf-v5-c-menu__menu-item">
72+
<Checkbox
73+
isChecked={showDuplicates}
74+
name={'show-duplicates'}
75+
onChange={() => setShowDuplicates(!showDuplicates)}
76+
label={t('Show duplicates')}
77+
data-test={'show-duplicates'}
78+
id={'show-duplicates'}
79+
/>
80+
</label>
81+
</div>
5182
</>
5283
);
5384
};

web/src/components/netflow-traffic.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ export const NetflowTraffic: React.FC<NetflowTrafficProps> = ({
875875
allowProm: allowProm(),
876876
allowFlow: isFlow(),
877877
allowConnection: isConnectionTracking(),
878-
allowShowDuplicates: model.selectedViewId === 'table' && model.recordType !== 'allConnections',
879878
allowPktDrops: isPktDrop(),
880879
useTopK: model.selectedViewId === 'overview'
881880
}}

web/src/components/toolbar/filters/__tests__/filters-toolbar.spec.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,17 @@ describe('<FiltersToolbar />', () => {
1919
limit: 100,
2020
recordType: 'allConnections',
2121
dataSource: 'auto',
22-
showDuplicates: true,
2322
allowFlow: true,
2423
allowConnection: true,
2524
allowProm: true,
2625
allowLoki: true,
27-
allowShowDuplicates: true,
2826
allowPktDrops: true,
2927
useTopK: false,
3028
match: 'all',
3129
packetLoss: 'all',
3230
setLimit: jest.fn(),
3331
setMatch: jest.fn(),
3432
setPacketLoss: jest.fn(),
35-
setShowDuplicates: jest.fn(),
3633
setRecordType: jest.fn(),
3734
setDataSource: jest.fn()
3835
},

web/src/components/toolbar/view-options-toolbar.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export interface ViewOptionsToolbarProps {
5252
scopes: ScopeConfigDef[];
5353
size: Size;
5454
setSize: (v: Size) => void;
55+
showDuplicates: boolean;
56+
setShowDuplicates: (showDuplicates: boolean) => void;
5557
setSearchEvent: (se: SearchEvent) => void;
5658
ref?: React.Ref<SearchHandle>;
5759
}
@@ -253,7 +255,14 @@ export const ViewOptionsToolbar: React.FC<ViewOptionsToolbarProps> = React.forwa
253255
scopes={props.scopes}
254256
/>
255257
)}
256-
{props.selectedViewId === 'table' && <TableDisplayDropdown size={props.size} setSize={props.setSize} />}
258+
{props.selectedViewId === 'table' && (
259+
<TableDisplayDropdown
260+
size={props.size}
261+
setSize={props.setSize}
262+
showDuplicates={props.showDuplicates}
263+
setShowDuplicates={props.setShowDuplicates}
264+
/>
265+
)}
257266
{props.selectedViewId === 'topology' && (
258267
<TopologyDisplayDropdown
259268
metricFunction={props.topologyMetricFunction}

0 commit comments

Comments
 (0)