Skip to content

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

chore: move WizardLayout to getLayout

Alaister Young66477417e5f9
diff --git a/studio/components/layouts/WizardLayout.tsx b/studio/components/layouts/WizardLayout.tsx
index e6ef990668e..e98105b1e33 100644
--- a/studio/components/layouts/WizardLayout.tsx
+++ b/studio/components/layouts/WizardLayout.tsx
@@ -1,35 +1,40 @@
import { FC } from 'react'
import Link from 'next/link'
import { IconChevronRight } from '@supabase/ui'
+import { withAuth } from 'hooks'
+import { observer } from 'mobx-react-lite'
const WizardLayout: FC<any> = ({ organization, project, children }) => {
return (
- <div className="flex flex-col h-full w-full">
+ <div className="flex h-full w-full flex-col">
<Header organization={organization} project={project} />
<div className="overflow-auto">
- <section className="mx-auto max-w-2xl relative my-10 has-slide-in slide-in">
+ <section className="has-slide-in slide-in relative mx-auto my-10 max-w-2xl">
{children}
</section>
</div>
</div>
)
}
-export default WizardLayout
+
+export default withAuth(observer(WizardLayout))
+
+export const WizardLayoutWithoutAuth = observer(WizardLayout)
const Header: FC<any> = ({ organization, project }) => {
let stepNumber = organization ? 1 : project ? 2 : 0
return (
- <div className="p-3 border-b dark:border-dark">
+ <div className="dark:border-dark border-b p-3">
<div className="PageHeader">
<div className="Breadcrumbs flex justify-between">
- <div className="text-sm flex items-center">
- <div className="space-x-2 flex items-center">
+ <div className="flex items-center text-sm">
+ <div className="flex items-center space-x-2">
<Link href="/">
<a>
<img
src="/img/supabase-logo.svg"
alt="Supabase"
- className="border dark:border-dark rounded p-1 hover:border-white"
+ className="dark:border-dark rounded border p-1 hover:border-white"
style={{ height: 24 }}
/>
</a>
diff --git a/studio/components/layouts/index.ts b/studio/components/layouts/index.ts
index 5a34f422f14..59a8f7cc1d3 100644
--- a/studio/components/layouts/index.ts
+++ b/studio/components/layouts/index.ts
@@ -9,6 +9,7 @@ import StorageLayout from './StorageLayout/StorageLayout'
import AccountLayout from './AccountLayout/AccountLayout'
import { AccountLayoutWithoutAuth } from './AccountLayout/AccountLayout'
import WizardLayout from './WizardLayout'
+import { WizardLayoutWithoutAuth } from './WizardLayout'
import VercelIntegrationLayout from './VercelIntegrationLayout'
import BillingLayout from './BillingLayout'
import LogsExplorerLayout from './LogsExplorerLayout/LogsExplorerLayout'
@@ -24,6 +25,7 @@ export {
AccountLayout,
AccountLayoutWithoutAuth,
WizardLayout,
+ WizardLayoutWithoutAuth,
VercelIntegrationLayout,
BillingLayout,
LogsExplorerLayout,
diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsx
index b8d9107377c..27bc4101257 100644
--- a/studio/pages/new/[slug].tsx
+++ b/studio/pages/new/[slug].tsx
@@ -25,11 +25,12 @@ import {
} from 'lib/constants'
import { useStore, withAuth, useSubscriptionStats } from 'hooks'
-import { WizardLayout } from 'components/layouts'
+import { WizardLayoutWithoutAuth } from 'components/layouts'
import Panel from 'components/to-be-cleaned/Panel'
import InformationBox from 'components/ui/InformationBox'
import PasswordStrengthBar from 'components/ui/PasswordStrengthBar'
import { AddNewPaymentMethodModal } from 'components/interfaces/Billing'
+import { NextPageWithLayout } from 'types'
interface StripeCustomer {
paymentMethods: any
@@ -49,13 +50,7 @@ async function fetchStripeAccount(stripeCustomerId: string) {
}
}
-export const PageLayout = () => {
- return <Wizard />
-}
-
-export default withAuth(observer(PageLayout))
-
-export const Wizard = observer(() => {
+const Wizard: NextPageWithLayout = () => {
const router = useRouter()
const { slug } = router.query
const { app, ui } = useStore()
@@ -194,181 +189,200 @@ export const Wizard = observer(() => {
}
return (
- <WizardLayout organization={currentOrg} project={null}>
- <Panel
- hideHeaderStyling
- isLoading={app.organizations.isInitialized}
- title={
- <div key="panel-title">
- <h3>Create a new project</h3>
- </div>
- }
- footer={
- <div key="panel-footer" className="flex items-center w-full justify-between">
- <Button type="default" onClick={() => Router.push('/')}>
- Cancel
+ <Panel
+ hideHeaderStyling
+ isLoading={app.organizations.isInitialized}
+ title={
+ <div key="panel-title">
+ <h3>Create a new project</h3>
+ </div>
+ }
+ footer={
+ <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">
+ <span className="text-scale-900 text-xs">You can rename your project later</span>
+ <Button
+ onClick={onClickNext}
+ loading={newProjectedLoading}
+ disabled={newProjectedLoading || !canSubmit}
+ >
+ Create new project
</Button>
- <div className="space-x-3 items-center">
- <span className="text-scale-900 text-xs">You can rename your project later</span>
- <Button
- onClick={onClickNext}
- loading={newProjectedLoading}
- disabled={newProjectedLoading || !canSubmit}
- >
- Create new project
- </Button>
- </div>
</div>
- }
- >
- <>
- <Panel.Content className="pt-0 pb-6">
- <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.
- <br />
- </p>
- </Panel.Content>
+ </div>
+ }
+ >
+ <>
+ <Panel.Content className="pt-0 pb-6">
+ <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.
+ <br />
+ </p>
+ </Panel.Content>
+
+ <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-b border-t">
+ {organizations.length > 0 && (
+ <Listbox
+ label="Organization"
+ layout="horizontal"
+ value={currentOrg?.slug}
+ onChange={(slug) => router.push(`/new/${slug}`)}
+ >
+ {organizations.map((x: any) => (
+ <Listbox.Option
+ key={x.id}
+ label={x.name}
+ value={x.slug}
+ addOnBefore={() => <IconUsers />}
+ >
+ {x.name}
+ </Listbox.Option>
+ ))}
+ </Listbox>
+ )}
- <Panel.Content className="Form section-block--body has-inputs-centered border-b border-t border-panel-border-interior-light dark:border-panel-border-interior-dark space-y-4">
- {organizations.length > 0 && (
- <Listbox
- label="Organization"
- layout="horizontal"
- value={currentOrg?.slug}
- onChange={(slug) => router.push(`/new/${slug}`)}
- >
- {organizations.map((x: any) => (
- <Listbox.Option
- key={x.id}
- label={x.name}
- value={x.slug}
- addOnBefore={() => <IconUsers />}
- >
- {x.name}
- </Listbox.Option>
- ))}
- </Listbox>
- )}
+ {!isOrganizationOwner && <NotOrganizationOwnerWarning />}
+ </Panel.Content>
- {!isOrganizationOwner && <NotOrganizationOwnerWarning />}
- </Panel.Content>
+ {canCreateProject && (
+ <>
+ <Panel.Content className="Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark border-b border-t">
+ <Input
+ id="project-name"
+ layout="horizontal"
+ label="Name"
+ type="text"
+ placeholder="Project name"
+ value={projectName}
+ onChange={onProjectNameChange}
+ autoFocus
+ />
+ </Panel.Content>
- {canCreateProject && (
- <>
- <Panel.Content className="Form section-block--body has-inputs-centered border-b border-t border-panel-border-interior-light dark:border-panel-border-interior-dark">
- <Input
- id="project-name"
- layout="horizontal"
- label="Name"
- type="text"
- placeholder="Project name"
- value={projectName}
- onChange={onProjectNameChange}
- autoFocus
- />
- </Panel.Content>
-
- <Panel.Content className="Form section-block--body has-inputs-centered border-b border-panel-border-interior-light dark:border-panel-border-interior-dark">
- <Input
- id="password"
- layout="horizontal"
- label="Database Password"
- type="password"
- placeholder="Type in a strong password"
- value={dbPass}
- onChange={onDbPassChange}
- descriptionText={
- <PasswordStrengthBar
- passwordStrengthScore={passwordStrengthScore}
- password={dbPass}
- passwordStrengthMessage={passwordStrengthMessage}
- />
- }
- error={passwordStrengthWarning}
- />
- </Panel.Content>
-
- <Panel.Content className="Form section-block--body has-inputs-centered border-b border-panel-border-interior-light dark:border-panel-border-interior-dark">
- <Listbox
- layout="horizontal"
- label="Region"
- type="select"
- value={dbRegion}
- // @ts-ignore
- onChange={(value: string) => onDbRegionChange(value)}
- descriptionText="Select a region close to you for the best performance."
- >
- {Object.keys(REGIONS).map((option: string, i) => {
- const label = Object.values(REGIONS)[i]
- return (
- <Listbox.Option
- key={option}
- label={label}
- value={label}
- addOnBefore={({ active, selected }: any) => (
- <img
- className="w-5 rounded-sm"
- src={`/img/regions/${Object.keys(REGIONS)[i]}.svg`}
- />
- )}
- >
- <span className="text-scale-1200">{label}</span>
- </Listbox.Option>
- )
- })}
- </Listbox>
- </Panel.Content>
- </>
- )}
+ <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"
+ layout="horizontal"
+ label="Database Password"
+ type="password"
+ placeholder="Type in a strong password"
+ value={dbPass}
+ onChange={onDbPassChange}
+ descriptionText={
+ <PasswordStrengthBar
+ passwordStrengthScore={passwordStrengthScore}
+ password={dbPass}
+ passwordStrengthMessage={passwordStrengthMessage}
+ />
+ }
+ error={passwordStrengthWarning}
+ />
+ </Panel.Content>
- {currentOrg?.is_owner && (
- <Panel.Content className="Form section-block--body has-inputs-centered ">
+ <Panel.Content className="Form section-block--body has-inputs-centered border-panel-border-interior-light dark:border-panel-border-interior-dark border-b">
<Listbox
- label="Pricing Plan"
layout="horizontal"
- value={dbPricingTierKey}
+ label="Region"
+ type="select"
+ value={dbRegion}
// @ts-ignore
- onChange={onDbPricingPlanChange}
- // @ts-ignore
- descriptionText={
- <>
- Select a plan that suits your needs.&nbsp;
- <a className="underline" target="_blank" href="https://supabase.com/pricing">
- More details
- </a>
- </>
- }
+ onChange={(value: string) => onDbRegionChange(value)}
+ descriptionText="Select a region close to you for the best performance."
>
- {Object.entries(PRICING_TIER_LABELS).map(([k, v]) => (
- <Listbox.Option key={k} label={v} value={k}>
- {`${v}${k === 'PRO' ? ' - $25/month' : ''}`}
- </Listbox.Option>
- ))}
+ {Object.keys(REGIONS).map((option: string, i) => {
+ const label = Object.values(REGIONS)[i]
+ return (
+ <Listbox.Option
+ key={option}
+ label={label}
+ value={label}
+ addOnBefore={({ active, selected }: any) => (
+ <img
+ className="w-5 rounded-sm"
+ src={`/img/regions/${Object.keys(REGIONS)[i]}.svg`}
+ />
+ )}
+ >
+ <span className="text-scale-1200">{label}</span>
+ </Listbox.Option>
+ )
+ })}
</Listbox>
-
- {isSelectFreeTier && isOverFreeProjectLimit && (
- <FreeProjectLimitWarning limit={freeProjectsLimit} />
- )}
- {!isSelectFreeTier && isEmptyPaymentMethod && (
- <EmptyPaymentMethodWarning stripeCustomerId={stripeCustomerId} />
- )}
</Panel.Content>
- )}
+ </>
+ )}
+
+ {currentOrg?.is_owner && (
+ <Panel.Content className="Form section-block--body has-inputs-centered ">
+ <Listbox
+ label="Pricing Plan"
+ layout="horizontal"
+ value={dbPricingTierKey}
+ // @ts-ignore
+ onChange={onDbPricingPlanChange}
+ // @ts-ignore
+ descriptionText={
+ <>
+ Select a plan that suits your needs.&nbsp;
+ <a className="underline" target="_blank" href="https://supabase.com/pricing">
+ More details
+ </a>
+ </>
+ }
+ >
+ {Object.entries(PRICING_TIER_LABELS).map(([k, v]) => (
+ <Listbox.Option key={k} label={v} value={k}>
+ {`${v}${k === 'PRO' ? ' - $25/month' : ''}`}
+ </Listbox.Option>
+ ))}
+ </Listbox>
+
+ {isSelectFreeTier && isOverFreeProjectLimit && (
+ <FreeProjectLimitWarning limit={freeProjectsLimit} />
+ )}
+ {!isSelectFreeTier && isEmptyPaymentMethod && (
+ <EmptyPaymentMethodWarning stripeCustomerId={stripeCustomerId} />
+ )}
+ </Panel.Content>
+ )}
- {subscriptionStats.isLoading && (
- <Panel.Content>
- <div className="py-10 flex items-center justify-center">
- <IconLoader size={16} className="animate-spin" />
- </div>
- </Panel.Content>
- )}
- </>
- </Panel>
- </WizardLayout>
+ {subscriptionStats.isLoading && (
+ <Panel.Content>
+ <div className="flex items-center justify-center py-10">
+ <IconLoader size={16} className="animate-spin" />
+ </div>
+ </Panel.Content>
+ )}
+ </>
+ </Panel>
)
-})
+}
+
+const PageLayout = withAuth(
+ observer(({ children }) => {
+ const router = useRouter()
+ const { slug } = router.query
+
+ const { app } = useStore()
+ const organizations = values(toJS(app.organizations.list()))
+ const currentOrg = organizations.find((o: any) => o.slug === slug)
+
+ return (
+ <WizardLayoutWithoutAuth organization={currentOrg} project={null}>
+ {children}
+ </WizardLayoutWithoutAuth>
+ )
+ })
+)
+
+Wizard.getLayout = (page) => <PageLayout>{page}</PageLayout>
+
+export default observer(Wizard)
const NotOrganizationOwnerWarning = () => {
return (
diff --git a/studio/pages/new/index.tsx b/studio/pages/new/index.tsx
index fc83795e56c..0c3675d85be 100644
--- a/studio/pages/new/index.tsx
+++ b/studio/pages/new/index.tsx
@@ -1,18 +1,19 @@
import { useState } from 'react'
import { observer } from 'mobx-react-lite'
-import { Button, Input, Typography } from '@supabase/ui'
+import { Button, Input } from '@supabase/ui'
import { useRouter } from 'next/router'
import { API_URL } from 'lib/constants'
-import { useStore, withAuth } from 'hooks'
+import { useStore } from 'hooks'
import { post } from 'lib/common/fetch'
import { WizardLayout } from 'components/layouts'
import Panel from 'components/to-be-cleaned/Panel'
+import { NextPageWithLayout } from 'types'
/**
* No org selected yet, create a new one
*/
-const Wizard = () => {
+const Wizard: NextPageWithLayout = () => {
const { ui, app } = useStore()
const router = useRouter()
@@ -55,49 +56,53 @@ const Wizard = () => {
}
return (
- <WizardLayout organization={null} project={null}>
- <Panel
- hideHeaderStyling
- title={[
- <div key="panel-title">
- <h4>Create a new organization</h4>
- </div>,
- ]}
- footer={[
- <div key="panel-footer" className="flex items-center w-full justify-between">
- <Button type="default" onClick={() => router.push('/')}>
- Cancel
+ <Panel
+ hideHeaderStyling
+ title={[
+ <div key="panel-title">
+ <h4>Create a new organization</h4>
+ </div>,
+ ]}
+ footer={[
+ <div key="panel-footer" className="flex w-full items-center justify-between">
+ <Button type="default" onClick={() => router.push('/')}>
+ Cancel
+ </Button>
+ <div className="flex items-center space-x-3">
+ <p className="text-scale-900 text-xs">You can rename your organization later</p>
+ <Button onClick={onClickSubmit} loading={newOrgLoading} disabled={newOrgLoading}>
+ Create organization
</Button>
- <div className="flex items-center space-x-3">
- <p className="text-xs text-scale-900">You can rename your organization later</p>
- <Button onClick={onClickSubmit} loading={newOrgLoading} disabled={newOrgLoading}>
- Create organization
- </Button>
- </div>
- </div>,
- ]}
- >
- <Panel.Content className="pt-0">
- <p className="text-sm">This is your organization's name within Supabase.</p>
- <p className="text-sm text-scale-1100">
- For example, you can use the name of your company or department
- </p>
- </Panel.Content>
- <Panel.Content className="Form section-block--body has-inputs-centered">
- <Input
- autoFocus
- label="Name"
- type="text"
- layout="horizontal"
- placeholder="Organization name"
- descriptionText="What's the name of your company or team?"
- value={orgName}
- onChange={onOrgNameChange}
- />
- </Panel.Content>
- </Panel>
- </WizardLayout>
+ </div>
+ </div>,
+ ]}
+ >
+ <Panel.Content className="pt-0">
+ <p className="text-sm">This is your organization's name within Supabase.</p>
+ <p className="text-scale-1100 text-sm">
+ For example, you can use the name of your company or department
+ </p>
+ </Panel.Content>
+ <Panel.Content className="Form section-block--body has-inputs-centered">
+ <Input
+ autoFocus
+ label="Name"
+ type="text"
+ layout="horizontal"
+ placeholder="Organization name"
+ descriptionText="What's the name of your company or team?"
+ value={orgName}
+ onChange={onOrgNameChange}
+ />
+ </Panel.Content>
+ </Panel>
)
}
-export default withAuth(observer(Wizard))
+Wizard.getLayout = (page) => (
+ <WizardLayout organization={null} project={null}>
+ {page}
+ </WizardLayout>
+)
+
+export default observer(Wizard)