fix: issue description empty state initial load in inbox and issue detail page (#3696)

* fix: updated description init loading and added loading confirmation alert in inbox issues, issue peek overview, and issue detail

* fix: updated the space issue in the editor and removed unwanted props in the description-input for issues
This commit is contained in:
guru_sainath 2024-02-19 15:43:57 +05:30 committed by GitHub
parent 17e5663e81
commit bbbd7047d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 80 additions and 35 deletions

View File

@ -100,7 +100,7 @@ const RichTextEditor = ({
}); });
React.useEffect(() => { React.useEffect(() => {
if (editor && initialValue) editor.commands.setContent(initialValue); if (editor && initialValue && editor.getHTML() != initialValue) editor.commands.setContent(initialValue);
}, [editor, initialValue]); }, [editor, initialValue]);
if (!editor) return null; if (!editor) return null;

View File

@ -1,5 +1,4 @@
import { FC, useState, useEffect } from "react"; import { FC, useState, useEffect } from "react";
import { observer } from "mobx-react";
// components // components
import { Loader } from "@plane/ui"; import { Loader } from "@plane/ui";
import { RichReadOnlyEditor, RichTextEditor } from "@plane/rich-text-editor"; import { RichReadOnlyEditor, RichTextEditor } from "@plane/rich-text-editor";
@ -14,19 +13,18 @@ import { TIssueOperations } from "./issue-detail";
import useDebounce from "hooks/use-debounce"; import useDebounce from "hooks/use-debounce";
export type IssueDescriptionInputProps = { export type IssueDescriptionInputProps = {
disabled?: boolean;
value: string | undefined | null;
workspaceSlug: string; workspaceSlug: string;
isSubmitting: "submitting" | "submitted" | "saved";
setIsSubmitting: (value: "submitting" | "submitted" | "saved") => void;
issueOperations: TIssueOperations;
projectId: string; projectId: string;
issueId: string; issueId: string;
initialValue?: string; value: string | undefined;
initialValue: string | undefined;
disabled?: boolean;
issueOperations: TIssueOperations;
setIsSubmitting: (value: "submitting" | "submitted" | "saved") => void;
}; };
export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((props) => { export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = (props) => {
const { disabled, value, workspaceSlug, setIsSubmitting, issueId, issueOperations, projectId, initialValue } = props; const { workspaceSlug, projectId, issueId, value, initialValue, disabled, issueOperations, setIsSubmitting } = props;
// states // states
const [descriptionHTML, setDescriptionHTML] = useState(value); const [descriptionHTML, setDescriptionHTML] = useState(value);
// store hooks // store hooks
@ -78,7 +76,7 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
uploadFile={fileService.getUploadFileFunction(workspaceSlug)} uploadFile={fileService.getUploadFileFunction(workspaceSlug)}
deleteFile={fileService.getDeleteImageFunction(workspaceId)} deleteFile={fileService.getDeleteImageFunction(workspaceId)}
restoreFile={fileService.getRestoreImageFunction(workspaceId)} restoreFile={fileService.getRestoreImageFunction(workspaceId)}
value={descriptionHTML === "" ? "<p></p>" : descriptionHTML} value={descriptionHTML}
initialValue={initialValue} initialValue={initialValue}
dragDropEnabled dragDropEnabled
customClassName="min-h-[150px] shadow-sm" customClassName="min-h-[150px] shadow-sm"
@ -90,4 +88,4 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
mentionHighlights={mentionHighlights} mentionHighlights={mentionHighlights}
/> />
); );
}); };

View File

