Skip to content

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

chore: adding loading states to forms

Jonathan Summers-Muir2392cf7b3bf1
diff --git a/studio/components/interfaces/Auth/AuthProvidersForm.tsx b/studio/components/interfaces/Auth/AuthProvidersForm.tsx
index 7fcafb1ef8f..bfd3d3029be 100644
--- a/studio/components/interfaces/Auth/AuthProvidersForm.tsx
+++ b/studio/components/interfaces/Auth/AuthProvidersForm.tsx
@@ -6,12 +6,12 @@ import {
IconCheck,
IconChevronUp,
Input,
+ InputNumber,
Listbox,
Toggle,
- Menu,
- InputNumber,
} from '@supabase/ui'
import { FormHeader } from 'components/ui/Forms'
+import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'
import { useStore } from 'hooks'
import { observer } from 'mobx-react-lite'
import { useState } from 'react'
@@ -52,8 +52,29 @@ interface Provider {
}
}
+const ProviderCollapsibleClasses = `
+ bg-scale-100 dark:bg-scale-300
+ hover:bg-scale-200 dark:hover:bg-scale-500
+ data-open:bg-scale-200 dark:data-open:bg-scale-500
+ border-scale-300
+
+ dark:border-scale-500 hover:border-scale-500
+ dark:hover:border-scale-700 data-open:border-scale-700
+
+ data-open:pb-px col-span-12 mx-auto
+ -space-y-px overflow-hidden
+ border shadow
+
+ transition
+ first:rounded-tl
+ first:rounded-tr
+ last:rounded-bl
+ last:rounded-br
+ hover:z-50`
+
const AuthProvidersForm = () => {
const providers = PROVIDERS_SCHEMAS
+ const { authConfig } = useStore()
return (
<div>
@@ -63,13 +84,17 @@ const AuthProvidersForm = () => {
/>
<div className="-space-y-px">
- {
- // @ts-expect-error
- // to do: fix type error, needs to be dynamic
- providers.map((provider: Provider, i) => {
- return <ProviderForm provider={provider} key={i} />
- })
- }
+ {!authConfig.isLoaded
+ ? providers.map((i) => (
+ <div className={ProviderCollapsibleClasses + ' p-3 px-6'}>
+ <HorizontalShimmerWithIcon />
+ </div>
+ ))
+ : // @ts-expect-error
+ // to do: fix type error, needs to be dynamic
+ providers.map((provider: Provider, i) => {
+ return <ProviderForm provider={provider} key={i} />
+ })}
</div>
</div>
)
@@ -92,30 +117,7 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {
})
return (
- <Collapsible
- open={open}
- onOpenChange={setOpen}
- className="
- bg-scale-100 dark:bg-scale-300
- hover:bg-scale-200 dark:hover:bg-scale-500
- data-open:bg-scale-200 dark:data-open:bg-scale-500
- border-scale-300
-
- dark:border-scale-500 hover:border-scale-500
- dark:hover:border-scale-700 data-open:border-scale-700
-
- data-open:pb-px col-span-12 mx-auto
- -space-y-px overflow-hidden
- border shadow
-
- transition
- first:rounded-tl
- first:rounded-tr
- last:rounded-bl
- last:rounded-br
- hover:z-50
- "
- >
+ <Collapsible open={open} onOpenChange={setOpen} className={ProviderCollapsibleClasses}>
<Collapsible.Trigger asChild>
<button
type="button"
diff --git a/studio/components/interfaces/Auth/AutoSchemaForm.tsx b/studio/components/interfaces/Auth/AutoSchemaForm.tsx
index 0dcde33f588..741f850edbf 100644
--- a/studio/components/interfaces/Auth/AutoSchemaForm.tsx
+++ b/studio/components/interfaces/Auth/AutoSchemaForm.tsx
@@ -1,6 +1,10 @@
-import { Form, Input, InputNumber, Toggle } from '@supabase/ui'
+import { Form, Input, InputNumber, Loading, Toggle } from '@supabase/ui'
import { useStore } from 'hooks'
+import { toJS } from 'mobx'
+import { observer } from 'mobx-react-lite'
import React from 'react'
+import { useState } from 'react'
+import { useEffect } from 'react'
import { boolean, number, object, string } from 'yup'
import {
FormActions,
@@ -11,9 +15,11 @@ import {
FormSectionLabel,
} from '../../ui/Forms'
-const AutoSchemaForm = () => {
+const AutoSchemaForm = observer(() => {
const { authConfig, ui } = useStore()
+ // const [isLoaded, setIsLoaded] = useState(false)
+
const INITIAL_VALUES = {
DISABLE_SIGNUP: !authConfig.config.DISABLE_SIGNUP,
JWT_EXP: authConfig.config.JWT_EXP,
@@ -32,6 +38,8 @@ const AutoSchemaForm = () => {
.required('Must have a Reuse Interval value'),
})
+ const isLoaded = authConfig.isLoaded
+
return (
<>
<Form
@@ -59,8 +67,19 @@ const AutoSchemaForm = () => {
}}
validationSchema={schema}
>
- {({ isSubmitting, handleReset, values, initialValues }: any) => {
+ {({ isSubmitting, handleReset, resetForm, values, initialValues }: any) => {
+ /**
+ * Tracks changes in form
+ */
const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)
+
+ /**
+ * Form is reset once remote data is loaded in store
+ */
+ useEffect(() => {
+ resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })
+ }, [authConfig.isLoaded])
+
return (
<>
<FormHeader
@@ -81,11 +100,7 @@ const AutoSchemaForm = () => {
}
>
<FormSection header={<FormSectionLabel>User Signups</FormSectionLabel>}>
- <FormSectionContent>
- {/* <div className="flex flex-col justify-between space-y-2">
- <div className="shimmering-loader mx-1 w-2/3 rounded py-3" />
- </div>
- <div className="shimmering-loader mx-1 w-1/3 rounded py-3"></div> */}
+ <FormSectionContent loading={!isLoaded}>
<Toggle
id="DISABLE_SIGNUP"
size="small"
@@ -97,7 +112,7 @@ const AutoSchemaForm = () => {
</FormSection>
<div className="border-scale-400 border-t"></div>
<FormSection header={<FormSectionLabel>User Sessions</FormSectionLabel>}>
- <FormSectionContent>
+ <FormSectionContent loading={!isLoaded}>
{/**
*
* permitted redirects
@@ -135,6 +150,6 @@ const AutoSchemaForm = () => {
</Form>
</>
)
-}
+})
export { AutoSchemaForm }
diff --git a/studio/components/interfaces/Forms/CommaSeperatedString.tsx b/studio/components/interfaces/Auth/RedirectDomains.tsx
similarity index 86%
rename from studio/components/interfaces/Forms/CommaSeperatedString.tsx
rename to studio/components/interfaces/Auth/RedirectDomains.tsx
index 120ca76d5a2..2048cbbe9f2 100644
--- a/studio/components/interfaces/Forms/CommaSeperatedString.tsx
+++ b/studio/components/interfaces/Auth/RedirectDomains.tsx
@@ -1,12 +1,13 @@
import { Button, Form, IconGlobe, IconTrash, Input, Modal } from '@supabase/ui'
import { FormHeader } from 'components/ui/Forms'
+import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'
import { EmptyListState } from 'components/ui/States'
import { useStore } from 'hooks'
import { observer } from 'mobx-react-lite'
import { useState } from 'react'
import { object, string } from 'yup'
-const CommaSeperatedString = () => {
+const RedirectDomains = () => {
const { authConfig, ui } = useStore()
const URI_ALLOW_LIST_ARRAY = authConfig.config.URI_ALLOW_LIST
@@ -36,7 +37,7 @@ const CommaSeperatedString = () => {
domain: string().matches(domainRegex, 'URL is not valid').required(),
})
- const DomainsForm = () => {
+ const Main = () => {
const [open, setOpen] = useState(false)
return (
@@ -51,14 +52,7 @@ const CommaSeperatedString = () => {
size="small"
visible={open}
onCancel={() => setOpen(!open)}
- header={
- <div className="text-scale-1200 flex items-center gap-2">
- <div className="flex items-baseline gap-2">
- <h3 className="text-sm">Add a new domain</h3>
- </div>
- </div>
- }
- contentStyle={{ padding: 0 }}
+ header={<h3 className="text-sm">Add a new domain</h3>}
hideFooter
>
<Form
@@ -124,24 +118,38 @@ const CommaSeperatedString = () => {
)
}
- console.log('RENDER DOMAINS')
+ const ValueContainer = ({ children }: { children: React.ReactNode }) => (
+ <div
+ className="
+ bg-scale-100 dark:bg-scale-300 border-scale-500 text-scale-1200 flex items-center
+ justify-between gap-2
+ border px-6
+ py-4 text-sm
+ first:rounded-tr first:rounded-tl last:rounded-br last:rounded-bl
+ "
+ >
+ {children}
+ </div>
+ )
return (
<div>
- <DomainsForm />
+ <Main />
<div className="-space-y-px">
- {URI_ALLOW_LIST_ARRAY.length > 0 ? (
+ {!authConfig.isLoaded ? (
+ <>
+ <ValueContainer>
+ <HorizontalShimmerWithIcon />
+ </ValueContainer>
+ <ValueContainer>
+ <HorizontalShimmerWithIcon />
+ </ValueContainer>
+ </>
+ ) : URI_ALLOW_LIST_ARRAY.length > 0 ? (
URI_ALLOW_LIST_ARRAY.map((domain: string) => {
return (
<>
- <div
- className="bg-scale-100 dark:bg-scale-300 border-scale-500 text-scale-1200 flex items-center
- justify-between gap-2
- border px-6
- py-4 text-sm
- first:rounded-tr first:rounded-tl last:rounded-br last:rounded-bl
- "
- >
+ <ValueContainer>
<div className="flex items-center gap-2 font-mono">
<span className="text-scale-900">
<IconGlobe strokeWidth={2} size={14} />
@@ -158,7 +166,7 @@ const CommaSeperatedString = () => {
>
Remove
</Button>
- </div>
+ </ValueContainer>
</>
)
})
@@ -184,14 +192,7 @@ const CommaSeperatedString = () => {
size="small"
visible={deleteOpen}
onCancel={() => setDeleteOpen(!open)}
- header={
- <div className="text-scale-1200 flex items-center gap-2">
- <div className="flex items-baseline gap-2">
- <h3 className="text-sm">Remove domain</h3>
- </div>
- </div>
- }
- contentStyle={{ padding: 0 }}
+ header={<h3 className="text-sm">Remove domain</h3>}
hideFooter
>
<div className="mb-4 space-y-4 pt-4">
@@ -245,4 +246,4 @@ const CommaSeperatedString = () => {
)
}
-export default observer(CommaSeperatedString)
+export default observer(RedirectDomains)
diff --git a/studio/components/ui/Forms/FormPanel.tsx b/studio/components/ui/Forms/FormPanel.tsx
index 148c686c498..f168ef1dd7a 100644
--- a/studio/components/ui/Forms/FormPanel.tsx
+++ b/studio/components/ui/Forms/FormPanel.tsx
@@ -11,9 +11,11 @@ interface Props {
const FormPanel = ({ children, header, footer }: Props) => (
<div
className="
- bg-scale-100
- dark:bg-scale-300
- border-scale-400 overflow-hidden rounded-md border shadow"
+ bg-scale-100
+ dark:bg-scale-300
+ border-scale-400
+ overflow-hidden
+ rounded-md border shadow"
>
{header && (
<div className="bg-scale-100 dark:bg-scale-200 border-scale-400 border-b px-8 py-4">
diff --git a/studio/components/ui/Forms/FormSection.tsx b/studio/components/ui/Forms/FormSection.tsx
index e1a7684672c..3f983ea99ec 100644
--- a/studio/components/ui/Forms/FormSection.tsx
+++ b/studio/components/ui/Forms/FormSection.tsx
@@ -14,8 +14,27 @@ const FormSection = ({
const FormSectionLabel = ({ children }: { children: React.ReactNode | string }) => {
return <label className="text-scale-1200 col-span-12 text-sm lg:col-span-4">{children}</label>
}
-const FormSectionContent = ({ children }: { children: React.ReactNode | string }) => {
- return <div className="col-span-12 flex flex-col gap-6 lg:col-span-8">{children}</div>
+const FormSectionContent = ({
+ children,
+ loading = true,
+}: {
+ children: React.ReactNode | string
+ loading?: boolean
+}) => {
+ return (
+ <div className="relative col-span-12 flex flex-col gap-6 lg:col-span-8">
+ {loading ? (
+ <div className="flex w-full flex-col gap-2">
+ <div className="shimmering-loader h-2 w-1/3 rounded"></div>
+ <div className="flex flex-col justify-between space-y-2">
+ <div className="shimmering-loader h-[34px] w-2/3 rounded" />
+ </div>
+ </div>
+ ) : (
+ children
+ )}
+ </div>
+ )
}
export { FormSection, FormSectionContent, FormSectionLabel }
diff --git a/studio/components/ui/Shimmers/Shimmers.tsx b/studio/components/ui/Shimmers/Shimmers.tsx
new file mode 100644
index 00000000000..88ee66fde88
--- /dev/null
+++ b/studio/components/ui/Shimmers/Shimmers.tsx
@@ -0,0 +1,11 @@
+const HorizontalShimmerWithIcon = () => (
+ <div className="flex w-full flex-row items-center justify-between gap-2">
+ <div className="flex flex-row items-center gap-3">
+ <div className="shimmering-loader h-6 w-6 rounded-full"></div>
+ <div className="shimmering-loader h-2 w-32 rounded"></div>
+ </div>
+ <div className="shimmering-loader h-6 w-20 rounded"></div>
+ </div>
+)
+
+export { HorizontalShimmerWithIcon }
diff --git a/studio/components/ui/Shimmers/index.tsx b/studio/components/ui/Shimmers/index.tsx
new file mode 100644
index 00000000000..32a430a74f8
--- /dev/null
+++ b/studio/components/ui/Shimmers/index.tsx
@@ -0,0 +1 @@
+export * from './Shimmers'
diff --git a/studio/package-lock.json b/studio/package-lock.json
index 5aa3face7f9..b935078514e 100644
--- a/studio/package-lock.json
+++ b/studio/package-lock.json
@@ -22,7 +22,7 @@
"@supabase/react-data-grid": "^7.1.0-beta.7",
"@supabase/shared-types": "^0.1.21",
"@supabase/supabase-js": "^1.35.3",
- "@supabase/ui": "0.37.0-alpha.63",
+ "@supabase/ui": "0.37.0-alpha.64",
"ajv": "^8.6.3",
"analytics-node": "^3.5.0",
"awesome-debounce-promise": "^2.1.0",
@@ -8319,9 +8319,9 @@
}
},
"node_modules/@supabase/ui": {
- "version": "0.37.0-alpha.63",
- "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.63.tgz",
- "integrity": "sha512-VMFAymtFzdZaviYFvEOfZYKT72A2yq/S023aXsbm0g7NIxedcCBhu60dYS3DlHV0zqzFvkg6b6VHlfRk9sKoEA==",
+ "version": "0.37.0-alpha.64",
+ "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.64.tgz",
+ "integrity": "sha512-fB9Z7CAk6Ul4AA/WgyVhLsbxeznyPLS1HGGgX3UKU6yzGRhJdXzvrAKz1M+eFUMEjUuOi6RR7kIwelJL/LVrQA==",
"dependencies": {
"@headlessui/react": "^1.0.0",
"@mertasan/tailwindcss-variables": "^2.0.1",
@@ -36160,9 +36160,9 @@
}
},
"@supabase/ui": {
- "version": "0.37.0-alpha.63",
- "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.63.tgz",
- "integrity": "sha512-VMFAymtFzdZaviYFvEOfZYKT72A2yq/S023aXsbm0g7NIxedcCBhu60dYS3DlHV0zqzFvkg6b6VHlfRk9sKoEA==",
+ "version": "0.37.0-alpha.64",
+ "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.64.tgz",
+ "integrity": "sha512-fB9Z7CAk6Ul4AA/WgyVhLsbxeznyPLS1HGGgX3UKU6yzGRhJdXzvrAKz1M+eFUMEjUuOi6RR7kIwelJL/LVrQA==",
"requires": {
"@headlessui/react": "^1.0.0",
"@mertasan/tailwindcss-variables": "^2.0.1",
diff --git a/studio/package.json b/studio/package.json
index 0f68eb4ef39..3fe307a18b4 100644
--- a/studio/package.json
+++ b/studio/package.json
@@ -26,7 +26,7 @@
"@supabase/react-data-grid": "^7.1.0-beta.7",
"@supabase/shared-types": "^0.1.21",
"@supabase/supabase-js": "^1.35.3",
- "@supabase/ui": "0.37.0-alpha.63",
+ "@supabase/ui": "0.37.0-alpha.64",
"ajv": "^8.6.3",
"analytics-node": "^3.5.0",
"awesome-debounce-promise": "^2.1.0",
diff --git a/studio/pages/project/[ref]/auth/settings-new.tsx b/studio/pages/project/[ref]/auth/settings-new.tsx
index 05f4da132c5..7b94774a78d 100644
--- a/studio/pages/project/[ref]/auth/settings-new.tsx
+++ b/studio/pages/project/[ref]/auth/settings-new.tsx
@@ -1,8 +1,7 @@
-import { Loading } from '@supabase/ui'
import { AuthProvidersForm } from 'components/interfaces'
-import CommaSeperatedString from 'components/interfaces/Forms/CommaSeperatedString'
+import RedirectDomains from 'components/interfaces/Auth/RedirectDomains'
import { AuthLayout } from 'components/layouts'
-import { AutoSchemaForm, FormHeader, FormsContainer } from 'components/ui/Forms'
+import { AutoSchemaForm, FormsContainer } from 'components/ui/Forms'
import { useStore } from 'hooks'
import { observer } from 'mobx-react-lite'
import React, { useEffect } from 'react'
@@ -16,22 +15,17 @@ const PageLayout: NextPageWithLayout = () => {
authConfig.load()
}, [ui.selectedProjectRef])
- if (!authConfig.isLoaded) {
- return <Loading active={true}>{''}</Loading>
- }
-
if (authConfig)
return (
<FormsContainer>
<AutoSchemaForm />
- <CommaSeperatedString />
+ <RedirectDomains />
<AuthProvidersForm />
</FormsContainer>
)
}
PageLayout.getLayout = (page) => {
- // console.log()
return <AuthLayout>{page}</AuthLayout>
}
diff --git a/studio/styles/storage.scss b/studio/styles/storage.scss
index 1d81cbb6021..6f619c4e361 100644
--- a/studio/styles/storage.scss
+++ b/studio/styles/storage.scss
@@ -65,9 +65,9 @@
animation: shimmer 2s infinite linear;
background: linear-gradient(
to right,
- var(--colors-scale4) 4%,
- var(--colors-scale5) 25%,
- var(--colors-scale4) 36%
+ var(--colors-scale5) 4%,
+ var(--colors-scale6) 25%,
+ var(--colors-scale5) 36%
);
background-size: 1000px 100%;
}
diff --git a/studio/tailwind.config.js b/studio/tailwind.config.js
index a8468bf8db4..e961bfa6b9b 100644
--- a/studio/tailwind.config.js
+++ b/studio/tailwind.config.js
@@ -81,6 +81,9 @@ module.exports = ui({
dark: 'var(--colors-scale2)',
}),
extend: {
+ transitionProperty: {
+ height: 'height',
+ },
typography: ({ theme }) => ({
// Removal of backticks in code blocks for tailwind v3.0
// https://github.com/tailwindlabs/tailwindcss-typography/issues/135
diff --git a/web/docs/guides/auth/auth-slack.mdx b/web/docs/guides/auth/auth-slack.mdx
index 75c4e4f0feb..fd60e76a8b1 100644
--- a/web/docs/guides/auth/auth-slack.mdx
+++ b/web/docs/guides/auth/auth-slack.mdx
@@ -73,7 +73,7 @@ Under `Redirect URLs`:
- Click `Settings` from the list to go to the `Authentication Settings` page.
- Enter the final (hosted) URL of your app under `Site URL` (this is important).
- Under `External OAuth Providers` turn `Slack Enabled` to ON.
-- Enter your `API Key` (`client_id`) and `API Secret Key` (`client_secret`) saved in the previous step.
+- Enter your `Client ID` (`client_id`) and `Client Secret` (`client_secret`) saved in the previous step.
- Click `Save`.
### Add login code to your client app
diff --git a/web/docs/guides/auth/auth-spotify.mdx b/web/docs/guides/auth/auth-spotify.mdx
index f27517b4b0e..760eaf85d04 100644
--- a/web/docs/guides/auth/auth-spotify.mdx
+++ b/web/docs/guides/auth/auth-spotify.mdx
@@ -68,7 +68,7 @@ Under `Redirect URIs`:
- Click `Settings` from the list to go to the `Authentication Settings` page.
- Enter the final (hosted) URL of your app under `Site URL` (this is important).
- Under `External OAuth Providers` turn `Spotify Enabled` to ON.
-- Enter your `API Key` (`client_id`) and `API Secret Key` (`client_secret`) saved in the previous step.
+- Enter your `Client ID` (`client_id`) and `Client Secret` (`client_secret`) saved in the previous step.
- Click `Save`.
### Add login code to your client app