Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/docs/content/guides/auth/server-side/nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,12 @@ export async function updateSession(request: NextRequest) {
}
)

// IMPORTANT: Avoid writing any logic between createServerClient and
// Do not run code between createServerClient and
// supabase.auth.getUser(). A simple mistake could make it very hard to debug
// issues with users being randomly logged out.

// IMPORTANT: DO NOT REMOVE auth.getUser()

const {
data: { user },
} = await supabase.auth.getUser()
Expand All @@ -266,8 +268,8 @@ export async function updateSession(request: NextRequest) {
return NextResponse.redirect(url)
}

// IMPORTANT: You *must* return the supabaseResponse object as it is. If you're
// creating a new response object with NextResponse.next() make sure to:
// IMPORTANT: You *must* return the supabaseResponse object as it is.
// If you're creating a new response object with NextResponse.next() make sure to:
// 1. Pass the request in it, like so:
// const myNewResponse = NextResponse.next({ request })
// 2. Copy over the cookies, like so:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,33 @@ const DiskUsage = ({
}
)

const relevantProjects = useMemo(() => {
return diskUsage
? diskUsage.projects
.filter((project) => {
// We do want to show branches that are exceeding the 8 GB limit, as people could have persistent or very long-living branches
const isBranchExceedingFreeQuota =
project.is_branch && project.databases.some((db) => (db.disk_volume_size_gb ?? 8) > 8)

const isActiveProject = project.status !== PROJECT_STATUS.INACTIVE

const isHostedOnAws = project.databases.every((db) => db.cloud_provider === 'AWS')

return (
(!project.is_branch || isBranchExceedingFreeQuota) && isActiveProject && isHostedOnAws
)
})
.filter((it) => it.ref === projectRef || !projectRef)
: []
}, [diskUsage, projectRef])

const hasProjectsExceedingDiskSize = useMemo(() => {
if (diskUsage) {
return diskUsage.projects.some((it) =>
it.databases.some(
(db) =>
db.type === 'READ_REPLICA' || (db.disk_volume_size_gb && db.disk_volume_size_gb > 8)
)
return relevantProjects.some((it) =>
it.databases.some(
(db) => db.type === 'READ_REPLICA' || (db.disk_volume_size_gb && db.disk_volume_size_gb > 8)
)
} else {
return false
}
}, [diskUsage])
)
}, [relevantProjects])

