-
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 chore: remove console logs
- Loading branch information
1 parent
179023b
commit 6bc5631
Showing
9 changed files
with
110 additions
and
16 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
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
57 changes: 57 additions & 0 deletions
57
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,57 @@ | ||
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) => { | ||
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
6bc5631
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the tags the expression should be label!=value instead of !label=value