import { useLocation } from "react-router"; import LogoHeader from "../assets/logo-header.svg"; import DropDown from "../components/common/DropDown"; import WatcherIcon from "../assets/k8s-watcher.svg"; import ShutDownButton from "../components/ShutDownButton"; import { BsArrowRepeat, BsBoxArrowUpRight, BsBraces, BsGithub, } from "react-icons/bs"; import { useGetApplicationStatus } from "../API/other"; import LinkWithSearchParams from "../components/LinkWithSearchParams"; import apiService from "../API/apiService"; import { useAppContext } from "../context/AppContext"; import { useEffect, useEffectEvent } from "react"; export default function Header() { const { clusterMode, setClusterMode } = useAppContext(); const { data: statusData, isSuccess } = useGetApplicationStatus(); const onSuccess = useEffectEvent(() => { setClusterMode(!!statusData?.ClusterMode); }); useEffect(() => { if (isSuccess && statusData) { onSuccess(); } }, [isSuccess, statusData]); const location = useLocation(); const openProjectPage = () => { window.open("https://github.com/komodorio/helm-dashboard", "_blank"); }; const resetCache = async () => { try { await apiService.fetchWithDefaults("/api/cache", { method: "DELETE", }); window.location.reload(); } catch (error) { console.error(error); } }; const handleResetCache = () => { void resetCache(); }; const openAPI = () => { window.open("/#/docs", "_blank"); }; const getBtnStyle = (identifier: string) => `text-md py-2.5 px-5 ${ location.pathname.includes(`/${identifier}`) ? " text-primary rounded-xs bg-header-install" : "" }`; return (