diff --git a/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx b/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx index f023ee2c3c0..5683dddc44a 100644 --- a/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx +++ b/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx @@ -2,7 +2,7 @@ import { useParams } from 'common' import { ChevronDown, FolderOpen, Settings, Shield, Trash2 } from 'lucide-react' import Link from 'next/link' import { useRouter } from 'next/router' -import { parseAsBoolean, parseAsStringEnum, useQueryState } from 'nuqs' +import { parseAsBoolean, useQueryState } from 'nuqs' import { useEffect } from 'react' import { toast } from 'sonner' import { @@ -18,8 +18,8 @@ import { DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, - NavMenu, - NavMenuItem, + Label, + Switch, Tooltip, TooltipContent, TooltipTrigger, @@ -34,24 +34,36 @@ import { useSelectedBucket } from '@/components/interfaces/Storage/FilesBuckets/ import { PublicBucketWarning } from '@/components/interfaces/Storage/PublicBucketWarning' import { PUBLIC_BUCKET_TOOLTIP } from '@/components/interfaces/Storage/Storage.constants' import StorageBucketsError from '@/components/interfaces/Storage/StorageBucketsError' -import { DeletedFilesProvider } from '@/components/interfaces/Storage/StorageExplorer/DeletedFilesContext' +import { + DeletedFilesProvider, + useDeletedFilesContext, +} from '@/components/interfaces/Storage/StorageExplorer/DeletedFilesContext' import { StorageExplorer } from '@/components/interfaces/Storage/StorageExplorer/StorageExplorer' -import { useIsStorageProtectionEnabled } from '@/components/interfaces/Storage/StorageProtection.constants' -import { Trash } from '@/components/interfaces/Storage/Trash/Trash' import { useBucketPolicyCount } from '@/components/interfaces/Storage/useBucketPolicyCount' import { DefaultLayout } from '@/components/layouts/DefaultLayout' import StorageLayout from '@/components/layouts/StorageLayout/StorageLayout' import { StorageExplorerStateContextProvider } from '@/state/storage-explorer' import type { NextPageWithLayout } from '@/types' -type BucketView = 'files' | 'trash' -const BUCKET_VIEWS: BucketView[] = ['files', 'trash'] - const BucketPage: NextPageWithLayout = () => { + const { ref } = useParams() + + return ( + + + + + + ) +} + +const BucketPageInner = () => { const router = useRouter() const { bucketId, ref } = useParams() const { data: bucket, error, isSuccess, isError } = useSelectedBucket() + const { isShowingDeleted, setIsShowingDeleted } = useDeletedFilesContext() + const [showEditModal, setShowEditModal] = useQueryState( 'edit', parseAsBoolean.withDefault(false).withOptions({ history: 'push', clearOnDefault: true }) @@ -65,16 +77,8 @@ const BucketPage: NextPageWithLayout = () => { parseAsBoolean.withDefault(false).withOptions({ history: 'push', clearOnDefault: true }) ) - const [view, setView] = useQueryState( - 'view', - parseAsStringEnum(BUCKET_VIEWS) - .withDefault('files') - .withOptions({ history: 'push', clearOnDefault: true }) - ) - const { getPolicyCount } = useBucketPolicyCount() const policyCount = bucket ? getPolicyCount(bucket.id) : 0 - const showProtection = useIsStorageProtectionEnabled() useEffect(() => { if (isSuccess && !bucket) { @@ -89,147 +93,138 @@ const BucketPage: NextPageWithLayout = () => { } return ( - - -
- - - - - - - - setShowEditModal(true)} - > - -

Bucket settings

-
- - setShowEmptyModal(true)} - > - -

Empty bucket

-
- setShowDeleteModal(true)} - > - -

Delete bucket

-
-
-
- - } - > - - - - Files - - - - - - Buckets - - - - - - {bucketId} - {bucket?.public && ( - - - - Public - - - {PUBLIC_BUCKET_TOOLTIP} - - )} - - - -
- - {showProtection && ( - - - - - - - - - )} - - {view === 'files' && ( - - {ref && bucketId && ( -
- -
- )} -
- + <> +
+ +
+ +
- - )} - {view === 'trash' && bucket && } -
+ + + + + + + setShowEditModal(true)} + > + +

Bucket settings

+
+ + setShowEmptyModal(true)} + > + +

Empty bucket

+
+ setShowDeleteModal(true)} + > + +

Delete bucket

