Skip to content

Commit

Permalink
feat: add include/exclude shortcuts in Catalog tag list
Browse files Browse the repository at this point in the history
Fixes #2165

fix: fix a few minor issue in filter
  • Loading branch information
mainawycliffe committed Sep 12, 2024
1 parent 6a4874c commit e8ca2d2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
14 changes: 1 addition & 13 deletions src/api/query-hooks/useAllConfigsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const useAllConfigsQuery = ({
const sortBy = searchParams.get("sortBy");
const sortOrder = searchParams.get("sortOrder");
const configType = searchParams.get("configType") ?? undefined;
const labels = searchParams.get("labels") ?? undefined;
const status = searchParams.get("status") ?? undefined;
const health = searchParams.get("health") ?? undefined;

Expand All @@ -34,20 +33,10 @@ export const useAllConfigsQuery = ({
sortOrder,
hideDeletedConfigs,
includeAgents: true,
labels: labels,
health,
status
}),
[
search,
configType,
sortBy,
sortOrder,
hideDeletedConfigs,
labels,
health,
status
]
[search, configType, sortBy, sortOrder, hideDeletedConfigs, health, status]
);

return useQuery(
Expand All @@ -59,7 +48,6 @@ export const useAllConfigsQuery = ({
sortOrder,
hideDeletedConfigs,
true,
labels,
health,
status
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ConfigListTagsCellProps<
hideGroupByView?: boolean;
label?: string;
enableFilterByTag?: boolean;
filterByTagParamKey?: string;
};

export default function ConfigListTagsCell<
Expand All @@ -21,7 +22,8 @@ export default function ConfigListTagsCell<
row,
getValue,
hideGroupByView = false,
enableFilterByTag = false
enableFilterByTag = false,
filterByTagParamKey = "tags"
}: ConfigListTagsCellProps<T>): JSX.Element | null {
const [params, setParams] = useSearchParams();

Expand Down Expand Up @@ -67,10 +69,10 @@ export default function ConfigListTagsCell<
.join(",");

// Update the URL
params.set("tags", updatedValue);
params.set(filterByTagParamKey, updatedValue);
setParams(params);
},
[enableFilterByTag, params, setParams]
[enableFilterByTag, filterByTagParamKey, params, setParams]
);

const groupByProp = decodeURIComponent(params.get("groupByProp") ?? "");
Expand Down
15 changes: 11 additions & 4 deletions src/components/Configs/ConfigList/ConfigListColumn.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Status } from "@flanksource-ui/components/Status";
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
import ChangeCountIcon, {
CountBar
} from "@flanksource-ui/ui/Icons/ChangeCount";
import { CellContext, ColumnDef, Row } from "@tanstack/react-table";
import React from "react";
import { FaTrash } from "react-icons/fa";
Expand All @@ -17,9 +20,6 @@ import ConfigListCostCell, {
import ConfigListDateCell from "./Cells/ConfigListDateCell";
import ConfigListNameCell from "./Cells/ConfigListNameCell";
import ConfigListTagsCell from "./Cells/ConfigListTagsCell";
import ChangeCountIcon, {
CountBar
} from "@flanksource-ui/ui/Icons/ChangeCount";

export const configListColumns: ColumnDef<ConfigItem, any>[] = [
{
Expand Down Expand Up @@ -114,7 +114,14 @@ export const configListColumns: ColumnDef<ConfigItem, any>[] = [
{
header: "Tags",
accessorKey: "tags",
cell: React.memo(ConfigListTagsCell),
cell: React.memo((props) => (
<ConfigListTagsCell
{...props}
hideGroupByView
enableFilterByTag
filterByTagParamKey="labels"
/>
)),
aggregatedCell: "",
maxSize: 300,
minSize: 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export function ConfigLabelsDropdown({ searchParamKey = "labels" }: Props) {
(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>
<span className="space-x-1 text-sm">
<span className="text-gray-600">{tag.key}:</span>
<span>{tag.value}</span>
</span>
),
value: `${tag.key}____${tag.value}`,
id: `${tag.key}____${tag.value}`
Expand Down Expand Up @@ -54,6 +54,7 @@ export function ConfigLabelsDropdown({ searchParamKey = "labels" }: Props) {
});
}
}}
minMenuWidth="400px"
value={field.value}
className="w-auto max-w-[400px]"
label={"Labels"}
Expand Down

0 comments on commit e8ca2d2

Please sign in to comment.