Skip to content

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

Auth Settings IA Update - Sign In / Up (#33579)

Joshen Lim32a042379ef5
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthAlert.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthAlert.tsx
new file mode 100644
index 00000000000..3679b94fb56
--- /dev/null
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthAlert.tsx
@@ -0,0 +1,64 @@
+import { ExternalLink } from 'lucide-react'
+import Link from 'next/link'
+
+import { useParams } from 'common'
+import {
+ Alert_Shadcn_,
+ AlertDescription_Shadcn_,
+ AlertTitle_Shadcn_,
+ Button,
+ WarningIcon,
+} from 'ui'
+
+export const AuthAlert = ({
+ title,
+ isHookSendSMSEnabled,
+}: {
+ title: string
+ isHookSendSMSEnabled: boolean
+}) => {
+ const { ref } = useParams()
+
+ switch (title) {
+ // TODO (KM): Remove after 10th October 2024 when we disable the provider
+ case 'Slack (Deprecated)':
+ return (
+ <Alert_Shadcn_ variant="warning">
+ <WarningIcon />
+ <AlertTitle_Shadcn_>Slack (Deprecated) Provider</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ Recently, Slack has updated their OAuth API. Please use the new Slack (OIDC) provider
+ below. Developers using this provider should move over to the new provider. Please refer
+ to our{' '}
+ <a
+ href="https://supabase.com/docs/guides/auth/social-login/auth-slack"
+ className="underline"
+ target="_blank"
+ >
+ documentation
+ </a>{' '}
+ for more details.
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )
+ case 'Phone':
+ return (
+ isHookSendSMSEnabled && (
+ <Alert_Shadcn_>
+ <WarningIcon />
+ <AlertTitle_Shadcn_>
+ SMS provider settings are disabled while the SMS hook is enabled.
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_ className="flex flex-col gap-y-3">
+ <p>The SMS hook will be used in place of the SMS provider configured</p>
+ <Button asChild type="default" className="w-min" icon={<ExternalLink />}>
+ <Link href={`/project/${ref}/auth/hooks`}>View auth hooks</Link>
+ </Button>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )
+ )
+ default:
+ return null
+ }
+}
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx
index 0c8cc9031d7..292497680b3 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx
@@ -2,21 +2,26 @@ import { ExternalLink } from 'lucide-react'
import Link from 'next/link'
import { useParams } from 'common'
-import { FormHeader } from 'components/ui/Forms/FormHeader'
+import {
+ ScaffoldSection,
+ ScaffoldSectionDescription,
+ ScaffoldSectionTitle,
+} from 'components/layouts/Scaffold'
+import { ResourceList } from 'components/ui/Resource/ResourceList'
import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers/Shimmers'
import { useAuthConfigQuery } from 'data/auth/auth-config-query'
import {
+ Alert_Shadcn_,
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
- Alert_Shadcn_,
Button,
WarningIcon,
} from 'ui'
import { getPhoneProviderValidationSchema, PROVIDERS_SCHEMAS } from '../AuthProvidersFormValidation'
-import { ProviderCollapsibleClasses } from './AuthProvidersForm.constants'
-import ProviderForm from './ProviderForm'
+import type { Provider } from './AuthProvidersForm.types'
+import { ProviderForm } from './ProviderForm'
-const AuthProvidersForm = () => {
+export const AuthProvidersForm = () => {
const { ref: projectRef } = useParams()
const {
isLoading,
@@ -27,11 +32,11 @@ const AuthProvidersForm = () => {
} = useAuthConfigQuery({ projectRef })
return (
- <div>
- <FormHeader
- title="Auth Providers"
- description="Authenticate your users through a suite of providers and login methods"
- />
+ <ScaffoldSection isFullWidth>
+ <ScaffoldSectionTitle>Auth Providers</ScaffoldSectionTitle>
+ <ScaffoldSectionDescription className="mb-4">
+ Authenticate your users through a suite of providers and login methods
+ </ScaffoldSectionDescription>
<div className="-space-y-px">
{authConfig?.EXTERNAL_EMAIL_ENABLED && authConfig?.MAILER_OTP_EXP > 3600 && (
@@ -56,41 +61,54 @@ const AuthProvidersForm = () => {
</div>
</Alert_Shadcn_>
)}
- {isLoading &&
- PROVIDERS_SCHEMAS.map((provider) => {
- return (
+ <ResourceList>
+ {isLoading &&
+ PROVIDERS_SCHEMAS.map((provider) => (
<div
key={`provider_${provider.title}`}
- className={[...ProviderCollapsibleClasses, 'px-6 py-3'].join(' ')}
+ className="py-4 px-6 border-b last:border-b-none"
>
<HorizontalShimmerWithIcon />
</div>
- )
- })}
- {isError && (
- <Alert_Shadcn_ variant="destructive">
- <WarningIcon />
- <AlertTitle_Shadcn_>Failed to retrieve auth configuration</AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>{authConfigError.message}</AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )}
- {isSuccess &&
- PROVIDERS_SCHEMAS.map((provider) => {
- const providerSchema =
- provider.title === 'Phone'
- ? { ...provider, validationSchema: getPhoneProviderValidationSchema(authConfig) }
- : provider
- return (
- <ProviderForm
- key={`provider_${providerSchema.title}`}
- config={authConfig}
- provider={providerSchema as any}
- />
- )
- })}
+ ))}
+ {isSuccess &&
+ PROVIDERS_SCHEMAS.map((provider) => {
+ const providerSchema =
+ provider.title === 'Phone'
+ ? { ...provider, validationSchema: getPhoneProviderValidationSchema(authConfig) }
+ : provider
+ let isActive = false
+ if (providerSchema.title === 'SAML 2.0') {
+ isActive = authConfig && (authConfig as any)['SAML_ENABLED']
+ } else if (providerSchema.title === 'LinkedIn (OIDC)') {
+ isActive = authConfig && (authConfig as any)['EXTERNAL_LINKEDIN_OIDC_ENABLED']
+ } else if (providerSchema.title === 'Slack (OIDC)') {
+ isActive = authConfig && (authConfig as any)['EXTERNAL_SLACK_OIDC_ENABLED']
+ } else {
+ isActive =
+ authConfig &&
+ (authConfig as any)[`EXTERNAL_${providerSchema.title.toUpperCase()}_ENABLED`]
+ }
+ return (
+ <ProviderForm
+ key={`provider_${providerSchema.title}`}
+ config={authConfig!}
+ provider={providerSchema as unknown as Provider}
+ isActive={isActive}
+ />
+ )
+ })}
+ {isError && (
+ <Alert_Shadcn_ variant="destructive">
+ <WarningIcon />
+ <AlertTitle_Shadcn_>Failed to retrieve auth configuration</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ {(authConfigError as any)?.message}
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )}
+ </ResourceList>
</div>
- </div>
+ </ScaffoldSection>
)
}
-
-export default AuthProvidersForm
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
index 1d7910cc620..4149642b55e 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
@@ -1,7 +1,6 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { Check, ChevronUp, ExternalLink } from 'lucide-react'
-import Link from 'next/link'
-import { useEffect, useRef, useState } from 'react'
+import { Check } from 'lucide-react'
+import { useState } from 'react'
import ReactMarkdown from 'react-markdown'
import { toast } from 'sonner'
@@ -9,35 +8,27 @@ import { useParams } from 'common'
import { Markdown } from 'components/interfaces/Markdown'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { DocsButton } from 'components/ui/DocsButton'
+import { ResourceItem } from 'components/ui/Resource/ResourceItem'
import type { components } from 'data/api'
import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { BASE_PATH } from 'lib/constants'
-import {
- Alert_Shadcn_,
- AlertDescription_Shadcn_,
- AlertTitle_Shadcn_,
- Button,
- Collapsible,
- Form,
- Input,
- WarningIcon,
-} from 'ui'
+import { Button, Form, Input, Sheet, SheetContent, SheetFooter, SheetHeader, SheetTitle } from 'ui'
import { Admonition } from 'ui-patterns'
import { NO_REQUIRED_CHARACTERS } from '../Auth.constants'
-import { ProviderCollapsibleClasses } from './AuthProvidersForm.constants'
+import { AuthAlert } from './AuthAlert'
import type { Provider } from './AuthProvidersForm.types'
import FormField from './FormField'
export interface ProviderFormProps {
config: components['schemas']['GoTrueConfigResponse']
provider: Provider
+ isActive: boolean
}
-const ProviderForm = ({ config, provider }: ProviderFormProps) => {
- const ref = useRef<HTMLButtonElement>(null)
+export const ProviderForm = ({ config, provider, isActive }: ProviderFormProps) => {
const [open, setOpen] = useState(false)
const { ref: projectRef, provider: urlProvider } = useParams()
const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation()
@@ -67,51 +58,6 @@ const ProviderForm = ({ config, provider }: ProviderFormProps) => {
)
}
- const showAlert = (title: string) => {
- switch (title) {
- // TODO (KM): Remove after 10th October 2024 when we disable the provider
- case 'Slack (Deprecated)':
- return (
- <Alert_Shadcn_ variant="warning">
- <WarningIcon />
- <AlertTitle_Shadcn_>Slack (Deprecated) Provider</AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- Recently, Slack has updated their OAuth API. Please use the new Slack (OIDC) provider
- below. Developers using this provider should move over to the new provider. Please
- refer to our{' '}
- <a
- href="https://supabase.com/docs/guides/auth/social-login/auth-slack"
- className="underline"
- target="_blank"
- >
- documentation
- </a>{' '}
- for more details.
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )
- case 'Phone':
- return (
- config.HOOK_SEND_SMS_ENABLED && (
- <Alert_Shadcn_>
- <WarningIcon />
- <AlertTitle_Shadcn_>
- SMS provider settings are disabled while the SMS hook is enabled.
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_ className="flex flex-col gap-y-3">
- <p>The SMS hook will be used in place of the SMS provider configured</p>
- <Button asChild type="default" className="w-min" icon={<ExternalLink />}>
- <Link href={`/project/${projectRef}/auth/hooks`}>View auth hooks</Link>
- </Button>
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )
- )
- default:
- return null
- }
- }
-
const { data: settings } = useProjectSettingsV2Query({ projectRef })
const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint
@@ -119,14 +65,10 @@ const ProviderForm = ({ config, provider }: ProviderFormProps) => {
const { data: customDomainData } = useCustomDomainsQuery({ projectRef })
- const generateInitialValues = () => {
+ const INITIAL_VALUES = (() => {
const initialValues: { [x: string]: string | boolean } = {}
-
- // the config is already loaded through the parent component
Object.keys(provider.properties).forEach((key) => {
- // When the key is a 'double negative' key, we must reverse the boolean before adding it to the form
const isDoubleNegative = doubleNegativeKeys.includes(key)
-
if (provider.title === 'SAML 2.0') {
const configValue = (config as any)[key]
initialValues[key] =
@@ -144,33 +86,11 @@ const ProviderForm = ({ config, provider }: ProviderFormProps) => {
}
}
})
-
return initialValues
- }
-
- const isSAMLEnabled: boolean =
- provider.title === 'SAML 2.0' && config && (config as any)['SAML_ENABLED']
- // [Joel] Introduced as the new LinkedIn provider has a corresponding config var of LINKEDIN_OIDC
- const isLinkedInOIDCEnabled: boolean =
- provider.title === 'LinkedIn (OIDC)' &&
- config &&
- (config as any)['EXTERNAL_LINKEDIN_OIDC_ENABLED']
- const isSlackOIDCEnabled =
- provider.title === 'Slack (OIDC)' && config['EXTERNAL_SLACK_OIDC_ENABLED']
- const isExternalProviderAndEnabled: boolean =
- config && (config as any)[`EXTERNAL_${provider?.title?.toUpperCase()}_ENABLED`]
-
- // [Joshen] Doing this check as SAML doesn't follow the same naming structure as the other provider options
- const isActive: boolean =
- isSAMLEnabled || isExternalProviderAndEnabled || isLinkedInOIDCEnabled || isSlackOIDCEnabled
- const INITIAL_VALUES = generateInitialValues()
+ })()
const onSubmit = (values: any, { resetForm }: any) => {
const payload = { ...values }
-
- // Format payload for the following checks:
- // 1. Convert all empty string values to null
- // 2. When the key is a 'double negative' key, we must reverse the boolean before the payload can be sent
Object.keys(values).map((x: string) => {
if (doubleNegativeKeys.includes(x)) payload[x] = !values[x]
if (payload[x] === '') payload[x] = null
@@ -193,154 +113,148 @@ const ProviderForm = ({ config, provider }: ProviderFormProps) => {
)
}
- useEffect(() => {
- if (urlProvider?.toLowerCase() === provider.title.toLowerCase()) {
- setOpen(true)
- ref.current?.scrollIntoView({ behavior: 'smooth', block: 'start' })
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [urlProvider])
-
return (
- <Collapsible
- open={open}
- onOpenChange={setOpen}
- className={ProviderCollapsibleClasses.join(' ')}
- >
- <Collapsible.Trigger asChild>
- <button
- ref={ref}
- type="button"
- className="group flex w-full items-center justify-between rounded py-3 px-4 text-foreground"
- >
- <div className="flex items-center gap-3">
- <ChevronUp
- className="text-border-stronger transition data-open-parent:rotate-0 data-closed-parent:rotate-180"
- strokeWidth={2}
- width={14}
- />
+ <>
+ <ResourceItem
+ onClick={() => setOpen(true)}
+ media={
+ <img
+ src={`${BASE_PATH}/img/icons/${provider.misc.iconKey}.svg`}
+ width={18}
+ height={18}
+ alt={`${provider.title} auth icon`}
+ />
+ }
+ meta={
+ isActive ? (
+ <div className="flex items-center gap-1 rounded-full border border-brand-400 bg-brand-200 py-1 px-1 text-xs text-brand">
+ <span className="rounded-full bg-brand p-0.5 text-xs text-brand-200">
+ <Check strokeWidth={2} size={12} />
+ </span>
+ <span className="px-1">Enabled</span>
+ </div>
+ ) : (
+ <div className="rounded-md border border-strong bg-surface-100 py-1 px-3 text-xs text-foreground-lighter">
+ Disabled
+ </div>
+ )
+ }
+ >
+ {provider.title}
+ </ResourceItem>
+
+ <Sheet open={open} onOpenChange={setOpen}>
+ <SheetContent className="flex flex-col gap-0">
+ <SheetHeader className="shrink-0 flex items-center gap-4">
<img
src={`${BASE_PATH}/img/icons/${provider.misc.iconKey}.svg`}
width={18}
+ height={18}
alt={`${provider.title} auth icon`}
/>
- <span className="text-sm">{provider.title}</span>
- </div>
- <div className="flex items-center gap-3">
- {isActive ? (
- <div className="flex items-center gap-1 rounded-full border border-brand-400 bg-brand-200 py-1 px-1 text-xs text-brand">
- <span className="rounded-full bg-brand p-0.5 text-xs text-brand-200">
- <Check strokeWidth={2} size={12} />
- </span>
- <span className="px-1">Enabled</span>
- </div>
- ) : (
- <div className="rounded-md border border-strong bg-surface-100 py-1 px-3 text-xs text-foreground-lighter">
- Disabled
- </div>
- )}
- </div>
- </button>
- </Collapsible.Trigger>
- <Form
- name={`provider-${provider.title}-form`}
- initialValues={INITIAL_VALUES}
- validationSchema={provider.validationSchema}
- onSubmit={onSubmit}
- >
- {({ handleReset, initialValues, values, setFieldValue }: any) => {
- const noChanges = JSON.stringify(initialValues) === JSON.stringify(values)
- return (
- <Collapsible.Content>
- <div className="group border-t border-strong bg-surface-100 py-6 px-4 md:px-6 text-foreground">
- <div className="mx-auto my-2 md:my-6 max-w-lg space-y-6">
- {showAlert(provider.title)}
- {Object.keys(provider.properties).map((x: string) => (
- <FormField
- key={x}
- name={x}
- setFieldValue={setFieldValue}
- properties={provider.properties[x]}
- formValues={values}
- disabled={
- // TODO (KM): Remove after 10th October 2024 when we disable the provider
- shouldDisableField(x) || !canUpdateConfig
- }
- />
- ))}
+ <SheetTitle>{provider.title}</SheetTitle>
+ </SheetHeader>
+ <Form
+ id={`provider-${provider.title}-form`}
+ name={`provider-${provider.title}-form`}
+ initialValues={INITIAL_VALUES}
+ validationSchema={provider.validationSchema}
+ onSubmit={onSubmit}
+ className="flex-1 overflow-hidden flex flex-col"
+ >
+ {({ handleReset, initialValues, values, setFieldValue }: any) => {
+ const noChanges = JSON.stringify(initialValues) === JSON.stringify(values)
+ return (
+ <>
+ <div className="flex-1 overflow-y-auto group py-6 px-4 md:px-6 text-foreground">
+ <div className="mx-auto max-w-lg space-y-6">
+ <AuthAlert
+ title={provider.title}
+ isHookSendSMSEnabled={config.HOOK_SEND_SMS_ENABLED}
+ />
+ {Object.keys(provider.properties).map((x: string) => (
+ <FormField
+ key={x}
+ name={x}
+ setFieldValue={setFieldValue}
+ properties={provider.properties[x]}
+ formValues={values}
+ disabled={shouldDisableField(x) || !canUpdateConfig}
+ />
+ ))}
- {provider?.misc?.alert && (
- <Admonition
- type="warning"
- title={provider.misc.alert.title}
- description={
- <>
- <ReactMarkdown>{provider.misc.alert.description}</ReactMarkdown>
- </>
- }
- />
- )}
+ {provider?.misc?.alert && (
+ <Admonition
+ type="warning"
+ title={provider.misc.alert.title}
+ description={
+ <>
+ <ReactMarkdown>{provider.misc.alert.description}</ReactMarkdown>
+ </>
+ }
+ />
+ )}
- {provider.misc.requiresRedirect && (
- <>
- <Input
- copy
- readOnly
- disabled
- label="Callback URL (for OAuth)"
- value={
- customDomainData?.customDomain?.status === 'active'
- ? `https://${customDomainData.customDomain?.hostname}/auth/v1/callback`
- : `${apiUrl}/auth/v1/callback`
- }
- descriptionText={
- <Markdown
- content={provider.misc.helper}
- className="text-foreground-lighter"
- />
- }
- />
- </>
- )}
- <div className="flex items-center justify-between">
- <DocsButton href={provider.link} />
- <div className="flex items-center gap-x-3">
- <Button
- type="default"
- htmlType="reset"
- onClick={() => {
- handleReset()
- setOpen(false)
- }}
- disabled={isUpdatingConfig}
- >
- Cancel
- </Button>
- <ButtonTooltip
- htmlType="submit"
- loading={isUpdatingConfig}
- disabled={isUpdatingConfig || !canUpdateConfig || noChanges}
- tooltip={{
- content: {
- side: 'bottom',
- text: !canUpdateConfig
- ? 'You need additional permissions to update provider settings'
- : undefined,
- },
- }}
- >
- Save
- </ButtonTooltip>
+ {provider.misc.requiresRedirect && (
+ <Input
+ copy
+ readOnly
+ disabled
+ label="Callback URL (for OAuth)"
+ value={
+ customDomainData?.customDomain?.status === 'active'
+ ? `https://${customDomainData.customDomain?.hostname}/auth/v1/callback`
+ : `${apiUrl}/auth/v1/callback`
+ }
+ descriptionText={
+ <Markdown
+ content={provider.misc.helper}
+ className="text-foreground-lighter"
+ />
+ }
+ />
+ )}
</div>
</div>
- </div>
- </div>
- </Collapsible.Content>
- )
- }}
- </Form>
- </Collapsible>
+ <SheetFooter className="shrink-0">
+ <div className="flex items-center justify-between w-full">
+ <DocsButton href={provider.link} />
+ <div className="flex items-center gap-x-3">
+ <Button
+ type="default"
+ htmlType="reset"
+ onClick={() => {
+ handleReset()
+ setOpen(false)
+ }}
+ disabled={isUpdatingConfig}
+ >
+ Cancel
+ </Button>
+ <ButtonTooltip
+ htmlType="submit"
+ loading={isUpdatingConfig}
+ disabled={isUpdatingConfig || !canUpdateConfig || noChanges}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: !canUpdateConfig
+ ? 'You need additional permissions to update provider settings'
+ : undefined,
+ },
+ }}
+ >
+ Save
+ </ButtonTooltip>
+ </div>
+ </div>
+ </SheetFooter>
+ </>
+ )
+ }}
+ </Form>
+ </SheetContent>
+ </Sheet>
+ </>
)
}
-
-export default ProviderForm
diff --git a/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx
index 1e1c108669c..e00210e1748 100644
--- a/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx
+++ b/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx
@@ -1,16 +1,15 @@
+import { yupResolver } from '@hookform/resolvers/yup'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { ExternalLink } from 'lucide-react'
import Link from 'next/link'
import { useEffect } from 'react'
+import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import { boolean, object, string } from 'yup'
import { useParams } from 'common'
-import { Markdown } from 'components/interfaces/Markdown'
-import { FormActions } from 'components/ui/Forms/FormActions'
-import { FormHeader } from 'components/ui/Forms/FormHeader'
-import { FormPanel } from 'components/ui/Forms/FormPanel'
-import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'
+import { ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold'
+import { InlineLink } from 'components/ui/InlineLink'
import NoPermission from 'components/ui/NoPermission'
import { useAuthConfigQuery } from 'data/auth/auth-config-query'
import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
@@ -20,10 +19,16 @@ import {
AlertTitle_Shadcn_,
Alert_Shadcn_,
Button,
- Form,
- Toggle,
+ Card,
+ CardContent,
+ CardFooter,
+ FormControl_Shadcn_,
+ FormField_Shadcn_,
+ Form_Shadcn_,
+ Switch,
WarningIcon,
} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { NO_REQUIRED_CHARACTERS } from '../Auth.constants'
const schema = object({
@@ -33,30 +38,36 @@ const schema = object({
SITE_URL: string().required('Must have a Site URL'),
})
-const formId = 'auth-config-basic-settings'
-
const BasicAuthSettingsForm = () => {
const { ref: projectRef } = useParams()
- const {
- data: authConfig,
- error: authConfigError,
- isLoading,
- isError,
- isSuccess,
- } = useAuthConfigQuery({ projectRef })
+ const { data: authConfig, error: authConfigError, isError } = useAuthConfigQuery({ projectRef })
const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation()
const canReadConfig = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')
const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')
- const INITIAL_VALUES = {
- DISABLE_SIGNUP: !authConfig?.DISABLE_SIGNUP,
- EXTERNAL_ANONYMOUS_USERS_ENABLED: authConfig?.EXTERNAL_ANONYMOUS_USERS_ENABLED,
- SECURITY_MANUAL_LINKING_ENABLED: authConfig?.SECURITY_MANUAL_LINKING_ENABLED || false,
- SITE_URL: authConfig?.SITE_URL,
- }
+ const form = useForm({
+ resolver: yupResolver(schema),
+ defaultValues: {
+ DISABLE_SIGNUP: true,
+ EXTERNAL_ANONYMOUS_USERS_ENABLED: false,
+ SECURITY_MANUAL_LINKING_ENABLED: false,
+ SITE_URL: '',
+ },
+ })
+
+ useEffect(() => {
+ if (authConfig) {
+ form.reset({
+ DISABLE_SIGNUP: !authConfig.DISABLE_SIGNUP,
+ EXTERNAL_ANONYMOUS_USERS_ENABLED: authConfig.EXTERNAL_ANONYMOUS_USERS_ENABLED,
+ SECURITY_MANUAL_LINKING_ENABLED: authConfig.SECURITY_MANUAL_LINKING_ENABLED || false,
+ SITE_URL: authConfig.SITE_URL,
+ })
+ }
+ }, [authConfig])
- const onSubmit = (values: any, { resetForm }: any) => {
+ const onSubmit = (values: any) => {
const payload = { ...values }
payload.DISABLE_SIGNUP = !values.DISABLE_SIGNUP
// The backend uses empty string to represent no required characters in the password
@@ -68,11 +79,10 @@ const BasicAuthSettingsForm = () => {
{ projectRef: projectRef!, config: payload },
{
onError: (error) => {
- toast.error(`Failed to update settings: ${error?.message}`)
+ toast.error(`Failed to update settings: ${error?.message}`)
},
onSuccess: () => {
- toast.success(`Successfully updated settings`)
- resetForm({ values: values, initialValues: values })
+ toast.success('Successfully updated settings')
},
}
)
@@ -89,159 +99,183 @@ const BasicAuthSettingsForm = () => {
}
if (!canReadConfig) {
- return <NoPermission resourceText="view auth configuration settings" />
+ return (
+ <div className="mt-8">
+ <NoPermission resourceText="view auth configuration settings" />
+ </div>
+ )
}
return (
- <div>
- <FormHeader title="General" />
+ <ScaffoldSection isFullWidth>
+ <ScaffoldSectionTitle className="mb-4">User Signups</ScaffoldSectionTitle>
- <Form
- id={formId}
- initialValues={INITIAL_VALUES}
- onSubmit={onSubmit}
- validationSchema={schema}
- >
- {({ handleReset, resetForm, values, initialValues, setFieldValue }: any) => {
- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)
- // Form is reset once remote data is loaded in store
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useEffect(() => {
- if (isSuccess) resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })
- }, [isSuccess])
+ <Form_Shadcn_ {...form}>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
+ <Card>
+ <CardContent>
+ <FormField_Shadcn_
+ control={form.control}
+ name="DISABLE_SIGNUP"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Allow new users to sign up"
+ description="If this is disabled, new users will not be able to sign up to your application"
+ >
+ <FormControl_Shadcn_>
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={!canUpdateConfig}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </CardContent>
+ <CardContent>
+ <FormField_Shadcn_
+ control={form.control}
+ name="SECURITY_MANUAL_LINKING_ENABLED"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Allow manual linking"
+ description={
+ <>
+ Enable{' '}
+ <InlineLink
+ className="text-foreground-light hover:text-foreground"
+ href="https://supabase.com/docs/guides/auth/auth-identity-linking#manual-linking-beta"
+ >
+ manual linking APIs
+ </InlineLink>{' '}
+ for your project
+ </>
+ }
+ >
+ <FormControl_Shadcn_>
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={!canUpdateConfig}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </CardContent>
+ <CardContent>
+ <FormField_Shadcn_
+ control={form.control}
+ name="EXTERNAL_ANONYMOUS_USERS_ENABLED"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Allow anonymous sign-ins"
+ description={
+ <>
+ Enable{' '}
+ <InlineLink
+ className="text-foreground-light hover:text-foreground"
+ href="https://supabase.com/docs/guides/auth/auth-anonymous"
+ >
+ anonymous sign-ins
+ </InlineLink>{' '}
+ for your project
+ </>
+ }
+ >
+ <FormControl_Shadcn_>
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={!canUpdateConfig}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
- return (
- <>
- <FormPanel
- disabled={true}
- footer={
- <div className="flex py-4 px-8">
- <FormActions
- form={formId}
- isSubmitting={isUpdatingConfig}
- hasChanges={hasChanges}
- handleReset={handleReset}
- disabled={!canUpdateConfig}
- helper={
- !canUpdateConfig
- ? 'You need additional permissions to update authentication settings'
- : undefined
- }
- />
+ {form.watch('EXTERNAL_ANONYMOUS_USERS_ENABLED') && (
+ <Alert_Shadcn_
+ className="flex w-full items-center justify-between mt-4"
+ variant="warning"
+ >
+ <WarningIcon />
+ <div>
+ <AlertTitle_Shadcn_>
+ Anonymous users will use the <code className="text-xs">authenticated</code>{' '}
+ role when signing in
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_ className="flex flex-col gap-y-3">
+ <p>
+ As a result, anonymous users will be subjected to RLS policies that apply to
+ the <code className="text-xs">public</code> and{' '}
+ <code className="text-xs">authenticated</code> roles. We strongly advise{' '}
+ <Link
+ href={`/project/${projectRef}/auth/policies`}
+ className="text-foreground underline"
+ >
+ reviewing your RLS policies
+ </Link>{' '}
+ to ensure that access to your data is restricted where required.
+ </p>
+ <Button asChild type="default" className="w-min" icon={<ExternalLink />}>
+ <Link href="https://supabase.com/docs/guides/auth/auth-anonymous#access-control">
+ View access control docs
+ </Link>
+ </Button>
+ </AlertDescription_Shadcn_>
</div>
- }
+ </Alert_Shadcn_>
+ )}
+
+ {!authConfig?.SECURITY_CAPTCHA_ENABLED &&
+ form.watch('EXTERNAL_ANONYMOUS_USERS_ENABLED') && (
+ <Alert_Shadcn_ className="mt-4">
+ <WarningIcon />
+ <AlertTitle_Shadcn_>
+ We highly recommend{' '}
+ <span
+ tabIndex={1}
+ className="cursor-pointer underline"
+ onClick={() => {
+ const el = document.getElementById('enable-captcha')
+ if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' })
+ }}
+ >
+ enabling captcha
+ </span>{' '}
+ for anonymous sign-ins
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ This will prevent potential abuse on sign-ins which may bloat your database
+ and incur costs for monthly active users (MAU)
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )}
+ </CardContent>
+ <CardFooter className="justify-end space-x-2">
+ {form.formState.isDirty && (
+ <Button type="default" onClick={() => form.reset()}>
+ Cancel
+ </Button>
+ )}
+ <Button
+ type="primary"
+ htmlType="submit"
+ disabled={!canUpdateConfig || isUpdatingConfig || !form.formState.isDirty}
+ loading={isUpdatingConfig}
>
- <FormSection header={<FormSectionLabel>User Signups</FormSectionLabel>}>
- <FormSectionContent loading={isLoading}>
- <Toggle
- id="DISABLE_SIGNUP"
- size="small"
- label="Allow new users to sign up"
- layout="flex"
- descriptionText="If this is disabled, new users will not be able to sign up to your application."
- disabled={!canUpdateConfig}
- />
- <Toggle
- id="SECURITY_MANUAL_LINKING_ENABLED"
- size="small"
- label="Allow manual linking"
- layout="flex"
- descriptionText={
- <Markdown
- extLinks
- className="[&>p>a]:text-foreground-light [&>p>a]:transition-all [&>p>a]:hover:text-foreground [&>p>a]:hover:decoration-brand"
- content="Enable [manual linking APIs](https://supabase.com/docs/guides/auth/auth-identity-linking#manual-linking-beta) for your project."
- />
- }
- disabled={!canUpdateConfig}
- />
- <Toggle
- id="EXTERNAL_ANONYMOUS_USERS_ENABLED"
- size="small"
- label="Allow anonymous sign-ins"
- layout="flex"
- descriptionText={
- <Markdown
- extLinks
- className="[&>p>a]:text-foreground-light [&>p>a]:transition-all [&>p>a]:hover:text-foreground [&>p>a]:hover:decoration-brand"
- content="Enable [anonymous sign-ins](https://supabase.com/docs/guides/auth/auth-anonymous) for your project."
- />
- }
- disabled={!canUpdateConfig}
- />
- {values.EXTERNAL_ANONYMOUS_USERS_ENABLED && (
- <div className="flex flex-col gap-y-2">
- <Alert_Shadcn_
- className="flex w-full items-center justify-between"
- variant="warning"
- >
- <WarningIcon />
- <div>
- <AlertTitle_Shadcn_>
- Anonymous users will use the{' '}
- <code className="text-xs">authenticated</code> role when signing in
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_ className="flex flex-col gap-y-3">
- <p>
- As a result, anonymous users will be subjected to RLS policies that
- apply to the <code className="text-xs">public</code> and{' '}
- <code className="text-xs">authenticated</code> roles. We strongly
- advise{' '}
- <Link
- href={`/project/${projectRef}/auth/policies`}
- className="text-foreground underline"
- >
- reviewing your RLS policies
- </Link>{' '}
- to ensure that access to your data is restricted where required.
- </p>
- <Button
- asChild
- type="default"
- className="w-min"
- icon={<ExternalLink />}
- >
- <Link href="https://supabase.com/docs/guides/auth/auth-anonymous#access-control">
- View access control docs
- </Link>
- </Button>
- </AlertDescription_Shadcn_>
- </div>
- </Alert_Shadcn_>
- </div>
- )}
- {!authConfig?.SECURITY_CAPTCHA_ENABLED &&
- values.EXTERNAL_ANONYMOUS_USERS_ENABLED && (
- <Alert_Shadcn_>
- <WarningIcon />
- <AlertTitle_Shadcn_>
- We highly recommend{' '}
- <span
- tabIndex={1}
- className="cursor-pointer underline"
- onClick={() => {
- const el = document.getElementById('enable-captcha')
- if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' })
- }}
- >
- enabling captcha
- </span>{' '}
- for anonymous sign-ins
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- This will prevent potential abuse on sign-ins which may bloat your
- database and incur costs for monthly active users (MAU)
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )}
- </FormSectionContent>
- </FormSection>
- </FormPanel>
- </>
- )
- }}
- </Form>
- </div>
+ Save changes
+ </Button>
+ </CardFooter>
+ </Card>
+ </form>
+ </Form_Shadcn_>
+ </ScaffoldSection>
)
}
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
index 0a51c9dea52..d969c70a25e 100644
--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
@@ -4,8 +4,14 @@ import { useState } from 'react'
import { toast } from 'sonner'
import { useParams } from 'common'
+import {
+ ScaffoldSection,
+ ScaffoldSectionDescription,
+ ScaffoldSectionTitle,
+} from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
-import { FormHeader } from 'components/ui/Forms/FormHeader'
+import { DocsButton } from 'components/ui/DocsButton'
+import { InlineLink } from 'components/ui/InlineLink'
import { useDeleteThirdPartyAuthIntegrationMutation } from 'data/third-party-auth/integration-delete-mutation'
import {
ThirdPartyAuthIntegration,
@@ -17,15 +23,14 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { AddIntegrationDropdown } from './AddIntegrationDropdown'
import { CreateAuth0IntegrationDialog } from './CreateAuth0Dialog'
import { CreateAwsCognitoAuthIntegrationDialog } from './CreateAwsCognitoAuthDialog'
-import { CreateFirebaseAuthIntegrationDialog } from './CreateFirebaseAuthDialog'
import { CreateClerkAuthIntegrationDialog } from './CreateClerkAuthDialog'
+import { CreateFirebaseAuthIntegrationDialog } from './CreateFirebaseAuthDialog'
import { IntegrationCard } from './IntegrationCard'
import {
getIntegrationType,
getIntegrationTypeLabel,
INTEGRATION_TYPES,
} from './ThirdPartyAuthForm.utils'
-import Link from 'next/link'
export const ThirdPartyAuthForm = () => {
const { ref: projectRef } = useParams()
@@ -55,29 +60,29 @@ export const ThirdPartyAuthForm = () => {
}
return (
- <div className="pb-4">
- <FormHeader
- title="Third Party Auth"
- className="mb-1"
- description="Use third-party authentication (TPA) systems based on JWTs to access your project."
- actions={
- integrations.length !== 0 ? (
+ <ScaffoldSection isFullWidth>
+ <div className="flex justify-between gap-4">
+ <div>
+ <ScaffoldSectionTitle>Third Party Auth</ScaffoldSectionTitle>
+ <ScaffoldSectionDescription className="mb-6">
+ Use third-party authentication (TPA) systems based on JWTs to access your project.
+ <br />
+ Billing is based on the number of monthly active users (MAUs) requesting your API
+ throughout the billing period. Refer to our{' '}
+ <InlineLink href="https://supabase.com/docs/guides/platform/manage-your-usage/monthly-active-users-third-party">
+ billing docs
+ </InlineLink>{' '}
+ for more information.
+ </ScaffoldSectionDescription>
+ </div>
+ <div className="flex items-center gap-2 ">
+ <DocsButton href="https://supabase.com/docs/guides/auth/third-party/overview" />
+ {integrations.length !== 0 && (
<AddIntegrationDropdown onSelectIntegrationType={setSelectedIntegration} />
- ) : null
- }
- docsUrl="https://supabase.com/docs/guides/auth/third-party/overview"
- />
- <div className="prose text-sm mb-6 max-w-full prose">
- Billing is based on the number of distinct monthly active users (MAUs) requesting your API
- throughout the billing period, see{' '}
- <Link
- href="/docs/guides/platform/manage-your-usage/monthly-active-users-third-party"
- target="_blank"
- >
- billing docs
- </Link>
- .
+ )}
+ </div>
</div>
+
{isLoading && (
<div
className={cn(
@@ -173,6 +178,6 @@ export const ThirdPartyAuthForm = () => {
{`Are you sure you want to delete the ${getIntegrationTypeLabel(getIntegrationType(selectedIntegrationForDeletion))} integration?`}
</p>
</ConfirmationModal>
- </div>
+ </ScaffoldSection>
)
}
diff --git a/apps/studio/components/interfaces/Auth/index.tsx b/apps/studio/components/interfaces/Auth/index.tsx
index 757641f55c0..4762496196c 100644
--- a/apps/studio/components/interfaces/Auth/index.tsx
+++ b/apps/studio/components/interfaces/Auth/index.tsx
@@ -1,4 +1,5 @@
-export { default as AuthProvidersForm } from './AuthProvidersForm/AuthProvidersForm'
+export { AdvancedAuthSettingsForm } from './AdvancedAuthSettingsForm'
+export { AuthProvidersForm } from './AuthProvidersForm/AuthProvidersForm'
export { default as BasicAuthSettingsForm } from './BasicAuthSettingsForm/BasicAuthSettingsForm'
export { default as EmailTemplates } from './EmailTemplates/EmailTemplates'
export { default as MfaAuthSettingsForm } from './MfaAuthSettingsForm/MfaAuthSettingsForm'
diff --git a/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx b/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
index d15ba14343a..74cdf9c6736 100644
--- a/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
+++ b/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
@@ -1,20 +1,16 @@
-import { useParams } from 'common'
+import Link from 'next/link'
import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
+import { useParams } from 'common'
import { useIsColumnLevelPrivilegesEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { ProductMenu } from 'components/ui/ProductMenu'
import { useAuthConfigPrefetch } from 'data/auth/auth-config-query'
import { withAuth } from 'hooks/misc/withAuth'
-import Link from 'next/link'
import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button } from 'ui'
import ProjectLayout from '../ProjectLayout/ProjectLayout'
import { generateAuthMenu } from './AuthLayout.utils'
-export interface AuthLayoutProps {
- title?: string
-}
-
const AuthProductMenu = () => {
const { ref: projectRef = 'default' } = useParams()
const columnLevelPrivileges = useIsColumnLevelPrivilegesEnabled()
@@ -48,10 +44,10 @@ const AuthProductMenu = () => {
)
}
-const AuthLayout = ({ title, children }: PropsWithChildren<AuthLayoutProps>) => {
+const AuthLayout = ({ children }: PropsWithChildren<{}>) => {
return (
<ProjectLayout
- title={title || 'Authentication'}
+ title="Authentication"
product="Authentication"
productMenu={<AuthProductMenu />}
isBlocking={false}
@@ -61,4 +57,9 @@ const AuthLayout = ({ title, children }: PropsWithChildren<AuthLayoutProps>) =>
)
}
+/**
+ * Layout for all auth pages on the dashboard, wrapped with withAuth to verify logged in state
+ *
+ * Handles rendering the navigation for each section under the auth pages.
+ */
export default withAuth(AuthLayout)
diff --git a/apps/studio/components/layouts/AuthLayout/AuthProvidersLayout.tsx b/apps/studio/components/layouts/AuthLayout/AuthProvidersLayout.tsx
new file mode 100644
index 00000000000..688b8eee551
--- /dev/null
+++ b/apps/studio/components/layouts/AuthLayout/AuthProvidersLayout.tsx
@@ -0,0 +1,39 @@
+import { ReactNode } from 'react'
+
+import { useParams } from 'common'
+import DefaultLayout from 'components/layouts/DefaultLayout'
+import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
+import AuthLayout from './AuthLayout'
+
+interface AuthProvidersLayoutProps {
+ children: ReactNode
+}
+
+export const AuthProvidersLayout = ({ children }: AuthProvidersLayoutProps) => {
+ const { ref } = useParams()
+
+ const navItems = [
+ {
+ label: 'Supabase Auth',
+ href: `/project/${ref}/auth/providers`,
+ },
+ {
+ label: 'Third Party Auth',
+ href: `/project/${ref}/auth/third-party`,
+ },
+ ]
+
+ return (
+ <DefaultLayout>
+ <AuthLayout>
+ <PageLayout
+ title="Sign In / Up"
+ subtitle="Configure authentication providers and login methods for your users"
+ navigationItems={navItems}
+ >
+ {children}
+ </PageLayout>
+ </AuthLayout>
+ </DefaultLayout>
+ )
+}
diff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsx
index 2e0bca40b33..8ab85cf71ca 100644
--- a/apps/studio/components/layouts/DefaultLayout.tsx
+++ b/apps/studio/components/layouts/DefaultLayout.tsx
@@ -9,39 +9,42 @@ import NavigationBar from './ProjectLayout/NavigationBar/NavigationBar'
import { ProjectContextProvider } from './ProjectLayout/ProjectContext'
export interface DefaultLayoutProps {
- title?: string
- product?: string
- selectedTable?: string
- hasProductMenu?: boolean
- // Shows header in the top left of the page
- headerTitle?: string
showProductMenu?: boolean
}
+/**
+ * Base layout for all project pages in the dashboard, rendered as the first child on all page files within a project.
+ *
+ * A second layout as the child to this is required, and the layout depends on which section of the dashboard the page is on. (e.g Auth - AuthLayout)
+ *
+ * The base layout handles rendering the following UI components:
+ * - App banner (e.g for notices or incidents)
+ * - Mobile navigation bar
+ * - First level side navigation bar (e.g For navigating to Table Editor, SQL Editor, Database page, etc)
+ * @param showProductMenu - (Mobile only) Show button to toggle visiblity of product menu (Default: true)
+ */
const DefaultLayout = ({ children, showProductMenu }: PropsWithChildren<DefaultLayoutProps>) => {
const { ref } = useParams()
return (
- <>
- <ProjectContextProvider projectRef={ref}>
- <AppBannerContextProvider>
- <div className="flex flex-col h-screen w-screen">
- {/* Top Banner */}
- <AppBannerWrapper />
- <div className="flex-shrink-0">
- <MobileNavigationBar />
- <LayoutHeader showProductMenu={showProductMenu} />
- </div>
- {/* Main Content Area */}
- <div className="flex flex-1 w-full overflow-y-hidden">
- {/* Sidebar */}
- <NavigationBar />
- {/* Main Content */}
- <div className="flex-grow h-full overflow-y-auto">{children}</div>
- </div>
+ <ProjectContextProvider projectRef={ref}>
+ <AppBannerContextProvider>
+ <div className="flex flex-col h-screen w-screen">
+ {/* Top Banner */}
+ <AppBannerWrapper />
+ <div className="flex-shrink-0">
+ <MobileNavigationBar />
+ <LayoutHeader showProductMenu={showProductMenu} />
</div>
- </AppBannerContextProvider>
- </ProjectContextProvider>
- </>
+ {/* Main Content Area */}
+ <div className="flex flex-1 w-full overflow-y-hidden">
+ {/* Sidebar */}
+ <NavigationBar />
+ {/* Main Content */}
+ <div className="flex-grow h-full overflow-y-auto">{children}</div>
+ </div>
+ </div>
+ </AppBannerContextProvider>
+ </ProjectContextProvider>
)
}
diff --git a/apps/studio/components/layouts/PageLayout/PageHeader.tsx b/apps/studio/components/layouts/PageLayout/PageHeader.tsx
new file mode 100644
index 00000000000..e929f97817a
--- /dev/null
+++ b/apps/studio/components/layouts/PageLayout/PageHeader.tsx
@@ -0,0 +1,104 @@
+import { Fragment, ReactNode } from 'react'
+
+import { useParams } from 'common'
+import { cn } from 'ui'
+import {
+ Breadcrumb,
+ BreadcrumbItem,
+ BreadcrumbLink,
+ BreadcrumbList,
+ BreadcrumbPage as BreadcrumbPageItem,
+ BreadcrumbSeparator,
+} from 'ui/src/components/shadcn/ui/breadcrumb'
+import { ScaffoldDescription, ScaffoldTitle } from '../Scaffold'
+
+interface PageHeaderProps {
+ title?: string
+ subtitle?: string
+ icon?: ReactNode
+ breadcrumbs?: Array<{
+ label: string
+ href?: string
+ }>
+ primaryActions?: ReactNode
+ secondaryActions?: ReactNode
+ className?: string
+ isCompact?: boolean
+}
+
+export const PageHeader = ({
+ title,
+ subtitle,
+ icon,
+ breadcrumbs = [],
+ primaryActions,
+ secondaryActions,
+ className,
+ isCompact = false,
+}: PageHeaderProps) => {
+ const { ref } = useParams()
+
+ const displayBreadcrumbs = isCompact && title ? [...breadcrumbs, { label: title }] : breadcrumbs
+
+ return (
+ <div className={cn('space-y-4', className)}>
+ {(displayBreadcrumbs.length > 0 ||
+ (isCompact && (title || primaryActions || secondaryActions))) && (
+ <div className={cn('flex items-center gap-4', isCompact ? 'justify-between' : 'mb-4')}>
+ {displayBreadcrumbs.length > 0 ? (
+ <Breadcrumb className={cn('text-foreground-muted', isCompact && 'text-base')}>
+ <BreadcrumbList className={isCompact ? 'text-base' : 'text-xs'}>
+ {displayBreadcrumbs.map((item, index) => (
+ <Fragment key={item.label}>
+ <BreadcrumbItem>
+ {item.href ? (
+ <BreadcrumbLink href={!!ref ? item.href.replace('[ref]', ref) : item.href}>
+ {item.label}
+ </BreadcrumbLink>
+ ) : (
+ <BreadcrumbPageItem>{item.label}</BreadcrumbPageItem>
+ )}
+ </BreadcrumbItem>
+ {index < displayBreadcrumbs.length - 1 && <BreadcrumbSeparator />}
+ </Fragment>
+ ))}
+ </BreadcrumbList>
+ </Breadcrumb>
+ ) : isCompact ? (
+ title
+ ) : null}
+ {isCompact && (
+ <div className="flex items-center gap-2">
+ {secondaryActions && (
+ <div className="flex items-center gap-2">{secondaryActions}</div>
+ )}
+ {primaryActions && <div className="flex items-center gap-2">{primaryActions}</div>}
+ </div>
+ )}
+ </div>
+ )}
+
+ {!isCompact && (
+ <div className="flex items-center justify-between gap-4">
+ <div className="space-y-4">
+ <div className="flex items-center gap-4">
+ {icon && <div className="text-foreground-light">{icon}</div>}
+ <div className="space-y-1">
+ {title && <ScaffoldTitle>{title}</ScaffoldTitle>}
+ {subtitle && (
+ <ScaffoldDescription className="text-sm text-foreground-light">
+ {subtitle}
+ </ScaffoldDescription>
+ )}
+ </div>
+ </div>
+ </div>
+ <div className="flex items-center gap-2">
+ {secondaryActions && <div className="flex items-center gap-2">{secondaryActions}</div>}
+ {primaryActions && <div className="flex items-center gap-2">{primaryActions}</div>}
+ </div>
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/apps/studio/components/layouts/PageLayout/PageLayout.tsx b/apps/studio/components/layouts/PageLayout/PageLayout.tsx
new file mode 100644
index 00000000000..e543abb8ecd
--- /dev/null
+++ b/apps/studio/components/layouts/PageLayout/PageLayout.tsx
@@ -0,0 +1,134 @@
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import { ReactNode } from 'react'
+
+import { Button, cn, NavMenu, NavMenuItem } from 'ui'
+import { ScaffoldContainer } from '../Scaffold'
+import { PageHeader } from './PageHeader'
+
+export interface NavigationItem {
+ id?: string
+ label: string
+ href?: string
+ icon?: ReactNode
+ onClick?: () => void
+}
+
+interface PageLayoutProps {
+ children?: ReactNode
+ title?: string
+ subtitle?: string
+ icon?: ReactNode
+ breadcrumbs?: Array<{
+ label: string
+ href?: string
+ }>
+ primaryActions?: ReactNode
+ secondaryActions?: ReactNode
+ navigationItems?: NavigationItem[]
+ className?: string
+ size?: 'default' | 'full'
+ isCompact?: boolean
+}
+
+/**
+ * For rendering a general single column based UI (which covers most of the dashboard's use case)
+ *
+ * Pages that would use this would for example be: Auth Sign In / Up, Project settings, Advisors, etc
+ *
+ * Pages that would deviate from this are those with dedicated UI, for example: Table Editor, SQL Editor, etc
+ *
+ * Handles rendering the following UI behaviors:
+ * - Page padding depending on the size property
+ * - Top level breadcrumbs (If applicable)
+ * - Top level page header (If applicable)
+ * - Top level tab navigations (If applicable)
+ * @param title - Title rendered in page header
+ * @param subtitle - Subtitle rendered in page header, below title
+ * @param icon - Icon rendered in Page header, to the left of title and subtitle
+ * @param breadcrumbs - Breadcrumbs rendered in page header, above title
+ * @param primaryActions - TBD
+ * @param secondaryActions - TBD
+ * @param navigationItems - Tab navigation rendered below the page header
+ * @param className - Optional additional class names to be applied
+ * @param size - Controls padding of the page header only, padding for the content to be controlled by PageContainer (Default: 'default')
+ * @param isCompact - TBD (Default: false)
+ */
+export const PageLayout = ({
+ children,
+ title,
+ subtitle,
+ icon,
+ breadcrumbs = [],
+ primaryActions,
+ secondaryActions,
+ navigationItems = [],
+ className,
+ size = 'default',
+ isCompact = false,
+}: PageLayoutProps) => {
+ const router = useRouter()
+
+ return (
+ <div className="w-full">
+ <ScaffoldContainer
+ className={cn(
+ 'w-full mx-auto',
+ size === 'full' &&
+ (isCompact ? 'max-w-none !px-6 border-b' : 'max-w-none p!x-8 border-b'),
+ isCompact ? 'pt-4' : 'pt-12',
+ navigationItems.length === 0 && size === 'full' && (isCompact ? 'pb-4' : 'pb-8'),
+ className
+ )}
+ >
+ {/* Header section */}
+ {(title || subtitle || primaryActions || secondaryActions || breadcrumbs.length > 0) && (
+ <PageHeader
+ title={title}
+ subtitle={subtitle}
+ icon={icon}
+ breadcrumbs={breadcrumbs}
+ primaryActions={primaryActions}
+ secondaryActions={secondaryActions}
+ isCompact={isCompact}
+ />
+ )}
+
+ {/* Navigation section */}
+ {navigationItems.length > 0 && (
+ <NavMenu className={cn('mt-4', size === 'full' && 'border-none')}>
+ {navigationItems.map((item) => (
+ <NavMenuItem key={item.label} active={router.asPath === item.href}>
+ {item.href ? (
+ <Link
+ href={item.href}
+ className={cn(
+ 'inline-flex items-center gap-2',
+ router.asPath === item.href && 'text-foreground'
+ )}
+ onClick={item.onClick}
+ >
+ {item.icon && <span>{item.icon}</span>}
+ {item.label}
+ </Link>
+ ) : (
+ <Button
+ type="link"
+ onClick={item.onClick}
+ className={cn(router.pathname === item.href && 'text-foreground font-medium')}
+ >
+ {item.icon && <span className="mr-2">{item.icon}</span>}
+ {item.label}
+ </Button>
+ )}
+ </NavMenuItem>
+ ))}
+ </NavMenu>
+ )}
+ </ScaffoldContainer>
+
+ {/* Content section */}
+ {children}
+ </div>
+ )
+}
diff --git a/apps/studio/components/layouts/Scaffold.tsx b/apps/studio/components/layouts/Scaffold.tsx
index 61a11f361c6..9abca549fe2 100644
--- a/apps/studio/components/layouts/Scaffold.tsx
+++ b/apps/studio/components/layouts/Scaffold.tsx
@@ -1,4 +1,5 @@
-import React from 'react'
+import { forwardRef, HTMLAttributes } from 'react'
+
import { useAppStateSnapshot } from 'state/app-state'
import { cn } from 'ui'
@@ -6,72 +7,190 @@ export const MAX_WIDTH_CLASSES = 'mx-auto w-full max-w-[1200px]'
export const PADDING_CLASSES = 'px-4 md:px-6 lg:px-14 xl:px-24 2xl:px-28'
export const MAX_WIDTH_CLASSES_COLUMN = 'min-w-[420px]'
-const ScaffoldHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+/**
+ * Controls the width and padding of the UI contents. Typically used as the top level child immediately after a layout.
+ *
+ * e.g:```
+ * <Layout>
+ * <ScaffoldContainer>
+ * {children}
+ * </ScaffoldContainer>
+ * </Layout>```
+ */
+export const ScaffoldContainer = forwardRef<
+ HTMLDivElement,
+ HTMLAttributes<HTMLDivElement> & { bottomPadding?: boolean }
+>(({ className, bottomPadding, ...props }, ref) => {
+ const { aiAssistantPanel } = useAppStateSnapshot()
+ const { open } = aiAssistantPanel
+ return (
+ <div
+ ref={ref}
+ {...props}
+ className={cn(
+ MAX_WIDTH_CLASSES,
+ PADDING_CLASSES,
+ bottomPadding && 'pb-16',
+ open ? 'xl:px-6' : '',
+ className
+ )}
+ />
+ )
+})
+
+/**
+ * Top most header for a page
+ *
+ * Note: In most cases, we won't use this directly in pages. Header title and description can be controlled via
+ * the PageLayout component, which uses the PageHeader component, and in turn uses this ScaffoldHeader component
+ */
+export const ScaffoldHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return (
- <header
- {...props}
- ref={ref}
- className={cn('w-full', 'flex-col gap-3 py-6', className)}
- ></header>
+ <header {...props} ref={ref} className={cn('w-full', 'flex-col gap-3 py-6', className)} />
)
}
)
-const ScaffoldTitle = React.forwardRef<
- HTMLHeadingElement,
- React.HTMLAttributes<HTMLHeadingElement>
->(({ className, ...props }, ref) => {
- return <h1 ref={ref} {...props} className={cn('text-2xl', className)} />
-})
+/**
+ * Title for the top most header for a page
+ *
+ * Note: In most cases, we won't use this directly in pages. Header title and description can be controlled via
+ * the PageLayout component, which uses the PageHeader component, and in turn uses this ScaffoldTitle component
+ */
+export const ScaffoldTitle = forwardRef<HTMLHeadingElement, HTMLAttributes<HTMLHeadingElement>>(
+ ({ className, ...props }, ref) => {
+ return <h1 ref={ref} {...props} className={cn('text-2xl', className)} />
+ }
+)
-const ScaffoldDescription = React.forwardRef<
+/**
+ * Description for the top most header for a page
+ *
+ * Note: In most cases, we won't use this directly in pages. Header title and description can be controlled via
+ * the PageLayout component, which uses the PageHeader component, and in turn uses this ScaffoldDescription component
+ */
+export const ScaffoldDescription = forwardRef<
HTMLHeadingElement,
- React.HTMLAttributes<HTMLHeadingElement>
+ HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => {
- return <span ref={ref} {...props} className={cn('text-sm text-foreground-light', className)} />
+ return <p ref={ref} {...props} className={cn('text-sm text-foreground-light', className)} />
})
-const ScaffoldContainer = React.forwardRef<
+export const ScaffoldSection = forwardRef<
HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement> & { bottomPadding?: boolean }
->(({ className, bottomPadding, ...props }, ref) => {
- const { aiAssistantPanel } = useAppStateSnapshot()
- const { open } = aiAssistantPanel
+ HTMLAttributes<HTMLDivElement> & { isFullWidth?: boolean; topPadding?: boolean }
+>(({ className, isFullWidth, topPadding, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
className={cn(
- MAX_WIDTH_CLASSES,
- PADDING_CLASSES,
- bottomPadding && 'pb-16',
- open ? 'xl:px-6' : '',
+ 'flex flex-col first:pt-12 py-6',
+ isFullWidth ? 'w-full' : 'gap-3 lg:grid md:grid-cols-12',
className
)}
/>
)
})
-const ScaffoldDivider = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+/**
+ * Horizontal divider between ScaffoldSections
+ */
+export const ScaffoldDivider = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return <div ref={ref} {...props} className={cn('w-full h-px bg-border', className)} />
}
)
-const ScaffoldSection = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+/**
+ * Title for a page section
+ */
+export const ScaffoldSectionTitle = forwardRef<
+ HTMLHeadingElement,
+ HTMLAttributes<HTMLHeadingElement>
+>(({ className, ...props }, ref) => {
+ return <h3 ref={ref} {...props} className={cn('text-foreground text-xl', className)} />
+})
+
+/**
+ * Description for a page section
+ */
+export const ScaffoldSectionDescription = forwardRef<
+ HTMLParagraphElement,
+ HTMLAttributes<HTMLParagraphElement>
+>(({ className, ...props }, ref) => {
+ return <p ref={ref} {...props} className={cn('text-sm text-foreground-light', className)} />
+})
+
+/**
+ * Child of ScaffoldSection - Left hand column for a section
+ */
+export const ScaffoldSectionDetail = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
+ ({ className, children, title, ...props }, ref) => {
+ return (
+ <div ref={ref} {...props} className={cn('col-span-4 xl:col-span-5 prose text-sm', className)}>
+ {title && <h2>{title}</h2>}
+ {children}
+ </div>
+ )
+ }
+)
+
+/**
+ * Child of ScaffoldSection - Right hand column for a section
+ */
+export const ScaffoldSectionContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
- className={cn('flex flex-col gap-3 py-6', 'lg:grid md:grid-cols-12 lg:py-12', className)}
+ className={cn('col-span-8 xl:col-span-7', 'flex flex-col gap-6', className)}
/>
)
}
)
-const ScaffoldColumn = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+/**
+ * TBD: Provide better JSDocs on how to use this component
+ *
+ * Table and filters
+ */
+export const ScaffoldFilterAndContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => {
+ return (
+ <div ref={ref} {...props} className={cn('flex flex-col gap-3 items-center', className)} />
+ )
+ }
+)
+
+/**
+ * TBD: Provide better JSDocs on how to use this component
+ *
+ * Actions Group
+ */
+export const ScaffoldActionsContainer = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => {
+ return <div ref={ref} {...props} className={cn('flex w-full items-center', className)} />
+ }
+)
+
+/**
+ * TBD: Provide better JSDocs on how to use this component
+ *
+ * Actions Group
+ */
+export const ScaffoldActionsGroup = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => {
+ return <div ref={ref} {...props} className={cn('flex flex-row gap-3', className)} />
+ }
+)
+
+/**
+ * For a single column section - currently only used for vercel integration
+ */
+export const ScaffoldColumn = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
return (
<div
@@ -83,68 +202,22 @@ const ScaffoldColumn = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTM
}
)
-const ScaffoldSectionDetail = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, children, title, ...props }, ref) => {
- return (
- <div ref={ref} {...props} className={cn('col-span-4 xl:col-span-5 prose text-sm', className)}>
- {title && <h2>{title}</h2>}
- {children}
- </div>
- )
-})
-
-const ScaffoldSectionContent = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => {
- return (
- <div
- ref={ref}
- {...props}
- className={cn('col-span-8 xl:col-span-7', 'flex flex-col gap-6', className)}
- />
- )
-})
-
-// Table and filters
-const ScaffoldFilterAndContent = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => {
- return <div ref={ref} {...props} className={cn('flex flex-col gap-3 items-center', className)} />
-})
-
-// Actions Group
-const ScaffoldActionsContainer = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => {
- return <div ref={ref} {...props} className={cn('flex w-full items-center', className)} />
-})
-
-// Actions Group
-const ScaffoldActionsGroup = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+/**
+ * For older layouts - eventually to be replaced with ScaffoldContainer component
+ * @deprecated
+ */
+export const ScaffoldContainerLegacy = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
- return <div ref={ref} {...props} className={cn('flex flex-row gap-3', className)} />
+ return (
+ <div
+ ref={ref}
+ {...props}
+ className={cn(MAX_WIDTH_CLASSES, PADDING_CLASSES, 'my-8 flex flex-col gap-8', className)}
+ />
+ )
}
)
-// For older layouts
-const ScaffoldContainerLegacy = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => {
- return (
- <div
- ref={ref}
- {...props}
- className={cn(MAX_WIDTH_CLASSES, PADDING_CLASSES, 'my-8 flex flex-col gap-8', className)}
- />
- )
-})
-
ScaffoldHeader.displayName = 'ScaffoldHeader'
ScaffoldTitle.displayName = 'ScaffoldTitle'
ScaffoldDescription.displayName = 'ScaffoldDescription'
@@ -158,19 +231,5 @@ ScaffoldFilterAndContent.displayName = 'ScaffoldFilterAndContent'
ScaffoldActionsContainer.displayName = 'ScaffoldActionsContainer'
ScaffoldActionsGroup.displayName = 'ScaffoldActionsGroup'
ScaffoldContainerLegacy.displayName = 'ScaffoldContainerLegacy'
-
-export {
- ScaffoldHeader,
- ScaffoldTitle,
- ScaffoldDescription,
- ScaffoldContainer,
- ScaffoldDivider,
- ScaffoldSection,
- ScaffoldColumn,
- ScaffoldSectionDetail,
- ScaffoldSectionContent,
- ScaffoldFilterAndContent,
- ScaffoldActionsContainer,
- ScaffoldActionsGroup,
- ScaffoldContainerLegacy,
-}
+ScaffoldSectionTitle.displayName = 'ScaffoldSectionTitle'
+ScaffoldSectionDescription.displayName = 'ScaffoldSectionDescription'
diff --git a/apps/studio/components/ui/InlineLink.tsx b/apps/studio/components/ui/InlineLink.tsx
index f8f547457f8..f1dd6fbddbc 100644
--- a/apps/studio/components/ui/InlineLink.tsx
+++ b/apps/studio/components/ui/InlineLink.tsx
@@ -1,13 +1,21 @@
import Link from 'next/link'
import { PropsWithChildren } from 'react'
+import { cn } from 'ui'
interface InlineLinkProps {
href: string
+ className?: string
}
-export const InlineLink = ({ href, children }: PropsWithChildren<InlineLinkProps>) => {
- const className =
- 'underline transition underline-offset-2 decoration-foreground-lighter hover:decoration-foreground text-foreground'
+export const InlineLink = ({
+ href,
+ className: _className,
+ children,
+}: PropsWithChildren<InlineLinkProps>) => {
+ const className = cn(
+ 'underline transition underline-offset-2 decoration-foreground-lighter hover:decoration-foreground text-foreground',
+ _className
+ )
if (href.startsWith('http')) {
return (
<a className={className} href={href} target="_blank" rel="noreferrer noopener">
diff --git a/apps/studio/components/ui/Resource/ResourceItem.tsx b/apps/studio/components/ui/Resource/ResourceItem.tsx
new file mode 100644
index 00000000000..67b144eecb6
--- /dev/null
+++ b/apps/studio/components/ui/Resource/ResourceItem.tsx
@@ -0,0 +1,37 @@
+import { ChevronRight } from 'lucide-react'
+import { forwardRef, HTMLAttributes, ReactNode } from 'react'
+
+import { CardContent, cn } from 'ui'
+
+export interface ResourceItemProps extends HTMLAttributes<HTMLDivElement> {
+ media?: ReactNode
+ meta?: ReactNode
+ onClick?: () => void
+ children?: ReactNode
+}
+
+export const ResourceItem = forwardRef<HTMLDivElement, ResourceItemProps>(
+ ({ media, meta, onClick, children, className, ...props }, ref) => {
+ return (
+ <CardContent
+ ref={ref}
+ className={cn(
+ 'flex items-center justify-between text-sm gap-4',
+ onClick && 'cursor-pointer hover:bg-surface-200',
+ className
+ )}
+ onClick={onClick}
+ {...props}
+ >
+ {media && (
+ <div className="text-foreground-light flex items-center justify-center">{media}</div>
+ )}
+ <div className="flex-1">{children}</div>
+ {meta && <div>{meta}</div>}
+ {onClick && <ChevronRight strokeWidth={1.5} size={16} />}
+ </CardContent>
+ )
+ }
+)
+
+ResourceItem.displayName = 'ResourceItem'
diff --git a/apps/studio/components/ui/Resource/ResourceList.tsx b/apps/studio/components/ui/Resource/ResourceList.tsx
new file mode 100644
index 00000000000..58c98a58aaa
--- /dev/null
+++ b/apps/studio/components/ui/Resource/ResourceList.tsx
@@ -0,0 +1,19 @@
+import { forwardRef, HTMLAttributes, ReactNode } from 'react'
+
+import { Card } from 'ui'
+
+export interface ResourceListProps extends HTMLAttributes<HTMLDivElement> {
+ children?: ReactNode
+}
+
+export const ResourceList = forwardRef<HTMLDivElement, ResourceListProps>(
+ ({ children, className, ...props }, ref) => {
+ return (
+ <Card ref={ref} {...props}>
+ <div className={className}>{children}</div>
+ </Card>
+ )
+ }
+)
+
+ResourceList.displayName = 'ResourceList'
diff --git a/apps/studio/pages/project/[ref]/auth/index.tsx b/apps/studio/pages/project/[ref]/auth/index.tsx
index 30ffe3662c9..8bef5974447 100644
--- a/apps/studio/pages/project/[ref]/auth/index.tsx
+++ b/apps/studio/pages/project/[ref]/auth/index.tsx
@@ -8,7 +8,7 @@ const Authentication: NextPageWithLayout = () => {
Authentication.getLayout = (page) => (
<DefaultLayout>
- <AuthLayout title="Authentication">{page}</AuthLayout>
+ <AuthLayout>{page}</AuthLayout>
</DefaultLayout>
)
diff --git a/apps/studio/pages/project/[ref]/auth/policies.tsx b/apps/studio/pages/project/[ref]/auth/policies.tsx
index 4d42fee486c..f4b5a3d90fa 100644
--- a/apps/studio/pages/project/[ref]/auth/policies.tsx
+++ b/apps/studio/pages/project/[ref]/auth/policies.tsx
@@ -4,11 +4,13 @@ import { partition } from 'lodash'
import { Search } from 'lucide-react'
import { useState } from 'react'
-import { PolicyEditorPanel } from 'components/interfaces/Auth/Policies/PolicyEditorPanel'
+import { useIsInlineEditorEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import Policies from 'components/interfaces/Auth/Policies/Policies'
-import { generatePolicyCreateSQL } from 'components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRow.utils'
import { getGeneralPolicyTemplates } from 'components/interfaces/Auth/Policies/PolicyEditorModal/PolicyEditorModal.constants'
+import { PolicyEditorPanel } from 'components/interfaces/Auth/Policies/PolicyEditorPanel'
+import { generatePolicyCreateSQL } from 'components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRow.utils'
import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'
+import DefaultLayout from 'components/layouts/DefaultLayout'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import AlertError from 'components/ui/AlertError'
import { DocsButton } from 'components/ui/DocsButton'
@@ -21,11 +23,9 @@ import { useTablesQuery } from 'data/tables/tables-query'
import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'
import { useUrlState } from 'hooks/ui/useUrlState'
import { PROTECTED_SCHEMAS } from 'lib/constants/schemas'
+import { useAppStateSnapshot } from 'state/app-state'
import type { NextPageWithLayout } from 'types'
import { Input } from 'ui'
-import DefaultLayout from 'components/layouts/DefaultLayout'
-import { useIsInlineEditorEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
-import { useAppStateSnapshot } from 'state/app-state'
/**
* Filter tables by table name and policy name
@@ -215,7 +215,7 @@ const AuthPoliciesPage: NextPageWithLayout = () => {
AuthPoliciesPage.getLayout = (page) => (
<DefaultLayout>
- <AuthLayout title="Auth">
+ <AuthLayout>
<div className="h-full p-4">{page}</div>
</AuthLayout>
</DefaultLayout>
diff --git a/apps/studio/pages/project/[ref]/auth/providers.tsx b/apps/studio/pages/project/[ref]/auth/providers.tsx
index 63c5d4e6cd6..a1bda754af3 100644
--- a/apps/studio/pages/project/[ref]/auth/providers.tsx
+++ b/apps/studio/pages/project/[ref]/auth/providers.tsx
@@ -1,80 +1,28 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useParams } from 'common'
+
import { AuthProvidersForm, BasicAuthSettingsForm } from 'components/interfaces/Auth'
-import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'
-import DefaultLayout from 'components/layouts/DefaultLayout'
-import {
- ScaffoldContainer,
- ScaffoldDescription,
- ScaffoldDivider,
- ScaffoldHeader,
- ScaffoldTitle,
-} from 'components/layouts/Scaffold'
+import { AuthProvidersLayout } from 'components/layouts/AuthLayout/AuthProvidersLayout'
+import { ScaffoldContainer } from 'components/layouts/Scaffold'
import NoPermission from 'components/ui/NoPermission'
import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'
-import { useCurrentPath } from 'hooks/misc/useCurrentPath'
-import Link from 'next/link'
import type { NextPageWithLayout } from 'types'
-import { NavMenu, NavMenuItem } from 'ui'
-const PageLayout: NextPageWithLayout = () => {
+const ProvidersPage: NextPageWithLayout = () => {
const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')
const isPermissionsLoaded = usePermissionsLoaded()
- const { ref } = useParams()
- const currentPath = useCurrentPath()
-
- const navMenuItems = [
- {
- label: 'Supabase Auth',
- href: `/project/${ref}/auth/providers`,
- },
- {
- label: 'Third Party Auth',
- href: `/project/${ref}/auth/third-party`,
- },
- ]
if (isPermissionsLoaded && !canReadAuthSettings) {
return <NoPermission isFullPage resourceText="access your project's auth provider settings" />
}
return (
- <div>
- <ScaffoldHeader className="pb-0">
- <ScaffoldContainer id="auth-page-top">
- <ScaffoldTitle>Sign In / Up</ScaffoldTitle>
- <ScaffoldDescription>
- Configure authentication providers and login methods for your users
- </ScaffoldDescription>
- <NavMenu
- className="border-none max-w-full overflow-y-hidden overflow-x-auto mt-4"
- aria-label="Auth provider settings navigation"
- >
- {navMenuItems.map((item) => (
- <NavMenuItem key={item.label} active={currentPath === item.href}>
- <Link href={item.href}>{item.label}</Link>
- </NavMenuItem>
- ))}
- </NavMenu>
- </ScaffoldContainer>
- </ScaffoldHeader>
-
- <ScaffoldDivider />
-
- <ScaffoldContainer className="my-8 space-y-8">
- <BasicAuthSettingsForm />
- <AuthProvidersForm />
- </ScaffoldContainer>
- </div>
+ <ScaffoldContainer>
+ <BasicAuthSettingsForm />
+ <AuthProvidersForm />
+ </ScaffoldContainer>
)
}
-PageLayout.getLayout = (page) => {
- return (
- <DefaultLayout>
- <AuthLayout>{page}</AuthLayout>
- </DefaultLayout>
- )
-}
+ProvidersPage.getLayout = (page) => <AuthProvidersLayout>{page}</AuthProvidersLayout>
-export default PageLayout
+export default ProvidersPage
diff --git a/apps/studio/pages/project/[ref]/auth/third-party.tsx b/apps/studio/pages/project/[ref]/auth/third-party.tsx
index f48b3eabf6a..5aa2b1ee245 100644
--- a/apps/studio/pages/project/[ref]/auth/third-party.tsx
+++ b/apps/studio/pages/project/[ref]/auth/third-party.tsx
@@ -1,79 +1,27 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { ThirdPartyAuthForm } from 'components/interfaces/Auth'
-import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'
-import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'
-import { useParams } from 'common'
-import { useCurrentPath } from 'hooks/misc/useCurrentPath'
-import Link from 'next/link'
-import { NavMenu, NavMenuItem } from 'ui'
-import {
- ScaffoldContainer,
- ScaffoldDescription,
- ScaffoldDivider,
- ScaffoldHeader,
- ScaffoldTitle,
-} from 'components/layouts/Scaffold'
+import { AuthProvidersLayout } from 'components/layouts/AuthLayout/AuthProvidersLayout'
+import { ScaffoldContainer } from 'components/layouts/Scaffold'
import NoPermission from 'components/ui/NoPermission'
+import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'
import type { NextPageWithLayout } from 'types'
-import DefaultLayout from 'components/layouts/DefaultLayout'
-const PageLayout: NextPageWithLayout = () => {
+const ThirdPartyPage: NextPageWithLayout = () => {
const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')
const isPermissionsLoaded = usePermissionsLoaded()
- const { ref } = useParams()
- const currentPath = useCurrentPath()
-
- const navMenuItems = [
- {
- label: 'Supabase auth',
- href: `/project/${ref}/auth/providers`,
- },
- {
- label: 'Third Party auth',
- href: `/project/${ref}/auth/third-party`,
- },
- ]
if (isPermissionsLoaded && !canReadAuthSettings) {
return <NoPermission isFullPage resourceText="access your project's auth provider settings" />
}
return (
- <>
- <ScaffoldHeader className="pb-0">
- <ScaffoldContainer id="auth-page-top">
- <ScaffoldTitle>Sign in / up</ScaffoldTitle>
- <ScaffoldDescription>
- Configure authentication providers and login methods for your users
- </ScaffoldDescription>
- <NavMenu
- className="border-none max-w-full overflow-y-hidden overflow-x-auto mt-4"
- aria-label="Auth provider settings navigation"
- >
- {navMenuItems.map((item) => (
- <NavMenuItem key={item.label} active={currentPath === item.href}>
- <Link href={item.href}>{item.label}</Link>
- </NavMenuItem>
- ))}
- </NavMenu>
- </ScaffoldContainer>
- </ScaffoldHeader>
-
- <ScaffoldDivider />
-
- <ScaffoldContainer className="my-8">
- <ThirdPartyAuthForm />
- </ScaffoldContainer>
- </>
+ <ScaffoldContainer className="pb-16">
+ <ThirdPartyAuthForm />
+ </ScaffoldContainer>
)
}
-PageLayout.getLayout = (page) => {
- return (
- <DefaultLayout>
- <AuthLayout>{page}</AuthLayout>
- </DefaultLayout>
- )
-}
-export default PageLayout
+ThirdPartyPage.getLayout = (page) => <AuthProvidersLayout>{page}</AuthProvidersLayout>
+
+export default ThirdPartyPage
diff --git a/apps/studio/pages/project/[ref]/auth/users.tsx b/apps/studio/pages/project/[ref]/auth/users.tsx
index 6fe46239939..33cde059efa 100644
--- a/apps/studio/pages/project/[ref]/auth/users.tsx
+++ b/apps/studio/pages/project/[ref]/auth/users.tsx
@@ -9,7 +9,7 @@ const UsersPage: NextPageWithLayout = () => {
UsersPage.getLayout = (page) => (
<DefaultLayout>
- <AuthLayout title="Auth">{page}</AuthLayout>
+ <AuthLayout>{page}</AuthLayout>
</DefaultLayout>
)
diff --git a/packages/ui-patterns/form/Layout/FormLayout.tsx b/packages/ui-patterns/form/Layout/FormLayout.tsx
index 48fb1e15517..f1940a90e6b 100644
--- a/packages/ui-patterns/form/Layout/FormLayout.tsx
+++ b/packages/ui-patterns/form/Layout/FormLayout.tsx
@@ -81,7 +81,7 @@ const LabelContainerVariants = cva('transition-all duration-500 ease-in-out', {
horizontal: 'flex flex-col gap-2 col-span-4',
vertical: 'flex flex-row gap-2 justify-between',
flex: 'flex flex-col gap-0',
- 'flex-row-reverse': 'flex flex-col gap-2',
+ 'flex-row-reverse': 'flex flex-col',
},
labelLayout: {
horizontal: '',
@@ -213,6 +213,12 @@ const FlexContainer = cva('', {
left: '',
right: '',
},
+ layout: {
+ horizontal: '',
+ vertical: '',
+ flex: '',
+ 'flex-row-reverse': '',
+ },
},
compoundVariants: [
{
@@ -225,6 +231,10 @@ const FlexContainer = cva('', {
align: 'right',
className: 'order-last',
},
+ {
+ layout: 'flex-row-reverse',
+ className: 'flex flex-col justify-center items-end',
+ },
],
})
@@ -294,10 +304,13 @@ export const FormLayout = React.forwardRef<
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
transition={{ duration: 0.3, ease: 'easeInOut' }}
- className="mt-2"
+ className={cn(layout === 'flex-row-reverse' ? 'mt-0' : 'mt-2')}
>
<FormMessage_Shadcn_
- className="mt-2 transition-opacity duration-300 ease-in-out"
+ className={cn(
+ 'mt-2 transition-opacity duration-300 ease-in-out',
+ layout === 'flex-row-reverse' && 'mt-0'
+ )}
data-formlayout-id={'message'}
/>
</motion.div>
@@ -351,7 +364,12 @@ export const FormLayout = React.forwardRef<
{...props}
className={cn(ContainerVariants({ size, flex, align, layout }), className)}
>
- {flex && <div className={cn(FlexContainer({ flex, align }))}>{props.children}</div>}
+ {flex && (
+ <div className={cn(FlexContainer({ flex, align, layout }))}>
+ {props.children}
+ {layout === 'flex-row-reverse' && renderError}
+ </div>
+ )}
{hasLabel || labelOptional || layout === 'horizontal' ? (
<>
<div
@@ -360,16 +378,16 @@ export const FormLayout = React.forwardRef<
>
{hasLabel && isReactForm ? (
<FormLabel_Shadcn_
- className="flex gap-2 items-center break-all"
- data-formlayout-id={'formLabel'}
+ className="text-foreground flex gap-2 items-center break-all"
+ data-formlayout-id="formLabel"
htmlFor={props.name || id}
>
<LabelContents />
</FormLabel_Shadcn_>
) : (
<Label_Shadcn_
- className="flex gap-2 items-center break-all"
- data-formlayout-id={'label'}
+ className="text-foreground flex gap-2 items-center break-all leading-normal"
+ data-formlayout-id="label"
htmlFor={props.name || id}
>
<LabelContents />
@@ -387,7 +405,7 @@ export const FormLayout = React.forwardRef<
{flex && (
<>
{renderDescription}
- {renderError}
+ {layout !== 'flex-row-reverse' && renderError}
</>
)}
</div>
diff --git a/packages/ui/src/components/shadcn/ui/card.tsx b/packages/ui/src/components/shadcn/ui/card.tsx
index 081e0715cdb..59529534d41 100644
--- a/packages/ui/src/components/shadcn/ui/card.tsx
+++ b/packages/ui/src/components/shadcn/ui/card.tsx
@@ -6,7 +6,7 @@ const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElemen
({ className, ...props }, ref) => (
<div
ref={ref}
- className={cn('rounded-lg border bg-card text-card-foreground shadow-sm', className)}
+ className={cn('rounded-lg border bg-surface-100 text-card-foreground shadow-sm', className)}
{...props}
/>
)
@@ -15,14 +15,18 @@ Card.displayName = 'Card'
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
- <div ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
+ <div
+ ref={ref}
+ className={cn('flex flex-col space-y-1.5 py-4 px-6 border-b', className)}
+ {...props}
+ />
)
)
CardHeader.displayName = 'CardHeader'
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
({ className, ...props }, ref) => (
- <h3 ref={ref} className={cn('text-base leading-none tracking-tight', className)} {...props} />
+ <h3 ref={ref} className={cn('text-xs font-mono uppercase', className)} {...props} />
)
)
CardTitle.displayName = 'CardTitle'
@@ -31,20 +35,20 @@ const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
- <p ref={ref} className={cn('text-sm text-foreground-light', className)} {...props} />
+ <p ref={ref} className={cn('text-sm text-foreground-muted', className)} {...props} />
))
CardDescription.displayName = 'CardDescription'
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
- <div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
+ <div ref={ref} className={cn('py-4 px-6 border-b last:border-none', className)} {...props} />
)
)
CardContent.displayName = 'CardContent'
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
- <div ref={ref} className={cn(' flex items-center p-6 pt-0', className)} {...props} />
+ <div ref={ref} className={cn(' flex items-center py-4 px-6', className)} {...props} />
)
)
CardFooter.displayName = 'CardFooter'
diff --git a/packages/ui/src/lib/constants.ts b/packages/ui/src/lib/constants.ts
index 6ce03165163..18357f71568 100644
--- a/packages/ui/src/lib/constants.ts
+++ b/packages/ui/src/lib/constants.ts
@@ -109,3 +109,13 @@ export const SIZE_VARIANTS_INNER = {
}
export const SIZE_VARIANTS_DEFAULT = 'small'
+
+export type PageSize = 'default' | 'small' | 'medium' | 'large' | 'full'
+
+export const PAGE_SIZE_CLASSES = {
+ small: 'max-w-3xl px-8',
+ medium: 'max-w-5xl px-8',
+ large: 'max-w-7xl px-8',
+ default: 'max-w-5xl px-8',
+ full: 'w-full',
+} as const