Skip to content

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

Fix build error

Joshen Limc600294d526c
diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsx
index c58cdb1ed7b..042eddb1a23 100644
--- a/studio/pages/new/[slug].tsx
+++ b/studio/pages/new/[slug].tsx
@@ -7,6 +7,7 @@ import { useRef, useState, useEffect } from 'react'
import { debounce, isUndefined, values } from 'lodash'
import { toJS } from 'mobx'
import { observer } from 'mobx-react-lite'
+import generator from 'generate-password'
import { Button, Listbox, IconUsers, Input, IconLoader, Alert } from '@supabase/ui'
import { NextPageWithLayout } from 'types'
@@ -35,7 +36,6 @@ import {
NotOrganizationOwnerWarning,
EmptyPaymentMethodWarning,
} from 'components/interfaces/Organization/NewProject'
-import generator from 'generate-password';
interface StripeCustomer {
paymentMethods: any
@@ -194,12 +194,14 @@ const Wizard: NextPageWithLayout = () => {
}
}
+ // [Joshen] Refactor: DB Password could be a common component
+ // used in multiple pages with repeated logic
function generateStrongPassword() {
const password = generator.generate({
length: 16,
numbers: true,
- uppercase: true
- });
+ uppercase: true,
+ })
setDbPass(password)
delayedCheckPasswordStrength(password)
@@ -215,13 +217,13 @@ const Wizard: NextPageWithLayout = () => {
</div>
}
footer={
- <div key="panel-footer" className="flex items-center justify-between w-full">
+ <div key="panel-footer" className="flex w-full items-center justify-between">
<Button type="default" onClick={() => Router.push('/')}>
Cancel
</Button>
<div className="items-center space-x-3">
{!projectCreationDisabled && (
- <span className="text-xs text-scale-900">You can rename your project later</span>
+ <span className="text-scale-900 text-xs">You can rename your project later</span>
)}
<Button
onClick={onClickNext}
@@ -236,7 +238,7 @@ const Wizard: NextPageWithLayout = () => {
>
<>
<Panel.Content className="pt-0 pb-6">
- <p className="text-sm text-scale-900">
+ <p className="text-scale-900 text-sm">
Your project will have its own dedicated instance and full postgres database.
<br />
An API will be set up so you can easily interact with your new database.
@@ -244,12 +246,12 @@ const Wizard: NextPageWithLayout = () => {
</p>
</Panel.Content>
{projectCreationDisabled ? (
- <Panel.Content className="pb-8 border-t border-panel-border-interior-light dark:border-panel-border-interior-dark">
+ <Panel.Content className="border-panel-border-interior-light dark:border-panel-border-interior-dark border-t pb-8">
<DisabledWarningDueToIncident title="Project creation is currently disabled" />
</Panel.Content>
) : (
<>
- <Panel.Content className="space-y-4 border-t border-b Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark">
+ <Panel.Content className="Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark space-y-4 border-t border-b">
{organizations.length > 0 && (
<Listbox
label="Organization"
@@ -274,7 +276,7 @@ const Wizard: NextPageWithLayout = () => {
</Panel.Content>
{canCreateProject && (
<>
- <Panel.Content className="border-t border-b Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark">
+ <Panel.Content className="Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark border-t border-b">
<Input
id="project-name"
layout="horizontal"
@@ -287,7 +289,7 @@ const Wizard: NextPageWithLayout = () => {
/>
</Panel.Content>
- <Panel.Content className="border-b Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark">
+ <Panel.Content className="Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark border-b">
<Input
id="password"
copy={dbPass.length > 0}
@@ -309,7 +311,7 @@ const Wizard: NextPageWithLayout = () => {
/>
</Panel.Content>
- <Panel.Content className="border-b Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark">
+ <Panel.Content className="Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark border-b">
<Listbox
layout="horizontal"
label="Region"
diff --git a/studio/pages/project/[ref]/settings/database.tsx b/studio/pages/project/[ref]/settings/database.tsx
index 0e9a380788d..5a399d3b345 100644
--- a/studio/pages/project/[ref]/settings/database.tsx
+++ b/studio/pages/project/[ref]/settings/database.tsx
@@ -5,6 +5,7 @@ import { toJS } from 'mobx'
import { observer } from 'mobx-react-lite'
import { useRouter } from 'next/router'
import { debounce } from 'lodash'
+import generator from 'generate-password'
import { Typography, Input, Button, IconDownload, IconArrowRight, Tabs, Modal } from '@supabase/ui'
import { useStore } from 'hooks'
@@ -201,6 +202,17 @@ const ResetDbPassword: FC<any> = () => {
}
}
+ function generateStrongPassword() {
+ const password = generator.generate({
+ length: 16,
+ numbers: true,
+ uppercase: true,
+ })
+
+ setPassword(password)
+ delayedCheckPasswordStrength(password)
+ }
+
return (
<>
<Panel>
@@ -244,6 +256,7 @@ const ResetDbPassword: FC<any> = () => {
passwordStrengthScore={passwordStrengthScore}
passwordStrengthMessage={passwordStrengthMessage}
password={password}
+ generateStrongPassword={generateStrongPassword}
/>
}
/>
@@ -327,7 +340,7 @@ const GeneralSettings: FC<any> = ({ projectRef }) => {
const DB_FIELDS = ['db_host', 'db_name', 'db_port', 'db_user', 'inserted_at']
const connectionInfo = pluckObjectFields(formModel, DB_FIELDS)
-const uriConnString =
+ const uriConnString =
`postgresql://${connectionInfo.db_user}:[YOUR-PASSWORD]@` +
`${connectionInfo.db_host}:${connectionInfo.db_port.toString()}` +
`/${connectionInfo.db_name}`
diff --git a/studio/pages/vercel/setupProject.tsx b/studio/pages/vercel/setupProject.tsx
index 3c0a13b3ada..f467f88e2aa 100644
--- a/studio/pages/vercel/setupProject.tsx
+++ b/studio/pages/vercel/setupProject.tsx
@@ -6,6 +6,7 @@ import { makeAutoObservable } from 'mobx'
import { debounce } from 'lodash'
import { Button, Input, Listbox, Typography } from '@supabase/ui'
import { Dictionary } from 'components/grid'
+import generator from 'generate-password'
import { useStore } from 'hooks'
import { post } from 'lib/common/fetch'
@@ -136,8 +137,8 @@ const SetupProject = () => {
export default observer(SetupProject)
const Connecting = () => (
- <div className="w-full h-full flex flex-col items-center justify-center">
- <div className="w-32 flex items-center justify-center">
+ <div className="flex h-full w-full flex-col items-center justify-center">
+ <div className="flex w-32 items-center justify-center">
<Loading />
</div>
<Typography.Text>
@@ -190,6 +191,17 @@ const CreateProject = observer(() => {
setPasswordStrengthMessage(message)
}
+ function generateStrongPassword() {
+ const password = generator.generate({
+ length: 16,
+ numbers: true,
+ uppercase: true,
+ })
+
+ setDbPass(password)
+ delayedCheckPasswordStrength(password)
+ }
+
async function createSupabaseProject(dbSql: string) {
const data = {
cloud_provider: PROVIDERS.AWS.id, // hardcoded for DB instances to be under AWS
@@ -281,6 +293,7 @@ const CreateProject = observer(() => {
passwordStrengthScore={passwordStrengthScore}
password={dbPass}
passwordStrengthMessage={passwordStrengthMessage}
+ generateStrongPassword={generateStrongPassword}
/>
}
/>