-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add filter by config tags for changes
Fixes #1961
- Loading branch information
1 parent
2edba09
commit 158b465
Showing
8 changed files
with
107 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/components/Configs/Changes/ConfigChangesFilters/ConfigTagsDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useGetConfigTagsListQuery } from "@flanksource-ui/api/query-hooks"; | ||
import TristateReactSelect, { | ||
TriStateOptions | ||
} from "@flanksource-ui/ui/Dropdowns/TristateReactSelect"; | ||
import { useField } from "formik"; | ||
import { useMemo } from "react"; | ||
|
||
type Props = { | ||
searchParamKey?: string; | ||
}; | ||
|
||
export function ConfigTagsDropdown({ searchParamKey = "tags" }: Props) { | ||
const [field] = useField({ | ||
name: searchParamKey | ||
}); | ||
|
||
const { data, isLoading } = useGetConfigTagsListQuery(); | ||
|
||
const tagItems = useMemo(() => { | ||
if (data) { | ||
return data.map( | ||
(tag) => | ||
({ | ||
id: `${tag.key}____${tag.value}`, | ||
label: ( | ||
<div className="block space-x-1 text-sm"> | ||
<span className="w-auto text-gray-600">{tag.key}:</span> | ||
<span className="w-full">{tag.value}</span> | ||
</div> | ||
), | ||
value: `${tag.key}____${tag.value}` | ||
} satisfies TriStateOptions) | ||
); | ||
} | ||
}, [data]); | ||
|
||
return ( | ||
<TristateReactSelect | ||
options={tagItems ?? []} | ||
onChange={(value) => { | ||
console.log(value); | ||
if (value) { | ||
field.onChange({ | ||
target: { name: searchParamKey, value: value } | ||
}); | ||
} else { | ||
field.onChange({ | ||
target: { name: searchParamKey, value: undefined } | ||
}); | ||
} | ||
}} | ||
value={field.value} | ||
className="w-auto max-w-[38rem]" | ||
label={"Tags"} | ||
isLoading={isLoading} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters