url-configuration.tsx67 lines · main
| 1 | import { PermissionAction } from '@supabase/shared-types/out/constants' |
| 2 | import { PageContainer } from 'ui-patterns/PageContainer' |
| 3 | import { |
| 4 | PageHeader, |
| 5 | PageHeaderDescription, |
| 6 | PageHeaderMeta, |
| 7 | PageHeaderSummary, |
| 8 | PageHeaderTitle, |
| 9 | } from 'ui-patterns/PageHeader' |
| 10 | import { PageSection, PageSectionContent } from 'ui-patterns/PageSection' |
| 11 | import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' |
| 12 | |
| 13 | import { RedirectUrls } from '@/components/interfaces/Auth/RedirectUrls/RedirectUrls' |
| 14 | import SiteUrl from '@/components/interfaces/Auth/SiteUrl/SiteUrl' |
| 15 | import AuthLayout from '@/components/layouts/AuthLayout/AuthLayout' |
| 16 | import DefaultLayout from '@/components/layouts/DefaultLayout' |
| 17 | import NoPermission from '@/components/ui/NoPermission' |
| 18 | import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions' |
| 19 | import type { NextPageWithLayout } from '@/types' |
| 20 | |
| 21 | const URLConfiguration: NextPageWithLayout = () => { |
| 22 | const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( |
| 23 | PermissionAction.READ, |
| 24 | 'custom_config_gotrue' |
| 25 | ) |
| 26 | |
| 27 | if (isPermissionsLoaded && !canReadAuthSettings) { |
| 28 | return <NoPermission isFullPage resourceText="access your project's authentication settings" /> |
| 29 | } |
| 30 | |
| 31 | return ( |
| 32 | <> |
| 33 | <PageHeader size="default"> |
| 34 | <PageHeaderMeta> |
| 35 | <PageHeaderSummary> |
| 36 | <PageHeaderTitle>URL Configuration</PageHeaderTitle> |
| 37 | <PageHeaderDescription> |
| 38 | Configure site URL and redirect URLs for authentication |
| 39 | </PageHeaderDescription> |
| 40 | </PageHeaderSummary> |
| 41 | </PageHeaderMeta> |
| 42 | </PageHeader> |
| 43 | <PageContainer size="default"> |
| 44 | {!isPermissionsLoaded ? ( |
| 45 | <PageSection> |
| 46 | <PageSectionContent> |
| 47 | <GenericSkeletonLoader /> |
| 48 | </PageSectionContent> |
| 49 | </PageSection> |
| 50 | ) : ( |
| 51 | <> |
| 52 | <SiteUrl /> |
| 53 | <RedirectUrls /> |
| 54 | </> |
| 55 | )} |
| 56 | </PageContainer> |
| 57 | </> |
| 58 | ) |
| 59 | } |
| 60 | |
| 61 | URLConfiguration.getLayout = (page) => ( |
| 62 | <DefaultLayout> |
| 63 | <AuthLayout title="URL Configuration">{page}</AuthLayout> |
| 64 | </DefaultLayout> |
| 65 | ) |
| 66 | |
| 67 | export default URLConfiguration |