-
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 fix: fix issue from pr review
- Loading branch information
1 parent
5085c61
commit 8e48ed4
Showing
18 changed files
with
334 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,65 @@ | ||
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); | ||
}, | ||
{ | ||
enabled: !!id, | ||
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,26 @@ | ||
import { Topology } from "@flanksource-ui/api/types/topology"; | ||
import { TopologyCard } from "../Topology/TopologyCard"; | ||
import { useTopologyCardWidth } from "../Topology/TopologyPopover/topologyPreference"; | ||
|
||
type ConfigComponentsProps = { | ||
topology?: Topology; | ||
}; | ||
|
||
export default function ConfigComponents({ topology }: ConfigComponentsProps) { | ||
const [topologyCardSize] = useTopologyCardWidth(); | ||
|
||
return ( | ||
<div className="flex w-full flex-1 overflow-y-auto"> | ||
<div className="flex w-full flex-wrap p-4"> | ||
{topology?.components?.map((component) => ( | ||
<TopologyCard | ||
key={component.id} | ||
topology={component} | ||
size={topologyCardSize} | ||
menuPosition="absolute" | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.