import { useRouter } from '@uirouter/react'; import { PropsWithChildren } from 'react'; import { RefreshCw } from 'lucide-react'; import { dispatchCacheRefreshEvent } from '@/portainer/services/http-request.helper'; import { Button } from '../buttons'; import { Breadcrumbs } from './Breadcrumbs'; import { Crumb } from './Breadcrumbs/Breadcrumbs'; import { HeaderContainer } from './HeaderContainer'; import { HeaderTitle } from './HeaderTitle'; import { PageTitle } from './PageTitle'; interface Props { id?: string; reload?: boolean; loading?: boolean; onReload?(): Promise | void; breadcrumbs?: (Crumb | string)[] | string; title?: string; /** Render the visible page title row. Defaults to true when title is provided. * Set to false on screens that display the title via another component (e.g. * `ResourceDetailHeader`) to avoid showing it twice. */ showTitle?: boolean; } export function PageHeader({ id, title, breadcrumbs = [], reload, loading, onReload, showTitle = !!title, children, }: PropsWithChildren) { const router = useRouter(); return ( <> {showTitle && title && ( {(reload || children) && (
{reload && ( )} {children}
)}
)} ); function onClickedRefresh() { dispatchCacheRefreshEvent(); return onReload ? onReload() : router.stateService.reload(); } }