@ -1,7 +1,8 @@
import { useState } from "react"; import { useEffect, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// hooks // hooks
import { useIssueDetail, useProjectState, useUser } from "hooks/store"; import { useIssueDetail, useProjectState, useUser } from "hooks/store";
import useReloadConfirmations from "hooks/use-reload-confirmation";
// components // components
import { IssueUpdateStatus, TIssueOperations } from "components/issues"; import { IssueUpdateStatus, TIssueOperations } from "components/issues";
import { IssueTitleInput } from "../../title-input"; import { IssueTitleInput } from "../../title-input";
@ -31,12 +32,31 @@ export const InboxIssueMainContent: React.FC<Props> = observer((props) => {
const { const {
issue: { getIssueById }, issue: { getIssueById },
} = useIssueDetail(); } = useIssueDetail();
const { setShowAlert } = useReloadConfirmations(isSubmitting === "submitting");
const issue = getIssueById(issueId); useEffect(() => {
if (isSubmitting === "submitted") {
setShowAlert(false);
setTimeout(async () => {
setIsSubmitting("saved");
}, 3000);
} else if (isSubmitting === "submitting") {
setShowAlert(true);
}
}, [isSubmitting, setShowAlert, setIsSubmitting]);
const issue = issueId ? getIssueById(issueId) : undefined;
if (!issue) return <></>; if (!issue) return <></>;
const currentIssueState = projectStates?.find((s) => s.id === issue.state_id); const currentIssueState = projectStates?.find((s) => s.id === issue.state_id);
const issueDescription =
issue.description_html !== undefined || issue.description_html !== null
? issue.description_html != ""
? issue.description_html
: "<p></p>"
: undefined;
return ( return (
<> <>
<div className="rounded-lg space-y-4"> <div className="rounded-lg space-y-4">
@ -74,12 +94,11 @@ export const InboxIssueMainContent: React.FC<Props> = observer((props) => {
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={issue.project_id} projectId={issue.project_id}
issueId={issue.id} issueId={issue.id}
isSubmitting={isSubmitting} value={issueDescription}
setIsSubmitting={(value) => setIsSubmitting(value)} initialValue={issueDescription}
issueOperations={issueOperations}
disabled={!is_editable} disabled={!is_editable}
value={issue.description_html} issueOperations={issueOperations}
initialValue={issue.description_html} setIsSubmitting={(value) => setIsSubmitting(value)}
/> />
{currentUser && ( {currentUser && (

View File

@ -1,7 +1,8 @@
import { useState } from "react"; import { useEffect, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// hooks // hooks
import { useIssueDetail, useProjectState, useUser } from "hooks/store"; import { useIssueDetail, useProjectState, useUser } from "hooks/store";
import useReloadConfirmations from "hooks/use-reload-confirmation";
// components // components
import { IssueAttachmentRoot, IssueUpdateStatus } from "components/issues"; import { IssueAttachmentRoot, IssueUpdateStatus } from "components/issues";
import { IssueTitleInput } from "../title-input"; import { IssueTitleInput } from "../title-input";
@ -33,12 +34,31 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
const { const {
issue: { getIssueById }, issue: { getIssueById },
} = useIssueDetail(); } = useIssueDetail();
const { setShowAlert } = useReloadConfirmations(isSubmitting === "submitting");
const issue = getIssueById(issueId); useEffect(() => {
if (isSubmitting === "submitted") {
setShowAlert(false);
setTimeout(async () => {
setIsSubmitting("saved");
}, 2000);
} else if (isSubmitting === "submitting") {
setShowAlert(true);
}
}, [isSubmitting, setShowAlert, setIsSubmitting]);
const issue = issueId ? getIssueById(issueId) : undefined;
if (!issue) return <></>; if (!issue) return <></>;
const currentIssueState = projectStates?.find((s) => s.id === issue.state_id); const currentIssueState = projectStates?.find((s) => s.id === issue.state_id);
const issueDescription =
issue.description_html !== undefined || issue.description_html !== null
? issue.description_html != ""
? issue.description_html
: "<p></p>"
: undefined;
return ( return (
<> <>
<div className="rounded-lg space-y-4"> <div className="rounded-lg space-y-4">
@ -78,11 +98,11 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={issue.project_id} projectId={issue.project_id}
issueId={issue.id} issueId={issue.id}
isSubmitting={isSubmitting} value={issueDescription}
setIsSubmitting={(value) => setIsSubmitting(value)} initialValue={issueDescription}
issueOperations={issueOperations}
disabled={!is_editable} disabled={!is_editable}
value={issue.description_html} issueOperations={issueOperations}
setIsSubmitting={(value) => setIsSubmitting(value)}
/> />
{currentUser && ( {currentUser && (

View File

@ -30,12 +30,6 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = observer(
} = useIssueDetail(); } = useIssueDetail();
// hooks // hooks
const { setShowAlert } = useReloadConfirmations(isSubmitting === "submitting"); const { setShowAlert } = useReloadConfirmations(isSubmitting === "submitting");
// derived values
const issue = getIssueById(issueId);
if (!issue) return <></>;
const projectDetails = getProjectById(issue?.project_id);
useEffect(() => { useEffect(() => {
if (isSubmitting === "submitted") { if (isSubmitting === "submitted") {
@ -48,6 +42,18 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = observer(
} }
}, [isSubmitting, setShowAlert, setIsSubmitting]); }, [isSubmitting, setShowAlert, setIsSubmitting]);
const issue = issueId ? getIssueById(issueId) : undefined;
if (!issue) return <></>;
const projectDetails = getProjectById(issue?.project_id);
const issueDescription =
issue.description_html !== undefined || issue.description_html !== null
? issue.description_html != ""
? issue.description_html
: "<p></p>"
: undefined;
return ( return (
<> <>
<span className="text-base font-medium text-custom-text-400"> <span className="text-base font-medium text-custom-text-400">
@ -63,16 +69,18 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = observer(
disabled={disabled} disabled={disabled}
value={issue.name} value={issue.name}
/> />
<IssueDescriptionInput <IssueDescriptionInput
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={issue.project_id} projectId={issue.project_id}
issueId={issue.id} issueId={issue.id}
isSubmitting={isSubmitting} value={issueDescription}
setIsSubmitting={(value) => setIsSubmitting(value)} initialValue={issueDescription}
issueOperations={issueOperations}
disabled={disabled} disabled={disabled}
value={issue.description_html} issueOperations={issueOperations}
setIsSubmitting={(value) => setIsSubmitting(value)}
/> />
{currentUser && ( {currentUser && (
<IssueReaction <IssueReaction
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}