@@ -13,6 +13,7 @@ import {
1313 FormHelperText ,
1414 FormLabel ,
1515 HStack ,
16+ IconButton ,
1617 Input ,
1718 Link ,
1819 Menu ,
@@ -31,7 +32,7 @@ import { motion } from "framer-motion";
3132import { v4 as uuidv4 } from "uuid" ;
3233import { useTranslation } from "react-i18next" ;
3334import dayjs from "dayjs" ;
34- import { FiMousePointer } from "react-icons/fi" ;
35+ import { FiMousePointer , FiChevronUp , FiChevronDown } from "react-icons/fi" ;
3536import { CustomPlaceholdersFormData } from "./constants/CustomPlaceholderFormSchema" ;
3637import { AnimatedComponent , ConfirmModal } from "../../../../components" ;
3738import { CustomPlaceholderPreview } from "./CustomPlaceholderPreview" ;
@@ -389,6 +390,26 @@ export const CustomPlaceholderForm = ({ index, onDelete, isExpanded }: Props) =>
389390 }
390391 } ;
391392
393+ const moveStepUp = ( stepIndex : number ) => {
394+ if ( stepIndex === 0 ) return ;
395+ const newSteps = [ ...steps ] ;
396+ [ newSteps [ stepIndex - 1 ] , newSteps [ stepIndex ] ] = [ newSteps [ stepIndex ] , newSteps [ stepIndex - 1 ] ] ;
397+ setValue ( `customPlaceholders.${ index } .steps` , newSteps , {
398+ shouldDirty : true ,
399+ shouldValidate : true ,
400+ } ) ;
401+ } ;
402+
403+ const moveStepDown = ( stepIndex : number ) => {
404+ if ( stepIndex === steps . length - 1 ) return ;
405+ const newSteps = [ ...steps ] ;
406+ [ newSteps [ stepIndex ] , newSteps [ stepIndex + 1 ] ] = [ newSteps [ stepIndex + 1 ] , newSteps [ stepIndex ] ] ;
407+ setValue ( `customPlaceholders.${ index } .steps` , newSteps , {
408+ shouldDirty : true ,
409+ shouldValidate : true ,
410+ } ) ;
411+ } ;
412+
392413 const referenceNameError = errors ?. customPlaceholders ?. [ index ] ?. referenceName ;
393414 const sourcePlaceholderError = errors ?. customPlaceholders ?. [ index ] ?. sourcePlaceholder ;
394415 const hasStepsError = errors ?. customPlaceholders ?. [ index ] ?. steps ;
@@ -574,31 +595,49 @@ export const CustomPlaceholderForm = ({ index, onDelete, isExpanded }: Props) =>
574595 </ Text >
575596 ) }
576597 </ Box >
577- < Button
578- colorScheme = "red"
579- size = "sm"
580- variant = "ghost"
581- aria-disabled = { steps . length === 1 }
582- onClick = { ( ) => {
583- if ( steps . length === 1 ) {
584- notifyInfo ( "At least one transformation step is required" ) ;
598+ < HStack >
599+ < IconButton
600+ icon = { < FiChevronUp /> }
601+ aria-label = "Move step up"
602+ size = "sm"
603+ variant = "ghost"
604+ isDisabled = { stepIndex === 0 }
605+ onClick = { ( ) => moveStepUp ( stepIndex ) }
606+ />
607+ < IconButton
608+ icon = { < FiChevronDown /> }
609+ aria-label = "Move step down"
610+ size = "sm"
611+ variant = "ghost"
612+ isDisabled = { stepIndex === steps . length - 1 }
613+ onClick = { ( ) => moveStepDown ( stepIndex ) }
614+ />
615+ < Button
616+ colorScheme = "red"
617+ size = "sm"
618+ variant = "ghost"
619+ aria-disabled = { steps . length === 1 }
620+ onClick = { ( ) => {
621+ if ( steps . length === 1 ) {
622+ notifyInfo ( "At least one transformation step is required" ) ;
585623
586- return ;
587- }
588-
589- setValue (
590- `customPlaceholders.${ index } .steps` ,
591- steps . filter ( ( _ , i ) => i !== stepIndex ) ,
592- {
593- shouldDirty : true ,
594- shouldTouch : true ,
595- shouldValidate : true ,
624+ return ;
596625 }
597- ) ;
598- } }
599- >
600- Delete Step
601- </ Button >
626+
627+ setValue (
628+ `customPlaceholders.${ index } .steps` ,
629+ steps . filter ( ( _ , i ) => i !== stepIndex ) ,
630+ {
631+ shouldDirty : true ,
632+ shouldTouch : true ,
633+ shouldValidate : true ,
634+ }
635+ ) ;
636+ } }
637+ >
638+ Delete Step
639+ </ Button >
640+ </ HStack >
602641 </ HStack >
603642 < Divider mb = { 2 } />
604643 { ! step . type ||
0 commit comments