@@ -250,9 +250,11 @@ const App: React.FC = () => {
250250 const [ newOpModeNameModalInitialValue , setNewOpModeNameModalInitialValue ] = useState ( '' ) ;
251251 const [ newOpModeNameModalIsOpen , setNewOpModeNameModalIsOpen ] = useState ( false ) ;
252252 const [ toolboxSettingsModalIsOpen , setToolboxSettingsModalIsOpen ] = useState ( false ) ;
253- const [ openAskToSave , setOpenAskToSave ] = useState ( false ) ;
254- const afterAskToSaveOk = useRef < ( ) => void > ( ( ) => { } ) ;
255- const [ askToSaveSaving , setAskToSaveSaving ] = useState ( false ) ;
253+ const [ popconfirmTitle , setPopconfirmTitle ] = useState ( '' ) ;
254+ const [ popconfirmDescription , setPopconfirmDescription ] = useState ( '' ) ;
255+ const [ openPopconfirm , setOpenPopconfirm ] = useState ( false ) ;
256+ const afterPopconfirmOk = useRef < ( ) => void > ( ( ) => { } ) ;
257+ const [ popconfirmLoading , setPopconfirmLoading ] = useState ( false ) ;
256258
257259 const ignoreEffect = ( ) => {
258260 if ( ! process . env . NODE_ENV || process . env . NODE_ENV === 'development' ) {
@@ -486,9 +488,9 @@ const App: React.FC = () => {
486488 setGeneratedCode ( code ) ;
487489 } ;
488490
489- const handleAskToSaveOk = ( ) => {
490- const callback = afterAskToSaveOk . current ;
491- afterAskToSaveOk . current = ( ) => { } ;
491+ const handlePopconfirmOk = ( ) => {
492+ const callback = afterPopconfirmOk . current ;
493+ afterPopconfirmOk . current = ( ) => { } ;
492494 callback ( ) ;
493495 } ;
494496
@@ -504,18 +506,20 @@ const App: React.FC = () => {
504506 }
505507
506508 // Show a bubble confirmation box to ask the user if they want to save the blocks.
507- // Set the function to be executed if the user clicks "ok".
508- afterAskToSaveOk . current = ( ) => {
509- setAskToSaveSaving ( true ) ;
509+ setPopconfirmTitle ( 'Blocks have been modified!' ) ;
510+ setPopconfirmDescription ( 'Press ok to save and continue' ) ;
511+ // Set the function to be executed if the user clicks 'ok'.
512+ afterPopconfirmOk . current = ( ) => {
513+ setPopconfirmLoading ( true ) ;
510514 saveModule ( ( success ) => {
511- setOpenAskToSave ( false ) ;
512- setAskToSaveSaving ( false ) ;
515+ setOpenPopconfirm ( false ) ;
516+ setPopconfirmLoading ( false ) ;
513517 if ( success ) {
514518 callback ( ) ;
515519 }
516520 } ) ;
517521 } ;
518- setOpenAskToSave ( true ) ;
522+ setOpenPopconfirm ( true ) ;
519523 }
520524 } ;
521525
@@ -704,59 +708,72 @@ const App: React.FC = () => {
704708 if ( workspaceName === moduleName ) {
705709 // This is a workspace.
706710 setNewWorkspaceNameModalPurpose ( 'CopyWorkspace' ) ;
707- setNewWorkspaceNameModalInitialValue ( workspaceName + " _copy" ) ;
711+ setNewWorkspaceNameModalInitialValue ( workspaceName + ' _copy' ) ;
708712 setNewWorkspaceNameModalIsOpen ( true ) ;
709713 } else {
710714 // This is an OpMode.
711715 setNewOpModeNameModalPurpose ( 'CopyOpMode' ) ;
712- setNewOpModeNameModalInitialValue ( moduleName + " _copy" ) ;
716+ setNewOpModeNameModalInitialValue ( moduleName + ' _copy' ) ;
713717 setNewOpModeNameModalIsOpen ( true ) ;
714718 }
715719 } ) ;
716720 } ;
717721
718722 const handleDeleteClicked = ( ) => {
719- checkIfBlocksWereModified ( ( ) => {
720- const workspaceName = commonStorage . getWorkspaceName ( currentModulePath ) ;
721- const moduleName = commonStorage . getModuleName ( currentModulePath ) ;
722- if ( workspaceName === moduleName ) {
723- // This is a workspace.
724- // Before deleting it, select another workspace, if there is one.
725- let foundAnotherWorkspace = false ;
726- for ( const workspace of modules ) {
727- if ( workspace . workspaceName !== workspaceName ) {
728- setCurrentModulePath ( workspace . modulePath ) ;
729- foundAnotherWorkspace = true ;
730- break ;
723+ const workspaceName = commonStorage . getWorkspaceName ( currentModulePath ) ;
724+ const moduleName = commonStorage . getModuleName ( currentModulePath ) ;
725+
726+ // Show a bubble confirmation box to ask the user if they are sure.
727+ setPopconfirmTitle ( 'Are you sure?' ) ;
728+ if ( workspaceName === moduleName ) {
729+ setPopconfirmDescription ( 'Press ok to delete this Workspace' ) ;
730+ } else {
731+ setPopconfirmDescription ( 'Press ok to delete this OpMode' ) ;
732+ }
733+ // Set the function to be executed if the user clicks 'ok'.
734+ afterPopconfirmOk . current = ( ) => {
735+ setOpenPopconfirm ( false ) ;
736+ checkIfBlocksWereModified ( ( ) => {
737+ if ( workspaceName === moduleName ) {
738+ // This is a workspace.
739+ // Before deleting it, select another workspace, if there is one.
740+ let foundAnotherWorkspace = false ;
741+ for ( const workspace of modules ) {
742+ if ( workspace . workspaceName !== workspaceName ) {
743+ setCurrentModulePath ( workspace . modulePath ) ;
744+ foundAnotherWorkspace = true ;
745+ break ;
746+ }
731747 }
748+ if ( ! foundAnotherWorkspace ) {
749+ setCurrentModulePath ( '' ) ;
750+ }
751+ storage . deleteWorkspace ( workspaceName ,
752+ ( success : boolean , errorMessage : string ) => {
753+ if ( success ) {
754+ setTriggerListModules ( ! triggerListModules ) ;
755+ } else if ( errorMessage ) {
756+ setAlertErrorMessage ( 'Failed to delete the Workspace: ' + errorMessage ) ;
757+ setAlertErrorVisible ( true ) ;
758+ }
759+ } ) ;
760+ } else {
761+ // This is an OpMode.
762+ const workspacePath = commonStorage . makeModulePath ( workspaceName , workspaceName ) ;
763+ setCurrentModulePath ( workspacePath ) ;
764+ storage . deleteOpMode ( currentModulePath ,
765+ ( success : boolean , errorMessage : string ) => {
766+ if ( success ) {
767+ setTriggerListModules ( ! triggerListModules ) ;
768+ } else if ( errorMessage ) {
769+ setAlertErrorMessage ( 'Failed to delete the OpMode: ' + errorMessage ) ;
770+ setAlertErrorVisible ( true ) ;
771+ }
772+ } ) ;
732773 }
733- if ( ! foundAnotherWorkspace ) {
734- setCurrentModulePath ( '' ) ;
735- }
736- storage . deleteWorkspace ( workspaceName ,
737- ( success : boolean , errorMessage : string ) => {
738- if ( success ) {
739- setTriggerListModules ( ! triggerListModules ) ;
740- } else if ( errorMessage ) {
741- setAlertErrorMessage ( 'Failed to rename the Workspace: ' + errorMessage ) ;
742- setAlertErrorVisible ( true ) ;
743- }
744- } ) ;
745- } else {
746- // This is an OpMode.
747- const workspacePath = commonStorage . makeModulePath ( workspaceName , workspaceName ) ;
748- setCurrentModulePath ( workspacePath ) ;
749- storage . deleteOpMode ( currentModulePath ,
750- ( success : boolean , errorMessage : string ) => {
751- if ( success ) {
752- setTriggerListModules ( ! triggerListModules ) ;
753- } else if ( errorMessage ) {
754- setAlertErrorMessage ( 'Failed to rename the Workspace: ' + errorMessage ) ;
755- setAlertErrorVisible ( true ) ;
756- }
757- } ) ;
758- }
759- } ) ;
774+ } ) ;
775+ } ;
776+ setOpenPopconfirm ( true ) ;
760777 } ;
761778
762779 const handleUploadClicked = ( ) => {
@@ -873,9 +890,11 @@ const App: React.FC = () => {
873890 >
874891 < Flex vertical gap = "small" >
875892 < Space >
876- < Tooltip title = "New Workspace" >
893+ < Tooltip title = "New Workspace"
894+ placement = "bottomRight"
895+ >
877896 < Button
878- icon = { < FolderAddOutlined /> }
897+ icon = { < FolderAddOutlined /> }
879898 size = "small"
880899 onClick = { handleNewWorkspaceClicked }
881900 style = { { color : 'white' } }
@@ -884,7 +903,7 @@ const App: React.FC = () => {
884903 </ Tooltip >
885904 < Tooltip title = "New OpMode" >
886905 < Button
887- icon = { < FileAddOutlined /> }
906+ icon = { < FileAddOutlined /> }
888907 size = "small"
889908 disabled = { ! currentModulePath }
890909 onClick = { handleNewOpModeClicked }
@@ -894,7 +913,7 @@ const App: React.FC = () => {
894913 </ Tooltip >
895914 < Tooltip title = "Save" >
896915 < Button
897- icon = { < SaveOutlined /> }
916+ icon = { < SaveOutlined /> }
898917 size = "small"
899918 disabled = { ! currentModulePath }
900919 onClick = { handleSaveClicked }
@@ -904,9 +923,11 @@ const App: React.FC = () => {
904923 </ Tooltip >
905924 </ Space >
906925 < Space >
907- < Tooltip title = { renameTooltip } >
926+ < Tooltip title = { renameTooltip }
927+ placement = "topRight"
928+ >
908929 < Button
909- icon = { < EditOutlined /> }
930+ icon = { < EditOutlined /> }
910931 size = "small"
911932 disabled = { ! currentModulePath }
912933 onClick = { handleRenameClicked }
@@ -916,7 +937,7 @@ const App: React.FC = () => {
916937 </ Tooltip >
917938 < Tooltip title = { copyTooltip } >
918939 < Button
919- icon = { < CopyOutlined /> }
940+ icon = { < CopyOutlined /> }
920941 size = "small"
921942 disabled = { ! currentModulePath }
922943 onClick = { handleCopyClicked }
@@ -926,7 +947,7 @@ const App: React.FC = () => {
926947 </ Tooltip >
927948 < Tooltip title = { deleteTooltip } >
928949 < Button
929- icon = { < DeleteOutlined /> }
950+ icon = { < DeleteOutlined /> }
930951 size = "small"
931952 disabled = { ! currentModulePath }
932953 onClick = { handleDeleteClicked }
@@ -983,12 +1004,12 @@ const App: React.FC = () => {
9831004 </ Tooltip >
9841005 </ Space >
9851006 < Popconfirm
986- title = "Blocks have been modified!"
987- description = "Press ok to save and continue"
988- open = { openAskToSave }
989- onConfirm = { handleAskToSaveOk }
990- okButtonProps = { { loading : askToSaveSaving } }
991- onCancel = { ( ) => setOpenAskToSave ( false ) }
1007+ title = { popconfirmTitle }
1008+ description = { popconfirmDescription }
1009+ open = { openPopconfirm }
1010+ onConfirm = { handlePopconfirmOk }
1011+ okButtonProps = { { loading : popconfirmLoading } }
1012+ onCancel = { ( ) => setOpenPopconfirm ( false ) }
9921013 >
9931014 < Flex
9941015 style = { {
0 commit comments