mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	fix: split single & bulk delete
This commit is contained in:
		
							parent
							
								
									de4ef3d4cc
								
							
						
					
					
						commit
						2d79c58816
					
				| @ -103,7 +103,32 @@ const ListPage = () => { | |||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const confirmDelete = async () => { |   const deleteWebhook = async (id: string) => { | ||||||
|  |     try { | ||||||
|  |       const res = await deleteManyWebhooks({ | ||||||
|  |         ids: [id], | ||||||
|  |       }); | ||||||
|  | 
 | ||||||
|  |       if ('error' in res) { | ||||||
|  |         toggleNotification({ | ||||||
|  |           type: 'danger', | ||||||
|  |           message: formatAPIError(res.error), | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|  |         return; | ||||||
|  |       } | ||||||
|  |     } catch { | ||||||
|  |       toggleNotification({ | ||||||
|  |         type: 'danger', | ||||||
|  |         message: formatMessage({ | ||||||
|  |           id: 'notification.error', | ||||||
|  |           defaultMessage: 'An error occurred', | ||||||
|  |         }), | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const confirmBulkDelete = async () => { | ||||||
|     try { |     try { | ||||||
|       const res = await deleteManyWebhooks({ |       const res = await deleteManyWebhooks({ | ||||||
|         ids: webhooksToDelete, |         ids: webhooksToDelete, | ||||||
| @ -349,20 +374,11 @@ const ListPage = () => { | |||||||
|                           </IconButton> |                           </IconButton> | ||||||
|                         )} |                         )} | ||||||
|                         {canDelete && ( |                         {canDelete && ( | ||||||
|                           <IconButton |                           <DeleteActionButton | ||||||
|                             onClick={(e) => { |                             onDelete={() => { | ||||||
|                               e.stopPropagation(); |                               deleteWebhook(webhook.id); | ||||||
|                               setWebhooksToDelete([webhook.id]); |  | ||||||
|                               setShowModal(true); |  | ||||||
|                             }} |                             }} | ||||||
|                             label={formatMessage({ |                           /> | ||||||
|                               id: 'Settings.webhooks.events.delete', |  | ||||||
|                               defaultMessage: 'Delete webhook', |  | ||||||
|                             })} |  | ||||||
|                             borderWidth={0} |  | ||||||
|                           > |  | ||||||
|                             <Trash /> |  | ||||||
|                           </IconButton> |  | ||||||
|                         )} |                         )} | ||||||
|                       </Flex> |                       </Flex> | ||||||
|                     </Td> |                     </Td> | ||||||
| @ -392,12 +408,52 @@ const ListPage = () => { | |||||||
|         </Layouts.Content> |         </Layouts.Content> | ||||||
|       </Page.Main> |       </Page.Main> | ||||||
|       <Dialog.Root open={showModal} onOpenChange={setShowModal}> |       <Dialog.Root open={showModal} onOpenChange={setShowModal}> | ||||||
|         <ConfirmDialog onConfirm={confirmDelete} /> |         <ConfirmDialog onConfirm={confirmBulkDelete} /> | ||||||
|       </Dialog.Root> |       </Dialog.Root> | ||||||
|     </Layouts.Root> |     </Layouts.Root> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | /* ------------------------------------------------------------------------------------------------- | ||||||
|  |  * DeleteActionButton | ||||||
|  |  * -----------------------------------------------------------------------------------------------*/ | ||||||
|  | 
 | ||||||
|  | type DeleteActionButtonProps = { | ||||||
|  |   onDelete: () => void; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const DeleteActionButton = ({ onDelete }: DeleteActionButtonProps) => { | ||||||
|  |   const [showModal, setShowModal] = React.useState(false); | ||||||
|  |   const { formatMessage } = useIntl(); | ||||||
|  | 
 | ||||||
|  |   return ( | ||||||
|  |     <> | ||||||
|  |       <IconButton | ||||||
|  |         onClick={(e) => { | ||||||
|  |           e.stopPropagation(); | ||||||
|  |           setShowModal(true); | ||||||
|  |         }} | ||||||
|  |         label={formatMessage({ | ||||||
|  |           id: 'Settings.webhooks.events.delete', | ||||||
|  |           defaultMessage: 'Delete webhook', | ||||||
|  |         })} | ||||||
|  |         borderWidth={0} | ||||||
|  |       > | ||||||
|  |         <Trash /> | ||||||
|  |       </IconButton> | ||||||
|  | 
 | ||||||
|  |       <Dialog.Root open={showModal} onOpenChange={setShowModal}> | ||||||
|  |         <ConfirmDialog | ||||||
|  |           onConfirm={(e) => { | ||||||
|  |             e?.stopPropagation(); | ||||||
|  |             onDelete(); | ||||||
|  |           }} | ||||||
|  |         /> | ||||||
|  |       </Dialog.Root> | ||||||
|  |     </> | ||||||
|  |   ); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| /* ------------------------------------------------------------------------------------------------- | /* ------------------------------------------------------------------------------------------------- | ||||||
|  * ProtectedListView |  * ProtectedListView | ||||||
|  * -----------------------------------------------------------------------------------------------*/ |  * -----------------------------------------------------------------------------------------------*/ | ||||||
|  | |||||||
| @ -131,7 +131,7 @@ const createBuildContext = async <TOptions extends BaseOptions>({ | |||||||
| 
 | 
 | ||||||
|   const features = strapiInstance.config.get('features', undefined); |   const features = strapiInstance.config.get('features', undefined); | ||||||
| 
 | 
 | ||||||
|   const { bundler = 'webpack', ...restOptions } = options; |   const { bundler = 'vite', ...restOptions } = options; | ||||||
| 
 | 
 | ||||||
|   const buildContext = { |   const buildContext = { | ||||||
|     appDir, |     appDir, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Alexandre Bodin
						Alexandre Bodin