@@ -39,17 +39,29 @@ interface AddStepButtonProps {
3939 onClick : ( appKey : string , eventKey : string ) => void
4040 isDisabled : boolean
4141 isLastStep : boolean
42+ isTriggerAbsent ?: boolean
43+ isActionAbsent ?: boolean
4244}
4345
4446function AddStepButton ( props : AddStepButtonProps ) : JSX . Element {
45- const { onClick, isDisabled, isLastStep } = props
47+ const { onClick, isDisabled, isLastStep, isTriggerAbsent, isActionAbsent } =
48+ props
4649 const { isOpen, onOpen, onClose } = useDisclosure ( )
4750
4851 const handleSubmit = ( appKey : string , actionKey : string ) => {
4952 onClick ( appKey , actionKey )
5053 onClose ( )
5154 }
5255
56+ let tooltipLabel = 'Add Step'
57+ if ( isTriggerAbsent ) {
58+ tooltipLabel = 'Choose how you want your workflow to start first'
59+ } else if ( isActionAbsent ) {
60+ tooltipLabel = 'Choose an action first'
61+ } else if ( isDisabled ) {
62+ tooltipLabel = 'Unpublish your pipe before adding steps'
63+ }
64+
5365 return (
5466 < >
5567 < Box pos = "relative" h = { 24 } >
@@ -64,10 +76,10 @@ function AddStepButton(props: AddStepButtonProps): JSX.Element {
6476 </ Box >
6577 ) }
6678 < AbsoluteCenter >
67- < TouchableTooltip label = "Add Step" placement = "right" >
79+ < TouchableTooltip label = { tooltipLabel } placement = "right" >
6880 < IconButton
6981 onClick = { onOpen }
70- isDisabled = { isDisabled }
82+ isDisabled = { isDisabled || isTriggerAbsent || isActionAbsent }
7183 aria-label = "Add Step"
7284 icon = { < BiPlus /> }
7385 variant = { isLastStep ? 'outline' : 'clear' }
@@ -319,6 +331,12 @@ export default function Editor(props: EditorProps): React.ReactElement {
319331 [ parentStepExecutionsToInclude , stepsBeforeGroup ] ,
320332 )
321333
334+ // Only affects editor when there are 2 steps: This works inside the If-Then editor too
335+ const isTriggerAbsent =
336+ steps . length === 2 && steps [ 0 ] . appKey === null && steps [ 0 ] . key === null
337+ const isActionAbsent =
338+ steps . length === 2 && steps [ 1 ] . appKey === null && steps [ 1 ] . key === null
339+
322340 if ( ! apps ) {
323341 return (
324342 < Center w = "full" h = "100vh" >
@@ -358,6 +376,8 @@ export default function Editor(props: EditorProps): React.ReactElement {
358376 } }
359377 isDisabled = { creationInProgress || isReadOnlyEditor }
360378 isLastStep = { index === steps . length - 1 }
379+ isTriggerAbsent = { isTriggerAbsent }
380+ isActionAbsent = { isActionAbsent }
361381 />
362382 </ Fragment >
363383 ) ) }
0 commit comments