@@ -11,44 +11,48 @@ import {
1111 Text ,
1212 useDisclosure ,
1313} from '@chakra-ui/react' ;
14- import { useAppDispatch } from 'app/store/storeHooks' ;
14+ import { useAppDispatch , useAppSelector } from 'app/store/storeHooks' ;
1515import { nodeEditorReset } from 'features/nodes/store/nodesSlice' ;
1616import { addToast } from 'features/system/store/systemSlice' ;
1717import { makeToast } from 'features/system/util/makeToast' ;
1818import { memo , useCallback , useRef } from 'react' ;
1919import { useTranslation } from 'react-i18next' ;
20- import { FaTrash } from 'react-icons/fa ' ;
20+ import { FaCircleNodes } from 'react-icons/fa6 ' ;
2121
22- const ResetWorkflowEditorMenuItem = ( ) => {
22+ const NewWorkflowMenuItem = ( ) => {
2323 const { t } = useTranslation ( ) ;
2424 const dispatch = useAppDispatch ( ) ;
2525 const { isOpen, onOpen, onClose } = useDisclosure ( ) ;
2626 const cancelRef = useRef < HTMLButtonElement | null > ( null ) ;
27+ const isTouched = useAppSelector ( ( state ) => state . workflow . isTouched ) ;
2728
28- const handleConfirmClear = useCallback ( ( ) => {
29+ const handleNewWorkflow = useCallback ( ( ) => {
2930 dispatch ( nodeEditorReset ( ) ) ;
3031
3132 dispatch (
3233 addToast (
3334 makeToast ( {
34- title : t ( 'workflows.workflowEditorReset ' ) ,
35+ title : t ( 'workflows.newWorkflowCreated ' ) ,
3536 status : 'success' ,
3637 } )
3738 )
3839 ) ;
3940
4041 onClose ( ) ;
41- } , [ dispatch , t , onClose ] ) ;
42+ } , [ dispatch , onClose , t ] ) ;
43+
44+ const onClick = useCallback ( ( ) => {
45+ if ( ! isTouched ) {
46+ handleNewWorkflow ( ) ;
47+ return ;
48+ }
49+ onOpen ( ) ;
50+ } , [ handleNewWorkflow , isTouched , onOpen ] ) ;
4251
4352 return (
4453 < >
45- < MenuItem
46- as = "button"
47- icon = { < FaTrash /> }
48- sx = { { color : 'error.600' , _dark : { color : 'error.300' } } }
49- onClick = { onOpen }
50- >
51- { t ( 'nodes.resetWorkflow' ) }
54+ < MenuItem as = "button" icon = { < FaCircleNodes /> } onClick = { onClick } >
55+ { t ( 'nodes.newWorkflow' ) }
5256 </ MenuItem >
5357
5458 < AlertDialog
@@ -61,21 +65,21 @@ const ResetWorkflowEditorMenuItem = () => {
6165
6266 < AlertDialogContent >
6367 < AlertDialogHeader fontSize = "lg" fontWeight = "bold" >
64- { t ( 'nodes.resetWorkflow ' ) }
68+ { t ( 'nodes.newWorkflow ' ) }
6569 </ AlertDialogHeader >
6670
6771 < AlertDialogBody py = { 4 } >
6872 < Flex flexDir = "column" gap = { 2 } >
69- < Text > { t ( 'nodes.resetWorkflowDesc ' ) } </ Text >
70- < Text variant = "subtext" > { t ( 'nodes.resetWorkflowDesc2 ' ) } </ Text >
73+ < Text > { t ( 'nodes.newWorkflowDesc ' ) } </ Text >
74+ < Text variant = "subtext" > { t ( 'nodes.newWorkflowDesc2 ' ) } </ Text >
7175 </ Flex >
7276 </ AlertDialogBody >
7377
7478 < AlertDialogFooter >
7579 < Button ref = { cancelRef } onClick = { onClose } >
7680 { t ( 'common.cancel' ) }
7781 </ Button >
78- < Button colorScheme = "error" ml = { 3 } onClick = { handleConfirmClear } >
82+ < Button colorScheme = "error" ml = { 3 } onClick = { handleNewWorkflow } >
7983 { t ( 'common.accept' ) }
8084 </ Button >
8185 </ AlertDialogFooter >
@@ -85,4 +89,4 @@ const ResetWorkflowEditorMenuItem = () => {
8589 ) ;
8690} ;
8791
88- export default memo ( ResetWorkflowEditorMenuItem ) ;
92+ export default memo ( NewWorkflowMenuItem ) ;
0 commit comments