-
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: add side panel for components checks list
Closes #1332
- Loading branch information
1 parent
00534d4
commit 01f2d3d
Showing
4 changed files
with
143 additions
and
1 deletion.
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
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,112 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useAtom } from "jotai"; | ||
import { useEffect } from "react"; | ||
import { AiFillHeart } from "react-icons/ai"; | ||
import { Link } from "react-router-dom"; | ||
import { | ||
ComponentHealthCheckView, | ||
getComponentChecks | ||
} from "../../api/services/topology"; | ||
import PillBadge from "../Badge/PillBadge"; | ||
import CollapsiblePanel from "../CollapsiblePanel"; | ||
import EmptyState from "../EmptyState"; | ||
import TextSkeletonLoader from "../SkeletonLoader/TextSkeletonLoader"; | ||
import { refreshButtonClickedTrigger } from "../SlidingSideBar"; | ||
import { Status } from "../Status"; | ||
import Title from "../Title/title"; | ||
import { Icon } from "../Icon"; | ||
|
||
type ComponentCheckLinkProps = { | ||
componentCheck: ComponentHealthCheckView; | ||
}; | ||
|
||
export function ComponentCheckLink({ | ||
componentCheck: check | ||
}: ComponentCheckLinkProps) { | ||
return ( | ||
<Link | ||
to={{ | ||
pathname: `/health`, | ||
search: `?checkId=${check.id}&timeRange=1h` | ||
}} | ||
className={`flex flex-row justify-between w-full items-center space-x-2 p-2 rounded-md hover:bg-gray-100`} | ||
> | ||
<div className="flex flex-row gap-2 w-full items-center"> | ||
<div className="flex flex-row space-x-1 items-center flex-1text-sm "> | ||
<Status good={check.status === "healthy"} /> | ||
<Icon | ||
name={check.check_component_relationships[0].check.type} | ||
icon={check.check_component_relationships[0].check.icon} | ||
className="w-4 h-auto" | ||
/> | ||
<div className="overflow-hidden text-ellipsis flex-1"> | ||
{check.name} | ||
</div> | ||
</div> | ||
</div> | ||
</Link> | ||
); | ||
} | ||
|
||
type Props = { | ||
componentId: string; | ||
isCollapsed?: boolean; | ||
onCollapsedStateChange?: (isClosed: boolean) => void; | ||
}; | ||
|
||
export function ComponentChecks({ | ||
componentId, | ||
isCollapsed, | ||
onCollapsedStateChange | ||
}: Props) { | ||
const { | ||
data: componentChecks, | ||
isLoading, | ||
refetch, | ||
isFetching | ||
} = useQuery( | ||
["component", "checks", componentId], | ||
() => getComponentChecks(componentId), | ||
{ | ||
enabled: !!componentId | ||
} | ||
); | ||
|
||
const [triggerRefresh] = useAtom(refreshButtonClickedTrigger); | ||
|
||
useEffect(() => { | ||
if (!isLoading && !isFetching) { | ||
refetch(); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [triggerRefresh]); | ||
|
||
return ( | ||
<CollapsiblePanel | ||
isCollapsed={isCollapsed} | ||
onCollapsedStateChange={onCollapsedStateChange} | ||
Header={ | ||
<div className="flex flex-row w-full items-center space-x-2"> | ||
<Title title="Checks" icon={<AiFillHeart className="w-6 h-auto" />} /> | ||
<PillBadge>{componentChecks?.length ?? 0}</PillBadge> | ||
</div> | ||
} | ||
dataCount={componentChecks?.length} | ||
> | ||
<div className="flex flex-col gap-4 w-full"> | ||
{isLoading ? ( | ||
<TextSkeletonLoader /> | ||
) : componentChecks && componentChecks.length > 0 ? ( | ||
componentChecks.map((componentCheck) => ( | ||
<ComponentCheckLink | ||
key={componentCheck.id} | ||
componentCheck={componentCheck} | ||
/> | ||
)) | ||
) : ( | ||
<EmptyState /> | ||
)} | ||
</div> | ||
</CollapsiblePanel> | ||
); | ||
} |
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