Some checks failed
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Admin Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Codespell / Check for spelling errors (push) Has been cancelled
Sync Repositories / sync_changes (push) Has been cancelled
Synced from upstream: 8853637e981ed7d8a6cff32bd98e7afe20f54362
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { observer } from "mobx-react";
|
|
// plane imports
|
|
import { Tooltip } from "@plane/ui";
|
|
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: React.FC<TReadonlyLabelsProps> = observer((props) => {
|
|
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<typeof label> => Boolean(label));
|
|
|
|
useEffect(() => {
|
|
if (projectId) {
|
|
fetchProjectLabels(workspaceSlug?.toString(), projectId);
|
|
}
|
|
}, [projectId, workspaceSlug]);
|
|
|
|
return (
|
|
<div className={cn("flex items-center gap-2 text-sm", className)}>
|
|
{labels && (
|
|
<>
|
|
<Tooltip
|
|
position="top"
|
|
tooltipHeading="Labels"
|
|
tooltipContent={labels.map((l) => l?.name).join(", ")}
|
|
isMobile={isMobile}
|
|
disabled={labels.length === 0}
|
|
>
|
|
<div className="h-full flex items-center gap-1 rounded py-1 text-sm">
|
|
<span className="h-2 w-2 flex-shrink-0 rounded-full bg-custom-primary" />
|
|
<span>{value.length}</span>
|
|
<span>Labels</span>
|
|
</div>
|
|
</Tooltip>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
});
|