mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
feat: use author to filter the list
This commit is contained in:
parent
c7a441bad6
commit
54c5b66271
@ -38,4 +38,5 @@ module.exports = {
|
|||||||
settings: {
|
settings: {
|
||||||
'import/internal-regex': '^src/',
|
'import/internal-regex': '^src/',
|
||||||
},
|
},
|
||||||
|
ignorePatterns: ['**/*.generated.tsx'],
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
"test": "react-scripts test --env=jsdom",
|
"test": "react-scripts test --env=jsdom",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"generate": "graphql-codegen",
|
"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.*"
|
"clean": "rimraf src/**.generated.* src/schema.json src/gqlTypes.* src/fragmentTypes.*"
|
||||||
},
|
},
|
||||||
"proxy": "http://localhost:3001",
|
"proxy": "http://localhost:3001",
|
||||||
|
@ -8,14 +8,15 @@ import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline';
|
|||||||
import ErrorOutline from '@material-ui/icons/ErrorOutline';
|
import ErrorOutline from '@material-ui/icons/ErrorOutline';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Filter,
|
||||||
FilterDropdown,
|
FilterDropdown,
|
||||||
FilterProps,
|
FilterProps,
|
||||||
Filter,
|
|
||||||
parse,
|
parse,
|
||||||
stringify,
|
|
||||||
Query,
|
Query,
|
||||||
|
stringify,
|
||||||
} from './Filter';
|
} from './Filter';
|
||||||
import { useBugCountQuery } from './FilterToolbar.generated';
|
import { useBugCountQuery } from './FilterToolbar.generated';
|
||||||
|
import { useListIdentitiesQuery } from './ListIdentities.generated';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
toolbar: {
|
toolbar: {
|
||||||
@ -35,6 +36,7 @@ type CountingFilterProps = {
|
|||||||
query: string; // the query used as a source to count the number of element
|
query: string; // the query used as a source to count the number of element
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
} & FilterProps;
|
} & FilterProps;
|
||||||
|
|
||||||
function CountingFilter({ query, children, ...props }: CountingFilterProps) {
|
function CountingFilter({ query, children, ...props }: CountingFilterProps) {
|
||||||
const { data, loading, error } = useBugCountQuery({
|
const { data, loading, error } = useBugCountQuery({
|
||||||
variables: { query },
|
variables: { query },
|
||||||
@ -57,9 +59,24 @@ type Props = {
|
|||||||
query: string;
|
query: string;
|
||||||
queryLocation: (query: string) => LocationDescriptor;
|
queryLocation: (query: string) => LocationDescriptor;
|
||||||
};
|
};
|
||||||
|
|
||||||
function FilterToolbar({ query, queryLocation }: Props) {
|
function FilterToolbar({ query, queryLocation }: Props) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const params: Query = parse(query);
|
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 =>
|
const hasKey = (key: string): boolean =>
|
||||||
params[key] && params[key].length > 0;
|
params[key] && params[key].length > 0;
|
||||||
@ -115,6 +132,13 @@ function FilterToolbar({ query, queryLocation }: Props) {
|
|||||||
<Filter active={hasKey('author')}>Author</Filter>
|
<Filter active={hasKey('author')}>Author</Filter>
|
||||||
<Filter active={hasKey('label')}>Label</Filter>
|
<Filter active={hasKey('label')}>Label</Filter>
|
||||||
*/}
|
*/}
|
||||||
|
<FilterDropdown
|
||||||
|
dropdown={identities}
|
||||||
|
itemActive={(key) => hasValue('author', key)}
|
||||||
|
to={(key) => pipe(replaceParam('author', key), loc)(params)}
|
||||||
|
>
|
||||||
|
Author
|
||||||
|
</FilterDropdown>
|
||||||
<FilterDropdown
|
<FilterDropdown
|
||||||
dropdown={[
|
dropdown={[
|
||||||
['id', 'ID'],
|
['id', 'ID'],
|
||||||
|
13
webui/src/pages/list/ListIdentities.graphql
Normal file
13
webui/src/pages/list/ListIdentities.graphql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
query ListIdentities {
|
||||||
|
repository {
|
||||||
|
allIdentities {
|
||||||
|
nodes {
|
||||||
|
id
|
||||||
|
humanId
|
||||||
|
name
|
||||||
|
email
|
||||||
|
displayName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user