@@ -15,6 +15,7 @@ import { copyUrlToClipboard } from "@/helpers/string.helper";
1515// hooks
1616import { useCycle , useEventTracker , useUserPermissions } from "@/hooks/store" ;
1717import { useAppRouter } from "@/hooks/use-app-router" ;
18+ import { useEndCycle , EndCycleModal } from "@/plane-web/components/cycles" ;
1819import { EUserPermissions , EUserPermissionsLevel } from "@/plane-web/constants/user-permissions" ;
1920
2021type 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 } />
0 commit comments