Skip to content

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

chore: implement getLayout in AuthLayout

Alaister Young18d570753e57
diff --git a/studio/components/layouts/AuthLayout/AuthLayout.tsx b/studio/components/layouts/AuthLayout/AuthLayout.tsx
index da038f2bfa5..425df98f1ae 100644
--- a/studio/components/layouts/AuthLayout/AuthLayout.tsx
+++ b/studio/components/layouts/AuthLayout/AuthLayout.tsx
@@ -2,7 +2,7 @@ import { FC, ReactNode, useState, useEffect } from 'react'
import { observer } from 'mobx-react-lite'
import { useRouter } from 'next/router'
-import { useStore } from 'hooks'
+import { useStore, withAuth } from 'hooks'
import BaseLayout from '../'
import Error from 'components/ui/Error'
import ProductMenu from 'components/ui/ProductMenu'
@@ -57,4 +57,4 @@ const AuthLayout: FC<Props> = ({ title, children }) => {
)
}
-export default observer(AuthLayout)
+export default withAuth(observer(AuthLayout))
diff --git a/studio/components/layouts/AuthLayout/AuthLayout.utils.ts b/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
index 83e371aa3e1..e535a05a179 100644
--- a/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
+++ b/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
@@ -15,7 +15,7 @@ export const generateAuthMenu = (ref: string): ProductMenuGroup[] => {
? [
{
name: 'Logs',
- key: 'logs',
+ key: 'auth-logs',
url: `/project/${ref}/auth/auth-logs`,
items: [],
},
diff --git a/studio/pages/project/[ref]/auth/auth-logs.tsx b/studio/pages/project/[ref]/auth/auth-logs.tsx
index 5671ee9ef92..fc343aa0542 100644
--- a/studio/pages/project/[ref]/auth/auth-logs.tsx
+++ b/studio/pages/project/[ref]/auth/auth-logs.tsx
@@ -1,17 +1,18 @@
import { observer } from 'mobx-react-lite'
-import { withAuth, useStore } from 'hooks'
+import { useStore } from 'hooks'
import { AuthLayout } from 'components/layouts'
import LogsPreviewer from 'components/interfaces/Settings/Logs/LogsPreviewer'
+import { NextPageWithLayout } from 'types'
-const Auth = () => {
+const LogsPage: NextPageWithLayout = () => {
const { ui } = useStore()
const project = ui.selectedProject
return (
- <AuthLayout title="Auth Logs">
- {project && <LogsPreviewer condensedLayout projectRef={project!.ref} queryType="auth" />}
- </AuthLayout>
+ <>{project && <LogsPreviewer condensedLayout projectRef={project!.ref} queryType="auth" />}</>
)
}
-export default withAuth(observer(Auth))
+LogsPage.getLayout = (page) => <AuthLayout title="Auth Logs">{page}</AuthLayout>
+
+export default observer(LogsPage)
diff --git a/studio/pages/project/[ref]/auth/index.tsx b/studio/pages/project/[ref]/auth/index.tsx
index 6a5220f456e..4544e8a6cdb 100644
--- a/studio/pages/project/[ref]/auth/index.tsx
+++ b/studio/pages/project/[ref]/auth/index.tsx
@@ -1,15 +1,12 @@
-import { NextPage } from 'next'
import { observer } from 'mobx-react-lite'
-import { withAuth } from 'hooks'
import { AuthLayout } from 'components/layouts'
+import { NextPageWithLayout } from 'types'
-const Authentication: NextPage = () => {
- return (
- <AuthLayout title="Authentication">
- <>{/* <h1>Use this as a template for authentication pages</h1> */}</>
- </AuthLayout>
- )
+const Authentication: NextPageWithLayout = () => {
+ return <>{/* <h1>Use this as a template for authentication pages</h1> */}</>
}
-export default withAuth(observer(Authentication))
+Authentication.getLayout = (page) => <AuthLayout title="Authentication">{page}</AuthLayout>
+
+export default observer(Authentication)
diff --git a/studio/pages/project/[ref]/auth/policies.tsx b/studio/pages/project/[ref]/auth/policies.tsx
index a2d73e5b52a..88a0e27ff55 100644
--- a/studio/pages/project/[ref]/auth/policies.tsx
+++ b/studio/pages/project/[ref]/auth/policies.tsx
@@ -1,5 +1,5 @@
import { isEmpty } from 'lodash'
-import React, { createContext, useContext, useState, useEffect } from 'react'
+import React, { createContext, useContext, useState, useEffect, PropsWithChildren } from 'react'
import { Button, IconSearch, Input } from '@supabase/ui'
import { observer, useLocalObservable } from 'mobx-react-lite'
@@ -10,10 +10,11 @@ import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'
import PolicyTableRow from 'components/to-be-cleaned/Auth/PolicyTableRow'
import PolicyEditorModal from 'components/to-be-cleaned/Auth/PolicyEditorModal'
import NoTableState from 'components/ui/States/NoTableState'
+import { NextPageWithLayout } from 'types'
const PageContext = createContext(null)
-const AuthPoliciesPage = ({}) => {
+const AuthPoliciesLayout = ({ children }: PropsWithChildren<{}>) => {
const PageState: any = useLocalObservable(() => ({
meta: null,
project: null,
@@ -60,17 +61,12 @@ const AuthPoliciesPage = ({}) => {
return (
<PageContext.Provider value={PageState}>
- <AuthLayout title="Auth">
- <div className="p-4">
- <AuthPolicies />
- </div>
- </AuthLayout>
+ <div className="p-4">{children}</div>
</PageContext.Provider>
)
}
-export default withAuth(observer(AuthPoliciesPage))
-const AuthPolicies = observer(() => {
+const AuthPoliciesPage: NextPageWithLayout = () => {
const PageState: any = useContext(PageContext)
const { meta } = useStore()
@@ -84,7 +80,7 @@ const AuthPolicies = observer(() => {
return (
<>
<div className="mb-4">
- <div className="flex justify-between items-center">
+ <div className="flex items-center justify-between">
<div>
<Input
size="small"
@@ -110,7 +106,15 @@ const AuthPolicies = observer(() => {
</div>
</>
)
-})
+}
+
+AuthPoliciesPage.getLayout = (page) => (
+ <AuthLayout title="Auth">
+ <AuthPoliciesLayout>{page}</AuthPoliciesLayout>
+ </AuthLayout>
+)
+
+export default observer(AuthPoliciesPage)
const AuthPoliciesTables = observer(() => {
const { ui, meta } = useStore()
diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsx
index 898bd73a8c6..21dcb237ec4 100644
--- a/studio/pages/project/[ref]/auth/settings.tsx
+++ b/studio/pages/project/[ref]/auth/settings.tsx
@@ -7,7 +7,7 @@ import { Button, Typography, Toggle as UIToggle } from '@supabase/ui'
import Divider from 'components/ui/Divider'
import { API_URL } from 'lib/constants'
-import { withAuth, useStore } from 'hooks'
+import { useStore } from 'hooks'
import { authConfig } from 'stores/jsonSchema'
import { get, patch } from 'lib/common/fetch'
import { pluckJsonSchemaFields } from 'lib/helpers'
@@ -18,17 +18,19 @@ import Toggle from 'components/to-be-cleaned/forms/Toggle'
import ToggleField from 'components/to-be-cleaned/forms/ToggleField'
import SecretField from 'components/to-be-cleaned/forms/SecretField'
import SchemaFormPanel from 'components/to-be-cleaned/forms/SchemaFormPanel'
+import { NextPageWithLayout } from 'types'
-const Auth = () => {
+const Auth: NextPageWithLayout = () => {
return (
- <AuthLayout title="Auth">
- <div className="p-4">
- <Settings />
- </div>
- </AuthLayout>
+ <div className="p-4">
+ <Settings />
+ </div>
)
}
-export default withAuth(observer(Auth))
+
+Auth.getLayout = (page) => <AuthLayout title="Auth">{page}</AuthLayout>
+
+export default observer(Auth)
const Settings = () => {
const router = useRouter()
@@ -129,7 +131,8 @@ const Settings = () => {
DISABLE_SIGNUP: model.DISABLE_SIGNUP,
JWT_EXP: model.JWT_EXP || undefined,
PASSWORD_MIN_LENGTH: model.PASSWORD_MIN_LENGTH || undefined,
- SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION: model.SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION || false,
+ SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION:
+ model.SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION || false,
}}
onSubmit={(model: any) => onFormSubmit(model)}
>
@@ -519,7 +522,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_APPLE_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://developer.apple.com/account/resources/identifiers/add/bundleId"
target="_blank"
>
@@ -548,7 +551,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_AZURE_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app"
target="_blank"
>
@@ -582,7 +585,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_BITBUCKET_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/"
target="_blank"
>
@@ -611,7 +614,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_DISCORD_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://discord.com/developers/applications#top"
target="_blank"
>
@@ -640,7 +643,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_FACEBOOK_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://developers.facebook.com/apps/"
target="_blank"
>
@@ -669,7 +672,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_GITHUB_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://github.com/settings/applications/new"
target="_blank"
>
@@ -698,7 +701,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_GITLAB_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://gitlab.com/oauth/applications"
target="_blank"
>
@@ -727,7 +730,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_GOOGLE_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://console.developers.google.com/apis/credentials"
target="_blank"
>
@@ -755,11 +758,7 @@ const Settings = () => {
name="EXTERNAL_KEYCLOAK_ENABLED"
addOns={
externalProvidersModel.EXTERNAL_KEYCLOAK_ENABLED && (
- <a
- className="pl-4 text-scale-900"
- href="https://www.keycloak.org/"
- target="_blank"
- >
+ <a className="text-scale-900 pl-4" href="https://www.keycloak.org/" target="_blank">
Create new credentials
</a>
)
@@ -848,7 +847,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_TWITCH_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://dev.twitch.tv/console"
target="_blank"
>
@@ -877,7 +876,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_TWITTER_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://developer.twitter.com/en/portal/dashboard"
target="_blank"
>
@@ -906,7 +905,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_SLACK_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://api.slack.com/apps"
target="_blank"
>
@@ -935,7 +934,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_SPOTIFY_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://developer.spotify.com/dashboard/"
target="_blank"
>
@@ -964,7 +963,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_WORKOS_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://dashboard.workos.com"
target="_blank"
>
@@ -998,7 +997,7 @@ const Settings = () => {
addOns={
externalProvidersModel.EXTERNAL_ZOOM_ENABLED && (
<a
- className="pl-4 text-scale-900"
+ className="text-scale-900 pl-4"
href="https://developers.zoom.us/"
target="_blank"
>
@@ -1071,8 +1070,8 @@ const AuditLog = ({ interval, projectRef }: any) => {
return (
<Panel
title={
- <div className=" w-full flex items-center justify-between">
- <Typography.Title level={5} className="flex-1 block">
+ <div className=" flex w-full items-center justify-between">
+ <Typography.Title level={5} className="block flex-1">
Audit Trail
</Typography.Title>
<div className="flex-1 text-right">
diff --git a/studio/pages/project/[ref]/auth/templates.tsx b/studio/pages/project/[ref]/auth/templates.tsx
index a6f277ea0f9..92c73531f3f 100644
--- a/studio/pages/project/[ref]/auth/templates.tsx
+++ b/studio/pages/project/[ref]/auth/templates.tsx
@@ -1,19 +1,20 @@
import { observer } from 'mobx-react-lite'
-import { withAuth, useStore } from 'hooks'
+import { useStore } from 'hooks'
import { AuthLayout } from 'components/layouts'
import { Templates } from 'components/interfaces/Authentication'
+import { NextPageWithLayout } from 'types'
-const Auth = () => {
+const TemplatesPage: NextPageWithLayout = () => {
const { ui } = useStore()
const project = ui.selectedProject
return (
- <AuthLayout title="Auth">
- <div className="p-4">
- <Templates project={project} />
- </div>
- </AuthLayout>
+ <div className="p-4">
+ <Templates project={project} />
+ </div>
)
}
-export default withAuth(observer(Auth))
+TemplatesPage.getLayout = (page) => <AuthLayout title="Auth">{page}</AuthLayout>
+
+export default observer(TemplatesPage)
diff --git a/studio/pages/project/[ref]/auth/users.tsx b/studio/pages/project/[ref]/auth/users.tsx
index 50c52762270..d88d8b88a14 100644
--- a/studio/pages/project/[ref]/auth/users.tsx
+++ b/studio/pages/project/[ref]/auth/users.tsx
@@ -1,16 +1,17 @@
-import React, { createContext, useContext, useEffect } from 'react'
+import React, { createContext, useContext, useEffect, PropsWithChildren } from 'react'
import { observer, useLocalObservable } from 'mobx-react-lite'
import { useRouter } from 'next/router'
import { get } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
-import { withAuth, useStore } from 'hooks'
+import { useStore } from 'hooks'
import { AuthLayout } from 'components/layouts'
import { Users } from 'components/interfaces/Authentication'
+import { NextPageWithLayout } from 'types'
export const PageContext = createContext(null)
-const Page = () => {
+const PageLayout = ({ children }: PropsWithChildren<{}>) => {
const PageState: any = useLocalObservable(() => ({
projectRef: undefined,
projectKpsVersion: undefined,
@@ -71,15 +72,10 @@ const Page = () => {
const router = useRouter()
PageState.projectRef = router.query.ref
- return (
- <PageContext.Provider value={PageState}>
- <PageLayout />
- </PageContext.Provider>
- )
+ return <PageContext.Provider value={PageState}>{children}</PageContext.Provider>
}
-export default withAuth(observer(Page))
-const PageLayout = observer(() => {
+const UsersPage: NextPageWithLayout = () => {
const { ui } = useStore()
const PageState: any = useContext(PageContext)
const project: any = ui.selectedProject
@@ -88,9 +84,13 @@ const PageLayout = observer(() => {
PageState!.projectKpsVersion = project?.kpsVersion
}, [project])
- return (
- <AuthLayout title="Auth">
- <Users />
- </AuthLayout>
- )
-})
+ return <Users />
+}
+
+UsersPage.getLayout = (page) => (
+ <AuthLayout title="Auth">
+ <PageLayout>{page}</PageLayout>
+ </AuthLayout>
+)
+
+export default observer(UsersPage)