Skip to content

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

Storage page components (#40935)

Saxon Fletcherda0b4c6f5712
diff --git a/apps/design-system/content/docs/fragments/page-header.mdx b/apps/design-system/content/docs/fragments/page-header.mdx
index 741efbbc0e1..2af086da1ee 100644
--- a/apps/design-system/content/docs/fragments/page-header.mdx
+++ b/apps/design-system/content/docs/fragments/page-header.mdx
@@ -21,4 +21,4 @@ fragment: true
- `PageHeaderTitle` - Primary page heading (h1)
- `PageHeaderDescription` - Supporting text below title
- `PageHeaderAside` - Container for action buttons (should be inside PageHeaderMeta, has `shrink-0`)
-- `PageHeaderFooter` - Container for tab navigation (NavMenu, should be last child)
+- `PageHeaderNavigationTabs` - Container for tab navigation (NavMenu, should be last child)
diff --git a/apps/design-system/registry/default/example/page-header-demo.tsx b/apps/design-system/registry/default/example/page-header-demo.tsx
index b3d2ae9263a..67d30e29b3c 100644
--- a/apps/design-system/registry/default/example/page-header-demo.tsx
+++ b/apps/design-system/registry/default/example/page-header-demo.tsx
@@ -15,9 +15,9 @@ import {
PageHeaderAside,
PageHeaderBreadcrumb,
PageHeaderDescription,
- PageHeaderFooter,
PageHeaderIcon,
PageHeaderMeta,
+ PageHeaderNavigationTabs,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
@@ -71,7 +71,7 @@ export default function PageHeaderDemo() {
</Button>
</PageHeaderAside>
</PageHeaderMeta>
- <PageHeaderFooter>
+ <PageHeaderNavigationTabs>
<NavMenu>
{navigationItems.map((item) => (
<NavMenuItem key={item.label} active={false}>
@@ -79,7 +79,7 @@ export default function PageHeaderDemo() {
</NavMenuItem>
))}
</NavMenu>
- </PageHeaderFooter>
+ </PageHeaderNavigationTabs>
</PageHeader>
</div>
)
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/index.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/index.tsx
index 08228cc76cf..5157f6d9bdf 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/index.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/index.tsx
@@ -3,7 +3,6 @@ import { useRouter } from 'next/navigation'
import { useState } from 'react'
import { useParams } from 'common'
-import { ScaffoldHeader, ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import { AlphaNotice } from 'components/ui/AlphaNotice'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
@@ -24,6 +23,8 @@ import {
} from 'ui'
import { TimestampInfo } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import { PageSection, PageSectionContent, PageSectionTitle } from 'ui-patterns/PageSection'
import { EmptyBucketState } from '../EmptyBucketState'
import { CreateAnalyticsBucketModal } from './CreateAnalyticsBucketModal'
@@ -63,129 +64,133 @@ export const AnalyticsBuckets = () => {
}
return (
- <ScaffoldSection isFullWidth>
- <AlphaNotice
- entity="Analytics buckets"
- feedbackUrl="https://github.com/orgs/supabase/discussions/40116"
- />
+ <PageContainer>
+ <PageSection>
+ <PageSectionContent>
+ <AlphaNotice
+ entity="Analytics buckets"
+ feedbackUrl="https://github.com/orgs/supabase/discussions/40116"
+ />
- {isLoadingBuckets && <GenericSkeletonLoader />}
+ {isLoadingBuckets && <GenericSkeletonLoader />}
- {isErrorBuckets && (
- <AlertError error={bucketsError} subject="Failed to retrieve analytics buckets" />
- )}
-
- {isSuccessBuckets && (
- <>
- {hasNoBuckets ? (
- <EmptyBucketState bucketType="analytics" />
- ) : (
- <div className="flex flex-col gap-y-4">
- <ScaffoldHeader className="py-0 flex flex-row items-center gap-x-2">
- <ScaffoldSectionTitle>Buckets</ScaffoldSectionTitle>
- {analyticsBuckets.length > 0 && (
- <Tooltip>
- <TooltipTrigger>
- <span className="bg-surface-200 rounded-full px-2 py-1 leading-none text-xs text-foreground-lighter tracking-widest">
- {analyticsBuckets.length}
- /2
- </span>
- </TooltipTrigger>
- <TooltipContent side="bottom" className="w-64 text-center">
- Each project can only have up to 2 buckets while analytics buckets are in
- alpha{' '}
- </TooltipContent>
- </Tooltip>
- )}
- </ScaffoldHeader>
- <div className="flex flex-grow justify-between gap-x-2 items-center">
- <Input
- size="tiny"
- className="flex-grow lg:flex-grow-0 w-52"
- placeholder="Search for a bucket"
- value={filterString}
- onChange={(e) => setFilterString(e.target.value)}
- icon={<Search />}
- />
- <CreateAnalyticsBucketModal buttonType="primary" buttonClassName="w-fit" />
- </div>
+ {isErrorBuckets && (
+ <AlertError error={bucketsError} subject="Failed to retrieve analytics buckets" />
+ )}
- {isLoadingBuckets ? (
- <GenericSkeletonLoader />
+ {isSuccessBuckets && (
+ <>
+ {hasNoBuckets ? (
+ <EmptyBucketState bucketType="analytics" />
) : (
- <Card>
- <Table>
- <TableHeader>
- <TableRow>
- {analyticsBuckets.length > 0 && (
- <TableHead className="w-2 pr-1">
- <span className="sr-only">Icon</span>
- </TableHead>
- )}
- <TableHead>Name</TableHead>
- <TableHead>Created at</TableHead>
- <TableHead>
- <span className="sr-only">Actions</span>
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {analyticsBuckets.length === 0 && filterString.length > 0 && (
- <TableRow className="[&>td]:hover:bg-inherit">
- <TableCell colSpan={3}>
- <p className="text-sm text-foreground">No results found</p>
- <p className="text-sm text-foreground-light">
- Your search for "{filterString}" did not return any results
- </p>
- </TableCell>
- </TableRow>
- )}
- {analyticsBuckets.map((bucket) => (
- <TableRow
- key={bucket.name}
- className="relative cursor-pointer h-16 inset-focus"
- onClick={(event) => handleBucketNavigation(bucket.name, event)}
- onKeyDown={(event) => {
- if (event.key === 'Enter' || event.key === ' ') {
- event.preventDefault()
- handleBucketNavigation(bucket.name, event)
- }
- }}
- tabIndex={0}
- >
- <TableCell className="w-2 pr-1">
- <AnalyticsBucketIcon size={16} className="text-foreground-muted" />
- </TableCell>
- <TableCell>
- <p className="whitespace-nowrap max-w-[512px] truncate">
- {bucket.name}
- </p>
- </TableCell>
+ <div className="flex flex-col gap-y-4">
+ <div className="flex flex-row items-center gap-x-2">
+ <PageSectionTitle>Buckets</PageSectionTitle>
+ {analyticsBuckets.length > 0 && (
+ <Tooltip>
+ <TooltipTrigger>
+ <span className="bg-surface-200 rounded-full px-2 py-1 leading-none text-xs text-foreground-lighter tracking-widest">
+ {analyticsBuckets.length}
+ /2
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" className="w-64 text-center">
+ Each project can only have up to 2 buckets while analytics buckets are in
+ alpha{' '}
+ </TooltipContent>
+ </Tooltip>
+ )}
+ </div>
+ <div className="flex flex-grow justify-between gap-x-2 items-center">
+ <Input
+ size="tiny"
+ className="flex-grow lg:flex-grow-0 w-52"
+ placeholder="Search for a bucket"
+ value={filterString}
+ onChange={(e) => setFilterString(e.target.value)}
+ icon={<Search />}
+ />
+ <CreateAnalyticsBucketModal buttonType="primary" buttonClassName="w-fit" />
+ </div>
+
+ {isLoadingBuckets ? (
+ <GenericSkeletonLoader />
+ ) : (
+ <Card>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ {analyticsBuckets.length > 0 && (
+ <TableHead className="w-2 pr-1">
+ <span className="sr-only">Icon</span>
+ </TableHead>
+ )}
+ <TableHead>Name</TableHead>
+ <TableHead>Created at</TableHead>
+ <TableHead>
+ <span className="sr-only">Actions</span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {analyticsBuckets.length === 0 && filterString.length > 0 && (
+ <TableRow className="[&>td]:hover:bg-inherit">
+ <TableCell colSpan={3}>
+ <p className="text-sm text-foreground">No results found</p>
+ <p className="text-sm text-foreground-light">
+ Your search for "{filterString}" did not return any results
+ </p>
+ </TableCell>
+ </TableRow>
+ )}
+ {analyticsBuckets.map((bucket) => (
+ <TableRow
+ key={bucket.name}
+ className="relative cursor-pointer h-16 inset-focus"
+ onClick={(event) => handleBucketNavigation(bucket.name, event)}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault()
+ handleBucketNavigation(bucket.name, event)
+ }
+ }}
+ tabIndex={0}
+ >
+ <TableCell className="w-2 pr-1">
+ <AnalyticsBucketIcon size={16} className="text-foreground-muted" />
+ </TableCell>
+ <TableCell>
+ <p className="whitespace-nowrap max-w-[512px] truncate">
+ {bucket.name}
+ </p>
+ </TableCell>
- <TableCell>
- <p className="text-foreground-light">
- <TimestampInfo
- utcTimestamp={bucket.created_at}
- className="text-sm text-foreground-light"
- />
- </p>
- </TableCell>
+ <TableCell>
+ <p className="text-foreground-light">
+ <TimestampInfo
+ utcTimestamp={bucket.created_at}
+ className="text-sm text-foreground-light"
+ />
+ </p>
+ </TableCell>
- <TableCell>
- <div className="flex justify-end items-center h-full">
- <ChevronRight size={14} className="text-foreground-muted/60" />
- </div>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
+ <TableCell>
+ <div className="flex justify-end items-center h-full">
+ <ChevronRight size={14} className="text-foreground-muted/60" />
+ </div>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ )}
+ </div>
)}
- </div>
+ </>
)}
- </>
- )}
- </ScaffoldSection>
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
)
}
diff --git a/apps/studio/components/interfaces/Storage/BucketsComingSoon.tsx b/apps/studio/components/interfaces/Storage/BucketsComingSoon.tsx
index 9b2f0ef7a42..feff318dc27 100644
--- a/apps/studio/components/interfaces/Storage/BucketsComingSoon.tsx
+++ b/apps/studio/components/interfaces/Storage/BucketsComingSoon.tsx
@@ -1,37 +1,42 @@
import { ExternalLink, FolderClock } from 'lucide-react'
import Link from 'next/link'
-import { ScaffoldSection } from 'components/layouts/Scaffold'
import { Button } from 'ui'
import { EmptyStatePresentational } from 'ui-patterns'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
import { BUCKET_TYPES } from './Storage.constants'
export const BucketsComingSoon = ({ type }: { type: 'analytics' | 'vector' }) => {
return (
- <ScaffoldSection isFullWidth>
- <EmptyStatePresentational
- icon={FolderClock}
- title="Coming soon"
- description={
- type === 'analytics'
- ? BUCKET_TYPES.analytics.valueProp
- : type === 'vector'
- ? BUCKET_TYPES.vectors.valueProp
- : undefined
- }
- >
- {type === 'analytics' && (
- <Button asChild type="default" icon={<ExternalLink />}>
- <Link
- target="_blank"
- rel="noopener noreferrer"
- href="https://forms.supabase.com/analytics-buckets"
- >
- Request access
- </Link>
- </Button>
- )}
- </EmptyStatePresentational>
- </ScaffoldSection>
+ <PageContainer>
+ <PageSection>
+ <PageSectionContent>
+ <EmptyStatePresentational
+ icon={FolderClock}
+ title="Coming soon"
+ description={
+ type === 'analytics'
+ ? BUCKET_TYPES.analytics.valueProp
+ : type === 'vector'
+ ? BUCKET_TYPES.vectors.valueProp
+ : undefined
+ }
+ >
+ {type === 'analytics' && (
+ <Button asChild type="default" icon={<ExternalLink />}>
+ <Link
+ target="_blank"
+ rel="noopener noreferrer"
+ href="https://forms.supabase.com/analytics-buckets"
+ >
+ Request access
+ </Link>
+ </Button>
+ )}
+ </EmptyStatePresentational>
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
)
}
diff --git a/apps/studio/components/interfaces/Storage/BucketsUpgradePlan.tsx b/apps/studio/components/interfaces/Storage/BucketsUpgradePlan.tsx
index 5867a855dc9..623d4faa10c 100644
--- a/apps/studio/components/interfaces/Storage/BucketsUpgradePlan.tsx
+++ b/apps/studio/components/interfaces/Storage/BucketsUpgradePlan.tsx
@@ -1,32 +1,39 @@
-import { ScaffoldSection } from 'components/layouts/Scaffold'
import { AlphaNotice } from 'components/ui/AlphaNotice'
import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { AnalyticsBucket as AnalyticsBucketIcon, VectorBucket as VectorBucketIcon } from 'icons'
import { EmptyStatePresentational } from 'ui-patterns'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
import { BUCKET_TYPES } from './Storage.constants'
export const BucketsUpgradePlan = ({ type }: { type: 'analytics' | 'vector' }) => {
return (
- <ScaffoldSection isFullWidth>
- <AlphaNotice
- entity={type === 'analytics' ? 'Analytics buckets' : 'Vector buckets'}
- feedbackUrl={
- type === 'analytics'
- ? 'https://github.com/orgs/supabase/discussions/40116'
- : 'https://github.com/orgs/supabase/discussions/40815'
- }
- />
- <EmptyStatePresentational
- icon={type === 'analytics' ? AnalyticsBucketIcon : VectorBucketIcon}
- title={
- type === 'analytics' ? BUCKET_TYPES.analytics.valueProp : BUCKET_TYPES.vectors.valueProp
- }
- description={`Upgrade to Pro to use ${type} buckets for your project`}
- >
- <div className="flex items-center gap-x-2">
- <UpgradePlanButton type="primary" plan="Pro" />
- </div>
- </EmptyStatePresentational>
- </ScaffoldSection>
+ <PageContainer>
+ <PageSection>
+ <PageSectionContent>
+ <AlphaNotice
+ entity={type === 'analytics' ? 'Analytics buckets' : 'Vector buckets'}
+ feedbackUrl={
+ type === 'analytics'
+ ? 'https://github.com/orgs/supabase/discussions/40116'
+ : 'https://github.com/orgs/supabase/discussions/40815'
+ }
+ />
+ <EmptyStatePresentational
+ icon={type === 'analytics' ? AnalyticsBucketIcon : VectorBucketIcon}
+ title={
+ type === 'analytics'
+ ? BUCKET_TYPES.analytics.valueProp
+ : BUCKET_TYPES.vectors.valueProp
+ }
+ description={`Upgrade to Pro to use ${type} buckets for your project`}
+ >
+ <div className="flex items-center gap-x-2">
+ <UpgradePlanButton type="primary" plan="Pro" />
+ </div>
+ </EmptyStatePresentational>
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
)
}
diff --git a/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsx b/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsx
index 4b70cbeccc8..c67793c2272 100644
--- a/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsx
+++ b/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsx
@@ -1,3 +1,4 @@
+import { useBucketPolicyCount } from 'components/interfaces/Storage/useBucketPolicyCount'
import {
VirtualizedTableCell,
VirtualizedTableHead,
@@ -73,7 +74,6 @@ type BucketTableRowProps = {
bucket: Bucket
projectRef: string
formattedGlobalUploadLimit: string
- getPolicyCount: (bucketName: string) => number
}
export const BucketTableRow = ({
@@ -81,13 +81,13 @@ export const BucketTableRow = ({
bucket,
projectRef,
formattedGlobalUploadLimit,
- getPolicyCount,
}: BucketTableRowProps) => {
+ const router = useRouter()
+ const { getPolicyCount } = useBucketPolicyCount()
+
const BucketTableRow = mode === 'standard' ? TableRow : VirtualizedTableRow
const BucketTableCell = mode === 'standard' ? TableCell : VirtualizedTableCell
- const router = useRouter()
-
const handleBucketNavigation = (
bucketId: string,
event: React.MouseEvent | React.KeyboardEvent
diff --git a/apps/studio/components/interfaces/Storage/FilesBuckets/BucketsTable.tsx b/apps/studio/components/interfaces/Storage/FilesBuckets/BucketsTable.tsx
index 7aedf7dd269..5dd406a8c85 100644
--- a/apps/studio/components/interfaces/Storage/FilesBuckets/BucketsTable.tsx
+++ b/apps/studio/components/interfaces/Storage/FilesBuckets/BucketsTable.tsx
@@ -8,7 +8,6 @@ type BucketsTableProps = {
projectRef: string
filterString: string
formattedGlobalUploadLimit: string
- getPolicyCount: (bucketName: string) => number
}
export const BucketsTable = (props: BucketsTableProps) => {
@@ -25,7 +24,6 @@ const BucketsTableUnvirtualized = ({
projectRef,
filterString,
formattedGlobalUploadLimit,
- getPolicyCount,
}: BucketsTableProps) => {
const showSearchEmptyState = buckets.length === 0 && filterString.length > 0
@@ -45,7 +43,6 @@ const BucketsTableUnvirtualized = ({
bucket={bucket}
projectRef={projectRef}
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
- getPolicyCount={getPolicyCount}
/>
))
)}
@@ -59,7 +56,6 @@ const BucketsTableVirtualized = ({
projectRef,
filterString,
formattedGlobalUploadLimit,
- getPolicyCount,
}: BucketsTableProps) => {
const showSearchEmptyState = buckets.length === 0 && filterString.length > 0
@@ -81,7 +77,6 @@ const BucketsTableVirtualized = ({
bucket={bucket}
projectRef={projectRef}
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
- getPolicyCount={getPolicyCount}
/>
)}
</VirtualizedTableBody>
diff --git a/apps/studio/components/interfaces/Storage/FilesBuckets/index.tsx b/apps/studio/components/interfaces/Storage/FilesBuckets/index.tsx
index 57f85cb3836..faa4c0c4ef3 100644
--- a/apps/studio/components/interfaces/Storage/FilesBuckets/index.tsx
+++ b/apps/studio/components/interfaces/Storage/FilesBuckets/index.tsx
@@ -2,13 +2,11 @@ import { ArrowDownNarrowWide, Search } from 'lucide-react'
import { useMemo, useState } from 'react'
import { useParams } from 'common'
-import { ScaffoldSection } from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import { InlineLink } from 'components/ui/InlineLink'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query'
import { useBucketsQuery } from 'data/storage/buckets-query'
-import { useStoragePolicyCounts } from 'hooks/storage/useStoragePolicyCounts'
import { IS_PLATFORM } from 'lib/constants'
import { formatBytes } from 'lib/helpers'
import { useStorageExplorerStateSnapshot } from 'state/storage-explorer'
@@ -23,6 +21,8 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
import { CreateBucketModal } from '../CreateBucketModal'
import { EmptyBucketState } from '../EmptyBucketState'
import { STORAGE_BUCKET_SORT } from '../Storage.constants'
@@ -41,11 +41,9 @@ export const FilesBuckets = () => {
isLoading: isLoadingBuckets,
isSuccess: isSuccessBuckets,
} = useBucketsQuery({ projectRef: ref })
- const { getPolicyCount, isLoading: isLoadingPolicies } = useStoragePolicyCounts(buckets)
const formattedGlobalUploadLimit = formatBytes(data?.fileSizeLimit ?? 0)
- const isLoading = isLoadingBuckets || isLoadingPolicies
const filesBuckets = buckets
.filter((bucket) => !('type' in bucket) || bucket.type === 'STANDARD')
.filter((bucket) =>
@@ -69,76 +67,81 @@ export const FilesBuckets = () => {
)
return (
- <ScaffoldSection isFullWidth className="h-full gap-y-4">
- {isLoading && <GenericSkeletonLoader />}
- {isErrorBuckets && (
- <>
- {hasNoApiKeys ? (
- <Admonition type="warning" title="Project has no active API keys enabled">
- <p className="!leading-normal text-sm">
- The Dashboard relies on having active API keys on the project to function. If you'd
- like to use Storage through the Dashboard, create a set of API keys{' '}
- <InlineLink href={`/project/${ref}/settings/api-keys/new`}>here</InlineLink>.
- </p>
- </Admonition>
- ) : (
- <AlertError error={bucketsError} subject="Failed to retrieve buckets" />
+ <PageContainer>
+ <PageSection>
+ <PageSectionContent className="h-full gap-y-4">
+ {isLoadingBuckets && <GenericSkeletonLoader />}
+ {isErrorBuckets && (
+ <>
+ {hasNoApiKeys ? (
+ <Admonition type="warning" title="Project has no active API keys enabled">
+ <p className="!leading-normal text-sm">
+ The Dashboard relies on having active API keys on the project to function. If
+ you'd like to use Storage through the Dashboard, create a set of API keys{' '}
+ <InlineLink href={`/project/${ref}/settings/api-keys/new`}>here</InlineLink>.
+ </p>
+ </Admonition>
+ ) : (
+ <AlertError error={bucketsError} subject="Failed to retrieve buckets" />
+ )}
+ </>
)}
- </>
- )}
- {isSuccessBuckets && (
- <>
- {hasNoBuckets ? (
- <EmptyBucketState bucketType="files" />
- ) : (
+ {isSuccessBuckets && (
<>
- <div className="flex flex-grow justify-between gap-x-2 items-center">
- <div className="flex items-center gap-x-2">
- <Input
- size="tiny"
- className="flex-grow lg:flex-grow-0 w-52"
- placeholder="Search for a bucket"
- value={filterString}
- onChange={(e) => setFilterString(e.target.value)}
- icon={<Search />}
- />
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button type="default" icon={<ArrowDownNarrowWide />}>
- Sorted by {snap.sortBucket === 'alphabetical' ? 'name' : 'created at'}
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="w-40">
- <DropdownMenuRadioGroup
- value={snap.sortBucket}
- onValueChange={(value) => snap.setSortBucket(value as STORAGE_BUCKET_SORT)}
- >
- <DropdownMenuRadioItem value="alphabetical">
- Sort by name
- </DropdownMenuRadioItem>
- <DropdownMenuRadioItem value="created_at">
- Sort by created at
- </DropdownMenuRadioItem>
- </DropdownMenuRadioGroup>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- <CreateBucketModal buttonType="primary" buttonClassName="w-fit" />
- </div>
+ {hasNoBuckets ? (
+ <EmptyBucketState bucketType="files" />
+ ) : (
+ <>
+ <div className="flex flex-grow justify-between gap-x-2 items-center mb-4">
+ <div className="flex items-center gap-x-2">
+ <Input
+ size="tiny"
+ className="flex-grow lg:flex-grow-0 w-52"
+ placeholder="Search for a bucket"
+ value={filterString}
+ onChange={(e) => setFilterString(e.target.value)}
+ icon={<Search />}
+ />
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button type="default" icon={<ArrowDownNarrowWide />}>
+ Sorted by {snap.sortBucket === 'alphabetical' ? 'name' : 'created at'}
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="w-40">
+ <DropdownMenuRadioGroup
+ value={snap.sortBucket}
+ onValueChange={(value) =>
+ snap.setSortBucket(value as STORAGE_BUCKET_SORT)
+ }
+ >
+ <DropdownMenuRadioItem value="alphabetical">
+ Sort by name
+ </DropdownMenuRadioItem>
+ <DropdownMenuRadioItem value="created_at">
+ Sort by created at
+ </DropdownMenuRadioItem>
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ <CreateBucketModal buttonType="primary" buttonClassName="w-fit" />
+ </div>
- <Card>
- <BucketsTable
- buckets={sortedFilesBuckets}
- projectRef={ref ?? '_'}
- filterString={filterString}
- formattedGlobalUploadLimit={formattedGlobalUploadLimit}
- getPolicyCount={getPolicyCount}
- />
- </Card>
+ <Card>
+ <BucketsTable
+ buckets={sortedFilesBuckets}
+ projectRef={ref ?? '_'}
+ filterString={filterString}
+ formattedGlobalUploadLimit={formattedGlobalUploadLimit}
+ />
+ </Card>
+ </>
+ )}
</>
)}
- </>
- )}
- </ScaffoldSection>
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
)
}
diff --git a/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePolicies.tsx b/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePolicies.tsx
index 0dacaf84bed..20c60845e26 100644
--- a/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePolicies.tsx
+++ b/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePolicies.tsx
@@ -7,11 +7,6 @@ import { useMemo, useState } from 'react'
import { toast } from 'sonner'
import PolicyEditorModal from 'components/interfaces/Auth/Policies/PolicyEditorModal'
-import {
- ScaffoldSection,
- ScaffoldSectionDescription,
- ScaffoldSectionTitle,
-} from 'components/layouts/Scaffold'
import { NoSearchResults } from 'components/ui/NoSearchResults'
import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
import { useDatabasePolicyCreateMutation } from 'data/database-policies/database-policy-create-mutation'
@@ -23,6 +18,15 @@ import { Button } from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import {
+ PageSection,
+ PageSectionContent,
+ PageSectionDescription,
+ PageSectionMeta,
+ PageSectionSummary,
+ PageSectionTitle,
+} from 'ui-patterns/PageSection'
import { formatPoliciesForStorage } from '../Storage.utils'
import { StoragePoliciesBucketRow } from './StoragePoliciesBucketRow'
import StoragePoliciesEditPolicyModal from './StoragePoliciesEditPolicyModal'
@@ -224,103 +228,119 @@ export const StoragePolicies = () => {
return (
<>
- {isLoading ? (
- <ScaffoldSection isFullWidth>
- <GenericSkeletonLoader />
- </ScaffoldSection>
- ) : (
- <div>
- <ScaffoldSection isFullWidth>
- <ScaffoldSectionTitle>Buckets</ScaffoldSectionTitle>
- <ScaffoldSectionDescription className="mb-6">
- Write policies for each bucket to control access to the bucket and its contents
- </ScaffoldSectionDescription>
- {buckets.length === 0 && <StoragePoliciesPlaceholder />}
-
- {buckets.length > 0 && (
- <div className="mb-4">
- <Input
- size="tiny"
- placeholder="Filter buckets"
- className="block"
- containerClassName="w-full lg:w-52"
- value={searchString || ''}
- onChange={(e) => {
- const str = e.target.value
- setSearchString(str)
- }}
- icon={<Search />}
- actions={
- searchString ? (
- <Button
- size="tiny"
- type="text"
- className="p-0 h-5 w-5"
- icon={<X />}
- onClick={() => setSearchString('')}
+ <PageContainer>
+ {isLoading ? (
+ <PageSection>
+ <PageSectionContent>
+ <GenericSkeletonLoader />
+ </PageSectionContent>
+ </PageSection>
+ ) : (
+ <div>
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Buckets</PageSectionTitle>
+ <PageSectionDescription>
+ Write policies for each bucket to control access to the bucket and its contents
+ </PageSectionDescription>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ {buckets.length === 0 && <StoragePoliciesPlaceholder />}
+
+ {buckets.length > 0 && (
+ <div className="mb-4">
+ <Input
+ size="tiny"
+ placeholder="Filter buckets"
+ className="block"
+ containerClassName="w-full lg:w-52"
+ value={searchString || ''}
+ onChange={(e) => {
+ const str = e.target.value
+ setSearchString(str)
+ }}
+ icon={<Search />}
+ actions={
+ searchString ? (
+ <Button
+ size="tiny"
+ type="text"
+ className="p-0 h-5 w-5"
+ icon={<X />}
+ onClick={() => setSearchString('')}
+ />
+ ) : null
+ }
+ />
+ </div>
+ )}
+
+ {searchString.length > 0 && filteredBucketsWithPolicies.length === 0 && (
+ <NoSearchResults
+ searchString={searchString}
+ onResetFilter={() => setSearchString('')}
+ />
+ )}
+
+ {/* Sections for policies grouped by buckets */}
+ <div className="flex flex-col gap-y-4">
+ {filteredBucketsWithPolicies.map(({ bucket, policies }) => {
+ return (
+ <StoragePoliciesBucketRow
+ key={bucket.name}
+ table="objects"
+ label={bucket.name}
+ bucket={bucket}
+ policies={policies}
+ onSelectPolicyAdd={onSelectPolicyAdd}
+ onSelectPolicyEdit={onSelectPolicyEdit}
+ onSelectPolicyDelete={onSelectPolicyDelete}
/>
- ) : null
- }
- />
- </div>
- )}
-
- {searchString.length > 0 && filteredBucketsWithPolicies.length === 0 && (
- <NoSearchResults
- searchString={searchString}
- onResetFilter={() => setSearchString('')}
- />
- )}
-
- {/* Sections for policies grouped by buckets */}
- <div className="flex flex-col gap-y-4">
- {filteredBucketsWithPolicies.map(({ bucket, policies }) => {
- return (
+ )
+ })}
+ </div>
+ </PageSectionContent>
+ </PageSection>
+
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Schema</PageSectionTitle>
+ <PageSectionDescription>
+ Write policies for the tables under the storage schema directly for greater
+ control
+ </PageSectionDescription>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ <div className="flex flex-col gap-y-4">
+ {/* Section for policies under storage.objects that are not tied to any buckets */}
<StoragePoliciesBucketRow
- key={bucket.name}
table="objects"
- label={bucket.name}
- bucket={bucket}
- policies={policies}
+ label="Other policies under storage.objects"
+ policies={ungroupedPolicies}
+ onSelectPolicyAdd={onSelectPolicyAdd}
+ onSelectPolicyEdit={onSelectPolicyEdit}
+ onSelectPolicyDelete={onSelectPolicyDelete}
+ />
+
+ {/* Section for policies under storage.buckets */}
+ <StoragePoliciesBucketRow
+ table="buckets"
+ label="Policies under storage.buckets"
+ policies={storageBucketPolicies}
onSelectPolicyAdd={onSelectPolicyAdd}
onSelectPolicyEdit={onSelectPolicyEdit}
onSelectPolicyDelete={onSelectPolicyDelete}
/>
- )
- })}
- </div>
- </ScaffoldSection>
-
- <ScaffoldSection isFullWidth>
- <ScaffoldSectionTitle>Schema</ScaffoldSectionTitle>
- <ScaffoldSectionDescription className="mb-6">
- Write policies for the tables under the storage schema directly for greater control
- </ScaffoldSectionDescription>
-
- <div className="flex flex-col gap-y-4">
- {/* Section for policies under storage.objects that are not tied to any buckets */}
- <StoragePoliciesBucketRow
- table="objects"
- label="Other policies under storage.objects"
- policies={ungroupedPolicies}
- onSelectPolicyAdd={onSelectPolicyAdd}
- onSelectPolicyEdit={onSelectPolicyEdit}
- onSelectPolicyDelete={onSelectPolicyDelete}
- />
-
- {/* Section for policies under storage.buckets */}
- <StoragePoliciesBucketRow
- table="buckets"
- label="Policies under storage.buckets"
- policies={storageBucketPolicies}
- onSelectPolicyAdd={onSelectPolicyAdd}
- onSelectPolicyEdit={onSelectPolicyEdit}
- onSelectPolicyDelete={onSelectPolicyDelete}
- />
- </div>
- </ScaffoldSection>
- </div>
- )}
+ </div>
+ </PageSectionContent>
+ </PageSection>
+ </div>
+ )}
+ </PageContainer>
{/* Only used for adding policies to buckets */}
<StoragePoliciesEditPolicyModal
diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx
index ebb010fe2bf..7582e3a531b 100644
--- a/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx
+++ b/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx
@@ -9,11 +9,6 @@ import * as z from 'zod'
import { useParams } from 'common'
import { useIsProjectActive } from 'components/layouts/ProjectLayout/ProjectContext'
-import {
- ScaffoldSection,
- ScaffoldSectionDescription,
- ScaffoldSectionTitle,
-} from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import { DocsButton } from 'components/ui/DocsButton'
import NoPermission from 'components/ui/NoPermission'
@@ -45,6 +40,16 @@ import {
} from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import {
+ PageSection,
+ PageSectionAside,
+ PageSectionContent,
+ PageSectionDescription,
+ PageSectionMeta,
+ PageSectionSummary,
+ PageSectionTitle,
+} from 'ui-patterns/PageSection'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
import { CreateCredentialModal } from './CreateCredentialModal'
import { RevokeCredentialModal } from './RevokeCredentialModal'
@@ -120,198 +125,210 @@ export const S3Connection = () => {
return (
<>
- <ScaffoldSection isFullWidth>
- <div className="flex items-end justify-between mb-6">
- <div>
- <ScaffoldSectionTitle>Connection</ScaffoldSectionTitle>
- <ScaffoldSectionDescription>
- Connect to your bucket using any S3-compatible service via the S3 protocol
- </ScaffoldSectionDescription>
- </div>
- <DocsButton href={`${DOCS_URL}/guides/storage/s3/authentication`} />
- </div>
+ <PageContainer>
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Connection</PageSectionTitle>
+ <PageSectionDescription>
+ Connect to your bucket using any S3-compatible service via the S3 protocol
+ </PageSectionDescription>
+ </PageSectionSummary>
+ <PageSectionAside>
+ <DocsButton href={`${DOCS_URL}/guides/storage/s3/authentication`} />
+ </PageSectionAside>
+ </PageSectionMeta>
- {isErrorStorageConfig && (
- <AlertError
- className="mb-4"
- subject="Failed to retrieve storage configuration"
- error={configError}
- />
- )}
+ <PageSectionContent>
+ {isErrorStorageConfig && (
+ <AlertError
+ className="mb-4"
+ subject="Failed to retrieve storage configuration"
+ error={configError}
+ />
+ )}
- <Form_Shadcn_ {...form}>
- <form id="s3-connection-form" onSubmit={form.handleSubmit(onSubmit)}>
- {projectIsLoading ? (
- <GenericSkeletonLoader />
- ) : isProjectActive ? (
- <Card>
- <CardContent className="pt-6">
- <FormField_Shadcn_
- name="s3ConnectionEnabled"
- control={form.control}
- render={({ field }) => (
- <FormItemLayout
- layout="horizontal"
- className="[&>*>label]:text-foreground"
- label="S3 protocol connection"
- description="Allow clients to connect to Supabase Storage via the S3 protocol"
- >
- <FormControl_Shadcn_>
- <Switch
- size="large"
- checked={field.value}
- onCheckedChange={field.onChange}
- disabled={!isSuccessStorageConfig || field.disabled}
+ <Form_Shadcn_ {...form}>
+ <form id="s3-connection-form" onSubmit={form.handleSubmit(onSubmit)}>
+ {projectIsLoading ? (
+ <GenericSkeletonLoader />
+ ) : isProjectActive ? (
+ <Card>
+ <CardContent className="pt-6">
+ <FormField_Shadcn_
+ name="s3ConnectionEnabled"
+ control={form.control}
+ render={({ field }) => (
+ <FormItemLayout
+ layout="horizontal"
+ className="[&>*>label]:text-foreground"
+ label="S3 protocol connection"
+ description="Allow clients to connect to Supabase Storage via the S3 protocol"
+ >
+ <FormControl_Shadcn_>
+ <Switch
+ size="large"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={!isSuccessStorageConfig || field.disabled}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </CardContent>
+
+ <CardContent className="py-6">
+ <div className="flex flex-col gap-y-4">
+ <FormItemLayout layout="horizontal" label="Endpoint" isReactForm={false}>
+ <Input readOnly copy value={s3connectionUrl} />
+ </FormItemLayout>
+ <FormItemLayout layout="horizontal" label="Region" isReactForm={false}>
+ <Input
+ readOnly
+ copy
+ value={project?.region}
+ data-1p-ignore
+ data-lpignore="true"
+ data-form-type="other"
+ data-bwignore
/>
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- </CardContent>
+ </FormItemLayout>
+ </div>
+ </CardContent>
- <CardContent className="py-6">
- <div className="flex flex-col gap-y-4">
- <FormItemLayout layout="horizontal" label="Endpoint" isReactForm={false}>
- <Input readOnly copy value={s3connectionUrl} />
- </FormItemLayout>
- {!projectIsLoading && (
- <FormItemLayout layout="horizontal" label="Region" isReactForm={false}>
- <Input
- readOnly
- copy
- value={project?.region}
- data-1p-ignore
- data-lpignore="true"
- data-form-type="other"
- data-bwignore
- />
- </FormItemLayout>
+ {!isLoadingPermissions && !canUpdateStorageSettings && (
+ <CardContent>
+ <p className="text-sm text-foreground-light">
+ You need additional permissions to update storage settings
+ </p>
+ </CardContent>
)}
- </div>
- </CardContent>
- {!isLoadingPermissions && !canUpdateStorageSettings && (
- <CardContent>
- <p className="text-sm text-foreground-light">
- You need additional permissions to update storage settings
- </p>
- </CardContent>
+ <CardFooter className="justify-end space-x-2">
+ {form.formState.isDirty && (
+ <Button
+ type="default"
+ htmlType="reset"
+ onClick={() => form.reset()}
+ disabled={
+ !form.formState.isDirty || !canUpdateStorageSettings || isUpdating
+ }
+ >
+ Cancel
+ </Button>
+ )}
+ <Button
+ type="primary"
+ htmlType="submit"
+ loading={isUpdating}
+ disabled={
+ !form.formState.isDirty || !canUpdateStorageSettings || isUpdating
+ }
+ >
+ Save
+ </Button>
+ </CardFooter>
+ </Card>
+ ) : (
+ <Alert_Shadcn_ variant="warning">
+ <WarningIcon />
+ <AlertTitle>Project is paused</AlertTitle>
+ <AlertDescription_Shadcn_>
+ To connect to your S3 bucket, you need to restore your project.
+ </AlertDescription_Shadcn_>
+ <div className="mt-3 flex items-center space-x-2">
+ <Button asChild type="default">
+ <Link href={`/project/${projectRef}`}>Restore project</Link>
+ </Button>
+ </div>
+ </Alert_Shadcn_>
)}
+ </form>
+ </Form_Shadcn_>
+ </PageSectionContent>
+ </PageSection>
- <CardFooter className="justify-end space-x-2">
- {form.formState.isDirty && (
- <Button
- type="default"
- htmlType="reset"
- onClick={() => form.reset()}
- disabled={!form.formState.isDirty || !canUpdateStorageSettings || isUpdating}
- >
- Cancel
- </Button>
- )}
- <Button
- type="primary"
- htmlType="submit"
- loading={isUpdating}
- disabled={!form.formState.isDirty || !canUpdateStorageSettings || isUpdating}
- >
- Save
- </Button>
- </CardFooter>
- </Card>
- ) : (
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Access keys</PageSectionTitle>
+ <PageSectionDescription>
+ Manage your access keys for this project
+ </PageSectionDescription>
+ </PageSectionSummary>
+ <PageSectionAside>
+ <CreateCredentialModal visible={openCreateCred} onOpenChange={setOpenCreateCred} />
+ </PageSectionAside>
+ </PageSectionMeta>
+
+ <PageSectionContent>
+ {projectIsLoading || isLoadingPermissions ? (
+ <GenericSkeletonLoader />
+ ) : !canReadS3Credentials ? (
+ <NoPermission resourceText="view this project's S3 access keys" />
+ ) : !isProjectActive ? (
<Alert_Shadcn_ variant="warning">
<WarningIcon />
- <AlertTitle>Project is paused</AlertTitle>
+ <AlertTitle>Can't fetch S3 access keys</AlertTitle>
<AlertDescription_Shadcn_>
- To connect to your S3 bucket, you need to restore your project.
+ To fetch your S3 access keys, you need to restore your project.
</AlertDescription_Shadcn_>
- <div className="mt-3 flex items-center space-x-2">
- <Button asChild type="default">
+ <AlertDescription_Shadcn_>
+ <Button asChild type="default" className="mt-3">
<Link href={`/project/${projectRef}`}>Restore project</Link>
</Button>
- </div>
+ </AlertDescription_Shadcn_>
</Alert_Shadcn_>
- )}
- </form>
- </Form_Shadcn_>
- </ScaffoldSection>
-
- <ScaffoldSection isFullWidth>
- <div className="flex items-end justify-between mb-6">
- <div>
- <ScaffoldSectionTitle>Access keys</ScaffoldSectionTitle>
- <ScaffoldSectionDescription>
- Manage your access keys for this project
- </ScaffoldSectionDescription>
- </div>
- <CreateCredentialModal visible={openCreateCred} onOpenChange={setOpenCreateCred} />
- </div>
-
- {projectIsLoading || isLoadingPermissions ? (
- <GenericSkeletonLoader />
- ) : !canReadS3Credentials ? (
- <NoPermission resourceText="view this project's S3 access keys" />
- ) : !isProjectActive ? (
- <Alert_Shadcn_ variant="warning">
- <WarningIcon />
- <AlertTitle>Can't fetch S3 access keys</AlertTitle>
- <AlertDescription_Shadcn_>
- To fetch your S3 access keys, you need to restore your project.
- </AlertDescription_Shadcn_>
- <AlertDescription_Shadcn_>
- <Button asChild type="default" className="mt-3">
- <Link href={`/project/${projectRef}`}>Restore project</Link>
- </Button>
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- ) : (
- <>
- {isLoadingStorageCreds ? (
- <GenericSkeletonLoader />
) : (
- <Card>
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead key="description">Name</TableHead>
- <TableHead key="access-key-id">Key ID</TableHead>
- <TableHead key="created-at">Created at</TableHead>
- <TableHead key="actions" />
- </TableRow>
- </TableHeader>
- <TableBody>
- {hasStorageCreds ? (
- storageCreds.data?.map((cred) => (
- <StorageCredItem
- key={cred.id}
- created_at={cred.created_at}
- access_key={cred.access_key}
- description={cred.description}
- id={cred.id}
- onDeleteClick={() => {
- setDeleteCred(cred)
- setOpenDeleteDialog(true)
- }}
- />
- ))
- ) : (
- <TableRow>
- <TableCell colSpan={4} className="!rounded-b-md overflow-hidden">
- <p className="text-sm text-foreground">No access keys created</p>
- <p className="text-sm text-foreground-light">
- There are no access keys associated with your project yet
- </p>
- </TableCell>
- </TableRow>
- )}
- </TableBody>
- </Table>
- </Card>
+ <>
+ {isLoadingStorageCreds ? (
+ <GenericSkeletonLoader />
+ ) : (
+ <Card>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead key="description">Name</TableHead>
+ <TableHead key="access-key-id">Key ID</TableHead>
+ <TableHead key="created-at">Created at</TableHead>
+ <TableHead key="actions" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {hasStorageCreds ? (
+ storageCreds.data?.map((cred) => (
+ <StorageCredItem
+ key={cred.id}
+ created_at={cred.created_at}
+ access_key={cred.access_key}
+ description={cred.description}
+ id={cred.id}
+ onDeleteClick={() => {
+ setDeleteCred(cred)
+ setOpenDeleteDialog(true)
+ }}
+ />
+ ))
+ ) : (
+ <TableRow>
+ <TableCell colSpan={4} className="!rounded-b-md overflow-hidden">
+ <p className="text-sm text-foreground">No access keys created</p>
+ <p className="text-sm text-foreground-light">
+ There are no access keys associated with your project yet
+ </p>
+ </TableCell>
+ </TableRow>
+ )}
+ </TableBody>
+ </Table>
+ </Card>
+ )}
+ </>
)}
- </>
- )}
- </ScaffoldSection>
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
<RevokeCredentialModal
visible={openDeleteDialog}
diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx
index 9e823f6d9d8..a7d7e281af1 100644
--- a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx
+++ b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx
@@ -7,7 +7,6 @@ import { toast } from 'sonner'
import * as z from 'zod'
import { useFlag, useParams } from 'common'
-import { ScaffoldSection } from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import { InlineLink } from 'components/ui/InlineLink'
import NoPermission from 'components/ui/NoPermission'
@@ -42,6 +41,8 @@ import {
TooltipTrigger,
} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
import {
StorageListV2MigratingCallout,
StorageListV2MigrationCallout,
@@ -218,249 +219,255 @@ export const StorageSettings = () => {
}, [isSuccess, config])
return (
- <ScaffoldSection isFullWidth>
- <Form_Shadcn_ {...form}>
- {isLoading || isLoadingPermissions ? (
- <GenericSkeletonLoader />
- ) : (
- <>
- {!canReadStorageSettings && (
- <NoPermission resourceText="view storage upload limit settings" />
- )}
- {isError && (
- <AlertError
- error={error}
- subject="Failed to retrieve project's storage configuration"
- />
- )}
- {isSuccess && showMigrationCallout && (
+ <PageContainer>
+ <PageSection>
+ <PageSectionContent>
+ <Form_Shadcn_ {...form}>
+ {isLoading || isLoadingPermissions ? (
+ <GenericSkeletonLoader />
+ ) : (
<>
- {isListV2UpgradeAvailable && <StorageListV2MigrationCallout />}
- {isListV2Upgrading && <StorageListV2MigratingCallout />}
- </>
- )}
- {isSuccess && (
- <form id={formId} className="" onSubmit={form.handleSubmit(onSubmit)}>
- <Card>
- <CardContent className="pt-6">
- <FormField_Shadcn_
- control={form.control}
- name="imageTransformationEnabled"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Enable image transformation"
- description={
- <>
- Optimize and resize images on the fly.{' '}
- <InlineLink
- href={`${DOCS_URL}/guides/storage/serving/image-transformations`}
+ {!canReadStorageSettings && (
+ <NoPermission resourceText="view storage upload limit settings" />
+ )}
+ {isError && (
+ <AlertError
+ error={error}
+ subject="Failed to retrieve project's storage configuration"
+ />
+ )}
+ {isSuccess && (
+ <>
+ {showMigrationCallout && (
+ <>
+ {isListV2UpgradeAvailable && <StorageListV2MigrationCallout />}
+ {isListV2Upgrading && <StorageListV2MigratingCallout />}
+ </>
+ )}
+ <form id={formId} className="" onSubmit={form.handleSubmit(onSubmit)}>
+ <Card>
+ <CardContent className="pt-6">
+ <FormField_Shadcn_
+ control={form.control}
+ name="imageTransformationEnabled"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Enable image transformation"
+ description={
+ <>
+ Optimize and resize images on the fly.{' '}
+ <InlineLink
+ href={`${DOCS_URL}/guides/storage/serving/image-transformations`}
+ >
+ Learn more
+ </InlineLink>
+ .
+ </>
+ }
>
- Learn more
- </InlineLink>
- .
- </>
- }
- >
- <FormControl_Shadcn_>
- <Switch
- size="large"
- disabled={isFreeTier}
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- </CardContent>
+ <FormControl_Shadcn_>
+ <Switch
+ size="large"
+ disabled={isFreeTier}
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </CardContent>
- <CardContent>
- <FormField_Shadcn_
- control={form.control}
- name="fileSizeLimit"
- render={({ field }) => (
- <FormItemLayout
- hideMessage
- layout="flex-row-reverse"
- label="Global file size limit"
- description={
- <>
- Restrict the size of files uploaded across all buckets.{' '}
- {isLoadingBuckets && (
- <span className="text-foreground-light">
- {' '}
- Loading bucket information...
- </span>
- )}{' '}
- <InlineLink href={`${DOCS_URL}/guides/storage/uploads/file-limits`}>
- Learn more
- </InlineLink>
- .
- </>
- }
- >
- <FormControl_Shadcn_>
- <div className="flex items-center gap-2">
- <Input_Shadcn_
- type="number"
- {...field}
- className="w-full"
- disabled={isFreeTier || !canUpdateStorageSettings}
- />
- <FormField_Shadcn_
- control={form.control}
- name="unit"
- render={({ field: unitField }) => (
- <Select_Shadcn_
- value={unitField.value}
- onValueChange={unitField.onChange}
- disabled={isFreeTier || !canUpdateStorageSettings}
- >
- <SelectTrigger_Shadcn_ className="w-[180px]">
- <SelectValue_Shadcn_ placeholder="Choose a prefix">
- {storageUnit}
- </SelectValue_Shadcn_>
- </SelectTrigger_Shadcn_>
- <SelectContent_Shadcn_>
- {Object.values(StorageSizeUnits).map((unit: string) => (
- <SelectItem_Shadcn_
- key={unit}
- disabled={isFreeTier}
- value={unit}
- >
- {unit}
- </SelectItem_Shadcn_>
- ))}
- </SelectContent_Shadcn_>
- </Select_Shadcn_>
- )}
- />
- </div>
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- {fileSizeLimitError && (
- <FormMessage_Shadcn_ className="ml-auto mt-2 text-right w-1/2">
- {isBucketLimitError ? (
- <>
- <p>Global limit must be greater than that of individual buckets.</p>
- <p>
- Remove or decrease the limit on{' '}
- <InlineLink
- href={`/project/${projectRef}/storage/buckets/${affectedBuckets[0]}`}
- className="text-destructive decoration-destructive-500 hover:decoration-destructive"
+ <CardContent>
+ <FormField_Shadcn_
+ control={form.control}
+ name="fileSizeLimit"
+ render={({ field }) => (
+ <FormItemLayout
+ hideMessage
+ layout="flex-row-reverse"
+ label="Global file size limit"
+ description={
+ <>
+ Restrict the size of files uploaded across all buckets.{' '}
+ <InlineLink
+ href={`${DOCS_URL}/guides/storage/uploads/file-limits`}
+ >
+ Learn more
+ </InlineLink>
+ .
+ </>
+ }
>
- {affectedBuckets[0]}
- </InlineLink>{' '}
- ({firstAffectBucketLimit.value}
- {firstAffectBucketLimit.unit})
- {affectedBuckets.length > 1 && (
- <>
- {' '}
- and{' '}
- <Tooltip>
- <TooltipTrigger asChild>
- <span className="underline underline-offset-2 decoration-dotted decoration-destructive-500 hover:decoration-destructive cursor-default">
- +{affectedBuckets.length - 1} other bucket
- {affectedBuckets.length > 2 ? 's' : ''}
- </span>
- </TooltipTrigger>
- <TooltipContent side="bottom">
- <ul>
- {affectedBuckets.slice(1).map((name) => {
- const bucket = buckets.find((x) => x.name === name)
- const formattedLimit = convertFromBytes(
- bucket?.file_size_limit ?? 0
- )
- return (
- <li
- key={name}
- className="hover:underline underline-offset-2"
- >
- <Link
- href={`/project/${projectRef}/storage/buckets/${name}`}
+ <FormControl_Shadcn_>
+ <div className="flex items-center gap-2">
+ <Input_Shadcn_
+ type="number"
+ {...field}
+ className="w-full"
+ disabled={isFreeTier || !canUpdateStorageSettings}
+ />
+ <FormField_Shadcn_
+ control={form.control}
+ name="unit"
+ render={({ field: unitField }) => (
+ <Select_Shadcn_
+ value={unitField.value}
+ onValueChange={unitField.onChange}
+ disabled={isFreeTier || !canUpdateStorageSettings}
+ >
+ <SelectTrigger_Shadcn_ className="w-[180px]">
+ <SelectValue_Shadcn_ placeholder="Choose a prefix">
+ {storageUnit}
+ </SelectValue_Shadcn_>
+ </SelectTrigger_Shadcn_>
+ <SelectContent_Shadcn_>
+ {Object.values(StorageSizeUnits).map((unit: string) => (
+ <SelectItem_Shadcn_
+ key={unit}
+ disabled={isFreeTier}
+ value={unit}
>
- {bucket?.name} ({formattedLimit.value}
- {formattedLimit.unit})
- </Link>
- </li>
- )
- })}
- </ul>
- </TooltipContent>
- </Tooltip>{' '}
- first
+ {unit}
+ </SelectItem_Shadcn_>
+ ))}
+ </SelectContent_Shadcn_>
+ </Select_Shadcn_>
+ )}
+ />
+ </div>
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ {fileSizeLimitError && (
+ <FormMessage_Shadcn_ className="ml-auto mt-2 text-right w-1/2">
+ {isBucketLimitError ? (
+ <>
+ <p>
+ Global limit must be greater than that of individual buckets.
+ </p>
+ <p>
+ Remove or decrease the limit on{' '}
+ <InlineLink
+ href={`/project/${projectRef}/storage/buckets/${affectedBuckets[0]}`}
+ className="text-destructive decoration-destructive-500 hover:decoration-destructive"
+ >
+ {affectedBuckets[0]}
+ </InlineLink>{' '}
+ ({firstAffectBucketLimit.value}
+ {firstAffectBucketLimit.unit})
+ {affectedBuckets.length > 1 && (
+ <>
+ {' '}
+ and{' '}
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="underline underline-offset-2 decoration-dotted decoration-destructive-500 hover:decoration-destructive cursor-default">
+ +{affectedBuckets.length - 1} other bucket
+ {affectedBuckets.length > 2 ? 's' : ''}
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ <ul>
+ {affectedBuckets.slice(1).map((name) => {
+ const bucket = buckets.find((x) => x.name === name)
+ const formattedLimit = convertFromBytes(
+ bucket?.file_size_limit ?? 0
+ )
+ return (
+ <li
+ key={name}
+ className="hover:underline underline-offset-2"
+ >
+ <Link
+ href={`/project/${projectRef}/storage/buckets/${name}`}
+ >
+ {bucket?.name} ({formattedLimit.value}
+ {formattedLimit.unit})
+ </Link>
+ </li>
+ )
+ })}
+ </ul>
+ </TooltipContent>
+ </Tooltip>{' '}
+ first
+ </>
+ )}
+ .
+ </p>
</>
+ ) : (
+ fileSizeLimitError.message
)}
- .
- </p>
- </>
- ) : (
- fileSizeLimitError.message
+ </FormMessage_Shadcn_>
+ )}
+ </CardContent>
+ {isFreeTier && (
+ <UpgradeToPro
+ fullWidth
+ primaryText="Free Plan has a fixed upload file size limit of 50 MB."
+ secondaryText={`Upgrade to Pro Plan for a configurable upload file size limit of ${formatBytes(
+ STORAGE_FILE_SIZE_LIMIT_MAX_BYTES_UNCAPPED
+ )} and unlock image transformations.`}
+ source="storageSizeLimit"
+ />
+ )}
+ {isSpendCapOn && (
+ <UpgradeToPro
+ fullWidth
+ buttonText="Disable Spend Cap"
+ primaryText="Reduced max upload file size limit due to Spend Cap"
+ secondaryText={`Disable your Spend Cap to allow file uploads of up to ${formatBytes(
+ STORAGE_FILE_SIZE_LIMIT_MAX_BYTES_UNCAPPED
+ )}.`}
+ source="storageSizeLimit"
+ />
)}
- </FormMessage_Shadcn_>
- )}
- </CardContent>
- {isFreeTier && (
- <UpgradeToPro
- fullWidth
- primaryText="Free Plan has a fixed upload file size limit of 50 MB."
- secondaryText={`Upgrade to Pro Plan for a configurable upload file size limit of ${formatBytes(
- STORAGE_FILE_SIZE_LIMIT_MAX_BYTES_UNCAPPED
- )} and unlock image transformations.`}
- source="storageSizeLimit"
- />
- )}
- {isSpendCapOn && (
- <UpgradeToPro
- fullWidth
- buttonText="Disable Spend Cap"
- primaryText="Reduced max upload file size limit due to Spend Cap"
- secondaryText={`Disable your Spend Cap to allow file uploads of up to ${formatBytes(
- STORAGE_FILE_SIZE_LIMIT_MAX_BYTES_UNCAPPED
- )}.`}
- source="storageSizeLimit"
- />
- )}
- {!canUpdateStorageSettings && (
- <CardContent>
- <p className="text-sm text-foreground-light">
- You need additional permissions to update storage settings
- </p>
- </CardContent>
- )}
+ {!canUpdateStorageSettings && (
+ <CardContent>
+ <p className="text-sm text-foreground-light">
+ You need additional permissions to update storage settings
+ </p>
+ </CardContent>
+ )}
- <CardFooter className="justify-end space-x-2">
- {form.formState.isDirty && (
- <Button
- type="default"
- htmlType="reset"
- onClick={() => form.reset()}
- disabled={
- !form.formState.isDirty || !canUpdateStorageSettings || isUpdating
- }
- >
- Cancel
- </Button>
- )}
- <Button
- type="primary"
- htmlType="submit"
- loading={isUpdating}
- disabled={!canUpdateStorageSettings || isUpdating || !form.formState.isDirty}
- >
- Save
- </Button>
- </CardFooter>
- </Card>
- </form>
+ <CardFooter className="justify-end space-x-2">
+ {form.formState.isDirty && (
+ <Button
+ type="default"
+ htmlType="reset"
+ onClick={() => form.reset()}
+ disabled={
+ !form.formState.isDirty || !canUpdateStorageSettings || isUpdating
+ }
+ >
+ Cancel
+ </Button>
+ )}
+ <Button
+ type="primary"
+ htmlType="submit"
+ loading={isUpdating}
+ disabled={
+ !canUpdateStorageSettings || isUpdating || !form.formState.isDirty
+ }
+ >
+ Save
+ </Button>
+ </CardFooter>
+ </Card>
+ </form>
+ </>
+ )}
+ </>
)}
- </>
- )}
- </Form_Shadcn_>
- </ScaffoldSection>
+ </Form_Shadcn_>
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
)
}
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/index.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/index.tsx
index 4eef95cd636..14e1fee38eb 100644
--- a/apps/studio/components/interfaces/Storage/VectorBuckets/index.tsx
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/index.tsx
@@ -4,7 +4,6 @@ import { parseAsBoolean, useQueryState } from 'nuqs'
import { useState, type KeyboardEvent, type MouseEvent } from 'react'
import { useParams } from 'common'
-import { ScaffoldHeader, ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import { AlphaNotice } from 'components/ui/AlphaNotice'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
@@ -13,6 +12,8 @@ import { VectorBucket as VectorBucketIcon } from 'icons'
import { BASE_PATH } from 'lib/constants'
import { Card, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import { PageSection, PageSectionContent, PageSectionTitle } from 'ui-patterns/PageSection'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'
import { EmptyBucketState } from '../EmptyBucketState'
import { CreateVectorBucketButton, CreateVectorBucketDialog } from './CreateVectorBucketDialog'
@@ -58,120 +59,124 @@ export const VectorsBuckets = () => {
}
return (
- <ScaffoldSection isFullWidth>
- <AlphaNotice
- entity="Vector buckets"
- feedbackUrl="https://github.com/orgs/supabase/discussions/40815"
- />
+ <PageContainer>
+ <PageSection>
+ <PageSectionContent>
+ <AlphaNotice
+ entity="Vector buckets"
+ feedbackUrl="https://github.com/orgs/supabase/discussions/40815"
+ />
- {isLoadingBuckets && <GenericSkeletonLoader />}
+ {isLoadingBuckets && <GenericSkeletonLoader />}
- {isErrorBuckets && (
- <AlertError error={bucketsError} subject="Failed to retrieve vector buckets" />
- )}
-
- {isSuccessBuckets && (
- <>
- {bucketsList.length === 0 ? (
- <EmptyBucketState bucketType="vectors" onCreateBucket={() => setVisible(true)} />
- ) : (
- <div className="flex flex-col gap-y-4">
- <ScaffoldHeader className="py-0">
- <ScaffoldSectionTitle>Buckets</ScaffoldSectionTitle>
- </ScaffoldHeader>
- <div className="flex flex-grow justify-between gap-x-2 items-center">
- <Input
- size="tiny"
- className="flex-grow lg:flex-grow-0 w-52"
- placeholder="Search for a bucket"
- value={filterString}
- onChange={(e) => setFilterString(e.target.value)}
- icon={<Search />}
- />
-
- <CreateVectorBucketButton onClick={() => setVisible(true)} />
- </div>
+ {isErrorBuckets && (
+ <AlertError error={bucketsError} subject="Failed to retrieve vector buckets" />
+ )}
- {isLoadingBuckets ? (
- <GenericSkeletonLoader />
+ {isSuccessBuckets && (
+ <>
+ {bucketsList.length === 0 ? (
+ <EmptyBucketState bucketType="vectors" onCreateBucket={() => setVisible(true)} />
) : (
- <Card>
- <Table>
- <TableHeader>
- <TableRow>
- {filteredBuckets.length > 0 && (
- <TableHead className="w-2 pr-1">
- <span className="sr-only">Icon</span>
- </TableHead>
- )}
- <TableHead>Name</TableHead>
- <TableHead>Created at</TableHead>
- <TableHead>
- <span className="sr-only">Actions</span>
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {filteredBuckets.length === 0 && filterString.length > 0 && (
- <TableRow className="[&>td]:hover:bg-inherit">
- <TableCell colSpan={3}>
- <p className="text-sm text-foreground">No results found</p>
- <p className="text-sm text-foreground-lighter">
- Your search for "{filterString}" did not return any results
- </p>
- </TableCell>
- </TableRow>
- )}
- {filteredBuckets.map((bucket, idx: number) => {
- const id = `bucket-${idx}`
- const name = bucket.vectorBucketName
- // the creation time is in seconds, convert it to milliseconds
- const created = +bucket.creationTime * 1000
+ <div className="flex flex-col gap-y-4">
+ <div className="py-0">
+ <PageSectionTitle>Buckets</PageSectionTitle>
+ </div>
+ <div className="flex flex-grow justify-between gap-x-2 items-center">
+ <Input
+ size="tiny"
+ className="flex-grow lg:flex-grow-0 w-52"
+ placeholder="Search for a bucket"
+ value={filterString}
+ onChange={(e) => setFilterString(e.target.value)}
+ icon={<Search />}
+ />
- return (
- <TableRow
- key={id}
- className="relative cursor-pointer h-16 inset-focus"
- onClick={(event) => handleBucketNavigation(name, event)}
- onKeyDown={(event) => {
- if (event.key === 'Enter' || event.key === ' ') {
- event.preventDefault()
- handleBucketNavigation(name, event)
- }
- }}
- tabIndex={0}
- >
- <TableCell className="w-2 pr-1">
- <VectorBucketIcon size={16} className="text-foreground-muted" />
- </TableCell>
- <TableCell>
- <p className="whitespace-nowrap max-w-[512px] truncate">{name}</p>
- </TableCell>
- <TableCell>
- <p className="text-foreground-light">
- <TimestampInfo
- utcTimestamp={created}
- className="text-sm text-foreground-light"
- />
- </p>
- </TableCell>
- <TableCell>
- <div className="flex justify-end items-center h-full">
- <ChevronRight size={14} className="text-foreground-muted/60" />
- </div>
- </TableCell>
+ <CreateVectorBucketButton onClick={() => setVisible(true)} />
+ </div>
+
+ {isLoadingBuckets ? (
+ <GenericSkeletonLoader />
+ ) : (
+ <Card>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ {filteredBuckets.length > 0 && (
+ <TableHead className="w-2 pr-1">
+ <span className="sr-only">Icon</span>
+ </TableHead>
+ )}
+ <TableHead>Name</TableHead>
+ <TableHead>Created at</TableHead>
+ <TableHead>
+ <span className="sr-only">Actions</span>
+ </TableHead>
</TableRow>
- )
- })}
- </TableBody>
- </Table>
- </Card>
+ </TableHeader>
+ <TableBody>
+ {filteredBuckets.length === 0 && filterString.length > 0 && (
+ <TableRow className="[&>td]:hover:bg-inherit">
+ <TableCell colSpan={3}>
+ <p className="text-sm text-foreground">No results found</p>
+ <p className="text-sm text-foreground-lighter">
+ Your search for "{filterString}" did not return any results
+ </p>
+ </TableCell>
+ </TableRow>
+ )}
+ {filteredBuckets.map((bucket, idx: number) => {
+ const id = `bucket-${idx}`
+ const name = bucket.vectorBucketName
+ // the creation time is in seconds, convert it to milliseconds
+ const created = +bucket.creationTime * 1000
+
+ return (
+ <TableRow
+ key={id}
+ className="relative cursor-pointer h-16 inset-focus"
+ onClick={(event) => handleBucketNavigation(name, event)}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault()
+ handleBucketNavigation(name, event)
+ }
+ }}
+ tabIndex={0}
+ >
+ <TableCell className="w-2 pr-1">
+ <VectorBucketIcon size={16} className="text-foreground-muted" />
+ </TableCell>
+ <TableCell>
+ <p className="whitespace-nowrap max-w-[512px] truncate">{name}</p>
+ </TableCell>
+ <TableCell>
+ <p className="text-foreground-light">
+ <TimestampInfo
+ utcTimestamp={created}
+ className="text-sm text-foreground-light"
+ />
+ </p>
+ </TableCell>
+ <TableCell>
+ <div className="flex justify-end items-center h-full">
+ <ChevronRight size={14} className="text-foreground-muted/60" />
+ </div>
+ </TableCell>
+ </TableRow>
+ )
+ })}
+ </TableBody>
+ </Table>
+ </Card>
+ )}
+ </div>
)}
- </div>
+ </>
)}
- </>
- )}
- <CreateVectorBucketDialog visible={visible} setVisible={setVisible} />
- </ScaffoldSection>
+ <CreateVectorBucketDialog visible={visible} setVisible={setVisible} />
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
)
}
diff --git a/apps/studio/components/interfaces/Storage/useBucketPolicyCount.ts b/apps/studio/components/interfaces/Storage/useBucketPolicyCount.ts
new file mode 100644
index 00000000000..8b307702236
--- /dev/null
+++ b/apps/studio/components/interfaces/Storage/useBucketPolicyCount.ts
@@ -0,0 +1,24 @@
+import { formatPoliciesForStorage } from 'components/interfaces/Storage/Storage.utils'
+import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
+import { useBucketsQuery } from 'data/storage/buckets-query'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+
+export const useBucketPolicyCount = () => {
+ const { data: project, isLoading: isLoadingProject } = useSelectedProjectQuery()
+ const { data: buckets = [], isLoading: isLoadingBuckets } = useBucketsQuery({
+ projectRef: project?.ref,
+ })
+ const { data: policiesData = [], isLoading: isLoadingPolicies } = useDatabasePoliciesQuery({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ schema: 'storage',
+ })
+ const storageObjectsPolicies = policiesData.filter((policy: any) => policy.table === 'objects')
+ const formattedPolicies = formatPoliciesForStorage(buckets, storageObjectsPolicies)
+
+ const getPolicyCount = (bucketName: string) => {
+ return formattedPolicies.find((x) => x.name === bucketName)?.policies.length ?? 0
+ }
+
+ return { getPolicyCount, isLoading: isLoadingProject || isLoadingBuckets || isLoadingPolicies }
+}
diff --git a/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx b/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx
index 4b284c6f4f5..220fc248acb 100644
--- a/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx
+++ b/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx
@@ -37,8 +37,8 @@ import {
PageHeader,
PageHeaderAside,
PageHeaderBreadcrumb,
- PageHeaderFooter,
PageHeaderMeta,
+ PageHeaderNavigationTabs,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
@@ -269,7 +269,7 @@ const EdgeFunctionDetailsLayout = ({
</PageHeaderMeta>
{navigationItems.length > 0 && (
- <PageHeaderFooter>
+ <PageHeaderNavigationTabs>
<NavMenu>
{navigationItems.map((item) => {
const isActive = router.asPath.split('?')[0] === item.href
@@ -280,7 +280,7 @@ const EdgeFunctionDetailsLayout = ({
)
})}
</NavMenu>
- </PageHeaderFooter>
+ </PageHeaderNavigationTabs>
)}
</PageHeader>
diff --git a/apps/studio/components/layouts/StorageLayout/StorageBucketsLayout.tsx b/apps/studio/components/layouts/StorageLayout/StorageBucketsLayout.tsx
index 3398ffa7e50..fdbba10cd53 100644
--- a/apps/studio/components/layouts/StorageLayout/StorageBucketsLayout.tsx
+++ b/apps/studio/components/layouts/StorageLayout/StorageBucketsLayout.tsx
@@ -1,11 +1,21 @@
+import Link from 'next/link'
import { PropsWithChildren } from 'react'
import { useParams } from 'common'
import { BUCKET_TYPES } from 'components/interfaces/Storage/Storage.constants'
import { useStorageV2Page } from 'components/interfaces/Storage/Storage.utils'
import { DocsButton } from 'components/ui/DocsButton'
-import { PageLayout } from '../PageLayout/PageLayout'
-import { ScaffoldContainer } from '../Scaffold'
+import { usePathname } from 'next/navigation'
+import { NavMenu, NavMenuItem } from 'ui'
+import {
+ PageHeader,
+ PageHeaderAside,
+ PageHeaderDescription,
+ PageHeaderMeta,
+ PageHeaderNavigationTabs,
+ PageHeaderSummary,
+ PageHeaderTitle,
+} from 'ui-patterns/PageHeader'
export const StorageBucketsLayout = ({
title,
@@ -13,6 +23,7 @@ export const StorageBucketsLayout = ({
children,
}: PropsWithChildren<{ title?: string; hideSubtitle?: boolean }>) => {
const { ref } = useParams()
+ const pathname = usePathname()
const page = useStorageV2Page()
const config = !!page && page !== 's3' ? BUCKET_TYPES[page] : undefined
@@ -35,15 +46,36 @@ export const StorageBucketsLayout = ({
: []
return (
- <PageLayout
- title={title || (config?.displayName ?? 'Storage')}
- subtitle={
- !hideSubtitle ? config?.description || 'Manage your storage buckets and files.' : null
- }
- navigationItems={navigationItems}
- secondaryActions={config?.docsUrl ? [<DocsButton key="docs" href={config.docsUrl} />] : []}
- >
- <ScaffoldContainer className="min-h-0">{children}</ScaffoldContainer>
- </PageLayout>
+ <>
+ <PageHeader>
+ <PageHeaderMeta>
+ <PageHeaderSummary>
+ <PageHeaderTitle>{title || (config?.displayName ?? 'Storage')}</PageHeaderTitle>
+ {!hideSubtitle && (
+ <PageHeaderDescription>
+ {config?.description || 'Manage your storage buckets and files.'}
+ </PageHeaderDescription>
+ )}
+ </PageHeaderSummary>
+
+ <PageHeaderAside>
+ {config?.docsUrl && <DocsButton key="docs" href={config.docsUrl} />}
+ </PageHeaderAside>
+ </PageHeaderMeta>
+
+ {navigationItems.length > 0 && (
+ <PageHeaderNavigationTabs>
+ <NavMenu>
+ {navigationItems.map((item) => (
+ <NavMenuItem key={item.label} active={pathname === item.href}>
+ <Link href={item.href}>{item.label}</Link>
+ </NavMenuItem>
+ ))}
+ </NavMenu>
+ </PageHeaderNavigationTabs>
+ )}
+ </PageHeader>
+ {children}
+ </>
)
}
diff --git a/apps/studio/hooks/storage/useStoragePolicyCounts.ts b/apps/studio/hooks/storage/useStoragePolicyCounts.ts
deleted file mode 100644
index 7ac72fd3ce7..00000000000
--- a/apps/studio/hooks/storage/useStoragePolicyCounts.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { useMemo } from 'react'
-
-import { formatPoliciesForStorage } from 'components/interfaces/Storage/Storage.utils'
-import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
-import { Bucket } from 'data/storage/buckets-query'
-import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
-
-export const useStoragePolicyCounts = (buckets: Bucket[]) => {
- const { data: project } = useSelectedProjectQuery()
- const { data: policiesData = [], isLoading } = useDatabasePoliciesQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- schema: 'storage',
- })
-
- const policyCountMap = useMemo(() => {
- const storageObjectsPolicies = policiesData.filter((policy: any) => policy.table === 'objects')
- const formattedPolicies = formatPoliciesForStorage(buckets, storageObjectsPolicies)
-
- return formattedPolicies.reduce((acc: Record<string, number>, bucketGroup: any) => {
- acc[bucketGroup.name] = bucketGroup.policies.length
- return acc
- }, {})
- }, [buckets, policiesData])
-
- const getPolicyCount = (bucketName: string) => {
- return policyCountMap[bucketName] || 0
- }
-
- return {
- getPolicyCount,
- isLoading,
- policyCountMap,
- }
-}
diff --git a/apps/studio/pages/project/[ref]/database/backups/pitr.tsx b/apps/studio/pages/project/[ref]/database/backups/pitr.tsx
index 083f015b1d9..290c9888c55 100644
--- a/apps/studio/pages/project/[ref]/database/backups/pitr.tsx
+++ b/apps/studio/pages/project/[ref]/database/backups/pitr.tsx
@@ -23,8 +23,8 @@ import { Admonition } from 'ui-patterns'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageHeader,
- PageHeaderFooter,
PageHeaderMeta,
+ PageHeaderNavigationTabs,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
@@ -39,9 +39,9 @@ const DatabasePhysicalBackups: NextPageWithLayout = () => {
<PageHeaderTitle>Database Backups</PageHeaderTitle>
</PageHeaderSummary>
</PageHeaderMeta>
- <PageHeaderFooter>
+ <PageHeaderNavigationTabs>
<DatabaseBackupsNav active="pitr" />
- </PageHeaderFooter>
+ </PageHeaderNavigationTabs>
</PageHeader>
<PageContainer>
<PageSection>
diff --git a/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx b/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx
index 1ec601b1fac..afa77cc8358 100644
--- a/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx
+++ b/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx
@@ -9,8 +9,8 @@ import type { NextPageWithLayout } from 'types'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageHeader,
- PageHeaderFooter,
PageHeaderMeta,
+ PageHeaderNavigationTabs,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
@@ -32,9 +32,9 @@ const RestoreToNewProjectPage: NextPageWithLayout = () => {
<PageHeaderTitle>Database Backups</PageHeaderTitle>
</PageHeaderSummary>
</PageHeaderMeta>
- <PageHeaderFooter>
+ <PageHeaderNavigationTabs>
<DatabaseBackupsNav active="rtnp" />
- </PageHeaderFooter>
+ </PageHeaderNavigationTabs>
</PageHeader>
<PageContainer>
<PageSection>
diff --git a/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx b/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx
index c69c782708b..8187988a18c 100644
--- a/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx
+++ b/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx
@@ -20,8 +20,8 @@ import { Admonition } from 'ui-patterns'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageHeader,
- PageHeaderFooter,
PageHeaderMeta,
+ PageHeaderNavigationTabs,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
@@ -48,9 +48,9 @@ const DatabaseScheduledBackups: NextPageWithLayout = () => {
<PageHeaderTitle>Database Backups</PageHeaderTitle>
</PageHeaderSummary>
</PageHeaderMeta>
- <PageHeaderFooter>
+ <PageHeaderNavigationTabs>
<DatabaseBackupsNav active="scheduled" />
- </PageHeaderFooter>
+ </PageHeaderNavigationTabs>
</PageHeader>
<PageContainer>
<PageSection>
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 0d1574e33f1..67a18147eec 100644
--- a/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx
+++ b/apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx
@@ -12,11 +12,10 @@ import { EmptyBucketModal } from 'components/interfaces/Storage/EmptyBucketModal
import { useSelectedBucket } from 'components/interfaces/Storage/FilesBuckets/useSelectedBucket'
import StorageBucketsError from 'components/interfaces/Storage/StorageBucketsError'
import { StorageExplorer } from 'components/interfaces/Storage/StorageExplorer/StorageExplorer'
+import { useBucketPolicyCount } from 'components/interfaces/Storage/useBucketPolicyCount'
import DefaultLayout from 'components/layouts/DefaultLayout'
import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
import StorageLayout from 'components/layouts/StorageLayout/StorageLayout'
-import { Bucket } from 'data/storage/buckets-query'
-import { useStoragePolicyCounts } from 'hooks/storage/useStoragePolicyCounts'
import type { NextPageWithLayout } from 'types'
import {
Badge,
@@ -46,7 +45,7 @@ const BucketPage: NextPageWithLayout = () => {
parseAsBoolean.withDefault(false).withOptions({ history: 'push', clearOnDefault: true })
)
- const { getPolicyCount } = useStoragePolicyCounts(bucket ? [bucket as Bucket] : [])
+ const { getPolicyCount } = useBucketPolicyCount()
const policyCount = bucket ? getPolicyCount(bucket.id) : 0
useEffect(() => {
diff --git a/packages/ui-patterns/src/PageHeader/index.tsx b/packages/ui-patterns/src/PageHeader/index.tsx
index 1170a5c9f52..30476b72c8e 100644
--- a/packages/ui-patterns/src/PageHeader/index.tsx
+++ b/packages/ui-patterns/src/PageHeader/index.tsx
@@ -187,7 +187,7 @@ export type PageHeaderMetaProps = React.ComponentProps<'div'>
/**
* Meta wrapper for page header.
* Contains icon, summary, and aside components with proper layout.
- * Should be placed after PageHeaderBreadcrumb (if present) and before PageHeaderFooter.
+ * Should be placed after PageHeaderBreadcrumb (if present) and before PageHeaderNavigationTabs.
* Uses CSS to style children based on their data-slot attributes.
*/
const PageHeaderMeta = ({ className, children, ...props }: PageHeaderMetaProps) => {
@@ -237,14 +237,14 @@ PageHeaderAside.displayName = 'PageHeaderAside'
// Navigation
// ============================================================================
-export type PageHeaderFooterProps = React.ComponentProps<'div'>
+export type PageHeaderNavigationTabsProps = React.ComponentProps<'div'>
/**
* Navigation component for page header.
* Container for tab navigation (NavMenu).
* Should be placed as the last child of PageHeader.
*/
-const PageHeaderFooter = ({ className, ...props }: PageHeaderFooterProps) => {
+const PageHeaderNavigationTabs = ({ className, ...props }: PageHeaderNavigationTabsProps) => {
const { size } = usePageHeaderContext()
return (
<PageContainer size={size} className={cn(size === 'full' && 'border-b')}>
@@ -256,7 +256,7 @@ const PageHeaderFooter = ({ className, ...props }: PageHeaderFooterProps) => {
</PageContainer>
)
}
-PageHeaderFooter.displayName = 'PageHeaderFooter'
+PageHeaderNavigationTabs.displayName = 'PageHeaderNavigationTabs'
// ============================================================================
// Exports
@@ -273,9 +273,9 @@ export {
PageHeaderAside,
PageHeaderBreadcrumb,
PageHeaderDescription,
- PageHeaderFooter,
PageHeaderIcon,
PageHeaderMeta,
+ PageHeaderNavigationTabs,
PageHeaderSummary,
PageHeaderTitle,
}