⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
import { useDraggable } from '@dnd-kit/core';
import { GripVertical } from 'lucide-react';
import { useTranslations } from 'next-intl';
import type { Label as LabelRow } from '@/lib/api/endpoints/labels';
import { colorDot } from '@/components/common/fields/colorDot';
import { SettingsRow } from '../crud/SettingsRow';
import { useSettingsCan } from '../../context/settingsPermission';
// `draggable` means the project has groups to move a label between.
export function SettingsDraggableLabelRow({
label,
draggable,
meta,
onEdit,
onDelete,
}: {
label: LabelRow;
draggable: boolean;
meta?: string;
onEdit: () => void;
onDelete: () => void;
}) {
// Moving a label between groups is a labels edit; disable dragging and hide the
// grip without it.
const canEdit = useSettingsCan()('edit');
const t = useTranslations('settings.labels');
const { setNodeRef, listeners, attributes, isDragging } = useDraggable({
id: label.id,
disabled: !canEdit,
});
const handle =
draggable && canEdit ? (
<button
ref={setNodeRef}
{...listeners}
{...attributes}
title={t('dragToGroup')}
aria-label={t('dragLabel')}
className="flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground active:cursor-grabbing"
>
<GripVertical className="size-4" />
</button>
) : undefined;
return (
<SettingsRow
className="h-11"
handle={handle}
dimmed={isDragging}
media={colorDot(label.color)}
title={label.name}
meta={meta}
editTitle={t('editLabel')}
deleteTitle={t('deleteLabel')}
onEdit={onEdit}
onDelete={onDelete}
/>
);
}