Merge branch 'preview' of github.com:makeplane/plane into develop

This commit is contained in:
sriram veeraghanta 2024-03-22 18:38:03 +05:30
commit e4211e5817
6 changed files with 38 additions and 41 deletions

View File

@ -1,18 +1,19 @@
import { FC, useState } from "react"; import { FC } from "react";
import { observer } from "mobx-react";
import Link from "next/link"; import Link from "next/link";
import { AlertCircle, X } from "lucide-react"; import { AlertCircle, X } from "lucide-react";
// hooks
// ui
import { Tooltip } from "@plane/ui"; import { Tooltip } from "@plane/ui";
// components
// icons
import { getFileIcon } from "@/components/icons"; import { getFileIcon } from "@/components/icons";
// helper
import { convertBytesToSize, getFileExtension, getFileName } from "@/helpers/attachment.helper"; import { convertBytesToSize, getFileExtension, getFileName } from "@/helpers/attachment.helper";
import { renderFormattedDate } from "@/helpers/date-time.helper"; import { renderFormattedDate } from "@/helpers/date-time.helper";
import { truncateText } from "@/helpers/string.helper"; import { truncateText } from "@/helpers/string.helper";
import { useIssueDetail, useMember } from "@/hooks/store"; import { useIssueDetail, useMember } from "@/hooks/store";
import { usePlatformOS } from "@/hooks/use-platform-os"; import { usePlatformOS } from "@/hooks/use-platform-os";
// hooks
// ui
// components
// icons
// helper
import { IssueAttachmentDeleteModal } from "./delete-attachment-confirmation-modal"; import { IssueAttachmentDeleteModal } from "./delete-attachment-confirmation-modal";
// types // types
import { TAttachmentOperations } from "./root"; import { TAttachmentOperations } from "./root";
@ -25,16 +26,17 @@ type TIssueAttachmentsDetail = {
disabled?: boolean; disabled?: boolean;
}; };
export const IssueAttachmentsDetail: FC<TIssueAttachmentsDetail> = (props) => { export const IssueAttachmentsDetail: FC<TIssueAttachmentsDetail> = observer((props) => {
// props // props
const { attachmentId, handleAttachmentOperations, disabled } = props; const { attachmentId, handleAttachmentOperations, disabled } = props;
// store hooks // store hooks
const { getUserDetails } = useMember(); const { getUserDetails } = useMember();
const { const {
attachment: { getAttachmentById }, attachment: { getAttachmentById },
isDeleteAttachmentModalOpen,
toggleDeleteAttachmentModal,
} = useIssueDetail(); } = useIssueDetail();
// states // states
const [attachmentDeleteModal, setAttachmentDeleteModal] = useState<boolean>(false);
const { isMobile } = usePlatformOS(); const { isMobile } = usePlatformOS();
const attachment = attachmentId && getAttachmentById(attachmentId); const attachment = attachmentId && getAttachmentById(attachmentId);
@ -42,8 +44,8 @@ export const IssueAttachmentsDetail: FC<TIssueAttachmentsDetail> = (props) => {
return ( return (
<> <>
<IssueAttachmentDeleteModal <IssueAttachmentDeleteModal
isOpen={attachmentDeleteModal} isOpen={isDeleteAttachmentModalOpen}
setIsOpen={setAttachmentDeleteModal} setIsOpen={() => toggleDeleteAttachmentModal(false)}
handleAttachmentOperations={handleAttachmentOperations} handleAttachmentOperations={handleAttachmentOperations}
data={attachment} data={attachment}
/> />
@ -81,15 +83,11 @@ export const IssueAttachmentsDetail: FC<TIssueAttachmentsDetail> = (props) => {
</Link> </Link>
{!disabled && ( {!disabled && (
<button <button onClick={() => toggleDeleteAttachmentModal(true)}>
onClick={() => {
setAttachmentDeleteModal(true);
}}
>
<X className="h-4 w-4 text-custom-text-200 hover:text-custom-text-100" /> <X className="h-4 w-4 text-custom-text-200 hover:text-custom-text-100" />
</button> </button>
)} )}
</div> </div>
</> </>
); );
}; });

View File

@ -53,7 +53,7 @@ export type PeekOverviewHeaderProps = {
issueId: string; issueId: string;
isArchived: boolean; isArchived: boolean;
disabled: boolean; disabled: boolean;
toggleDeleteIssueModal: (value: boolean) => void; toggleDeleteIssueModal: (issueId: string | null) => void;
toggleArchiveIssueModal: (value: boolean) => void; toggleArchiveIssueModal: (value: boolean) => void;
handleRestoreIssue: () => void; handleRestoreIssue: () => void;
isSubmitting: "submitting" | "submitted" | "saved"; isSubmitting: "submitting" | "submitted" | "saved";
@ -188,7 +188,7 @@ export const IssuePeekOverviewHeader: FC<PeekOverviewHeaderProps> = observer((pr
)} )}
{!disabled && ( {!disabled && (
<Tooltip tooltipContent="Delete" isMobile={isMobile}> <Tooltip tooltipContent="Delete" isMobile={isMobile}>
<button type="button" onClick={() => toggleDeleteIssueModal(true)}> <button type="button" onClick={() => toggleDeleteIssueModal(issueId)}>
<Trash2 className="h-4 w-4 text-custom-text-300 hover:text-custom-text-200" /> <Trash2 className="h-4 w-4 text-custom-text-300 hover:text-custom-text-200" />
</button> </button>
</Tooltip> </Tooltip>

View File

@ -91,26 +91,18 @@ export const IssueView: FC<IIssueView> = observer((props) => {
/> />
)} )}
{issue && !is_archived && ( {issue && isDeleteIssueModalOpen === issue.id && (
<DeleteIssueModal <DeleteIssueModal
isOpen={isDeleteIssueModalOpen} isOpen={!!isDeleteIssueModalOpen}
handleClose={() => { handleClose={() => {
toggleDeleteIssueModal(false); toggleDeleteIssueModal(null);
removeRoutePeekId();
}} }}
data={issue} data={issue}
onSubmit={() => issueOperations.remove(workspaceSlug, projectId, issueId)} onSubmit={() => issueOperations.remove(workspaceSlug, projectId, issueId)}
/> />
)} )}
{issue && is_archived && (
<DeleteIssueModal
data={issue}
isOpen={isDeleteIssueModalOpen}
handleClose={() => toggleDeleteIssueModal(false)}
onSubmit={() => issueOperations.remove(workspaceSlug, projectId, issueId)}
/>
)}
<div className="w-full !text-base"> <div className="w-full !text-base">
{issueId && ( {issueId && (
<div <div

View File

@ -158,7 +158,7 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {
<CustomMenu.MenuItem <CustomMenu.MenuItem
onClick={() => { onClick={() => {
handleIssueCrudState("delete", parentIssueId, issue); handleIssueCrudState("delete", parentIssueId, issue);
toggleDeleteIssueModal(true); toggleDeleteIssueModal(issue.id);
}} }}
> >
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">

View File

@ -523,7 +523,7 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {
isOpen={issueCrudState?.delete?.toggle} isOpen={issueCrudState?.delete?.toggle}
handleClose={() => { handleClose={() => {
handleIssueCrudState("delete", null, null); handleIssueCrudState("delete", null, null);
toggleDeleteIssueModal(false); toggleDeleteIssueModal(null);
}} }}
data={issueCrudState?.delete?.issue as TIssue} data={issueCrudState?.delete?.issue as TIssue}
onSubmit={async () => onSubmit={async () =>

View File

@ -47,10 +47,11 @@ export interface IIssueDetail
isCreateIssueModalOpen: boolean; isCreateIssueModalOpen: boolean;
isIssueLinkModalOpen: boolean; isIssueLinkModalOpen: boolean;
isParentIssueModalOpen: boolean; isParentIssueModalOpen: boolean;
isDeleteIssueModalOpen: boolean; isDeleteIssueModalOpen: string | null;
isArchiveIssueModalOpen: boolean; isArchiveIssueModalOpen: boolean;
isRelationModalOpen: TIssueRelationTypes | null; isRelationModalOpen: TIssueRelationTypes | null;
isSubIssuesModalOpen: boolean; isSubIssuesModalOpen: boolean;
isDeleteAttachmentModalOpen: boolean;
// computed // computed
isAnyModalOpen: boolean; isAnyModalOpen: boolean;
// actions // actions
@ -58,10 +59,11 @@ export interface IIssueDetail
toggleCreateIssueModal: (value: boolean) => void; toggleCreateIssueModal: (value: boolean) => void;
toggleIssueLinkModal: (value: boolean) => void; toggleIssueLinkModal: (value: boolean) => void;
toggleParentIssueModal: (value: boolean) => void; toggleParentIssueModal: (value: boolean) => void;
toggleDeleteIssueModal: (value: boolean) => void; toggleDeleteIssueModal: (issueId: string | null) => void;
toggleArchiveIssueModal: (value: boolean) => void; toggleArchiveIssueModal: (value: boolean) => void;
toggleRelationModal: (value: TIssueRelationTypes | null) => void; toggleRelationModal: (relationType: TIssueRelationTypes | null) => void;
toggleSubIssuesModal: (value: boolean) => void; toggleSubIssuesModal: (value: boolean) => void;
toggleDeleteAttachmentModal: (value: boolean) => void;
// store // store
rootIssueStore: IIssueRootStore; rootIssueStore: IIssueRootStore;
issue: IIssueStore; issue: IIssueStore;
@ -82,10 +84,11 @@ export class IssueDetail implements IIssueDetail {
isCreateIssueModalOpen: boolean = false; isCreateIssueModalOpen: boolean = false;
isIssueLinkModalOpen: boolean = false; isIssueLinkModalOpen: boolean = false;
isParentIssueModalOpen: boolean = false; isParentIssueModalOpen: boolean = false;
isDeleteIssueModalOpen: boolean = false; isDeleteIssueModalOpen: string | null = null;
isArchiveIssueModalOpen: boolean = false; isArchiveIssueModalOpen: boolean = false;
isRelationModalOpen: TIssueRelationTypes | null = null; isRelationModalOpen: TIssueRelationTypes | null = null;
isSubIssuesModalOpen: boolean = false; isSubIssuesModalOpen: boolean = false;
isDeleteAttachmentModalOpen: boolean = false;
// store // store
rootIssueStore: IIssueRootStore; rootIssueStore: IIssueRootStore;
issue: IIssueStore; issue: IIssueStore;
@ -110,6 +113,7 @@ export class IssueDetail implements IIssueDetail {
isArchiveIssueModalOpen: observable.ref, isArchiveIssueModalOpen: observable.ref,
isRelationModalOpen: observable.ref, isRelationModalOpen: observable.ref,
isSubIssuesModalOpen: observable.ref, isSubIssuesModalOpen: observable.ref,
isDeleteAttachmentModalOpen: observable.ref,
// computed // computed
isAnyModalOpen: computed, isAnyModalOpen: computed,
// action // action
@ -121,6 +125,7 @@ export class IssueDetail implements IIssueDetail {
toggleArchiveIssueModal: action, toggleArchiveIssueModal: action,
toggleRelationModal: action, toggleRelationModal: action,
toggleSubIssuesModal: action, toggleSubIssuesModal: action,
toggleDeleteAttachmentModal: action,
}); });
// store // store
@ -143,10 +148,11 @@ export class IssueDetail implements IIssueDetail {
this.isCreateIssueModalOpen || this.isCreateIssueModalOpen ||
this.isIssueLinkModalOpen || this.isIssueLinkModalOpen ||
this.isParentIssueModalOpen || this.isParentIssueModalOpen ||
this.isDeleteIssueModalOpen || !!this.isDeleteIssueModalOpen ||
this.isArchiveIssueModalOpen || this.isArchiveIssueModalOpen ||
Boolean(this.isRelationModalOpen) || !!this.isRelationModalOpen ||
this.isSubIssuesModalOpen this.isSubIssuesModalOpen ||
this.isDeleteAttachmentModalOpen
); );
} }
@ -155,10 +161,11 @@ export class IssueDetail implements IIssueDetail {
toggleCreateIssueModal = (value: boolean) => (this.isCreateIssueModalOpen = value); toggleCreateIssueModal = (value: boolean) => (this.isCreateIssueModalOpen = value);
toggleIssueLinkModal = (value: boolean) => (this.isIssueLinkModalOpen = value); toggleIssueLinkModal = (value: boolean) => (this.isIssueLinkModalOpen = value);
toggleParentIssueModal = (value: boolean) => (this.isParentIssueModalOpen = value); toggleParentIssueModal = (value: boolean) => (this.isParentIssueModalOpen = value);
toggleDeleteIssueModal = (value: boolean) => (this.isDeleteIssueModalOpen = value); toggleDeleteIssueModal = (issueId: string | null) => (this.isDeleteIssueModalOpen = issueId);
toggleArchiveIssueModal = (value: boolean) => (this.isArchiveIssueModalOpen = value); toggleArchiveIssueModal = (value: boolean) => (this.isArchiveIssueModalOpen = value);
toggleRelationModal = (value: TIssueRelationTypes | null) => (this.isRelationModalOpen = value); toggleRelationModal = (relationType: TIssueRelationTypes | null) => (this.isRelationModalOpen = relationType);
toggleSubIssuesModal = (value: boolean) => (this.isSubIssuesModalOpen = value); toggleSubIssuesModal = (value: boolean) => (this.isSubIssuesModalOpen = value);
toggleDeleteAttachmentModal = (value: boolean) => (this.isDeleteAttachmentModalOpen = value);
// issue // issue
fetchIssue = async ( fetchIssue = async (