Skip to content

Commit

Permalink
chore: show loading animation when loading config
Browse files Browse the repository at this point in the history
  • Loading branch information
mainawycliffe committed Oct 2, 2024
1 parent 82a3629 commit 3c38f01
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Configs/ConfigLink/ConfigLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getConfigsByID } from "@flanksource-ui/api/services/configs";
import { ConfigIcon } from "@flanksource-ui/ui/Icons/ConfigIcon";
import TextSkeletonLoader from "@flanksource-ui/ui/SkeletonLoader/TextSkeletonLoader";
import { useQuery } from "@tanstack/react-query";
import clsx from "clsx";
import { HTMLAttributeAnchorTarget } from "react";
Expand All @@ -25,7 +26,7 @@ export default function ConfigLink({
showPrimaryIcon = true,
showSecondaryIcon = true
}: ConfigLinkProps) {
const { data: configFromRequest } = useQuery({
const { data: configFromRequest, isLoading } = useQuery({
queryKey: ["config", configId, config],
queryFn: () => getConfigsByID(configId!),
// Only run the query if we have a configId and we don't have a config
Expand All @@ -34,6 +35,10 @@ export default function ConfigLink({

const data = config || configFromRequest;

if (isLoading) {
return <TextSkeletonLoader className="h-5 w-24" />;
}

if (!data) {
return null;
}
Expand Down

0 comments on commit 3c38f01

Please sign in to comment.