Skip to content

Commit ee3eeed

Browse files
committed
Make it look like other filter menu
(small hack to make PF do what we want)
1 parent 72915fe commit ee3eeed

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

web/locales/en/plugin__netobserv-plugin.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"Scope": "Scope",
2929
"Long labels can reduce visibility.": "Long labels can reduce visibility.",
3030
"Truncate labels": "Truncate labels",
31+
"Long labels can reduce visibility.": "Long labels can reduce visibility.",
32+
"Truncate labels": "Truncate labels",
3133
"Display options": "Display options",
3234
"Source": "Source",
3335
"Destination": "Destination",
@@ -167,6 +169,7 @@
167169
"JSON": "JSON",
168170
"Kind not managed": "Kind not managed",
169171
"Unable to get flows": "Unable to get flows",
172+
"Name": "Name",
170173
"Step into this {{name}}": "Step into this {{name}}",
171174
"Add {{name}} filter": "Add {{name}} filter",
172175
"Unpin this element": "Unpin this element",
@@ -241,7 +244,6 @@
241244
"Kubernetes Objects": "Kubernetes Objects",
242245
"Owner Kubernetes Objects": "Owner Kubernetes Objects",
243246
"IPs & Ports": "IPs & Ports",
244-
"Name": "Name",
245247
"Kind": "Kind",
246248
"Owner Kind": "Owner Kind",
247249
"Port": "Port",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pf-c-options-menu.summary-filter-menu ul {
2+
padding-left: 0;
3+
}

web/src/components/filters/summary-filter-button.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import * as React from 'react';
22
import { useTranslation } from 'react-i18next';
3-
import { OptionsMenu, OptionsMenuItem, OptionsMenuPosition, OptionsMenuToggle } from '@patternfly/react-core';
3+
import { Checkbox, OptionsMenu, OptionsMenuItem, OptionsMenuPosition, OptionsMenuToggle } from '@patternfly/react-core';
44
import { FilterIcon } from '@patternfly/react-icons';
55
import { Filter } from '../../model/filters';
66
import { FilterDir, isElementFiltered, toggleElementFilter } from '../../model/topology';
77
import { TopologyMetricPeer } from '../../api/loki';
88
import { NodeType } from '../../model/flow-query';
9+
import './summary-filter-button.css';
910

1011
export interface SummaryFilterButtonProps {
1112
id: string;
@@ -33,19 +34,26 @@ export const SummaryFilterButton: React.FC<SummaryFilterButtonProps> = ({
3334
isElementFiltered(filterType, fields, dir, activeFilters, t)
3435
);
3536

36-
const onSelect = (dir: FilterDir) => {
37+
const onSelect = (dir: FilterDir, e: React.BaseSyntheticEvent) => {
3738
toggleElementFilter(filterType, fields, dir, selected.includes(dir), activeFilters, setFilters, t);
39+
e.preventDefault();
3840
};
3941

4042
const menuItem = (id: FilterDir, label: string) => (
41-
<OptionsMenuItem id={id} key={id} isSelected={selected.includes(id)} onSelect={() => onSelect(id)}>
42-
{label}
43+
<OptionsMenuItem id={id} key={id} onSelect={e => onSelect(id, e!)}>
44+
<Checkbox
45+
id={id + '-checkbox'}
46+
label={label}
47+
isChecked={selected.includes(id)}
48+
onChange={(_, e) => onSelect(id, e)}
49+
/>
4350
</OptionsMenuItem>
4451
);
4552

4653
return (
4754
<OptionsMenu
4855
id={id}
56+
className={'summary-filter-menu'}
4957
data-test={id}
5058
toggle={<OptionsMenuToggle toggleTemplate={<FilterIcon />} onToggle={setIsOpen} hideCaret />}
5159
menuItems={[menuItem('src', t('Source')), menuItem('dst', t('Destination')), menuItem('any', t('Common'))]}

0 commit comments

Comments
 (0)