The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Revert "Chore/support temp enable db writes (#18171)" (#18229)
Ivan Vasilov3d70a1cdca36
diff --git a/package-lock.json b/package-lock.jsonindex 4ab022be6d3..9db6b170ae6 100644--- a/package-lock.json+++ b/package-lock.json@@ -15279,6 +15279,11 @@"websocket": "^1.0.34"}},+ "node_modules/@supabase/shared-types": {+ "version": "0.1.47",+ "resolved": "https://registry.npmjs.org/@supabase/shared-types/-/shared-types-0.1.47.tgz",+ "integrity": "sha512-OsXFgKd7yID/5mHuQ8k7I+dCT++ctEEj4YqV8soAik2EP0oiqqRzPwJ8kdmpwK+YyB0Z+AfOxex4dVa7J9J6eA=="+ },"node_modules/@supabase/storage-js": {"version": "2.5.1","license": "MIT",@@ -42944,7 +42949,7 @@"@supabase/auth-helpers-nextjs": "^0.5.6","@supabase/auth-helpers-react": "^0.3.1","@supabase/react-data-grid": "^7.1.0-beta.7",- "@supabase/shared-types": "0.1.51",+ "@supabase/shared-types": "0.1.47","@supabase/supabase-js": "^2.23.0","@tanstack/react-query": "^4.22.0","@tanstack/react-query-devtools": "^4.22.0",@@ -43269,11 +43274,6 @@"url": "https://opencollective.com/storybook"}},- "studio/node_modules/@supabase/shared-types": {- "version": "0.1.51",- "resolved": "https://registry.npmjs.org/@supabase/shared-types/-/shared-types-0.1.51.tgz",- "integrity": "sha512-ZCm3sdxFwFDIOakciAH+or1gWQ6SKqiSWmmejsUCyH5QfMl4ngFc6hZcNEky5+NJ5wI7YtukUpvKihNVR0iNSg=="- },"studio/node_modules/@tanstack/match-sorter-utils": {"version": "8.7.6","license": "MIT",diff --git a/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsx b/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsxindex c826d2555ce..6fc508b5974 100644--- a/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsx+++ b/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsx@@ -1,62 +1,13 @@-import { OAuthScope } from '@supabase/shared-types/out/constants'-import { IconCheck } from 'ui'-export interface AuthorizeRequesterDetailsProps {icon: string | nullname: stringdomain: string- scopes: OAuthScope[]-}--const ScopeSection = ({- description,- hasReadScope,- hasWriteScope,-}: {- description: string- hasReadScope: boolean- hasWriteScope: boolean-}) => {- if (hasReadScope || hasWriteScope) {- const perms = [hasReadScope ? 'Read' : null, hasWriteScope ? 'Write' : null]- .filter(Boolean)-- .map((str) => (- <span key={str} className="font-semibold text-foreground">- {str}- </span>- ))- .reduce((acc, v) => (- <>- {acc}- <span> and </span>- {v}- </>- ))-- return (- <div className="first:border-t border-b flex flex-row space-x-1 text-sm text-foreground-light py-2 px-1">- <div className="pt-0.5">- <IconCheck stroke="green" height={18} width={18} strokeWidth={1.5} />- </div>- <div>- {perms} {description}- </div>- </div>- )- }- return null}-const AuthorizeRequesterDetails = ({- icon,- name,- domain,- scopes,-}: AuthorizeRequesterDetailsProps) => {+const AuthorizeRequesterDetails = ({ icon, name, domain }: AuthorizeRequesterDetailsProps) => {return (- <div className="flex space-y-4 flex-col">- <div className="flex flex-row space-x-4">+ <div className="flex space-x-4">+ <div><div className="flex items-center"><divclassName="w-14 h-14 md:w-16 md:h-16 bg-center bg-no-repeat bg-cover flex items-center justify-center rounded-md border border-scale-600"@@ -67,64 +18,14 @@ const AuthorizeRequesterDetails = ({{icon === null && <p className="text-foreground-light text-lg">{name[0]}</p>}</div></div>- <p className="text-sm text-foreground-light">- {name} ({domain}) is requesting API access to an organization.- </p>- </div>- <div>- <h2>Permissions</h2>- <p className="text-sm text-foreground-light">- The following scopes will apply for the{' '}- <span className="text-amber-900">selected organization and all of its projects.</span>- </p>- <div className="pt-2">- <ScopeSection- description="access to auth configurations and SSO providers."- hasReadScope={scopes.includes(OAuthScope.AUTH_READ)}- hasWriteScope={scopes.includes(OAuthScope.AUTH_WRITE)}- />- <ScopeSection- description="access to Postgres configurations, SQL snippets, SSL enforcement configurations and Typescript schema types."- hasReadScope={scopes.includes(OAuthScope.DATABASE_READ)}- hasWriteScope={scopes.includes(OAuthScope.DATABASE_WRITE)}- />- <ScopeSection- description="access to custom domains and vanity subdomains."- hasReadScope={scopes.includes(OAuthScope.DOMAINS_READ)}- hasWriteScope={scopes.includes(OAuthScope.DOMAINS_WRITE)}- />- <ScopeSection- description="access to edge functions."- hasReadScope={scopes.includes(OAuthScope.EDGE_FUNCTIONS_READ)}- hasWriteScope={scopes.includes(OAuthScope.EDGE_FUNCTIONS_WRITE)}- />- <ScopeSection- description="access to environments/branches."- hasReadScope={scopes.includes(OAuthScope.ENVIRONMENT_READ)}- hasWriteScope={scopes.includes(OAuthScope.ENVIRONMENT_WRITE)}- />- <ScopeSection- description="access to the organization and all its members."- hasReadScope={scopes.includes(OAuthScope.ORGANIZATIONS_READ)}- hasWriteScope={scopes.includes(OAuthScope.ORGANIZATIONS_WRITE)}- />- <ScopeSection- description="access to metadata, its upgrade status, network restrictions and network bans."- hasReadScope={scopes.includes(OAuthScope.PROJECTS_READ)}- hasWriteScope={scopes.includes(OAuthScope.PROJECTS_WRITE)}- />- <ScopeSection- description="access to PostgREST configurations."- hasReadScope={scopes.includes(OAuthScope.REST_READ)}- hasWriteScope={scopes.includes(OAuthScope.REST_WRITE)}- />- <ScopeSection- description="access to API keys, secrets and pgsodium configurations."- hasReadScope={scopes.includes(OAuthScope.SECRETS_READ)}- hasWriteScope={scopes.includes(OAuthScope.SECRETS_WRITE)}- />- </div></div>+ <p className="text-sm text-foreground-light">+ {name} ({domain}) is requesting API access to an organization. The application will be able+ to{' '}+ <span className="text-amber-1200">+ read and write the organization's settings and all of its projects.+ </span>+ </p></div>)}diff --git a/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsx b/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel.tsxsimilarity index 89%rename from studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsxrename to studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel.tsxindex 56f646716f8..24171c32dff 100644--- a/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsx+++ b/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel.tsx@@ -1,7 +1,6 @@import clsx from 'clsx'import { ChangeEvent, useEffect, useRef, useState } from 'react'-import { OAuthScope } from '@supabase/shared-types/out/constants'import { useParams } from 'common'import {OAuthAppCreateResponse,@@ -21,15 +20,12 @@ import {DropdownMenuTrigger,Form,IconEdit,- IconExternalLink,IconUpload,Input,Modal,SidePanel,} from 'ui'-import AuthorizeRequesterDetails from '../AuthorizeRequesterDetails'-import { ScopesPanel } from './Scopes'-import Link from 'next/link'+import AuthorizeRequesterDetails from './AuthorizeRequesterDetails'export interface PublishAppSidePanelProps {visible: boolean@@ -92,7 +88,6 @@ const PublishAppSidePanel = ({const [iconUrl, setIconUrl] = useState<string>()const [errors, setErrors] = useState<{ [key: string]: string }>({})const [urls, setUrls] = useState<{ id: string; value: string }[]>([{ id: uuidv4(), value: '' }])- const [scopes, setScopes] = useState<OAuthScope[]>([])useEffect(() => {if (visible) {@@ -106,11 +101,9 @@ const PublishAppSidePanel = ({return { id: uuidv4(), value: url }}))- setScopes(selectedApp.scopes)setIconUrl(selectedApp.icon === null ? undefined : selectedApp.icon)} else {setUrls([{ id: uuidv4(), value: '' }])- setScopes([])setIconUrl(undefined)}}@@ -171,7 +164,6 @@ const PublishAppSidePanel = ({name,website,redirect_uris,- scopes,icon: uploadedIconUrl,})} else {@@ -182,7 +174,6 @@ const PublishAppSidePanel = ({name,website,redirect_uris,- scopes,icon: uploadedIconUrl === undefined ? null : uploadedIconUrl,})}@@ -341,30 +332,6 @@ const PublishAppSidePanel = ({</div></SidePanel.Content><SidePanel.Separator />- <div className="p-6 ">- <div className="pb-4 flex items-start justify-between space-x-4">- <div className="flex flex-col">- <span className="prose text-sm">Application permissions</span>- <span className="text-sm text-foreground-light">- The application permissions are organized in scopes and will be- presented to the user when adding an app to their organization and all- of its projects.- </span>- </div>- <Link- passHref- href="https://supabase.com/docs/guides/platform/oauth-apps/oauth-scopes"- >- <Button asChild type="default" icon={<IconExternalLink />}>- <a target="_blank" rel="noreferrer">- Documentation- </a>- </Button>- </Link>- </div>-- <ScopesPanel scopes={scopes} setScopes={setScopes} />- </div></div><SidePanel.Separator />@@ -392,7 +359,7 @@ const PublishAppSidePanel = ({<ModalhideFooter- className="!max-w-[600px]"+ className="!w-[500px]"visible={showPreview}onCancel={() => setShowPreview(false)}>@@ -409,7 +376,6 @@ const PublishAppSidePanel = ({icon={iconUrl || null}name={values.name}domain={values.website}- scopes={scopes}/><div className="pt-4 space-y-2"><p className="prose text-sm">diff --git a/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/Scopes.tsx b/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/Scopes.tsxdeleted file mode 100644index 8116d3bffe6..00000000000--- a/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/Scopes.tsx+++ /dev/null@@ -1,183 +0,0 @@-import { OAuthScope } from '@supabase/shared-types/out/constants'-import { Dispatch, PropsWithChildren, SetStateAction } from 'react'-import {- Button,- DropdownMenu,- DropdownMenuCheckboxItem,- DropdownMenuContent,- DropdownMenuLabel,- DropdownMenuSeparator,- DropdownMenuTrigger,- IconChevronDown,-} from 'ui'--const ScopeDropdownCheckboxItem = ({- children,- scopeName,- scopes,- onChange,-}: PropsWithChildren<{- scopeName: OAuthScope- scopes: OAuthScope[]- onChange: (v: OAuthScope[]) => void-}>) => {- return (- <DropdownMenuCheckboxItem- checked={scopes.includes(scopeName)}- onCheckedChange={(checked) => {- if (checked) {- onChange([...scopes, scopeName])- } else {- onChange([...scopes.filter((s) => s !== scopeName)])- }- }}- >- {children}- </DropdownMenuCheckboxItem>- )-}--const Scope = ({- title,- description,- readScopeName,- writeScopeName,- scopes,- setScopes,-}: {- title: string- description: string- readScopeName: OAuthScope- writeScopeName: OAuthScope- scopes: OAuthScope[]- setScopes: Dispatch<SetStateAction<OAuthScope[]>>-}) => {- let accessDescription = 'Access: No access'- if (scopes.includes(readScopeName)) {- accessDescription = 'Access: Read-only'- }- if (scopes.includes(writeScopeName)) {- accessDescription = 'Access: Write-only'- }- if (scopes.includes(readScopeName) && scopes.includes(writeScopeName)) {- accessDescription = 'Access: Read and write'- }-- return (- <div- className="flex flex-row justify-between p-4 border border-scale-300 dark:border-scale-500 first:rounded-t last:rounded-b"- key={title}- >- <div className="flex flex-col">- <span className="text-foreground text-sm">{title}</span>- <span className="text-foreground-light text-xs">{description}</span>- </div>- <DropdownMenu>- <DropdownMenuTrigger>- <Button type="default" iconRight={<IconChevronDown />}>- <p>{accessDescription}</p>- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuLabel>Select an access level</DropdownMenuLabel>- <DropdownMenuSeparator />- <ScopeDropdownCheckboxItem scopeName={readScopeName} scopes={scopes} onChange={setScopes}>- Read- </ScopeDropdownCheckboxItem>- <ScopeDropdownCheckboxItem- scopeName={writeScopeName}- scopes={scopes}- onChange={setScopes}- >- Write- </ScopeDropdownCheckboxItem>- </DropdownMenuContent>- </DropdownMenu>- </div>- )-}--export const ScopesPanel = ({- scopes,- setScopes,-}: {- scopes: OAuthScope[]- setScopes: Dispatch<SetStateAction<OAuthScope[]>>-}) => {- return (- <div className="-space-y-px">- <Scope- title="Auth"- description="Auth configurations and SSO providers."- readScopeName={OAuthScope.AUTH_READ}- writeScopeName={OAuthScope.AUTH_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="Database"- description="Postgres configurations, SQL snippets, SSL enforcement configurations and Typescript schema types."- readScopeName={OAuthScope.DATABASE_READ}- writeScopeName={OAuthScope.DATABASE_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="Domains"- description="Custom domains and vanity subdomains."- readScopeName={OAuthScope.DOMAINS_READ}- writeScopeName={OAuthScope.DOMAINS_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="Edge Functions"- description="Edge functions."- readScopeName={OAuthScope.EDGE_FUNCTIONS_READ}- writeScopeName={OAuthScope.EDGE_FUNCTIONS_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="Environment"- description="Environments/branches."- readScopeName={OAuthScope.ENVIRONMENT_READ}- writeScopeName={OAuthScope.ENVIRONMENT_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="Organizations"- description="Organizations and all its members."- readScopeName={OAuthScope.ORGANIZATIONS_READ}- writeScopeName={OAuthScope.ORGANIZATIONS_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="Projects"- description="Metadata, upgrade status, network restrictions and network bans."- readScopeName={OAuthScope.PROJECTS_READ}- writeScopeName={OAuthScope.PROJECTS_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="REST"- description="PostgREST configurations."- readScopeName={OAuthScope.REST_READ}- writeScopeName={OAuthScope.REST_WRITE}- scopes={scopes}- setScopes={setScopes}- />- <Scope- title="Secrets"- description="API keys, secrets and pgsodium configurations."- readScopeName={OAuthScope.SECRETS_READ}- writeScopeName={OAuthScope.SECRETS_WRITE}- scopes={scopes}- setScopes={setScopes}- />- </div>- )-}diff --git a/studio/components/interfaces/Settings/Database/DatabaseSettings/ConfirmDisableReadOnlyModeModal.tsx b/studio/components/interfaces/Settings/Database/DatabaseSettings/ConfirmDisableReadOnlyModeModal.tsxdeleted file mode 100644index 1ed5977e7d0..00000000000--- a/studio/components/interfaces/Settings/Database/DatabaseSettings/ConfirmDisableReadOnlyModeModal.tsx+++ /dev/null@@ -1,53 +0,0 @@-import { useParams } from 'common'-import toast from 'react-hot-toast'-import { Modal } from 'ui'--import { useDisableReadOnlyModeMutation } from 'data/config/project-temp-disable-read-only-mutation'--interface ConfirmDisableReadOnlyModeModalProps {- visible: boolean- onClose: () => void-}--const ConfirmDisableReadOnlyModeModal = ({- visible,- onClose,-}: ConfirmDisableReadOnlyModeModalProps) => {- const { ref } = useParams()- const { mutate: disableReadOnlyMode, isLoading } = useDisableReadOnlyModeMutation({- onSuccess: () => {- toast.success('Successfully disabled read-only mode for 15 minutes')- onClose()- },- })-- return (- <Modal- alignFooter="right"- visible={visible}- onCancel={onClose}- loading={isLoading}- confirmText="Disable read-only mode"- header="Confirm to temporarily disable read-only mode"- onConfirm={() => {- if (!ref) return console.error('Project ref is required')- disableReadOnlyMode({ projectRef: ref })- }}- >- <Modal.Content className="py-4 space-y-2">- <p className="text-sm">- This will temporarily allow writes to your database for the{' '}- <span className="text-amber-900">next 15 minutes</span>, during which you can reduce your- database size. After deleting data, you should run a vacuum to reclaim as much space as- possible.- </p>- <p className="text-sm">- If your database size has not been sufficiently reduced after 15 minutes, read-only mode- will be toggled back on. Otherwise, it will stay disabled.- </p>- </Modal.Content>- </Modal>- )-}--export default ConfirmDisableReadOnlyModeModaldiff --git a/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx b/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsxindex a4fe758a4d6..5b2d41c4241 100644--- a/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx+++ b/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx@@ -1,44 +1,19 @@import { useParams, useTelemetryProps } from 'common'-import Link from 'next/link'import { useRouter } from 'next/router'-import { useState } from 'react'-import {- AlertDescription_Shadcn_,- AlertTitle_Shadcn_,- Alert_Shadcn_,- Button,- IconAlertTriangle,- IconExternalLink,- Input,- Tabs,-} from 'ui'+import { Input, Tabs } from 'ui'import Panel from 'components/ui/Panel'import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { useProjectSettingsQuery } from 'data/config/project-settings-query'-import { useProjectSubscriptionV2Query } from 'data/subscriptions/project-subscription-v2-query'-import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'-import { useSelectedOrganization } from 'hooks'import { pluckObjectFields } from 'lib/helpers'import Telemetry from 'lib/telemetry'-import ConfirmDisableReadOnlyModeModal from './ConfirmDisableReadOnlyModeModal'import ResetDbPassword from './ResetDbPassword'const DatabaseSettings = () => {const router = useRouter()const { ref: projectRef } = useParams()const telemetryProps = useTelemetryProps()- const selectedOrganization = useSelectedOrganization()- const [showConfirmationModal, setShowConfirmationModal] = useState(false)-const { data, isLoading, isError } = useProjectSettingsQuery({ projectRef })- const { data: subscription } = useProjectSubscriptionV2Query({ projectRef })- const { data: resourceWarnings } = useResourceWarningsQuery()-- const isOrgBilling = !!selectedOrganization?.subscription_id- const isReadOnlyMode =- (resourceWarnings ?? [])?.find((warning) => warning.project === projectRef)- ?.is_readonly_mode_enabled ?? falseif (isError) {return (@@ -156,271 +131,199 @@ const DatabaseSettings = () => {`-U ${connectionInfo.db_user}`return (- <>- <div className="space-y-10">- <section className="space-y-6">- <h3 className="text-foreground mb-2 text-xl">Database Settings</h3>-- {isReadOnlyMode && (- <Alert_Shadcn_ variant="destructive">- <IconAlertTriangle />- <AlertTitle_Shadcn_>- Project is in read-only mode and database is no longer accepting write requests- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- You have reached 95% of your project's disk space, and read-only mode has been- enabled to preserve your database's stability and prevent your project from- exceeding its current billing plan. To resolve this, you may:- <ul className="list-disc pl-6 mt-1">- <li>- Temporarily disable read-only mode to free up space and reduce your database- size- </li>- {subscription?.plan.id === 'free' ? (- <li>- <Link- href={- isOrgBilling- ? `/org/${selectedOrganization.slug}/billing?panel=subscriptionPlan`- : `/project/${projectRef}/settings/billing/subscription?panel=subscriptionPlan`- }- >- <a className="text underline">Upgrade to the Pro plan</a>- </Link>{' '}- to increase your database size limit to 8GB.- </li>- ) : subscription?.plan.id === 'pro' && subscription?.usage_billing_enabled ? (- <li>- <Link- href={- isOrgBilling- ? `/org/${selectedOrganization.slug}/billing?panel=subscriptionPlan`- : `/project/${projectRef}/settings/billing/subscription?panel=subscriptionPlan`- }- >- <a className="text-foreground underline">Disable your Spend Cap</a>- </Link>{' '}- to allow your project to auto-scale and expand beyond the 8GB database size- limit- </li>- ) : null}- </ul>- </AlertDescription_Shadcn_>- <div className="mt-4 flex items-center space-x-2">- <Button type="default" onClick={() => setShowConfirmationModal(true)}>- Disable read-only mode- </Button>- <Link- passHref- href="https://supabase.com/docs/guides/platform/database-size#disabling-read-only-mode"- >- <a target="_blank" rel="noreferrer">- <Button type="default" icon={<IconExternalLink />}>- Learn more- </Button>- </a>- </Link>- </div>- </Alert_Shadcn_>- )}-- <Panel- title={- <h5 key="panel-title" className="mb-0">- Connection info- </h5>- }- className="!m-0"- >- <Panel.Content className="space-y-6">- <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={connectionInfo.db_port.toString()}- label="Port"- />-- <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={'[The password you provided when you created this project]'}- label="Password"- />- </Panel.Content>- </Panel>- </section>-- <ResetDbPassword />-- <section className="space-y-6">- <Panel- title={- <h5 key="panel-title" className="mb-0">- Connection string- </h5>- }- className="!m-0"- >- <Panel.Content>- <Tabs type="underlined" size="small">- <Tabs.Panel id="psql" label="PSQL">- <Input- copy- readOnly- disabled- value={psqlConnString}- onCopy={() => {- handleCopy('PSQL')- }}- />- </Tabs.Panel>-- <Tabs.Panel id="uri" label="URI">- <Input- copy- readOnly- disabled- value={uriConnString}- onCopy={() => {- handleCopy('URI')- }}- />- </Tabs.Panel>-- <Tabs.Panel id="golang" label="Golang">- <Input- copy- readOnly- disabled- value={golangConnString}- onCopy={() => {- handleCopy('Golang')- }}- />- </Tabs.Panel>-- <Tabs.Panel id="jdbc" label="JDBC">- <Input- copy- readOnly- disabled- value={- `jdbc:postgresql://${- connectionInfo.db_host- }:${connectionInfo.db_port.toString()}` +- `/${connectionInfo.db_name}?user=${connectionInfo.db_user}&password=[YOUR-PASSWORD]`- }- onCopy={() => {- handleCopy('JDBC')- }}- />- </Tabs.Panel>-- <Tabs.Panel id="dotnet" label=".NET">- <Input- copy- readOnly- disabled- value={- `User Id=${connectionInfo.db_user};Password=[YOUR-PASSWORD];` +- `Server=${- connectionInfo.db_host- };Port=${connectionInfo.db_port.toString()};` +- `Database=${connectionInfo.db_name}`- }- onCopy={() => {- handleCopy('.NET')- }}- />- </Tabs.Panel>-- <Tabs.Panel id="nodejs" label="Nodejs">- <Input- copy- readOnly- disabled- value={uriConnString}- onCopy={() => {- handleCopy('Nodejs')- }}- />- </Tabs.Panel>-- <Tabs.Panel id="php" label="PHP">- <Input- copy- readOnly- disabled- value={golangConnString}- onCopy={() => {- handleCopy('PHP')- }}- />- </Tabs.Panel>-- <Tabs.Panel id="python" label="Python">- <Input- copy- readOnly- disabled- value={- `user=${connectionInfo.db_user} password=[YOUR-PASSWORD]` +- ` host=${connectionInfo.db_host} port=${connectionInfo.db_port.toString()}` +- ` database=${connectionInfo.db_name}`- }- onCopy={() => {- handleCopy('Python')- }}- />- </Tabs.Panel>- </Tabs>- </Panel.Content>- </Panel>- </section>- </div>- <ConfirmDisableReadOnlyModeModal- visible={showConfirmationModal}- onClose={() => setShowConfirmationModal(false)}- />- </>+ <div className="space-y-10">+ <section className="space-y-6">+ <h3 className="text-foreground mb-2 text-xl">Database Settings</h3>+ <Panel+ title={+ <h5 key="panel-title" className="mb-0">+ Connection info+ </h5>+ }+ className="!m-0"+ >+ <Panel.Content className="space-y-6">+ <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={connectionInfo.db_port.toString()}+ label="Port"+ />++ <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={'[The password you provided when you created this project]'}+ label="Password"+ />+ </Panel.Content>+ </Panel>+ </section>++ <ResetDbPassword />++ <section className="space-y-6">+ <Panel+ title={+ <h5 key="panel-title" className="mb-0">+ Connection string+ </h5>+ }+ className="!m-0"+ >+ <Panel.Content>+ <Tabs type="underlined" size="small">+ <Tabs.Panel id="psql" label="PSQL">+ <Input+ copy+ readOnly+ disabled+ value={psqlConnString}+ onCopy={() => {+ handleCopy('PSQL')+ }}+ />+ </Tabs.Panel>++ <Tabs.Panel id="uri" label="URI">+ <Input+ copy+ readOnly+ disabled+ value={uriConnString}+ onCopy={() => {+ handleCopy('URI')+ }}+ />+ </Tabs.Panel>++ <Tabs.Panel id="golang" label="Golang">+ <Input+ copy+ readOnly+ disabled+ value={golangConnString}+ onCopy={() => {+ handleCopy('Golang')+ }}+ />+ </Tabs.Panel>++ <Tabs.Panel id="jdbc" label="JDBC">+ <Input+ copy+ readOnly+ disabled+ value={+ `jdbc:postgresql://${+ connectionInfo.db_host+ }:${connectionInfo.db_port.toString()}` ++ `/${connectionInfo.db_name}?user=${connectionInfo.db_user}&password=[YOUR-PASSWORD]`+ }+ onCopy={() => {+ handleCopy('JDBC')+ }}+ />+ </Tabs.Panel>++ <Tabs.Panel id="dotnet" label=".NET">+ <Input+ copy+ readOnly+ disabled+ value={+ `User Id=${connectionInfo.db_user};Password=[YOUR-PASSWORD];` ++ `Server=${connectionInfo.db_host};Port=${connectionInfo.db_port.toString()};` ++ `Database=${connectionInfo.db_name}`+ }+ onCopy={() => {+ handleCopy('.NET')+ }}+ />+ </Tabs.Panel>++ <Tabs.Panel id="nodejs" label="Nodejs">+ <Input+ copy+ readOnly+ disabled+ value={uriConnString}+ onCopy={() => {+ handleCopy('Nodejs')+ }}+ />+ </Tabs.Panel>++ <Tabs.Panel id="php" label="PHP">+ <Input+ copy+ readOnly+ disabled+ value={golangConnString}+ onCopy={() => {+ handleCopy('PHP')+ }}+ />+ </Tabs.Panel>++ <Tabs.Panel id="python" label="Python">+ <Input+ copy+ readOnly+ disabled+ value={+ `user=${connectionInfo.db_user} password=[YOUR-PASSWORD]` ++ ` host=${connectionInfo.db_host} port=${connectionInfo.db_port.toString()}` ++ ` database=${connectionInfo.db_name}`+ }+ onCopy={() => {+ handleCopy('Python')+ }}+ />+ </Tabs.Panel>+ </Tabs>+ </Panel.Content>+ </Panel>+ </section>+ </div>)}diff --git a/studio/components/layouts/APIAuthorizationLayout.tsx b/studio/components/layouts/APIAuthorizationLayout.tsxindex ad7e43de299..c517fbcbce3 100644--- a/studio/components/layouts/APIAuthorizationLayout.tsx+++ b/studio/components/layouts/APIAuthorizationLayout.tsx@@ -1,9 +1,9 @@-import Divider from 'components/ui/Divider'-import { BASE_PATH } from 'lib/constants'-import { useTheme } from 'next-themes'import Head from 'next/head'import Image from 'next/image'+import { useTheme } from 'next-themes'import { PropsWithChildren } from 'react'+import { BASE_PATH } from 'lib/constants'+import Divider from 'components/ui/Divider'export interface APIAuthorizationLayoutProps {}@@ -37,7 +37,7 @@ const APIAuthorizationLayout = ({ children }: PropsWithChildren<APIAuthorization</div></div><Divider light />- <div className="flex flex-col justify-center flex-grow mx-auto w-[90vw] max-w-[600px] h-full space-y-4">+ <div className="flex flex-col justify-center flex-grow mx-auto max-w-[90vw] md:max-w-xl h-full space-y-4">{children}</div></main>diff --git a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.tsindex fd5f679b2b6..5ed9d61b5f9 100644--- a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts+++ b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts@@ -25,8 +25,8 @@ export const RESOURCE_WARNING_MESSAGES = {},},docsUrl: 'https://supabase.com/docs/guides/platform/database-size#disabling-read-only-mode',- buttonText: 'View database settings',- metric: 'read_only',+ buttonText: undefined,+ metric: undefined,},disk_io_exhaustion: {bannerContent: {diff --git a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsxindex 99ca6389430..37df8e4bb7a 100644--- a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx+++ b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx@@ -82,7 +82,7 @@ const ResourceExhaustionWarningBanner = () => {? undefined: metric === null? '/project/[ref]/settings/[infra-path]'- : metric === 'disk_space' || metric === 'read_only'+ : metric === 'disk_space'? '/project/[ref]/settings/database': `/project/[ref]/settings/[infra-path]#${metric}`)@@ -99,9 +99,7 @@ const ResourceExhaustionWarningBanner = () => {if (activeWarnings.length === 0 ||((router.pathname.endsWith('/usage') || router.pathname.endsWith('/infrastructure')) &&- !activeWarnings.includes('is_readonly_mode_enabled')) ||- (activeWarnings.includes('is_readonly_mode_enabled') &&- router.pathname.endsWith('settings/database'))+ !activeWarnings.includes('is_readonly_mode_enabled')))return nulldiff --git a/studio/data/api-authorization/api-authorization-query.ts b/studio/data/api-authorization/api-authorization-query.tsindex 506461f479b..837738e0045 100644--- a/studio/data/api-authorization/api-authorization-query.ts+++ b/studio/data/api-authorization/api-authorization-query.ts@@ -1,4 +1,3 @@-import { OAuthScope } from '@supabase/shared-types/out/constants'import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'import { get } from 'lib/common/fetch'import { API_ADMIN_URL } from 'lib/constants'@@ -14,7 +13,6 @@ export type ApiAuthorizationResponse = {website: stringicon: string | nulldomain: string- scopes: OAuthScope[]expires_at: stringapproved_at: string | nullapproved_organization_slug?: stringdiff --git a/studio/data/config/project-read-only-query.ts b/studio/data/config/project-read-only-query.tsnew file mode 100644index 00000000000..151b0ff12e2--- /dev/null+++ b/studio/data/config/project-read-only-query.ts@@ -0,0 +1,48 @@+import { UseQueryOptions } from '@tanstack/react-query'+import { useCallback } from 'react'+import { ExecuteSqlData, useExecuteSqlPrefetch, useExecuteSqlQuery } from '../sql/execute-sql-query'++// TODO: temporary solution to check if project is in read only mode+// until we get an api endpoint for this++export const getProjectReadOnlySql = () => {+ const sql = /* SQL */ `+ show default_transaction_read_only;+ `++ return sql+}++export type ProjectReadOnlyVariables = {+ projectRef?: string+ connectionString?: string+}++export type ProjectReadOnlyData = boolean+export type ProjectReadOnlyError = unknown++export const useProjectReadOnlyQuery = (+ { projectRef, connectionString }: ProjectReadOnlyVariables,+ options: Omit<+ UseQueryOptions<ExecuteSqlData, ProjectReadOnlyError, ProjectReadOnlyData>,+ 'select'+ > = {}+) =>+ useExecuteSqlQuery(+ {+ projectRef,+ connectionString,+ sql: getProjectReadOnlySql(),+ queryKey: ['project-read-only'],+ },+ {+ select(data) {+ return data.result[0]?.default_transaction_read_only === 'on'+ },+ enabled: typeof projectRef !== 'undefined' && typeof connectionString !== 'undefined',+ retry: (failureCount) => {+ return failureCount < 3+ },+ ...options,+ }+ )diff --git a/studio/data/config/project-temp-disable-read-only-mutation.ts b/studio/data/config/project-temp-disable-read-only-mutation.tsdeleted file mode 100644index 769fce31388..00000000000--- a/studio/data/config/project-temp-disable-read-only-mutation.ts+++ /dev/null@@ -1,49 +0,0 @@-import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'-import { toast } from 'react-hot-toast'--import { post } from 'data/fetchers'-import { usageKeys } from 'data/usage/keys'-import { ResponseError } from 'types'--export type TempDisableReadOnlyModeVariables = {- projectRef: string-}--export async function tempDisableReadOnlyMode({ projectRef }: TempDisableReadOnlyModeVariables) {- const { data, error } = await post('/v1/projects/{ref}/readonly/temporary-disable', {- params: { path: { ref: projectRef } },- })-- if (error) throw error- return data-}--type DisableReadOnlyModeData = Awaited<ReturnType<typeof tempDisableReadOnlyMode>>--export const useDisableReadOnlyModeMutation = ({- onSuccess,- onError,- ...options-}: Omit<- UseMutationOptions<DisableReadOnlyModeData, ResponseError, TempDisableReadOnlyModeVariables>,- 'mutationFn'-> = {}) => {- const queryClient = useQueryClient()- return useMutation<DisableReadOnlyModeData, ResponseError, TempDisableReadOnlyModeVariables>(- (vars) => tempDisableReadOnlyMode(vars),- {- async onSuccess(data, variables, context) {- setTimeout(() => queryClient.invalidateQueries(usageKeys.resourceWarnings()), 2000)- await onSuccess?.(data, variables, context)- },- async onError(data, variables, context) {- if (onError === undefined) {- toast.error(`Failed to disable read only mode: ${data.message}`)- } else {- onError(data, variables, context)- }- },- ...options,- }- )-}diff --git a/studio/data/oauth/oauth-app-create-mutation.ts b/studio/data/oauth/oauth-app-create-mutation.tsindex a2241701781..21fb099ff1d 100644--- a/studio/data/oauth/oauth-app-create-mutation.ts+++ b/studio/data/oauth/oauth-app-create-mutation.ts@@ -1,18 +1,16 @@-import { OAuthScope } from '@supabase/shared-types/out/constants'-import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'import { toast } from 'react-hot-toast'+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'import { post } from 'lib/common/fetch'import { API_ADMIN_URL } from 'lib/constants'-import { ResponseError } from 'types'import { oauthAppKeys } from './keys'+import { ResponseError } from 'types'export type OAuthAppCreateVariables = {slug: stringname: stringwebsite: stringicon?: string- scopes?: OAuthScope[]redirect_uris: string[]}@@ -27,14 +25,12 @@ export async function createOAuthApp({name,website,icon,- scopes,redirect_uris,}: OAuthAppCreateVariables) {const response = await post(`${API_ADMIN_URL}/organizations/${slug}/oauth/apps`, {name,website,icon,- scopes,redirect_uris,})if (response.error) throw response.errordiff --git a/studio/data/oauth/oauth-app-update-mutation.ts b/studio/data/oauth/oauth-app-update-mutation.tsindex 4e53c1e1367..453b0647e08 100644--- a/studio/data/oauth/oauth-app-update-mutation.ts+++ b/studio/data/oauth/oauth-app-update-mutation.ts@@ -1,4 +1,3 @@-import { OAuthScope } from '@supabase/shared-types/out/constants'import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'import { toast } from 'react-hot-toast'@@ -13,7 +12,6 @@ export type OAuthAppUpdateVariables = {name: stringwebsite: stringicon?: string | null- scopes?: OAuthScope[]redirect_uris: string[]}@@ -23,7 +21,6 @@ export async function updateOAuthApp({name,website,icon,- scopes,redirect_uris,}: OAuthAppUpdateVariables) {if (!id) throw new Error('OAuth app ID is required')@@ -36,7 +33,6 @@ export async function updateOAuthApp({name,website,icon,- scopes,redirect_uris,})if (response.error) throw response.errordiff --git a/studio/data/oauth/oauth-apps-query.ts b/studio/data/oauth/oauth-apps-query.tsindex 78247b54dd1..5dc6a229ce1 100644--- a/studio/data/oauth/oauth-apps-query.ts+++ b/studio/data/oauth/oauth-apps-query.ts@@ -1,10 +1,9 @@-import { OAuthScope } from '@supabase/shared-types/out/constants'import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'import { get } from 'lib/common/fetch'import { API_ADMIN_URL } from 'lib/constants'import { useCallback } from 'react'-import { ResponseError } from 'types'import { oauthAppKeys } from './keys'+import { ResponseError } from 'types'export type OAuthAppsVariables = {slug?: string@@ -18,7 +17,6 @@ export type OAuthApp = {created_at: stringname: stringwebsite: string- scopes: OAuthScope[]redirect_uris: string[]}diff --git a/studio/package.json b/studio/package.jsonindex 6a475825b79..af246b8ca65 100644--- a/studio/package.json+++ b/studio/package.json@@ -7,6 +7,7 @@"dev:secrets:pull": "AWS_PROFILE=supabase-dev node internals/getSecrets.js","build": "next build","start": "next start",+ "test": "jest","lint": "next lint","deploy:staging": "VERCEL_ORG_ID=team_E6KJ1W561hMTjon1QSwOh0WO VERCEL_PROJECT_ID=QmcmhbiAtCMFTAHCuGgQscNbke4TzgWULECctNcKmxWCoT vercel --prod -A .vercel/staging.json","typecheck": "tsc --noEmit",@@ -35,7 +36,7 @@"@supabase/auth-helpers-nextjs": "^0.5.6","@supabase/auth-helpers-react": "^0.3.1","@supabase/react-data-grid": "^7.1.0-beta.7",- "@supabase/shared-types": "0.1.51",+ "@supabase/shared-types": "0.1.47","@supabase/supabase-js": "^2.23.0","@tanstack/react-query": "^4.22.0","@tanstack/react-query-devtools": "^4.22.0",diff --git a/studio/pages/authorize.tsx b/studio/pages/authorize.tsxindex 6183ac81c1d..a6b134030f6 100644--- a/studio/pages/authorize.tsx+++ b/studio/pages/authorize.tsx@@ -158,13 +158,12 @@ const APIAuthorizationPage: NextPageWithLayout = () => {</div>}>- <div className="w-full px-8 py-6 space-y-8">+ <div className="w-full md:w-[500px] px-8 py-6 space-y-8">{/* API Authorization requester details */}<AuthorizeRequesterDetailsicon={requester.icon}name={requester.name}domain={requester.domain}- scopes={requester.scopes}/>{/* Expiry warning */}