From 31871f29f13677131d7cb66da189d74fb1d48696 Mon Sep 17 00:00:00 2001 From: Aien Saidi Date: Thu, 18 Mar 2021 18:09:03 +0100 Subject: feat: add filter by label --- webui/src/pages/list/FilterToolbar.tsx | 31 ++++++++++++++++++++++++++----- webui/src/pages/list/ListLabels.graphql | 9 +++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 webui/src/pages/list/ListLabels.graphql (limited to 'webui/src') diff --git a/webui/src/pages/list/FilterToolbar.tsx b/webui/src/pages/list/FilterToolbar.tsx index 92154ad2..37f63b98 100644 --- a/webui/src/pages/list/FilterToolbar.tsx +++ b/webui/src/pages/list/FilterToolbar.tsx @@ -17,6 +17,7 @@ import { } from './Filter'; import { useBugCountQuery } from './FilterToolbar.generated'; import { useListIdentitiesQuery } from './ListIdentities.generated'; +import { useListLabelsQuery } from './ListLabels.generated'; const useStyles = makeStyles((theme) => ({ toolbar: { @@ -63,16 +64,29 @@ type Props = { function FilterToolbar({ query, queryLocation }: Props) { const classes = useStyles(); const params: Query = parse(query); - const { data } = useListIdentitiesQuery(); + const { data: identitiesData } = useListIdentitiesQuery(); + const { data: labelsData } = useListLabelsQuery() let identities: any = []; + let labels: any = []; if ( - data?.repository && - data.repository.allIdentities && - data.repository.allIdentities.nodes + identitiesData?.repository && + identitiesData.repository.allIdentities && + identitiesData.repository.allIdentities.nodes ) { - identities = data.repository.allIdentities.nodes.map((node) => [ + identities = identitiesData.repository.allIdentities.nodes.map((node) => [ + node.name, + node.name, + ]); + } + + if ( + labelsData?.repository && + labelsData.repository.validLabels && + labelsData.repository.validLabels.nodes + ) { + labels = labelsData.repository.validLabels.nodes.map((node) => [ node.name, node.name, ]); @@ -139,6 +153,13 @@ function FilterToolbar({ query, queryLocation }: Props) { > Author + hasValue('label', key)} + to={(key) => pipe(replaceParam('label', key), loc)(params)} + > + Label +