@@ -359,28 +359,32 @@ export default function ModuleOutline(props: ModuleOutlineProps) {
359359 props . setAlertErrorMessage ( 'Failed to create a new project.' ) ;
360360 }
361361 } else if ( newProjectNameModalPurpose === PURPOSE_RENAME_PROJECT ) {
362- try {
363- await props . storage . renameModule (
364- props . currentModule . moduleType , props . currentModule . projectName ,
365- props . currentModule . moduleName , newProjectName ) ;
366- await fetchListOfModules ( ) ;
367- setCurrentModulePath ( newProjectPath ) ;
368- } catch ( e ) {
369- console . log ( 'Failed to rename the project. Caught the following error...' ) ;
370- console . log ( e ) ;
371- props . setAlertErrorMessage ( 'Failed to rename the project.' ) ;
362+ if ( props . currentModule ) {
363+ try {
364+ await props . storage . renameModule (
365+ props . currentModule . moduleType , props . currentModule . projectName ,
366+ props . currentModule . moduleName , newProjectName ) ;
367+ await fetchListOfModules ( ) ;
368+ setCurrentModulePath ( newProjectPath ) ;
369+ } catch ( e ) {
370+ console . log ( 'Failed to rename the project. Caught the following error...' ) ;
371+ console . log ( e ) ;
372+ props . setAlertErrorMessage ( 'Failed to rename the project.' ) ;
373+ }
372374 }
373375 } else if ( newProjectNameModalPurpose === PURPOSE_COPY_PROJECT ) {
374- try {
375- await props . storage . copyModule (
376- props . currentModule . moduleType , props . currentModule . projectName ,
377- props . currentModule . moduleName , newProjectName ) ;
378- await fetchListOfModules ( ) ;
379- setCurrentModulePath ( newProjectPath ) ;
380- } catch ( e ) {
381- console . log ( 'Failed to copy the project. Caught the following error...' ) ;
382- console . log ( e ) ;
383- props . setAlertErrorMessage ( 'Failed to copy the project.' ) ;
376+ if ( props . currentModule ) {
377+ try {
378+ await props . storage . copyModule (
379+ props . currentModule . moduleType , props . currentModule . projectName ,
380+ props . currentModule . moduleName , newProjectName ) ;
381+ await fetchListOfModules ( ) ;
382+ setCurrentModulePath ( newProjectPath ) ;
383+ } catch ( e ) {
384+ console . log ( 'Failed to copy the project. Caught the following error...' ) ;
385+ console . log ( e ) ;
386+ props . setAlertErrorMessage ( 'Failed to copy the project.' ) ;
387+ }
384388 }
385389 }
386390 } ;
0 commit comments