@@ -51,7 +51,7 @@ export default function ProjectManageModal(props: ProjectManageModalProps) {
5151 // Sort modules alphabetically by title
5252 projects . sort ( ( a , b ) => a . className . localeCompare ( b . className ) ) ;
5353 setModules ( projects ) ;
54- if ( ( projects . length > 0 ) && props . noProjects ) {
54+ if ( ( projects . length > 0 ) && props . noProjects ) {
5555 props . setProject ( projects [ 0 ] ) ; // Set the first project as the current project
5656 props . onCancel ( ) ; // Close the modal after selecting
5757 }
@@ -133,7 +133,7 @@ export default function ProjectManageModal(props: ProjectManageModalProps) {
133133 width : 160 ,
134134 render : ( _ , record : commonStorage . Project ) => (
135135 < Antd . Space size = "small" >
136- < Antd . Tooltip title = { t ( "Select" ) } >
136+ < Antd . Tooltip title = { t ( "Select" ) } >
137137 < Antd . Button
138138 type = "text"
139139 size = "small"
@@ -168,44 +168,46 @@ export default function ProjectManageModal(props: ProjectManageModalProps) {
168168 } }
169169 />
170170 </ Antd . Tooltip >
171- < Antd . Tooltip title = { t ( "Delete" ) } >
172- < Antd . Popconfirm
173- title = { `Delete ${ record . className } ?` }
174- description = "This action cannot be undone."
175- onConfirm = { async ( ) => {
176- const newModules = modules . filter ( m => m . modulePath !== record . modulePath ) ;
177- setModules ( newModules ) ;
178- let foundAnotherProject = false ;
179- for ( const project of modules ) {
180- if ( project . modulePath !== record . modulePath ) {
181- props . setProject ( project ) ;
182- foundAnotherProject = true ;
183- break ;
171+ { modules . length > 1 && (
172+ < Antd . Tooltip title = { t ( "Delete" ) } >
173+ < Antd . Popconfirm
174+ title = { `Delete ${ record . className } ?` }
175+ description = "This action cannot be undone."
176+ onConfirm = { async ( ) => {
177+ const newModules = modules . filter ( m => m . modulePath !== record . modulePath ) ;
178+ setModules ( newModules ) ;
179+ let foundAnotherProject = false ;
180+ for ( const project of modules ) {
181+ if ( project . modulePath !== record . modulePath ) {
182+ props . setProject ( project ) ;
183+ foundAnotherProject = true ;
184+ break ;
185+ }
184186 }
185- }
186- if ( ! foundAnotherProject ) {
187- props . setProject ( null ) ;
188- }
189- try {
190- await props . storage ! . deleteModule ( commonStorage . MODULE_TYPE_PROJECT , record . modulePath ) ;
191- } catch ( e ) {
192- console . log ( 'Failed to delete the project. Caught the following error...' ) ;
193- console . log ( e ) ;
194- props . setAlertErrorMessage ( 'Failed to delete the project.' ) ;
195- }
196- } }
197- okText = { t ( "Delete " ) }
198- cancelText = { t ( "Cancel" ) }
199- okType = "danger"
200- >
201- < Antd . Button
202- type = "text "
203- size = "small"
204- icon = { < DeleteOutlined /> }
205- danger
206- / >
207- </ Antd . Popconfirm >
208- </ Antd . Tooltip >
187+ if ( ! foundAnotherProject ) {
188+ props . setProject ( null ) ;
189+ }
190+ try {
191+ await props . storage ! . deleteModule ( commonStorage . MODULE_TYPE_PROJECT , record . modulePath ) ;
192+ } catch ( e ) {
193+ console . log ( 'Failed to delete the project. Caught the following error...' ) ;
194+ console . log ( e ) ;
195+ props . setAlertErrorMessage ( 'Failed to delete the project.' ) ;
196+ }
197+ } }
198+ okText = { t ( "Delete" ) }
199+ cancelText = { t ( "Cancel " ) }
200+ okType = "danger"
201+ >
202+ < Antd . Button
203+ type = "text"
204+ size = "small "
205+ icon = { < DeleteOutlined /> }
206+ danger
207+ />
208+ </ Antd . Popconfirm >
209+ </ Antd . Tooltip >
210+ ) }
209211 </ Antd . Space >
210212 ) ,
211213 } ,
0 commit comments