Skip to content

Commit 9917bd3

Browse files
puretensionguanguxiansheng
authored andcommitted
feat(ui): add label filter sync with URL query params (argoproj#14816)
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
1 parent ccef81d commit 9917bd3

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Component: UI
2+
Issues: 14807
3+
Description: Add label query parameter sync with URL in WorkflowTemplates UI to match Workflows list behavior for consistent filtering.
4+
Author: [puretension](https://github.com/puretension)
5+
6+
- WorkflowTemplates UI now properly handles label query parameters (e.g., ?label=key%3Dvalue)
7+
- Combined URL updates and localStorage persistence in single useEffect
8+
- Enables custom UI links for filtered template views
9+
- Verified that URL updates when changing filters and filters persist on page refresh

ui/src/workflow-templates/workflow-template-list.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ export function WorkflowTemplateList({match, location, history}: RouteComponentP
4444
const [namespace, setNamespace] = useState(nsUtils.getNamespace(match.params.namespace) || '');
4545
const [sidePanel, setSidePanel] = useState(queryParams.get('sidePanel') === 'true');
4646
const [namePattern, setNamePattern] = useState('');
47-
const [labels, setLabels] = useState([]);
47+
const [labels, setLabels] = useState<string[]>(() => {
48+
const savedOptions = storage.getItem('options', {});
49+
const savedLabels = savedOptions.labels || [];
50+
const labelQueryParam = queryParams.getAll('label');
51+
return labelQueryParam.length > 0 ? labelQueryParam : savedLabels;
52+
});
53+
4854
const [pagination, setPagination] = useState<Pagination>({
4955
offset: queryParams.get('offset'),
5056
limit: parseLimit(queryParams.get('limit')) || savedOptions.paginationLimit || 500
@@ -62,14 +68,19 @@ export function WorkflowTemplateList({match, location, history}: RouteComponentP
6268
isFirstRender.current = false;
6369
return;
6470
}
71+
storage.setItem('options', {labels}, {});
72+
const params = new URLSearchParams();
73+
labels?.forEach(label => params.append('label', label));
74+
if (sidePanel) {
75+
params.append('sidePanel', 'true');
76+
}
6577
history.push(
6678
historyUrl('workflow-templates' + (nsUtils.getManagedNamespace() ? '' : '/{namespace}'), {
6779
namespace,
68-
sidePanel
80+
extraSearchParams: params
6981
})
7082
);
71-
}, [namespace, sidePanel]);
72-
83+
}, [namespace, sidePanel, labels.toString()]);
7384
// internal state
7485
const [error, setError] = useState<Error>();
7586
const [templates, setTemplates] = useState<WorkflowTemplate[]>();

0 commit comments

Comments
 (0)