ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: source-side редактирование открытого внешнего запроса и перестройка маршрутизации
This commit is contained in:
@@ -13,7 +13,7 @@ import { Badge } from "@plane/propel/badge";
|
||||
import { TOAST_TYPE, setToast } from "@plane/propel/toast";
|
||||
import type { TExternalContourRequest, TIssue, TNameDescriptionLoader } from "@plane/types";
|
||||
import { EFileAssetType } from "@plane/types";
|
||||
import { getTextContent, renderFormattedDate } from "@plane/utils";
|
||||
import { getTextContent } from "@plane/utils";
|
||||
import { DescriptionVersionsRoot } from "@/components/core/description-versions";
|
||||
import { DescriptionInput } from "@/components/editor/rich-text/description-input";
|
||||
import { DescriptionInputLoader } from "@/components/editor/rich-text/description-input/loader";
|
||||
@@ -45,16 +45,26 @@ type Props = {
|
||||
contourRequest: TExternalContourRequest;
|
||||
hasDirectTargetAccess: boolean;
|
||||
isEditable: boolean;
|
||||
isSourceEditable: boolean;
|
||||
isSubmitting: TNameDescriptionLoader;
|
||||
setIsSubmitting: Dispatch<SetStateAction<TNameDescriptionLoader>>;
|
||||
};
|
||||
|
||||
export const ExternalContoursIssueMainContent = observer(function ExternalContoursIssueMainContent(props: Props) {
|
||||
const { workspaceSlug, sourceProjectId, contourRequest, hasDirectTargetAccess, isEditable, isSubmitting, setIsSubmitting } = props;
|
||||
const {
|
||||
workspaceSlug,
|
||||
sourceProjectId,
|
||||
contourRequest,
|
||||
hasDirectTargetAccess,
|
||||
isEditable,
|
||||
isSourceEditable,
|
||||
isSubmitting,
|
||||
setIsSubmitting,
|
||||
} = props;
|
||||
const { t } = useTranslation();
|
||||
const editorRef = useRef<EditorRefApi>(null);
|
||||
const { data: currentUser } = useUser();
|
||||
const { loader, updateRequestIssue } = useProjectExternalContours();
|
||||
const { loader, updateRequest, updateRequestIssue } = useProjectExternalContours();
|
||||
const { setShowAlert } = useReloadConfirmations(isSubmitting === "submitting");
|
||||
|
||||
useEffect(() => {
|
||||
@@ -107,17 +117,77 @@ export const ExternalContoursIssueMainContent = observer(function ExternalContou
|
||||
[contourRequest.id, targetProjectId, t, updateRequestIssue, workspaceSlug]
|
||||
);
|
||||
|
||||
const sourceIssueOperations: TIssueOperations = useMemo(
|
||||
() => ({
|
||||
fetch: async () => undefined,
|
||||
remove: async () => undefined,
|
||||
update: async (_workspaceSlug: string, _projectId: string, requestId: string, data: Partial<TIssue>) => {
|
||||
try {
|
||||
await updateRequest(workspaceSlug, sourceProjectId, requestId, {
|
||||
name: data.name,
|
||||
description_html: data.description_html,
|
||||
});
|
||||
} catch {
|
||||
setToast({ title: t("error"), type: TOAST_TYPE.ERROR, message: t("issue_could_not_be_updated") });
|
||||
}
|
||||
},
|
||||
}),
|
||||
[sourceProjectId, t, updateRequest, workspaceSlug]
|
||||
);
|
||||
|
||||
if (!issue || !issue.project_id || !issue.id) return <></>;
|
||||
|
||||
if (!hasDirectTargetAccess) {
|
||||
return (
|
||||
<>
|
||||
<div className="space-y-4 pb-4">
|
||||
<h1 className="text-xl font-semibold text-primary">{issue.name}</h1>
|
||||
<div
|
||||
className="prose prose-invert max-w-none text-sm text-secondary [&_p]:mb-3"
|
||||
dangerouslySetInnerHTML={{ __html: issue.description_html || "<p></p>" }}
|
||||
/>
|
||||
{isSourceEditable ? (
|
||||
<>
|
||||
<IssueTitleInput
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={sourceProjectId}
|
||||
issueId={contourRequest.id}
|
||||
isSubmitting={isSubmitting}
|
||||
setIsSubmitting={(value) => setIsSubmitting(value)}
|
||||
issueOperations={sourceIssueOperations}
|
||||
disabled={false}
|
||||
value={issue.name}
|
||||
containerClassName="-ml-3"
|
||||
/>
|
||||
|
||||
{loader === "issue-loading" || issue.description_html === undefined ? (
|
||||
<DescriptionInputLoader />
|
||||
) : (
|
||||
<DescriptionInput
|
||||
issueSequenceId={issue.sequence_id}
|
||||
containerClassName="-ml-3 border-none"
|
||||
disabled={false}
|
||||
disabledExtensions={["image"]}
|
||||
editorRef={editorRef}
|
||||
entityId={issue.id}
|
||||
fileAssetType={EFileAssetType.ISSUE_DESCRIPTION}
|
||||
initialValue={!issue.description_html || issue.description_html === "" ? "<p></p>" : issue.description_html}
|
||||
key={`${issue.id}-source`}
|
||||
onSubmit={async (value) => {
|
||||
await sourceIssueOperations.update(workspaceSlug, sourceProjectId, contourRequest.id, {
|
||||
description_html: value.description_html,
|
||||
});
|
||||
}}
|
||||
projectId={sourceProjectId}
|
||||
setIsSubmitting={(value) => setIsSubmitting(value)}
|
||||
workspaceSlug={workspaceSlug}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h1 className="text-xl font-semibold text-primary">{issue.name}</h1>
|
||||
<div
|
||||
className="prose prose-invert max-w-none text-sm text-secondary [&_p]:mb-3"
|
||||
dangerouslySetInnerHTML={{ __html: issue.description_html || "<p></p>" }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="py-4">
|
||||
@@ -127,34 +197,11 @@ export const ExternalContoursIssueMainContent = observer(function ExternalContou
|
||||
<div className="py-4">
|
||||
<div className="mb-2 text-body-sm-medium">{t("external_contours_page.properties.section_title")}</div>
|
||||
<div className="flex flex-col gap-3 text-13 text-secondary">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-tertiary">{t("external_contours_page.properties.target_contour")}</span>
|
||||
<Badge variant="neutral">{issue.project_detail?.name || t("common.none")}</Badge>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-tertiary">{t("assignees")}</span>
|
||||
{issue.assignee_details?.length ? (
|
||||
issue.assignee_details.map((assignee) => (
|
||||
<Badge key={assignee.id} variant="neutral">
|
||||
{assignee.display_name}
|
||||
</Badge>
|
||||
))
|
||||
) : (
|
||||
<span>{t("external_contours_page.list.unassigned")}</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-tertiary">{t("priority")}</span>
|
||||
<Badge variant="neutral">{issue.priority || t("none")}</Badge>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-tertiary">{t("due_date")}</span>
|
||||
<span>{issue.target_date ? renderFormattedDate(issue.target_date) : t("common.none")}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-tertiary">{t("labels")}</span>
|
||||
{issue.label_details?.length ? (
|
||||
@@ -183,7 +230,7 @@ export const ExternalContoursIssueMainContent = observer(function ExternalContou
|
||||
|
||||
<ExternalContoursMirroredActivity activity={mirroredActivity} />
|
||||
|
||||
<div className="py-4 text-13 text-secondary">{t("external_contours_page.readonly_source_view")}</div>
|
||||
{!isSourceEditable && <div className="py-4 text-13 text-secondary">{t("external_contours_page.readonly_source_view")}</div>}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user