Skip to content

Commit

Permalink
fix: fix missing breadcrumbs for catalog changes tab
Browse files Browse the repository at this point in the history
Fixes #2350
  • Loading branch information
mainawycliffe authored and moshloop committed Oct 18, 2024
1 parent 6accf46 commit 4c248f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function ConfigChangeFilters({

const arbitraryFilters = useConfigChangesArbitraryFilters();

const configType = params.get("configTypes") ?? undefined;
const configType = params.get("configType") ?? undefined;

const defaultConfigType = useMemo(() => {
return configType ? `${configType?.replaceAll("::", "__")}:1` : undefined;
Expand All @@ -86,7 +86,7 @@ export function ConfigChangeFilters({
return (
<div className="flex w-full flex-col gap-2">
<FormikFilterForm
paramsToReset={paramsToReset}
paramsToReset={[...paramsToReset, "configType"]}
filterFields={["configTypes", "changeType", "severity", "tags"]}
defaultFieldValues={{
...(configType && { configTypes: defaultConfigType })
Expand Down
10 changes: 5 additions & 5 deletions src/components/Configs/ConfigPageTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import TabbedLinks from "@flanksource-ui/ui/Tabs/TabbedLinks";
import { useMemo } from "react";
import { useSearchParams } from "react-router-dom";
import TabbedLinks from "../../ui/Tabs/TabbedLinks";

type ConfigPageTabsProps = {
activeTab: string;
children: React.ReactNode;
configType?: string;
};

export default function ConfigPageTabs({
activeTab,
children
children,
configType
}: ConfigPageTabsProps) {
const [searchParams] = useSearchParams();

const type = searchParams.get("configType") ?? undefined;

const type = searchParams.get("configType") ?? configType;
const configTabsLists = useMemo(() => {
const query = type ? `?configType=${type}` : "";
return [
Expand Down
27 changes: 25 additions & 2 deletions src/pages/config/ConfigChangesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useGetAllConfigsChangesQuery } from "@flanksource-ui/api/query-hooks/us
import { ConfigChangeTable } from "@flanksource-ui/components/Configs/Changes/ConfigChangeTable";
import { ConfigChangeFilters } from "@flanksource-ui/components/Configs/Changes/ConfigChangesFilters/ConfigChangesFilters";
import ConfigPageTabs from "@flanksource-ui/components/Configs/ConfigPageTabs";
import ConfigsTypeIcon from "@flanksource-ui/components/Configs/ConfigsTypeIcon";
import { InfoMessage } from "@flanksource-ui/components/InfoMessage";
import {
BreadcrumbChild,
Expand All @@ -20,6 +21,14 @@ export function ConfigChangesPage() {
);
const [params] = useSearchParams({});

const configTypes = params.get("configTypes") ?? undefined;
const configType =
// we want to show breadcrumb only if there is only one config type selected
// in the filter dropdown and not multiple
configTypes?.split(",").length === 1
? configTypes.split(",")[0]?.split(":")?.[0].split("__").join("::")
: undefined;

const pageSize = params.get("pageSize") ?? "200";

const { data, isLoading, error, isRefetching, refetch } =
Expand Down Expand Up @@ -59,7 +68,21 @@ export function ConfigChangesPage() {
key="config-catalog-changes"
>
Changes
</BreadcrumbChild>
</BreadcrumbChild>,
...(configType
? [
<BreadcrumbChild
link={`/catalog?configType=${configType}`}
key={configType}
>
<ConfigsTypeIcon
config={{ type: configType }}
showSecondaryIcon
showLabel
/>
</BreadcrumbChild>
]
: [])
]}
/>
}
Expand All @@ -70,7 +93,7 @@ export function ConfigChangesPage() {
loading={isLoading || isRefetching}
contentClass="p-0 h-full flex flex-col flex-1"
>
<ConfigPageTabs activeTab="Changes">
<ConfigPageTabs activeTab="Changes" configType={configType}>
{error ? (
<InfoMessage message={errorMessage} />
) : (
Expand Down

0 comments on commit 4c248f7

Please sign in to comment.