Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Bring changes in from master and resolve conflicts

Joshen Limb654ec6d8bfc
diff --cc studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
index 6a2945b9003,d89f20573fd..5d6848070a7
--- a/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
+++ b/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
@@@ -24,33 -26,50 +24,34 @@@ const DeleteBucketModal = ({ visible =
const buckets = data ?? []
- useEffect(() => {
- setDeleting(false)
- }, [visible])
-
const onDeleteBucket = async () => {
if (!projectRef) return console.error('Project ref is required')
+ if (!bucket) return console.error('No bucket is selected')
- setDeleting(true)
- try {
- await deleteBucket({ projectRef, id: bucket.id })
-
- // Clean up policies from the corresponding bucket that was deleted
- await meta.policies.loadBySchema('storage')
- const policies = meta.policies.list()
- const storageObjectsPolicies = policies.filter((policy) => policy.table === 'objects')
- const formattedStorageObjectPolicies = formatPoliciesForStorage(
- buckets,
- storageObjectsPolicies
- )
- const bucketPolicies = _get(
- find(formattedStorageObjectPolicies, { name: bucket.name }),
- ['policies'],
- []
- )
- await Promise.all(
- bucketPolicies.map((policy: any) => {
- meta.policies.del(policy.id)
- })
- )
+ await deleteBucket({ projectRef, id: bucket.id })
- ui.setNotification({
- category: 'success',
- message: `Successfully deleted bucket ${bucket.name}`,
+ // Clean up policies from the corresponding bucket that was deleted
+ await meta.policies.loadBySchema('storage')
+ const policies = meta.policies.list()
+ const storageObjectsPolicies = policies.filter((policy) => policy.table === 'objects')
+ const formattedStorageObjectPolicies = formatPoliciesForStorage(buckets, storageObjectsPolicies)
+ const bucketPolicies = _get(
+ find(formattedStorageObjectPolicies, { name: bucket.name }),
+ ['policies'],
+ []
+ )
+ await Promise.all(
+ bucketPolicies.map((policy: any) => {
+ meta.policies.del(policy.id)
})
- router.push(`/project/${projectRef}/storage/buckets`)
- onClose()
- } catch (error: any) {
- setDeleting(false)
- ui.setNotification({
- category: 'error',
- message: `Failed to delete bucket: ${error.message}`,
- })
- }
+ )
+
+ ui.setNotification({
+ category: 'success',
+ message: `Successfully deleted bucket ${bucket.name}`,
+ })
+ router.push(`/project/${projectRef}/storage/buckets`)
+ onClose()
}
return (
@@@ -60,11 -79,11 +61,11 @@@
confirmPlaceholder="Type in name of bucket"
onConfirm={onDeleteBucket}
onCancel={onClose}
- confirmString={bucket.name}
+ confirmString={bucket?.name ?? ''}
- loading={deleting}
+ loading={isDeleting}
text={
<>
- Your bucket <span className="font-bold">{bucket.name}</span> and all its contents will be
+ Your bucket <span className="font-bold">{bucket?.name}</span> and all its contents will be
permanently deleted.
</>
}