From f3b09a13b86530c9518d8986ee36fb6ff227fdef Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Mon, 24 Jul 2023 12:56:27 +0530 Subject: [PATCH] chore: set all issue properties as true by default (#1640) --- .../components/cycles/delete-cycle-modal.tsx | 20 +++++++++++++++++-- apps/app/components/cycles/modal.tsx | 17 +++++++++++++++- apps/app/hooks/use-issue-properties.tsx | 20 ++++++++++--------- .../projects/[projectId]/cycles/index.tsx | 4 ++-- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/apps/app/components/cycles/delete-cycle-modal.tsx b/apps/app/components/cycles/delete-cycle-modal.tsx index 00bd8b9ad..35b8e118e 100644 --- a/apps/app/components/cycles/delete-cycle-modal.tsx +++ b/apps/app/components/cycles/delete-cycle-modal.tsx @@ -14,7 +14,7 @@ import { DangerButton, SecondaryButton } from "components/ui"; // icons import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; // types -import type { ICurrentUserResponse, ICycle } from "types"; +import type { ICurrentUserResponse, ICycle, IProject } from "types"; type TConfirmCycleDeletionProps = { isOpen: boolean; setIsOpen: React.Dispatch>; @@ -27,6 +27,7 @@ import { CURRENT_CYCLE_LIST, CYCLES_LIST, DRAFT_CYCLES_LIST, + PROJECT_DETAILS, UPCOMING_CYCLES_LIST, } from "constants/fetch-keys"; import { getDateRangeStatus } from "helpers/date-time.helper"; @@ -50,7 +51,7 @@ export const DeleteCycleModal: React.FC = ({ }; const handleDeletion = async () => { - if (!data || !workspaceSlug) return; + if (!data || !workspaceSlug || !projectId) return; setIsDeleteLoading(true); @@ -85,6 +86,21 @@ export const DeleteCycleModal: React.FC = ({ }, false ); + + // update total cycles count in the project details + mutate( + PROJECT_DETAILS(projectId.toString()), + (prevData) => { + if (!prevData) return prevData; + + return { + ...prevData, + total_cycles: prevData.total_cycles - 1, + }; + }, + false + ); + handleClose(); setToastAlert({ diff --git a/apps/app/components/cycles/modal.tsx b/apps/app/components/cycles/modal.tsx index 9833bc375..703636256 100644 --- a/apps/app/components/cycles/modal.tsx +++ b/apps/app/components/cycles/modal.tsx @@ -15,7 +15,7 @@ import { CycleForm } from "components/cycles"; // helper import { getDateRangeStatus } from "helpers/date-time.helper"; // types -import type { CycleDateCheckData, ICurrentUserResponse, ICycle } from "types"; +import type { CycleDateCheckData, ICurrentUserResponse, ICycle, IProject } from "types"; // fetch keys import { COMPLETED_CYCLES_LIST, @@ -23,6 +23,7 @@ import { CYCLES_LIST, DRAFT_CYCLES_LIST, INCOMPLETE_CYCLES_LIST, + PROJECT_DETAILS, UPCOMING_CYCLES_LIST, } from "constants/fetch-keys"; @@ -66,6 +67,20 @@ export const CreateUpdateCycleModal: React.FC = ({ mutate(INCOMPLETE_CYCLES_LIST(projectId.toString())); mutate(CYCLES_LIST(projectId.toString())); + // update total cycles count in the project details + mutate( + PROJECT_DETAILS(projectId.toString()), + (prevData) => { + if (!prevData) return prevData; + + return { + ...prevData, + total_cycles: prevData.total_cycles + 1, + }; + }, + false + ); + setToastAlert({ type: "success", title: "Success!", diff --git a/apps/app/hooks/use-issue-properties.tsx b/apps/app/hooks/use-issue-properties.tsx index 443adf4f0..4f7368ba5 100644 --- a/apps/app/hooks/use-issue-properties.tsx +++ b/apps/app/hooks/use-issue-properties.tsx @@ -1,5 +1,7 @@ import { useState, useEffect, useCallback } from "react"; + import useSWR from "swr"; + // services import issueServices from "services/issues.service"; // hooks @@ -9,17 +11,17 @@ import { IssuePriorities, Properties } from "types"; const initialValues: Properties = { assignee: true, - due_date: false, + due_date: true, key: true, - labels: false, - priority: false, + labels: true, + priority: true, state: true, - sub_issue_count: false, - attachment_count: false, - link: false, - estimate: false, - created_on: false, - updated_on: false, + sub_issue_count: true, + attachment_count: true, + link: true, + estimate: true, + created_on: true, + updated_on: true, }; const useIssuesProperties = (workspaceSlug?: string, projectId?: string) => { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx index 3ef5c9eb4..744d636fa 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx @@ -176,8 +176,8 @@ const ProjectCycles: NextPage = () => {
{cycleViews.map((view) => { - if (view.key === "gantt" && (cycleTab === "Active" || cycleTab === "Drafts")) - return null; + if (cycleTab === "Active") return null; + if (view.key === "gantt" && cycleTab === "Drafts") return null; return (