+
+
+
+ + } + > + + + + Files + + + + + + Buckets + + + + + + {bucketId} + {bucket?.public && ( + + + + Public + + + {PUBLIC_BUCKET_TOOLTIP} + + )} + + + + - {bucket && ( - <> - setShowEditModal(false)} - /> - setShowEmptyModal(false)} - /> - setShowDeleteModal(false)} - /> - - )} - - + + {ref && bucketId && ( +
+ +
+ )} +
+ +
+
+
+ + {bucket && ( + <> + setShowEditModal(false)} + /> + setShowEmptyModal(false)} + /> + setShowDeleteModal(false)} + /> + + )} + ) } diff --git a/apps/studio/pages/project/[ref]/storage/files/bucketsV2/[bucketId].tsx b/apps/studio/pages/project/[ref]/storage/files/bucketsV2/[bucketId].tsx index e6fddf52e17..e4f97a45db3 100644 --- a/apps/studio/pages/project/[ref]/storage/files/bucketsV2/[bucketId].tsx +++ b/apps/studio/pages/project/[ref]/storage/files/bucketsV2/[bucketId].tsx @@ -2,7 +2,7 @@ import { useParams } from 'common' import { ChevronDown, FolderOpen, Settings, Shield, Trash2 } from 'lucide-react' import Link from 'next/link' import { useRouter } from 'next/router' -import { parseAsBoolean, useQueryState } from 'nuqs' +import { parseAsBoolean, parseAsStringEnum, useQueryState } from 'nuqs' import { useEffect } from 'react' import { toast } from 'sonner' import { @@ -18,8 +18,8 @@ import { DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, - Label, - Switch, + NavMenu, + NavMenuItem, Tooltip, TooltipContent, TooltipTrigger, @@ -34,36 +34,24 @@ import { useSelectedBucket } from '@/components/interfaces/Storage/FilesBuckets/ import { PublicBucketWarning } from '@/components/interfaces/Storage/PublicBucketWarning' import { PUBLIC_BUCKET_TOOLTIP } from '@/components/interfaces/Storage/Storage.constants' import StorageBucketsError from '@/components/interfaces/Storage/StorageBucketsError' -import { - DeletedFilesProvider, - useDeletedFilesContext, -} from '@/components/interfaces/Storage/StorageExplorer/DeletedFilesContext' +import { DeletedFilesProvider } from '@/components/interfaces/Storage/StorageExplorer/DeletedFilesContext' import { StorageExplorer } from '@/components/interfaces/Storage/StorageExplorer/StorageExplorer' +import { useIsStorageProtectionEnabled } from '@/components/interfaces/Storage/StorageProtection.constants' +import { Trash } from '@/components/interfaces/Storage/Trash/Trash' import { useBucketPolicyCount } from '@/components/interfaces/Storage/useBucketPolicyCount' import { DefaultLayout } from '@/components/layouts/DefaultLayout' import StorageLayout from '@/components/layouts/StorageLayout/StorageLayout' import { StorageExplorerStateContextProvider } from '@/state/storage-explorer' import type { NextPageWithLayout } from '@/types' +type BucketView = 'files' | 'trash' +const BUCKET_VIEWS: BucketView[] = ['files', 'trash'] + const BucketV2Page: NextPageWithLayout = () => { - const { ref } = useParams() - - return ( - - - - - - ) -} - -const BucketV2PageInner = () => { const router = useRouter() const { bucketId, ref } = useParams() const { data: bucket, error, isSuccess, isError } = useSelectedBucket() - const { isShowingDeleted, setIsShowingDeleted } = useDeletedFilesContext() - const [showEditModal, setShowEditModal] = useQueryState( 'edit', parseAsBoolean.withDefault(false).withOptions({ history: 'push', clearOnDefault: true }) @@ -77,8 +65,16 @@ const BucketV2PageInner = () => { parseAsBoolean.withDefault(false).withOptions({ history: 'push', clearOnDefault: true }) ) + const [view, setView] = useQueryState( + 'view', + parseAsStringEnum(BUCKET_VIEWS) + .withDefault('files') + .withOptions({ history: 'push', clearOnDefault: true }) + ) + const { getPolicyCount } = useBucketPolicyCount() const policyCount = bucket ? getPolicyCount(bucket.id) : 0 + const showProtection = useIsStorageProtectionEnabled() useEffect(() => { if (isSuccess && !bucket) { @@ -93,138 +89,147 @@ const BucketV2PageInner = () => { } return ( - <> -
- -
- - -
- - - - - - - setShowEditModal(true)} + - -

Bucket settings

-
- - setShowEmptyModal(true)} - > - -

Empty bucket

-
- setShowDeleteModal(true)} - > - -

Delete bucket

-
-
-
- - } - > - - - - Files - - - - - - Buckets - - - - - - {bucketId} - {bucket?.public && ( - - - - Public - - - {PUBLIC_BUCKET_TOOLTIP} - - )} - - - -
+ Policies + + + + + + + + setShowEditModal(true)} + > + +

Bucket settings

+
+ + setShowEmptyModal(true)} + > + +

Empty bucket

+
+ setShowDeleteModal(true)} + > + +

Delete bucket

+
+
+
+ + } + > + + + + Files + + + + + + Buckets + + + + + + {bucketId} + {bucket?.public && ( + + + + Public + + + {PUBLIC_BUCKET_TOOLTIP} + + )} + + + + - - {ref && bucketId && ( -
- -
+ {showProtection && ( + + + + + + + + )} -
- -
-
-
- {bucket && ( - <> - setShowEditModal(false)} - /> - setShowEmptyModal(false)} - /> - setShowDeleteModal(false)} - /> - - )} - + {view === 'files' && ( + + {ref && bucketId && ( +
+ +
+ )} +
+ +
+
+ )} + {view === 'trash' && bucket && } +
+ + {bucket && ( + <> + setShowEditModal(false)} + /> + setShowEmptyModal(false)} + /> + setShowDeleteModal(false)} + /> + + )} +
+
) }