From c0b0637a675d664915ef785338146923faa387b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Gr=C3=BCneberg?= Date: Tue, 10 Dec 2024 13:14:06 +0800 Subject: [PATCH 1/5] fix: include branches exceeding disk quota (#31022) Fixes two issues: - The check for exceeding disk size should only look at relevant projects and ignore projects that are filtered out - We now include branches that exceed the 8 GB disk, as customers can have long-running / persistent branches --- .../Usage/UsageSection/DiskUsage.tsx | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx b/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx index df7486172fe31..94ecf0119a6b8 100644 --- a/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx +++ b/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx @@ -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 @@ -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 (
From 862dee997d574a0460e0c5b45fa16f4ee981994e Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Tue, 10 Dec 2024 14:18:59 +0800 Subject: [PATCH 2/5] Reinstate reset db password (#31033) --- .../DatabaseSettings/DatabaseSettings.tsx | 234 +++++++++--------- .../pages/project/[ref]/settings/database.tsx | 2 + 2 files changed, 116 insertions(+), 120 deletions(-) diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx index aaa0deef01de4..9fb82b60a3f7e 100644 --- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx +++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx @@ -102,135 +102,129 @@ const DatabaseSettings = () => { }, [primaryConfig?.pool_mode]) return ( - <> -
- -
-
Connection parameters
-
- +
+ +
+
Connection parameters
- } - > - - {isLoading && - Array.from({ length: 5 }).map((_, i) => ( -
- - -
- ))} - {isError && } - {isSuccess && ( - <> -
- - {defaultPoolingMode === 'session' && poolingMode === 'transaction' && ( - - )} - {ipv4Addon !== undefined && - poolingMode === 'session' && - snap.usePoolerConnection && } - {ipv4Addon === undefined && !snap.usePoolerConnection && ( - - )} - {isMd5 && ( - - - - If you are connecting to your database via a GUI client, use the{' '} - connection string above instead - - - GUI clients only support database connections for Postgres 13 via a - connection string. - - - )} -
- { - handleCopy('Host') - }} - /> - - +
+ } + > + + {isLoading && + Array.from({ length: 5 }).map((_, i) => ( +
+ + +
+ ))} + {isError && } + {isSuccess && ( + <> +
+ - {isMd5 && snap.usePoolerConnection && ( - + {defaultPoolingMode === 'session' && poolingMode === 'transaction' && ( + )} + {ipv4Addon !== undefined && + poolingMode === 'session' && + snap.usePoolerConnection && } + {ipv4Addon === undefined && !snap.usePoolerConnection && } + {isMd5 && ( + + + + If you are connecting to your database via a GUI client, use the{' '} + connection string above instead + + + GUI clients only support database connections for Postgres 13 via a connection + string. + + + )} +
+ { + handleCopy('Host') + }} + /> + + + {isMd5 && snap.usePoolerConnection && ( - - - )} -
- - - - - + )} + + + + )} + + + ) } diff --git a/apps/studio/pages/project/[ref]/settings/database.tsx b/apps/studio/pages/project/[ref]/settings/database.tsx index 1ed247a0807ac..b046c5555c7ab 100644 --- a/apps/studio/pages/project/[ref]/settings/database.tsx +++ b/apps/studio/pages/project/[ref]/settings/database.tsx @@ -8,6 +8,7 @@ import BannedIPs from 'components/interfaces/Settings/Database/BannedIPs' import { ConnectionStringMoved } from 'components/interfaces/Settings/Database/ConnectionStringMoved' import { DatabaseReadOnlyAlert } from 'components/interfaces/Settings/Database/DatabaseReadOnlyAlert' import { DatabaseConnectionString } from 'components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString' +import ResetDbPassword from 'components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword' import DiskSizeConfiguration from 'components/interfaces/Settings/Database/DiskSizeConfiguration' import { PoolingModesModal } from 'components/interfaces/Settings/Database/PoolingModesModal' import SSLConfiguration from 'components/interfaces/Settings/Database/SSLConfiguration' @@ -43,6 +44,7 @@ const ProjectSettings: NextPageWithLayout = () => { )} + From c05123a9c0ac4490741fe67794c0bfc890b7816a Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Tue, 10 Dec 2024 14:29:56 +0800 Subject: [PATCH 3/5] move button (#31036) --- .../layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx index 6808d0d377947..7f3c4f568cbe0 100644 --- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx +++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx @@ -98,8 +98,8 @@ const LayoutHeader = ({ customHeaderComponents, breadcrumbs = [], headerBorder =
- {!isBranchingEnabled && } {connectDialogUpdate && } + {!isBranchingEnabled && }
)} From 6af2bcf346b1604689f235a222373e1d5cf27f34 Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Tue, 10 Dec 2024 14:33:08 +0800 Subject: [PATCH 4/5] fix: update next.js auth middleware example (#31035) fix: update next.js example --- apps/docs/content/guides/auth/server-side/nextjs.mdx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/docs/content/guides/auth/server-side/nextjs.mdx b/apps/docs/content/guides/auth/server-side/nextjs.mdx index 8189371cc262b..f489a5344d23d 100644 --- a/apps/docs/content/guides/auth/server-side/nextjs.mdx +++ b/apps/docs/content/guides/auth/server-side/nextjs.mdx @@ -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() @@ -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: From b862a74f607a989d17bede2a6a2acefd5ba2c27d Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Tue, 10 Dec 2024 16:07:10 +0800 Subject: [PATCH 5/5] Remove warehouse settings from settings menu (#31038) --- .../layouts/ProjectSettingsLayout/SettingsLayout.tsx | 2 -- .../ProjectSettingsLayout/SettingsMenu.utils.tsx | 12 ------------ apps/studio/next.config.js | 5 +++++ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx index 81af839800a79..6145630674574 100644 --- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx +++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx @@ -46,7 +46,6 @@ const SettingsLayout = ({ title, children }: PropsWithChildren { @@ -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 [ @@ -124,16 +122,6 @@ export const generateSettingsMenu = ( }, ] : []), - ...(IS_PLATFORM && warehouseEnabled - ? [ - { - name: 'Warehouse', - key: 'warehouse', - url: `/project/${ref}/settings/warehouse`, - items: [], - }, - ] - : []), ...(IS_PLATFORM ? [ { diff --git a/apps/studio/next.config.js b/apps/studio/next.config.js index 6eca251889ea1..604c300a633b6 100644 --- a/apps/studio/next.config.js +++ b/apps/studio/next.config.js @@ -434,6 +434,11 @@ const nextConfig = { source: '/project/:ref/integrations/cron-jobs', destination: '/project/:ref/integrations/cron', }, + { + permanent: true, + source: '/project/:ref/settings/warehouse', + destination: '/project/:ref/settings/general', + }, ...(process.env.NEXT_PUBLIC_BASE_PATH?.length ? [ {