const gp3UsageInPeriod = usage?.usages.find(
(it) => it.metric === PricingMetric.DISK_SIZE_GB_HOURS_GP3
Expand All @@ -73,14 +88,6 @@ const DiskUsage = ({
(it) => it.metric === PricingMetric.DISK_SIZE_GB_HOURS_IO2
)

const relevantProjects = useMemo(() => {
return diskUsage
? diskUsage.projects
.filter((it) => !it.is_branch && it.status !== PROJECT_STATUS.INACTIVE)
.filter((it) => it.ref === projectRef || !projectRef)
: []
}, [diskUsage, projectRef])

return (
<div id={attribute.anchor} className="scroll-my-12">
<SectionContent section={attribute}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,135 +102,129 @@ const DatabaseSettings = () => {
}, [primaryConfig?.pool_mode])

return (
<>
<section id="direct-connection">
<Panel
className="!m-0"
title={
<div className="w-full flex items-center justify-between">
<div className="flex items-center gap-x-2">
<h5 className="mb-0">Connection parameters</h5>
</div>
<DatabaseSelector />
<section id="direct-connection">
<Panel
className="!m-0"
title={
<div className="w-full flex items-center justify-between">
<div className="flex items-center gap-x-2">
<h5 className="mb-0">Connection parameters</h5>
</div>
}
>
<Panel.Content className="space-y-6">
{isLoading &&
Array.from({ length: 5 }).map((_, i) => (
<div
key={i}
className="grid gap-2 items-center md:grid md:grid-cols-12 md:gap-x-4 w-full"
>
<ShimmeringLoader className="h-4 w-1/3 col-span-4" delayIndex={i} />
<ShimmeringLoader className="h-8 w-full col-span-8" delayIndex={i} />
</div>
))}
{isError && <AlertError error={error} subject="Failed to retrieve databases" />}
{isSuccess && (
<>
<div className="space-y-4">
<UsePoolerCheckbox
id="connection-params"
checked={snap.usePoolerConnection}
ipv4AddonAdded={!!ipv4Addon}
poolingMode={poolingMode}
onCheckedChange={snap.setUsePoolerConnection}
onSelectPoolingMode={setPoolingMode}
/>
{defaultPoolingMode === 'session' && poolingMode === 'transaction' && (
<DefaultSessionModeNotice />
)}
{ipv4Addon !== undefined &&
poolingMode === 'session' &&
snap.usePoolerConnection && <IPv4AddonDirectConnectionNotice />}
{ipv4Addon === undefined && !snap.usePoolerConnection && (
<IPv4DeprecationNotice />
)}
{isMd5 && (
<Alert_Shadcn_>
<WarningIcon />
<AlertTitle_Shadcn_>
If you are connecting to your database via a GUI client, use the{' '}
<span tabIndex={0}>connection string</span> above instead
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
GUI clients only support database connections for Postgres 13 via a
connection string.
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
</div>
<Input
className="input-mono"
layout="horizontal"
readOnly
copy
disabled
value={connectionInfo.db_host}
label="Host"
onCopy={() => {
handleCopy('Host')
}}
/>
<Input
className="input-mono"
layout="horizontal"
readOnly
copy
disabled
value={connectionInfo.db_name}
label="Database name"
/>
<Input
className="input-mono"
layout="horizontal"
readOnly
copy
disabled
value={poolingMode === 'transaction' ? connectionInfo.db_port : '5432'}
label="Port"
<DatabaseSelector />
</div>
}
>
<Panel.Content className="space-y-6">
{isLoading &&
Array.from({ length: 5 }).map((_, i) => (
<div
key={i}
className="grid gap-2 items-center md:grid md:grid-cols-12 md:gap-x-4 w-full"
>
<ShimmeringLoader className="h-4 w-1/3 col-span-4" delayIndex={i} />
<ShimmeringLoader className="h-8 w-full col-span-8" delayIndex={i} />
</div>
))}
{isError && <AlertError error={error} subject="Failed to retrieve databases" />}
{isSuccess && (
<>
<div className="space-y-4">
<UsePoolerCheckbox
id="connection-params"
checked={snap.usePoolerConnection}
ipv4AddonAdded={!!ipv4Addon}
poolingMode={poolingMode}
onCheckedChange={snap.setUsePoolerConnection}
onSelectPoolingMode={setPoolingMode}
/>
{isMd5 && snap.usePoolerConnection && (
<Input
className="input-mono"
layout="horizontal"
readOnly
copy
disabled
value={`reference=${projectRef}`}
label="Options"
/>
{defaultPoolingMode === 'session' && poolingMode === 'transaction' && (
<DefaultSessionModeNotice />
)}
{ipv4Addon !== undefined &&
poolingMode === 'session' &&
snap.usePoolerConnection && <IPv4AddonDirectConnectionNotice />}
{ipv4Addon === undefined && !snap.usePoolerConnection && <IPv4DeprecationNotice />}
{isMd5 && (
<Alert_Shadcn_>
<WarningIcon />
<AlertTitle_Shadcn_>
If you are connecting to your database via a GUI client, use the{' '}
<span tabIndex={0}>connection string</span> above instead
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
GUI clients only support database connections for Postgres 13 via a connection
string.
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
</div>
<Input
className="input-mono"
layout="horizontal"
readOnly
copy
disabled
value={connectionInfo.db_host}
label="Host"
onCopy={() => {
handleCopy('Host')
}}
/>
<Input
className="input-mono"
layout="horizontal"
readOnly
copy
disabled
value={connectionInfo.db_name}
label="Database name"
/>
<Input
className="input-mono"
layout="horizontal"
readOnly
copy
disabled
value={poolingMode === 'transaction' ? connectionInfo.db_port : '5432'}
label="Port"
/>
{isMd5 && snap.usePoolerConnection && (
<Input
className="input-mono"
layout="horizontal"
className="input-mono table-input-cell text-base"
readOnly
copy
disabled
value={connectionInfo.db_user}
label="User"
/>
<Input
className="input-mono"
layout="horizontal"
disabled
readOnly
value={
state.selectedDatabaseId !== projectRef
? '[The password for your primary database]'
: '[The password for your database]'
}
label="Password"
value={`reference=${projectRef}`}
label="Options"
/>
</>
)}
</Panel.Content>
</Panel>
</section>

<ResetDbPassword disabled={isLoading || isError} />
</>
)}
<Input
layout="horizontal"
className="input-mono table-input-cell text-base"
readOnly
copy
disabled
value={connectionInfo.db_user}
label="User"
/>
<Input
className="input-mono"
layout="horizontal"
disabled
readOnly
value={
state.selectedDatabaseId !== projectRef
? '[The password for your primary database]'
: '[The password for your database]'
}
label="Password"
/>
</>
)}
</Panel.Content>
</Panel>
</section>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ const LayoutHeader = ({ customHeaderComponents, breadcrumbs = [], headerBorder =
</div>

<div className="ml-3 flex items-center gap-x-3">
{!isBranchingEnabled && <EnableBranchingButton />}
{connectDialogUpdate && <Connect />}
{!isBranchingEnabled && <EnableBranchingButton />}
</div>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@ const SettingsLayout = ({ title, children }: PropsWithChildren<SettingsLayoutPro
'billing:invoices',
])

const warehouseEnabled = useFlag('warehouse')
const diskAndComputeEnabled = useFlag('diskAndComputeForm')

const menuRoutes = generateSettingsMenu(ref, project, organization, {
auth: authEnabled,
edgeFunctions: edgeFunctionsEnabled,
storage: storageEnabled,
invoices: invoicesEnabled,
warehouse: warehouseEnabled,
diskAndCompute: diskAndComputeEnabled,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const generateSettingsMenu = (
edgeFunctions?: boolean
storage?: boolean
invoices?: boolean
warehouse?: boolean
diskAndCompute?: boolean
}
): ProductMenuGroup[] => {
Expand All @@ -24,7 +23,6 @@ export const generateSettingsMenu = (
const authEnabled = features?.auth ?? true
const edgeFunctionsEnabled = features?.edgeFunctions ?? true
const storageEnabled = features?.storage ?? true
const warehouseEnabled = features?.warehouse ?? false
const newDiskComputeEnabled = features?.diskAndCompute ?? false

return [
Expand Down Expand Up @@ -124,16 +122,6 @@ export const generateSettingsMenu = (
},
]
: []),
...(IS_PLATFORM && warehouseEnabled
? [
{
name: 'Warehouse',
key: 'warehouse',
url: `/project/${ref}/settings/warehouse`,
items: [],
},
]
: []),
...(IS_PLATFORM
? [
{
Expand Down
Loading
Loading