1616
1717import { useState , useContext , Fragment , SyntheticEvent } from 'react'
1818import {
19- PopupMenu ,
2019 BuildStageVariable ,
2120 PluginType ,
2221 RefVariableStageType ,
@@ -27,17 +26,21 @@ import {
2726 PipelineStageTaskActionModalType ,
2827 PipelineStageTaskActionModalStateType ,
2928 ResourceKindType ,
29+ ActionMenu ,
30+ ButtonStyleType ,
31+ ButtonVariantType ,
32+ ComponentSizeType ,
33+ ActionMenuProps ,
34+ Icon ,
3035} from '@devtron-labs/devtron-fe-common-lib'
3136import { importComponentFromFELibrary } from '@Components/common'
3237import TaskTitle from './TaskTitle'
3338import { ReactComponent as Add } from '../../assets/icons/ic-add.svg'
3439import { ReactComponent as Drag } from '../../assets/icons/drag.svg'
35- import { ReactComponent as Dots } from '@Icons/ic-more-vertical.svg'
36- import { ReactComponent as Trash } from '../../assets/icons/ic-delete-interactive.svg'
3740import { ReactComponent as AlertTriangle } from '../../assets/icons/ic-alert-triangle.svg'
38- import { ReactComponent as MoveToPre } from '../../assets/icons/ic-arrow-backward.svg'
3941import { TaskListType } from '../ciConfig/types'
4042import { pipelineContext } from '../workflowEditor/workflowEditor'
43+ import { TaskActionMenuOptionIdEnum } from './Constants'
4144
4245const getTaskActionPluginValidationStatus : ( params ) => ValidationResponseType = importComponentFromFELibrary (
4346 'getTaskActionPluginValidationStatus' ,
@@ -337,6 +340,23 @@ export const TaskList = ({ withWarning, setInputVariablesListFromPrevStep, isJob
337340
338341 const currentStageText = isCdPipeline ? 'deploy' : 'build'
339342
343+ const handleDragging = ( ) => {
344+ setDragAllowed ( true )
345+ }
346+
347+ const handleActionMenuClick : ActionMenuProps < TaskActionMenuOptionIdEnum > [ 'onClick' ] = ( item ) => {
348+ switch ( item . id ) {
349+ case TaskActionMenuOptionIdEnum . DELETE :
350+ handleTaskAction ( selectedTaskIndex , PipelineStageTaskActionModalType . DELETE )
351+ break
352+ case TaskActionMenuOptionIdEnum . MOVE :
353+ handleTaskAction ( selectedTaskIndex , PipelineStageTaskActionModalType . MOVE_PLUGIN )
354+ break
355+ default :
356+ break
357+ }
358+ }
359+
340360 return (
341361 < >
342362 < div className = { withWarning ? 'with-warning' : '' } >
@@ -355,7 +375,7 @@ export const TaskList = ({ withWarning, setInputVariablesListFromPrevStep, isJob
355375 >
356376 < Drag
357377 className = "dc__grabbable icon-dim-20 p-2 dc__no-shrink"
358- onMouseDown = { ( ) => setDragAllowed ( true ) }
378+ onMouseDown = { handleDragging }
359379 />
360380 < div className = { `flex left dc__gap-6 dc__content-space w-100` } >
361381 < TaskTitle taskDetail = { taskDetail } />
@@ -364,47 +384,39 @@ export const TaskList = ({ withWarning, setInputVariablesListFromPrevStep, isJob
364384 ! formDataErrorObj [ activeStageName ] . steps [ index ] . isValid && (
365385 < AlertTriangle className = "icon-dim-16 mr-5 ml-5 mt-2 mw-16" />
366386 ) }
367- < PopupMenu autoClose >
368- < PopupMenu . Button isKebab >
369- < Dots
370- className = "icon-dim-16 mt-2 rotate fcn-7"
371- style = { { [ '--rotateBy' as any ] : '90deg' } }
372- />
373- </ PopupMenu . Button >
374- < PopupMenu . Body >
375- < button
376- className = "dc__transparent cr-5 flex left p-8 pointer dc__hover-n50 w-100 dc__gap-10"
377- data-index = { index }
378- onClick = { handleTriggerDelete }
379- type = "button"
380- >
381- < Trash className = "icon-dim-16 scr-5 dc__no-shrink" />
382- Remove
383- </ button >
384- { ! isJobView && taskDetail . stepType && (
385- < button
386- className = "dc__transparent flex left p-8 pointer dc__hover-n50 w-100 dc__gap-10"
387- data-index = { index }
388- onClick = { handleTriggerMoveToOtherStage }
389- >
390- { activeStageName === BuildStageVariable . PreBuild ? (
391- < >
392- < MoveToPre
393- className = "rotate icon-dim-16 dc__no-shrink"
394- style = { { [ '--rotateBy' as any ] : '180deg' } }
395- />
396- Move to post-{ currentStageText } stage
397- </ >
398- ) : (
399- < >
400- < MoveToPre className = "icon-dim-16 dc__no-shrink" />
401- Move to pre-{ currentStageText } stage
402- </ >
403- ) }
404- </ button >
405- ) }
406- </ PopupMenu . Body >
407- </ PopupMenu >
387+
388+ < ActionMenu < TaskActionMenuOptionIdEnum >
389+ id = "task-item-action-menu"
390+ onClick = { handleActionMenuClick }
391+ options = { [
392+ {
393+ items : [
394+ {
395+ id : TaskActionMenuOptionIdEnum . DELETE ,
396+ label : 'Remove' ,
397+ startIcon : { name : 'ic-delete' } ,
398+ type : 'negative' ,
399+ } ,
400+ ! isJobView &&
401+ taskDetail . stepType && {
402+ id : TaskActionMenuOptionIdEnum . MOVE ,
403+ label : `Move to ${
404+ activeStageName === BuildStageVariable . PreBuild ? 'post' : 'pre'
405+ } -${ currentStageText } stage`,
406+ startIcon : { name : 'ic-arrow-right' } ,
407+ } ,
408+ ] ,
409+ } ,
410+ ] }
411+ buttonProps = { {
412+ dataTestId : 'task-item-action-menu-button' ,
413+ icon : < Icon name = "ic-more-vertical" color = { null } rotateBy = { 90 } /> ,
414+ variant : ButtonVariantType . borderLess ,
415+ ariaLabel : 'Open action menu' ,
416+ style : ButtonStyleType . neutral ,
417+ size : ComponentSizeType . xs ,
418+ } }
419+ />
408420 </ div >
409421 < div className = "vertical-line-connector" />
410422 </ Fragment >
0 commit comments