From fb46249ccfefea54952b6d164b8ccc9324077ec0 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:55:53 +0530 Subject: [PATCH] [WEB-1872] fix: completed cycle gantt layout quick add issue validation (#5066) * fix: completed cycle gantt layout quick add issue validation * chore: code refactor --- .../issue-layouts/gantt/base-gantt-root.tsx | 12 ++++++++---- .../issue-layouts/roots/cycle-layout-root.tsx | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/web/core/components/issues/issue-layouts/gantt/base-gantt-root.tsx b/web/core/components/issues/issue-layouts/gantt/base-gantt-root.tsx index 2cc5fad1466..db7c79c2421 100644 --- a/web/core/components/issues/issue-layouts/gantt/base-gantt-root.tsx +++ b/web/core/components/issues/issue-layouts/gantt/base-gantt-root.tsx @@ -21,6 +21,7 @@ import { IssueLayoutHOC } from "../issue-layout-HOC"; interface IBaseGanttRoot { viewId?: string | undefined; + isCompletedCycle?: boolean; } type GanttStoreType = @@ -30,7 +31,7 @@ type GanttStoreType = | EIssuesStoreType.PROJECT_VIEW; export const BaseGanttRoot: React.FC = observer((props: IBaseGanttRoot) => { - const { viewId } = props; + const { viewId, isCompletedCycle = false } = props; // router const { workspaceSlug } = useParams(); @@ -84,6 +85,11 @@ export const BaseGanttRoot: React.FC = observer((props: IBaseGan const isAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; + const quickAdd = + enableIssueCreation && isAllowed && !isCompletedCycle ? ( + + ) : undefined; + return (
@@ -102,9 +108,7 @@ export const BaseGanttRoot: React.FC = observer((props: IBaseGan enableReorder={appliedDisplayFilters?.order_by === "sort_order" && isAllowed} enableAddBlock={isAllowed} enableSelection={isBulkOperationsEnabled && isAllowed} - quickAdd={ - enableIssueCreation && isAllowed ? : undefined - } + quickAdd={quickAdd} loadMoreBlocks={loadMoreIssues} canLoadMoreBlocks={nextPageResults} showAllBlocks diff --git a/web/core/components/issues/issue-layouts/roots/cycle-layout-root.tsx b/web/core/components/issues/issue-layouts/roots/cycle-layout-root.tsx index 5ef308fcc75..d6f1b1a7d18 100644 --- a/web/core/components/issues/issue-layouts/roots/cycle-layout-root.tsx +++ b/web/core/components/issues/issue-layouts/roots/cycle-layout-root.tsx @@ -21,7 +21,11 @@ import { EIssueLayoutTypes, EIssuesStoreType } from "@/constants/issue"; import { useCycle, useIssues } from "@/hooks/store"; import { IssuesStoreContext } from "@/hooks/use-issue-layout-store"; -const CycleIssueLayout = (props: { activeLayout: EIssueLayoutTypes | undefined; cycleId: string }) => { +const CycleIssueLayout = (props: { + activeLayout: EIssueLayoutTypes | undefined; + cycleId: string; + isCompletedCycle: boolean; +}) => { switch (props.activeLayout) { case EIssueLayoutTypes.LIST: return ; @@ -30,7 +34,7 @@ const CycleIssueLayout = (props: { activeLayout: EIssueLayoutTypes | undefined; case EIssueLayoutTypes.CALENDAR: return ; case EIssueLayoutTypes.GANTT: - return ; + return ; case EIssueLayoutTypes.SPREADSHEET: return ; default: @@ -62,6 +66,7 @@ export const CycleLayoutRoot: React.FC = observer(() => { const cycleDetails = cycleId ? getCycleById(cycleId.toString()) : undefined; const cycleStatus = cycleDetails?.status?.toLocaleLowerCase() ?? "draft"; + const isCompletedCycle = cycleStatus === "completed"; if (!workspaceSlug || !projectId || !cycleId) return <>; @@ -78,7 +83,11 @@ export const CycleLayoutRoot: React.FC = observer(() => {
- +
{/* peek overview */}