aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/pages/list/FilterToolbar.tsx
diff options
context:
space:
mode:
authorAien Saidi <aien.saidi@gmail.com>2021-03-24 00:37:04 +0100
committerSascha <GlancingMind@outlook.com>2021-04-07 13:08:26 +0200
commit92ce861fabe0fde3dd180cf4b795355093597a90 (patch)
treed3e35e0876ae6f91255606fb289dfac4d42ac00c /webui/src/pages/list/FilterToolbar.tsx
parent7a7e93c91351781db0361591bcedb5f81b05eb6c (diff)
downloadgit-bug-92ce861fabe0fde3dd180cf4b795355093597a90.tar.gz
feat: multiple label filter
- add search functionality in menu items
Diffstat (limited to 'webui/src/pages/list/FilterToolbar.tsx')
-rw-r--r--webui/src/pages/list/FilterToolbar.tsx34
1 files changed, 24 insertions, 10 deletions
diff --git a/webui/src/pages/list/FilterToolbar.tsx b/webui/src/pages/list/FilterToolbar.tsx
index 3046d9d8..1af96d0f 100644
--- a/webui/src/pages/list/FilterToolbar.tsx
+++ b/webui/src/pages/list/FilterToolbar.tsx
@@ -109,6 +109,20 @@ function FilterToolbar({ query, queryLocation }: Props) {
...params,
[key]: params[key] && params[key].includes(value) ? [] : [value],
});
+ const toggleOrAddParam = (key: string, value: string) => (
+ params: Query
+ ): Query => {
+ const values = params[key];
+ return {
+ ...params,
+ [key]:
+ params[key] && params[key].includes(value)
+ ? values.filter((v) => v !== value)
+ : values
+ ? [...values, value]
+ : [value],
+ };
+ };
const clearParam = (key: string) => (params: Query): Query => ({
...params,
[key]: [],
@@ -150,18 +164,18 @@ function FilterToolbar({ query, queryLocation }: Props) {
dropdown={identities}
itemActive={(key) => hasValue('author', key)}
to={(key) => pipe(replaceParam('author', key), loc)(params)}
+ hasFilter
>
Author
</FilterDropdown>
- {labels.length ? (
- <FilterDropdown
- dropdown={labels}
- itemActive={(key) => hasValue('label', key)}
- to={(key) => pipe(replaceParam('label', key), loc)(params)}
- >
- Label
- </FilterDropdown>
- ) : null}
+ <FilterDropdown
+ dropdown={labels}
+ itemActive={(key) => hasValue('label', key)}
+ to={(key) => pipe(toggleOrAddParam('label', key), loc)(params)}
+ hasFilter
+ >
+ Label
+ </FilterDropdown>
<FilterDropdown
dropdown={[
['id', 'ID'],
@@ -171,7 +185,7 @@ function FilterToolbar({ query, queryLocation }: Props) {
['edit-asc', 'Least recently updated'],
]}
itemActive={(key) => hasValue('sort', key)}
- to={(key) => pipe(replaceParam('sort', key), loc)(params)}
+ to={(key) => pipe(toggleParam('sort', key), loc)(params)}
>
Sort
</FilterDropdown>