/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { useEffect } from "react"; import { observer } from "mobx-react"; // plane imports import { Tooltip } from "@makeplane/propel/components/tooltip"; import { cn } from "@plane/utils"; // hooks import { useLabel } from "@/hooks/store/use-label"; import { usePlatformOS } from "@/hooks/use-platform-os"; export type TReadonlyLabelsProps = { className?: string; hideIcon?: boolean; value: string[]; placeholder?: string; projectId: string | undefined; workspaceSlug: string; }; export const ReadonlyLabels = observer(function ReadonlyLabels(props: TReadonlyLabelsProps) { const { className, value, projectId, workspaceSlug } = props; const { getLabelById, fetchProjectLabels } = useLabel(); const { isMobile } = usePlatformOS(); const labels = value .map((labelId) => getLabelById(labelId)) .filter((label): label is NonNullable => Boolean(label)); useEffect(() => { if (projectId) { fetchProjectLabels(workspaceSlug?.toString(), projectId); } }, [projectId, workspaceSlug]); return (
{labels && ( <> l?.name).join(", ")}`} layout="stacked" disabled={labels.length === 0 || isMobile} >
{value.length} Labels
)}
); });