diff --git a/web/components/command-palette/command-pallette.tsx b/web/components/command-palette/command-pallette.tsx index 0bd7d7eb7..0488455fb 100644 --- a/web/components/command-palette/command-pallette.tsx +++ b/web/components/command-palette/command-pallette.tsx @@ -34,6 +34,7 @@ export const CommandPalette: FC = observer(() => { theme: { toggleSidebar }, user: { currentUser }, trackEvent: { setTrackElement }, + projectIssues: { removeIssue }, } = useMobxStore(); const { toggleCommandPaletteModal, @@ -218,11 +219,15 @@ export const CommandPalette: FC = observer(() => { currentStore={createIssueStoreType} /> - {issueId && issueDetails && ( + {workspaceSlug && projectId && issueId && issueDetails && ( toggleDeleteIssueModal(false)} isOpen={isDeleteIssueModalOpen} data={issueDetails} + onSubmit={async () => { + await removeIssue(workspaceSlug.toString(), projectId.toString(), issueId.toString()); + router.push(`/${workspaceSlug}/projects/${projectId}/issues`); + }} /> )} diff --git a/web/components/core/modals/user-image-upload-modal.tsx b/web/components/core/modals/user-image-upload-modal.tsx index 6358a4aee..6e1c8b519 100644 --- a/web/components/core/modals/user-image-upload-modal.tsx +++ b/web/components/core/modals/user-image-upload-modal.tsx @@ -57,12 +57,8 @@ export const UserImageUploadModal: React.FC = observer((props) => { }; const handleSubmit = async () => { - console.log("Submit triggered"); - if (!image) return; - console.log("Inside submit"); - setIsImageUploading(true); const formData = new FormData(); diff --git a/web/components/issues/delete-issue-modal.tsx b/web/components/issues/delete-issue-modal.tsx index 86d31d5eb..50f53911d 100644 --- a/web/components/issues/delete-issue-modal.tsx +++ b/web/components/issues/delete-issue-modal.tsx @@ -29,7 +29,10 @@ export const DeleteIssueModal: React.FC = (props) => { const handleIssueDelete = async () => { setIsDeleteLoading(true); - if (onSubmit) await onSubmit().finally(() => setIsDeleteLoading(false)); + if (onSubmit) + await onSubmit() + .then(() => onClose()) + .finally(() => setIsDeleteLoading(false)); }; return ( diff --git a/web/components/issues/description-form.tsx b/web/components/issues/description-form.tsx index 34361108a..663a58d79 100644 --- a/web/components/issues/description-form.tsx +++ b/web/components/issues/description-form.tsx @@ -61,8 +61,6 @@ export const IssueDescriptionForm: FC = (props) => { description_html: issue.description_html, }); - console.log("in form", localIssueDescription); - useEffect(() => { if (issue.id) { setLocalIssueDescription({ id: issue.id, description_html: issue.description_html }); diff --git a/web/components/issues/sidebar.tsx b/web/components/issues/sidebar.tsx index 7f9a00593..bd645769f 100644 --- a/web/components/issues/sidebar.tsx +++ b/web/components/issues/sidebar.tsx @@ -81,11 +81,10 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { const [selectedLinkToUpdate, setSelectedLinkToUpdate] = useState(null); const { - user: userStore, + user: { currentUser, currentProjectRole }, projectState: { states }, + projectIssues: { removeIssue }, } = useMobxStore(); - const user = userStore.currentUser; - const userRole = userStore.currentProjectRole; const router = useRouter(); const { workspaceSlug, projectId, issueId, inboxIssueId } = router.query; @@ -102,7 +101,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { const handleCycleChange = useCallback( (cycleId: string) => { - if (!workspaceSlug || !projectId || !issueDetail || !user) return; + if (!workspaceSlug || !projectId || !issueDetail || !currentUser) return; issueService .addIssueToCycle(workspaceSlug as string, projectId as string, cycleId, { @@ -112,12 +111,12 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { mutate(ISSUE_DETAILS(issueId as string)); }); }, - [workspaceSlug, projectId, issueId, issueDetail, user] + [workspaceSlug, projectId, issueId, issueDetail, currentUser] ); const handleModuleChange = useCallback( (moduleId: string) => { - if (!workspaceSlug || !projectId || !issueDetail || !user) return; + if (!workspaceSlug || !projectId || !issueDetail || !currentUser) return; moduleService .addIssuesToModule(workspaceSlug as string, projectId as string, moduleId, { @@ -127,7 +126,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { mutate(ISSUE_DETAILS(issueId as string)); }); }, - [workspaceSlug, projectId, issueId, issueDetail, user] + [workspaceSlug, projectId, issueId, issueDetail, currentUser] ); const handleCreateLink = async (formData: IIssueLink) => { @@ -249,7 +248,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { setLinkModal(true); }; - const isAllowed = !!userRole && userRole >= EUserWorkspaceRoles.MEMBER; + const isAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER; const currentIssueState = projectId ? states[projectId.toString()]?.find((s) => s.id === issueDetail?.state) @@ -268,8 +267,16 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { createIssueLink={handleCreateLink} updateIssueLink={handleUpdateLink} /> - {issueDetail && ( - setDeleteIssueModal(false)} isOpen={deleteIssueModal} data={issueDetail} /> + {workspaceSlug && projectId && issueDetail && ( + setDeleteIssueModal(false)} + isOpen={deleteIssueModal} + data={issueDetail} + onSubmit={async () => { + await removeIssue(workspaceSlug.toString(), projectId.toString(), issueDetail.id); + router.push(`/${workspaceSlug}/projects/${projectId}/issues`); + }} + /> )}
@@ -288,8 +295,8 @@ export const IssueDetailsSidebar: React.FC = observer((props) => {
- {issueDetail?.created_by !== user?.id && - !issueDetail?.assignees.includes(user?.id ?? "") && + {issueDetail?.created_by !== currentUser?.id && + !issueDetail?.assignees.includes(currentUser?.id ?? "") && !router.pathname.includes("[archivedIssueId]") && (fieldsToShow.includes("all") || fieldsToShow.includes("subscribe")) && (
- + {editable && ( handleIssueCrudOperation("edit", parentIssue?.id, issue)}> -
- +
+ Edit issue
@@ -135,8 +134,8 @@ export const SubIssues: React.FC = ({ {editable && ( handleIssueCrudOperation("delete", parentIssue?.id, issue)}> -
- +
+ Delete issue
@@ -145,8 +144,8 @@ export const SubIssues: React.FC = ({ copyText(`${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`)} > -
- +
+ Copy issue link
diff --git a/web/components/issues/sub-issues/properties.tsx b/web/components/issues/sub-issues/properties.tsx index 93c07eed3..cba7c7aea 100644 --- a/web/components/issues/sub-issues/properties.tsx +++ b/web/components/issues/sub-issues/properties.tsx @@ -1,15 +1,11 @@ import React from "react"; -import { observer } from "mobx-react-lite"; import { mutate } from "swr"; -// mobx store -import { useMobxStore } from "lib/mobx/store-provider"; // services import { IssueService } from "services/issue"; // components -import { ViewDueDateSelect, ViewStartDateSelect } from "components/issues"; import { PrioritySelect } from "components/project"; // types -import { IUser, IIssue, IState } from "types"; +import { IIssue, IState } from "types"; // fetch-keys import { SUB_ISSUES } from "constants/fetch-keys"; import { IssuePropertyAssignee, IssuePropertyState } from "../issue-layouts/properties"; @@ -18,19 +14,14 @@ export interface IIssueProperty { workspaceSlug: string; parentIssue: IIssue; issue: IIssue; - user: IUser | undefined; editable: boolean; } // services const issueService = new IssueService(); -export const IssueProperty: React.FC = observer((props) => { - const { workspaceSlug, parentIssue, issue, user, editable } = props; - - const { issueFilter: issueFilterStore } = useMobxStore(); - - const displayProperties = issueFilterStore.userDisplayProperties ?? {}; +export const IssueProperty: React.FC = (props) => { + const { workspaceSlug, parentIssue, issue, editable } = props; const handlePriorityChange = (data: any) => { partialUpdateIssue({ priority: data }); @@ -77,63 +68,30 @@ export const IssueProperty: React.FC = observer((props) => { }; return ( -
- {displayProperties.priority && ( -
- -
- )} +
+
+ +
- {displayProperties.state && ( -
- handleStateChange(data)} - disabled={false} - hideDropdownArrow - /> -
- )} +
+ handleStateChange(data)} + disabled={false} + hideDropdownArrow + /> +
- {displayProperties.start_date && issue.start_date && ( -
- partialUpdateIssue({ start_date: val })} - disabled={!editable} - /> -
- )} - - {displayProperties.due_date && issue.target_date && ( -
- {user && ( - partialUpdateIssue({ target_date: val })} - disabled={!editable} - /> - )} -
- )} - - {displayProperties.assignee && ( -
- handleAssigneeChange(val)} - disabled={false} - /> -
- )} +
+ handleAssigneeChange(val)} + disabled={false} + /> +
); -}); +}; diff --git a/web/components/issues/sub-issues/root.tsx b/web/components/issues/sub-issues/root.tsx index e6cf5d8cc..24d8f2587 100644 --- a/web/components/issues/sub-issues/root.tsx +++ b/web/components/issues/sub-issues/root.tsx @@ -45,11 +45,10 @@ export const SubIssuesRoot: React.FC = observer((props) => { const { parentIssue, user } = props; const { - user: userStore, + user: { currentProjectRole }, issue: { updateIssueStructure }, - projectIssues: { updateIssue }, + projectIssues: { updateIssue, removeIssue }, } = useMobxStore(); - const userRole = userStore.currentProjectRole; const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -177,7 +176,7 @@ export const SubIssuesRoot: React.FC = observer((props) => { [updateIssueStructure, projectId, updateIssue, user, workspaceSlug] ); - const isEditable = !!userRole && userRole >= EUserWorkspaceRoles.MEMBER; + const isEditable = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER; const mutateSubIssues = (parentIssueId: string | null) => { if (parentIssueId) mutate(SUB_ISSUES(parentIssueId)); @@ -261,7 +260,7 @@ export const SubIssuesRoot: React.FC = observer((props) => { } buttonClassName="whitespace-nowrap" - // position="left" + placement="bottom-end" noBorder noChevron > @@ -297,7 +296,7 @@ export const SubIssuesRoot: React.FC = observer((props) => { } buttonClassName="whitespace-nowrap" - // position="left" + placement="bottom-end" noBorder noChevron > @@ -356,7 +355,8 @@ export const SubIssuesRoot: React.FC = observer((props) => { )} {isEditable && - issueCrudOperation?.delete?.toggle && + workspaceSlug && + projectId && issueCrudOperation?.delete?.issueId && issueCrudOperation?.delete?.issue && ( = observer((props) => { handleIssueCrudOperation("delete", null, null); }} data={issueCrudOperation?.delete?.issue} + onSubmit={async () => { + await removeIssue( + workspaceSlug.toString(), + projectId.toString(), + issueCrudOperation?.delete?.issue?.id ?? "" + ); + }} /> )}