Skip to content

Commit 6a13a64

Browse files
[WEB-1964]chore: cycles actions restructuring (#6298)
* chore: cycles quick actions restructuring * chore: added additional actions to cycle list actions * chore: cycle quick action structure * chore: added additional actions to cycle list actions * chore: added end cycle hook * fix: updated end cycle export --------- Co-authored-by: gurusinath <[email protected]>
1 parent 5e6c023 commit 6a13a64

File tree

10 files changed

+53
-3
lines changed

10 files changed

+53
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { FC } from "react";
2+
import { observer } from "mobx-react";
3+
type Props = {
4+
cycleId: string;
5+
projectId: string;
6+
};
7+
export const CycleAdditionalActions: FC<Props> = observer(() => <></>);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./modal";
2+
export * from "./use-end-cycle";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from "react";
2+
3+
interface Props {
4+
isOpen: boolean;
5+
handleClose: () => void;
6+
cycleId: string;
7+
projectId: string;
8+
workspaceSlug: string;
9+
transferrableIssuesCount: number;
10+
}
11+
12+
export const EndCycleModal: React.FC<Props> = () => <></>;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2+
export const useEndCycle = (isCurrentCycle: boolean) => ({
3+
isEndCycleModalOpen: false,
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5+
setEndCycleModalOpen: (value: boolean) => {},
6+
endCycleContextMenu: undefined,
7+
});

web/ce/components/cycles/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export * from "./active-cycle";
22
export * from "./analytics-sidebar";
3+
export * from "./additional-actions";
4+
export * from "./end-cycle";

web/core/components/cycles/list/cycle-list-item-action.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import { generateQueryParams } from "@/helpers/router.helper";
3333
import { useCycle, useEventTracker, useMember, useUserPermissions } from "@/hooks/store";
3434
import { useAppRouter } from "@/hooks/use-app-router";
3535
import { usePlatformOS } from "@/hooks/use-platform-os";
36-
// plane web
36+
// plane web components
37+
import { CycleAdditionalActions } from "@/plane-web/components/cycles";
3738
// plane web constants
3839
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
3940
// services
@@ -156,7 +157,7 @@ export const CycleListItemAction: FC<Props> = observer((props) => {
156157
try {
157158
const res = await cycleService.cycleDateCheck(workspaceSlug as string, projectId as string, payload);
158159
return res.status;
159-
} catch (err) {
160+
} catch {
160161
return false;
161162
}
162163
};
@@ -244,6 +245,7 @@ export const CycleListItemAction: FC<Props> = observer((props) => {
244245
</div>
245246
)}
246247

248+
<CycleAdditionalActions cycleId={cycleId} projectId={projectId} />
247249
{showTransferIssues && (
248250
<div
249251
className="px-2 h-6 text-custom-primary-200 flex items-center gap-1 cursor-pointer"

web/core/components/cycles/list/cycles-list-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import type { TCycleGroups } from "@plane/types";
1111
import { CircularProgressIndicator } from "@plane/ui";
1212
// components
1313
import { ListItem } from "@/components/core/list";
14+
import { CycleQuickActions } from "@/components/cycles/";
1415
import { CycleListItemAction } from "@/components/cycles/list";
1516
// helpers
1617
import { generateQueryParams } from "@/helpers/router.helper";
1718
// hooks
1819
import { useCycle } from "@/hooks/store";
1920
import { useAppRouter } from "@/hooks/use-app-router";
2021
import { usePlatformOS } from "@/hooks/use-platform-os";
21-
import { CycleQuickActions } from "../quick-actions";
2222

2323
type TCyclesListItem = {
2424
cycleId: string;

web/core/components/cycles/quick-actions.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { copyUrlToClipboard } from "@/helpers/string.helper";
1515
// hooks
1616
import { useCycle, useEventTracker, useUserPermissions } from "@/hooks/store";
1717
import { useAppRouter } from "@/hooks/use-app-router";
18+
import { useEndCycle, EndCycleModal } from "@/plane-web/components/cycles";
1819
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
1920

2021
type Props = {
@@ -40,6 +41,8 @@ export const CycleQuickActions: React.FC<Props> = observer((props) => {
4041
const cycleDetails = getCycleById(cycleId);
4142
const isArchived = !!cycleDetails?.archived_at;
4243
const isCompleted = cycleDetails?.status?.toLowerCase() === "completed";
44+
const isCurrentCycle = cycleDetails?.status?.toLowerCase() === "current";
45+
const transferableIssuesCount = cycleDetails ? cycleDetails.total_issues - cycleDetails.completed_issues : 0;
4346
// auth
4447
const isEditingAllowed = allowPermissions(
4548
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
@@ -48,6 +51,8 @@ export const CycleQuickActions: React.FC<Props> = observer((props) => {
4851
projectId
4952
);
5053

54+
const { isEndCycleModalOpen, setEndCycleModalOpen, endCycleContextMenu } = useEndCycle(isCurrentCycle);
55+
5156
const cycleLink = `${workspaceSlug}/projects/${projectId}/cycles/${cycleId}`;
5257
const handleCopyText = () =>
5358
copyUrlToClipboard(cycleLink).then(() => {
@@ -138,6 +143,8 @@ export const CycleQuickActions: React.FC<Props> = observer((props) => {
138143
},
139144
];
140145

146+
if (endCycleContextMenu) MENU_ITEMS.splice(3, 0, endCycleContextMenu);
147+
141148
return (
142149
<>
143150
{cycleDetails && (
@@ -163,6 +170,14 @@ export const CycleQuickActions: React.FC<Props> = observer((props) => {
163170
workspaceSlug={workspaceSlug}
164171
projectId={projectId}
165172
/>
173+
<EndCycleModal
174+
isOpen={isEndCycleModalOpen}
175+
handleClose={() => setEndCycleModalOpen(false)}
176+
cycleId={cycleId}
177+
projectId={projectId}
178+
workspaceSlug={workspaceSlug}
179+
transferrableIssuesCount={transferableIssuesCount}
180+
/>
166181
</div>
167182
)}
168183
<ContextMenu parentRef={parentRef} items={MENU_ITEMS} />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "ce/components/cycles/end-cycle";

web/ee/components/cycles/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export * from "./active-cycle";
22
export * from "./analytics-sidebar";
3+
export * from "./end-cycle";
4+
export * from "ce/components/cycles/additional-actions";

0 commit comments

Comments
 (0)