2024-01-10 14:39:45 +00:00
|
|
|
import { useState } from "react";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// hooks
|
2024-01-23 07:58:58 +00:00
|
|
|
import { useIssueDetail, useProjectState, useUser } from "hooks/store";
|
2024-01-10 14:39:45 +00:00
|
|
|
// components
|
|
|
|
import { IssueDescriptionForm, IssueAttachmentRoot, IssueUpdateStatus } from "components/issues";
|
|
|
|
import { IssueParentDetail } from "./parent";
|
|
|
|
import { IssueReaction } from "./reactions";
|
|
|
|
import { SubIssuesRoot } from "../sub-issues";
|
2024-01-23 07:58:58 +00:00
|
|
|
import { IssueActivity } from "./issue-activity";
|
2024-01-10 14:39:45 +00:00
|
|
|
// ui
|
|
|
|
import { StateGroupIcon } from "@plane/ui";
|
|
|
|
// types
|
|
|
|
import { TIssueOperations } from "./root";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
issueId: string;
|
|
|
|
issueOperations: TIssueOperations;
|
|
|
|
is_archived: boolean;
|
|
|
|
is_editable: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const IssueMainContent: React.FC<Props> = observer((props) => {
|
|
|
|
const { workspaceSlug, projectId, issueId, issueOperations, is_archived, is_editable } = props;
|
|
|
|
// states
|
|
|
|
const [isSubmitting, setIsSubmitting] = useState<"submitting" | "submitted" | "saved">("saved");
|
|
|
|
// hooks
|
2024-01-11 12:56:58 +00:00
|
|
|
const { currentUser } = useUser();
|
2024-01-10 14:39:45 +00:00
|
|
|
const { projectStates } = useProjectState();
|
|
|
|
const {
|
|
|
|
issue: { getIssueById },
|
|
|
|
} = useIssueDetail();
|
|
|
|
|
|
|
|
const issue = getIssueById(issueId);
|
|
|
|
if (!issue) return <></>;
|
|
|
|
|
|
|
|
const currentIssueState = projectStates?.find((s) => s.id === issue.state_id);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="rounded-lg space-y-4">
|
|
|
|
{issue.parent_id && (
|
|
|
|
<IssueParentDetail
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
issueId={issueId}
|
|
|
|
issue={issue}
|
|
|
|
issueOperations={issueOperations}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<div className="mb-2.5 flex items-center">
|
|
|
|
{currentIssueState && (
|
|
|
|
<StateGroupIcon
|
|
|
|
className="mr-3 h-4 w-4"
|
|
|
|
stateGroup={currentIssueState.group}
|
|
|
|
color={currentIssueState.color}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<IssueUpdateStatus isSubmitting={isSubmitting} issueDetail={issue} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<IssueDescriptionForm
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
issueId={issueId}
|
|
|
|
setIsSubmitting={(value) => setIsSubmitting(value)}
|
|
|
|
isSubmitting={isSubmitting}
|
|
|
|
issue={issue}
|
|
|
|
issueOperations={issueOperations}
|
2024-01-11 12:56:58 +00:00
|
|
|
disabled={!is_editable}
|
2024-01-10 14:39:45 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
{currentUser && (
|
|
|
|
<IssueReaction
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
issueId={issueId}
|
|
|
|
currentUser={currentUser}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{currentUser && (
|
|
|
|
<SubIssuesRoot
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
2024-01-16 07:16:03 +00:00
|
|
|
parentIssueId={issueId}
|
2024-01-10 14:39:45 +00:00
|
|
|
currentUser={currentUser}
|
2024-01-16 07:16:03 +00:00
|
|
|
disabled={!is_editable}
|
2024-01-10 14:39:45 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<IssueAttachmentRoot
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
issueId={issueId}
|
2024-01-11 12:56:58 +00:00
|
|
|
disabled={!is_editable}
|
2024-01-10 14:39:45 +00:00
|
|
|
/>
|
|
|
|
|
2024-01-23 07:58:58 +00:00
|
|
|
<IssueActivity workspaceSlug={workspaceSlug} projectId={projectId} issueId={issueId} disabled={!is_editable} />
|
2024-01-10 14:39:45 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
});
|