-
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
- Loading branch information
1 parent
4f414e8
commit 547e8ac
Showing
7 changed files
with
108 additions
and
7 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
60 changes: 60 additions & 0 deletions
60
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,60 @@ | ||
import { useGetConfigTagsListQuery } from "@flanksource-ui/api/query-hooks"; | ||
import { useField } from "formik"; | ||
import { useMemo } from "react"; | ||
import { ReactSelectDropdown } from "../../../ReactSelectDropdown"; | ||
|
||
type Props = { | ||
searchParamKey?: string; | ||
}; | ||
|
||
export function ConfigTagsDropdown({ searchParamKey = "tags" }: Props) { | ||
const [field] = useField({ | ||
name: searchParamKey | ||
}); | ||
|
||
const { data, isLoading } = useGetConfigTagsListQuery(); | ||
|
||
const tagItems = useMemo(() => { | ||
if (data) { | ||
const options = data.map((tag) => ({ | ||
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}` | ||
})); | ||
return [{ label: "All", value: "All" }, ...options]; | ||
} | ||
}, [data]); | ||
|
||
return ( | ||
<ReactSelectDropdown | ||
items={tagItems} | ||
name="tags" | ||
onChange={(value) => { | ||
if (value && value !== "All") { | ||
field.onChange({ | ||
target: { name: searchParamKey, value: value } | ||
}); | ||
} else { | ||
field.onChange({ | ||
target: { name: searchParamKey, value: undefined } | ||
}); | ||
} | ||
}} | ||
value={field.value ?? "All"} | ||
className="w-auto max-w-[38rem]" | ||
dropDownClassNames="w-auto max-w-[38rem] left-0" | ||
hideControlBorder | ||
isMulti | ||
prefix={ | ||
<div className="text-xs text-gray-500 mr-2 whitespace-nowrap"> | ||
Tags: | ||
</div> | ||
} | ||
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