import hljs from "highlight.js/lib/core"; import yaml from "highlight.js/lib/languages/yaml"; import { useMemo, useState } from "react"; import { RiExternalLinkLine } from "react-icons/ri"; import Drawer from "react-modern-drawer"; import { useParams } from "react-router"; import { type StructuredResources, useGetResourceDescription, useGetResources, } from "../../API/releases"; import closeIcon from "../../assets/close.png"; import "react-modern-drawer/dist/index.css"; import Badge, { getBadgeType } from "../Badge"; import Button from "../Button"; import Spinner from "../Spinner"; import { Troubleshoot } from "../Troubleshoot"; hljs.registerLanguage("yaml", yaml); interface Props { isLatest: boolean; } export default function RevisionResource({ isLatest }: Props) { const { namespace = "", chart = "" } = useParams(); const { data: resources, isLoading } = useGetResources(namespace, chart); return ( {isLoading ? ( ) : ( {resources?.length ? ( resources?.map((resource: StructuredResources) => ( )) ) : (
Looks like you don't have any resources.{" "}
)} )}
RESOURCE TYPE NAME STATUS STATUS MESSAGE
); } const ResourceRow = ({ resource, isLatest, }: { resource: StructuredResources; isLatest: boolean; }) => { const { kind, metadata: { name }, status: { conditions }, } = resource; const [isOpen, setIsOpen] = useState(false); const toggleDrawer = () => { setIsOpen((prevState) => !prevState); }; const { reason = "", status = "", message = "" } = conditions?.[0] || {}; const badgeType = getBadgeType(status); return ( <> {kind} {name} {reason ? {reason} : null}
{message && (
{message}
)} {(badgeType === "error" || badgeType === "warning") && ( )}
{isLatest && reason !== "NotFound" ? (
) : null} {isOpen ? ( { setIsOpen(false); }} /> ) : null} ); }; const DescribeResource = ({ resource, closeDrawer, }: { resource: StructuredResources; closeDrawer: () => void; }) => { const { kind, metadata: { name }, status: { conditions }, } = resource; const { status, reason = "" } = conditions?.[0] || {}; const { namespace = "", chart = "" } = useParams(); const { data, isLoading } = useGetResourceDescription( resource.kind, namespace, chart ); const yamlFormattedData = useMemo( () => hljs.highlight(data ?? "", { language: "yaml" })?.value, [data] ); const badgeType = getBadgeType(status); return (

{name}

{reason}

{kind}

See more details in Komodor
{isLoading ? ( ) : (
        
)}
); };