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