2024-01-10 14:39:45 +00:00
|
|
|
import { FC } from "react";
|
2024-03-12 13:40:35 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-01-10 14:39:45 +00:00
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useIssueDetail } from "@/hooks/store";
|
2024-01-10 14:39:45 +00:00
|
|
|
import { LabelListItem } from "./label-list-item";
|
|
|
|
// hooks
|
|
|
|
// types
|
|
|
|
import { TLabelOperations } from "./root";
|
|
|
|
|
|
|
|
type TLabelList = {
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
issueId: string;
|
|
|
|
labelOperations: TLabelOperations;
|
2024-01-11 12:56:58 +00:00
|
|
|
disabled: boolean;
|
2024-01-10 14:39:45 +00:00
|
|
|
};
|
|
|
|
|
2024-03-12 13:40:35 +00:00
|
|
|
export const LabelList: FC<TLabelList> = observer((props) => {
|
2024-01-11 12:56:58 +00:00
|
|
|
const { workspaceSlug, projectId, issueId, labelOperations, disabled } = props;
|
2024-01-10 14:39:45 +00:00
|
|
|
// hooks
|
|
|
|
const {
|
|
|
|
issue: { getIssueById },
|
|
|
|
} = useIssueDetail();
|
|
|
|
|
|
|
|
const issue = getIssueById(issueId);
|
|
|
|
const issueLabels = issue?.label_ids || undefined;
|
|
|
|
|
|
|
|
if (!issue || !issueLabels) return <></>;
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{issueLabels.map((labelId) => (
|
|
|
|
<LabelListItem
|
2024-03-06 13:09:14 +00:00
|
|
|
key={labelId}
|
2024-01-10 14:39:45 +00:00
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
issueId={issueId}
|
|
|
|
labelId={labelId}
|
|
|
|
labelOperations={labelOperations}
|
2024-01-11 12:56:58 +00:00
|
|
|
disabled={disabled}
|
2024-01-10 14:39:45 +00:00
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
);
|
2024-03-12 13:40:35 +00:00
|
|
|
});
|