-
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: when a catalog has one topology, show only topology card
Fixes #2174 fix: show loading animation, until card is shown or not chore: wip fix: fix incorrect import fix: change how merged pages work
- Loading branch information
1 parent
0dd788c
commit 405c0f3
Showing
16 changed files
with
530 additions
and
255 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useRef } from "react"; | ||
import { useSearchParams } from "react-router-dom"; | ||
import { LoadingBarRef } from "react-top-loading-bar"; | ||
import { getTopology } from "../services/topology"; | ||
|
||
export default function useTopologyByIDQuery(id: string) { | ||
const [searchParams] = useSearchParams({ | ||
sortBy: "status", | ||
sortOrder: "desc" | ||
}); | ||
|
||
const selectedLabel = searchParams.get("labels") ?? "All"; | ||
const team = searchParams.get("team") ?? "All"; | ||
const topologyType = searchParams.get("type") ?? "All"; | ||
const healthStatus = searchParams.get("status") ?? "All"; | ||
const sortBy = searchParams.get("sortBy") ?? "status"; | ||
const sortOrder = searchParams.get("sortOrder") ?? "desc"; | ||
const agentId = searchParams.get("agent_id") ?? undefined; | ||
const showHiddenComponents = | ||
searchParams.get("showHiddenComponents") ?? undefined; | ||
|
||
const loadingBarRef = useRef<LoadingBarRef>(null); | ||
|
||
return useQuery( | ||
[ | ||
"topologies", | ||
id, | ||
healthStatus, | ||
team, | ||
selectedLabel, | ||
topologyType, | ||
showHiddenComponents, | ||
sortBy, | ||
sortOrder, | ||
agentId | ||
], | ||
() => { | ||
loadingBarRef.current?.continuousStart(); | ||
const apiParams = { | ||
id, | ||
status: healthStatus, | ||
type: topologyType, | ||
team: team, | ||
labels: selectedLabel, | ||
sortBy, | ||
sortOrder, | ||
// only flatten, if topology type is set | ||
...(topologyType && | ||
topologyType.toString().toLowerCase() !== "all" && { | ||
flatten: true | ||
}), | ||
hidden: showHiddenComponents === "no" ? false : undefined, | ||
agent_id: agentId | ||
}; | ||
return getTopology(apiParams); | ||
}, | ||
{ | ||
onSettled: () => { | ||
loadingBarRef.current?.complete(); | ||
} | ||
} | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import useTopologyByIDQuery from "@flanksource-ui/api/query-hooks/useTopologyByIDQuery"; | ||
import IncidentDetailsPageSkeletonLoader from "@flanksource-ui/ui/SkeletonLoader/IncidentDetailsPageSkeletonLoader"; | ||
import { TopologyCard } from "../Topology/TopologyCard"; | ||
import { useTopologyCardWidth } from "../Topology/TopologyPopover/topologyPreference"; | ||
|
||
type ConfigComponentsProps = { | ||
topologyId: string; | ||
}; | ||
|
||
export default function ConfigComponents({ | ||
topologyId | ||
}: ConfigComponentsProps) { | ||
const { data, isLoading } = useTopologyByIDQuery(topologyId); | ||
|
||
const [topologyCardSize] = useTopologyCardWidth(); | ||
|
||
return ( | ||
<div className="flex w-full flex-1 overflow-y-auto"> | ||
<div className="flex w-full flex-wrap p-4"> | ||
{isLoading && data ? ( | ||
<IncidentDetailsPageSkeletonLoader /> | ||
) : ( | ||
data?.components?.[0].components?.map((component) => ( | ||
<TopologyCard | ||
key={component.id} | ||
topology={component} | ||
size={topologyCardSize} | ||
menuPosition="absolute" | ||
/> | ||
)) | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.