mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
feat: add filter by label
This commit is contained in:
parent
54c5b66271
commit
31871f29f1
@ -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
|
||||
</FilterDropdown>
|
||||
<FilterDropdown
|
||||
dropdown={labels}
|
||||
itemActive={(key) => hasValue('label', key)}
|
||||
to={(key) => pipe(replaceParam('label', key), loc)(params)}
|
||||
>
|
||||
Label
|
||||
</FilterDropdown>
|
||||
<FilterDropdown
|
||||
dropdown={[
|
||||
['id', 'ID'],
|
||||
|
9
webui/src/pages/list/ListLabels.graphql
Normal file
9
webui/src/pages/list/ListLabels.graphql
Normal file
@ -0,0 +1,9 @@
|
||||
query ListLabels {
|
||||
repository {
|
||||
validLabels {
|
||||
nodes {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user