import { ViewLayout } from '@/application/collab.type'; import { usePublishContext } from '@/application/publish'; import { notify } from '@/components/_shared/notify'; import { ViewIcon } from '@/components/_shared/view-icon'; import SpaceIcon from '@/components/publish/header/SpaceIcon'; import { renderColor } from '@/utils/color'; import { Tooltip } from '@mui/material'; import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; export interface Crumb { viewId: string; rowId?: string; name: string; icon: string; layout: ViewLayout; extra?: string | null; } function BreadcrumbItem({ crumb, disableClick = false }: { crumb: Crumb; disableClick?: boolean }) { const { viewId, icon, name, layout, extra } = crumb; const extraObj: { is_space?: boolean; space_icon?: string; space_icon_color?: string; } = useMemo(() => { try { return extra ? JSON.parse(extra) : {}; } catch (e) { return {}; } }, [extra]); const { t } = useTranslation(); const onNavigateToView = usePublishContext()?.toView; return (
{ if (disableClick) return; try { await onNavigateToView?.(viewId); } catch (e) { notify.default(t('publish.hasNotBeenPublished')); } }} > {extraObj && extraObj.is_space ? ( ) : ( {icon || } )} {name || t('menuAppHeader.defaultNewPageName')}
); } export default BreadcrumbItem;