From 54c5b66271f4f3d95881a186c8124e7e5dcdb6d4 Mon Sep 17 00:00:00 2001 From: Aien Saidi Date: Thu, 18 Mar 2021 18:00:16 +0100 Subject: [PATCH] feat: use author to filter the list --- webui/.eslintrc.js | 1 + webui/package.json | 2 +- webui/src/pages/list/FilterToolbar.tsx | 28 +++++++++++++++++++-- webui/src/pages/list/ListIdentities.graphql | 13 ++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 webui/src/pages/list/ListIdentities.graphql diff --git a/webui/.eslintrc.js b/webui/.eslintrc.js index 2dfa7543..125fe801 100644 --- a/webui/.eslintrc.js +++ b/webui/.eslintrc.js @@ -38,4 +38,5 @@ module.exports = { settings: { 'import/internal-regex': '^src/', }, + ignorePatterns: ['**/*.generated.tsx'], }; diff --git a/webui/package.json b/webui/package.json index 39696a25..a69473d8 100644 --- a/webui/package.json +++ b/webui/package.json @@ -46,7 +46,7 @@ "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", "generate": "graphql-codegen", - "lint": "eslint src --ext .ts --ext .tsx --ext .js --ext .jsx --ext .graphql", + "lint": "eslint --fix src --ext .ts --ext .tsx --ext .js --ext .jsx --ext .graphql", "clean": "rimraf src/**.generated.* src/schema.json src/gqlTypes.* src/fragmentTypes.*" }, "proxy": "http://localhost:3001", diff --git a/webui/src/pages/list/FilterToolbar.tsx b/webui/src/pages/list/FilterToolbar.tsx index 74eefe4c..92154ad2 100644 --- a/webui/src/pages/list/FilterToolbar.tsx +++ b/webui/src/pages/list/FilterToolbar.tsx @@ -8,14 +8,15 @@ import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline'; import ErrorOutline from '@material-ui/icons/ErrorOutline'; import { + Filter, FilterDropdown, FilterProps, - Filter, parse, - stringify, Query, + stringify, } from './Filter'; import { useBugCountQuery } from './FilterToolbar.generated'; +import { useListIdentitiesQuery } from './ListIdentities.generated'; const useStyles = makeStyles((theme) => ({ toolbar: { @@ -35,6 +36,7 @@ type CountingFilterProps = { query: string; // the query used as a source to count the number of element children: React.ReactNode; } & FilterProps; + function CountingFilter({ query, children, ...props }: CountingFilterProps) { const { data, loading, error } = useBugCountQuery({ variables: { query }, @@ -57,9 +59,24 @@ type Props = { query: string; queryLocation: (query: string) => LocationDescriptor; }; + function FilterToolbar({ query, queryLocation }: Props) { const classes = useStyles(); const params: Query = parse(query); + const { data } = useListIdentitiesQuery(); + + let identities: any = []; + + if ( + data?.repository && + data.repository.allIdentities && + data.repository.allIdentities.nodes + ) { + identities = data.repository.allIdentities.nodes.map((node) => [ + node.name, + node.name, + ]); + } const hasKey = (key: string): boolean => params[key] && params[key].length > 0; @@ -115,6 +132,13 @@ function FilterToolbar({ query, queryLocation }: Props) { Author Label */} + hasValue('author', key)} + to={(key) => pipe(replaceParam('author', key), loc)(params)} + > + Author +