Skip to content

Commit

Permalink
fix: fix issue with catalog page crashing after inactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
mainawycliffe authored and moshloop committed Sep 11, 2024
1 parent 7b9a055 commit baa7c46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/api/query-hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { tristateOutputToQueryFilterParam } from "@flanksource-ui/ui/Dropdowns/TristateReactSelect";
import { UseQueryOptions, useQuery } from "@tanstack/react-query";
import { isNull } from "lodash";
import { CostsData } from "../../api/types/common";
import { toastError } from "../../components/Toast/toast";
import { getIncidentHistory } from "../services/IncidentsHistory";
import { getAllAgents } from "../services/agents";
Expand Down Expand Up @@ -30,6 +29,7 @@ import {
getTopologyNameByID
} from "../services/topology";
import { getPersons, getVersionInfo } from "../services/users";
import { Analysis } from "../types/configs";
import { IncidentHistory } from "../types/incident";
import { ComponentTeamItem } from "../types/topology";

Expand Down Expand Up @@ -372,7 +372,10 @@ export function useGetConfigLabelsListQuery() {
throw error;
}
return data ?? [];
}
},
// 1 minute
cacheTime: 1000 * 60,
staleTime: 1000 * 60
});
}

Expand Down Expand Up @@ -435,9 +438,9 @@ export function useIncidentsHistoryQuery(

export function useConfigAnalysisQuery(
configId: string,
options?: UseQueryOptions<CostsData[], Error>
options?: UseQueryOptions<Analysis[], Error>
) {
return useQuery<CostsData[], Error>(
return useQuery<Analysis[], Error>(
["config_analysis", configId],
() => getConfigAnalysis(configId),
options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function ConfigLabelsDropdown({ searchParamKey = "labels" }: Props) {
const { data, isLoading } = useGetConfigLabelsListQuery();

const labelItems = useMemo(() => {
if (data) {
if (data && Array.isArray(data)) {
const options = data.map((tag) => ({
label: (
<div className="block space-x-1 text-sm">
Expand All @@ -26,6 +26,11 @@ export function ConfigLabelsDropdown({ searchParamKey = "labels" }: Props) {
value: `${tag.key}__:__${tag.value}`
}));
return [{ label: "All", value: "All" }, ...options];
} else {
// Adding this console.error to help debug the issue I noticed happening
// inside the Saas, that's leading to the catalog page crashing
console.error("Invalid data for ConfigLabelsDropdown", data);
return [{ label: "All", value: "All" }];
}
}, [data]);

Expand Down

0 comments on commit baa7c46

Please sign in to comment.