Skip to content

Commit 98ca650

Browse files
djangolivogiorgis
andauthored
feat: add urlparams for filters in intermittent failure view (#8748)
Closes #1912975 Co-authored-by: Olivier Giorgis <[email protected]>
1 parent 09e685a commit 98ca650

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ui/intermittent-failures/MainView.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import moment from 'moment';
55
import ReactTable from 'react-table-6';
66

77
import { bugsEndpoint } from '../helpers/url';
8+
import { setUrlParam, getUrlParam } from '../helpers/location';
89

910
import BugColumn from './BugColumn';
1011
import {
@@ -32,6 +33,9 @@ const MainView = (props) => {
3233
} = props;
3334

3435
const textFilter = (filter, row) => {
36+
if (getUrlParam(filter.id) !== filter.value) {
37+
setUrlParam(filter.id, filter.value);
38+
}
3539
const text = row[filter.id];
3640
const regex = RegExp(filter.value, 'i');
3741
if (regex.test(text)) {
@@ -119,6 +123,17 @@ const MainView = (props) => {
119123
};
120124
};
121125

126+
const setInitialFiltersFromUrl = () => {
127+
const filters = [];
128+
for (const header of ['product', 'component', 'summary', 'whiteboard']) {
129+
const param = getUrlParam(header);
130+
if (param) {
131+
filters.push({ id: header, value: getUrlParam(header) });
132+
}
133+
}
134+
return filters;
135+
};
136+
122137
return (
123138
<Layout
124139
{...props}
@@ -179,6 +194,7 @@ const MainView = (props) => {
179194
showPaginationTop
180195
defaultPageSize={50}
181196
filterable
197+
defaultFiltered={setInitialFiltersFromUrl()}
182198
/>
183199
)
184200
}

0 commit comments

Comments
 (0)