Skip to content

Commit

Permalink
[WEB-1872] fix: completed cycle gantt layout quick add issue validati…
Browse files Browse the repository at this point in the history
…on (#5066)

* fix: completed cycle gantt layout quick add issue validation

* chore: code refactor
  • Loading branch information
anmolsinghbhatia authored Jul 8, 2024
1 parent 0e4ce2b commit fb46249
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IssueLayoutHOC } from "../issue-layout-HOC";

interface IBaseGanttRoot {
viewId?: string | undefined;
isCompletedCycle?: boolean;
}

type GanttStoreType =
Expand All @@ -30,7 +31,7 @@ type GanttStoreType =
| EIssuesStoreType.PROJECT_VIEW;

export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGanttRoot) => {
const { viewId } = props;
const { viewId, isCompletedCycle = false } = props;
// router
const { workspaceSlug } = useParams();

Expand Down Expand Up @@ -84,6 +85,11 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan

const isAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;

const quickAdd =
enableIssueCreation && isAllowed && !isCompletedCycle ? (
<GanttQuickAddIssueForm quickAddCallback={quickAddIssue} />
) : undefined;

return (
<IssueLayoutHOC layout={EIssueLayoutTypes.GANTT}>
<div className="h-full w-full">
Expand All @@ -102,9 +108,7 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan
enableReorder={appliedDisplayFilters?.order_by === "sort_order" && isAllowed}
enableAddBlock={isAllowed}
enableSelection={isBulkOperationsEnabled && isAllowed}
quickAdd={
enableIssueCreation && isAllowed ? <GanttQuickAddIssueForm quickAddCallback={quickAddIssue} /> : undefined
}
quickAdd={quickAdd}
loadMoreBlocks={loadMoreIssues}
canLoadMoreBlocks={nextPageResults}
showAllBlocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CycleListLayout />;
Expand All @@ -30,7 +34,7 @@ const CycleIssueLayout = (props: { activeLayout: EIssueLayoutTypes | undefined;
case EIssueLayoutTypes.CALENDAR:
return <CycleCalendarLayout />;
case EIssueLayoutTypes.GANTT:
return <BaseGanttRoot viewId={props.cycleId} />;
return <BaseGanttRoot viewId={props.cycleId} isCompletedCycle={props.isCompletedCycle} />;
case EIssueLayoutTypes.SPREADSHEET:
return <CycleSpreadsheetLayout />;
default:
Expand Down Expand Up @@ -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 <></>;

Expand All @@ -78,7 +83,11 @@ export const CycleLayoutRoot: React.FC = observer(() => {
<CycleAppliedFiltersRoot />

<div className="h-full w-full overflow-auto">
<CycleIssueLayout activeLayout={activeLayout} cycleId={cycleId?.toString()} />
<CycleIssueLayout
activeLayout={activeLayout}
cycleId={cycleId?.toString()}
isCompletedCycle={isCompletedCycle}
/>
</div>
{/* peek overview */}
<IssuePeekOverview />
Expand Down

0 comments on commit fb46249

Please sign in to comment.