Skip to content

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

Redirect to new bucket when creating a new bucket

Joshen Lim7132a893e176
diff --git a/studio/components/layouts/StorageLayout/StorageLayout.tsx b/studio/components/layouts/StorageLayout/StorageLayout.tsx
index a04d241504d..0aa2181bc65 100644
--- a/studio/components/layouts/StorageLayout/StorageLayout.tsx
+++ b/studio/components/layouts/StorageLayout/StorageLayout.tsx
@@ -64,6 +64,11 @@ const StorageLayout: FC<Props> = ({ title, children }) => {
storageExplorerStore.setLoaded(true)
}
+ const onSelectCreateBucket = async (bucketName: string, isPublic: boolean) => {
+ const bucket = await createBucket(bucketName, isPublic)
+ if (bucket.name) router.push(`/project/${ref}/storage/buckets/${bucket.name}`)
+ }
+
const onSelectDeleteBucket = async (bucket: any) => {
const res = await deleteBucket(bucket)
// Ideally this should be within deleteBucket as its a necessary side effect
@@ -101,7 +106,7 @@ const StorageLayout: FC<Props> = ({ title, children }) => {
<CreateBucketModal
visible={showCreateBucketModal}
onSelectCancel={closeCreateBucketModal}
- onSelectSave={createBucket}
+ onSelectSave={onSelectCreateBucket}
/>
<DeleteBucketModal
visible={showDeleteBucketModal}
diff --git a/studio/components/to-be-cleaned/Storage/CreateBucketModal.tsx b/studio/components/to-be-cleaned/Storage/CreateBucketModal.tsx
index 407f7abd82e..334df29c71f 100644
--- a/studio/components/to-be-cleaned/Storage/CreateBucketModal.tsx
+++ b/studio/components/to-be-cleaned/Storage/CreateBucketModal.tsx
@@ -4,13 +4,13 @@ import { Modal, Alert, Button, Input, Toggle } from 'ui'
interface Props {
visible: boolean
onSelectCancel: () => {}
- onSelectSave: () => {}
+ onSelectSave: (bucketName: string, isPublic: boolean) => {}
}
const CreateBucketModal: FC<Props> = ({
visible = false,
onSelectCancel = () => {},
- onSelectSave = (bucketName: string, isPublic: boolean) => {},
+ onSelectSave = () => {},
}) => {
const [saving, setSaving] = useState(false)
const [error, setError] = useState('')
diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.js
index 3241b0e02c4..f3bcfd79a4b 100644
--- a/studio/localStores/storageExplorer/StorageExplorerStore.js
+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js
@@ -451,7 +451,7 @@ class StorageExplorerStore {
})
}
- const { error } = await this.supabaseClient.storage.createBucket(bucketName, {
+ const { data, error } = await this.supabaseClient.storage.createBucket(bucketName, {
public: isPublic,
})
if (error) {
@@ -464,6 +464,7 @@ class StorageExplorerStore {
await this.fetchBuckets()
this.closeCreateBucketModal()
+ return data
}
openBucket = async (bucket) => {