general.tsx76 lines · main
| 1 | import { IS_PLATFORM } from 'common' |
| 2 | import { useRouter } from 'next/router' |
| 3 | import { useEffect } from 'react' |
| 4 | import { PageContainer } from 'ui-patterns/PageContainer' |
| 5 | import { |
| 6 | PageHeader, |
| 7 | PageHeaderDescription, |
| 8 | PageHeaderMeta, |
| 9 | PageHeaderSummary, |
| 10 | PageHeaderTitle, |
| 11 | } from 'ui-patterns/PageHeader' |
| 12 | |
| 13 | import { subscriptionHasHipaaAddon } from '@/components/interfaces/Billing/Subscription/Subscription.utils' |
| 14 | import { ComplianceConfig } from '@/components/interfaces/Settings/General/ComplianceConfig/ProjectComplianceMode' |
| 15 | import { CustomDomainConfig } from '@/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainConfig' |
| 16 | import { DeleteProjectPanel } from '@/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectPanel' |
| 17 | import { General } from '@/components/interfaces/Settings/General/General' |
| 18 | import { Project } from '@/components/interfaces/Settings/General/Project' |
| 19 | import { TransferProjectPanel } from '@/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectPanel' |
| 20 | import DefaultLayout from '@/components/layouts/DefaultLayout' |
| 21 | import SettingsLayout from '@/components/layouts/ProjectSettingsLayout/SettingsLayout' |
| 22 | import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query' |
| 23 | import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled' |
| 24 | import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' |
| 25 | import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' |
| 26 | import type { NextPageWithLayout } from '@/types' |
| 27 | |
| 28 | const ProjectSettings: NextPageWithLayout = () => { |
| 29 | const { data: project } = useSelectedProjectQuery() |
| 30 | const { data: selectedOrganization } = useSelectedOrganizationQuery() |
| 31 | |
| 32 | const isBranch = !!project?.parent_project_ref |
| 33 | const { projectsTransfer: projectTransferEnabled, projectSettingsCustomDomains } = |
| 34 | useIsFeatureEnabled(['projects:transfer', 'project_settings:custom_domains']) |
| 35 | const router = useRouter() |
| 36 | |
| 37 | useEffect(() => { |
| 38 | if (!IS_PLATFORM) { |
| 39 | router.push(`/project/default/settings/log-drains`) |
| 40 | } |
| 41 | }, [router]) |
| 42 | |
| 43 | const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: selectedOrganization?.slug }) |
| 44 | const hasHipaaAddon = subscriptionHasHipaaAddon(subscription) |
| 45 | |
| 46 | return ( |
| 47 | <> |
| 48 | <PageHeader size="small"> |
| 49 | <PageHeaderMeta> |
| 50 | <PageHeaderSummary> |
| 51 | <PageHeaderTitle>Project Settings</PageHeaderTitle> |
| 52 | <PageHeaderDescription> |
| 53 | General configuration, domains, ownership, and lifecycle |
| 54 | </PageHeaderDescription> |
| 55 | </PageHeaderSummary> |
| 56 | </PageHeaderMeta> |
| 57 | </PageHeader> |
| 58 | <PageContainer size="small"> |
| 59 | <General /> |
| 60 | <Project /> |
| 61 | {/* this is only settable on compliance orgs, currently that means HIPAA orgs */} |
| 62 | {!isBranch && hasHipaaAddon && <ComplianceConfig />} |
| 63 | {projectSettingsCustomDomains && <CustomDomainConfig />} |
| 64 | {!isBranch && projectTransferEnabled && <TransferProjectPanel />} |
| 65 | {!isBranch && <DeleteProjectPanel />} |
| 66 | </PageContainer> |
| 67 | </> |
| 68 | ) |
| 69 | } |
| 70 | |
| 71 | ProjectSettings.getLayout = (page) => ( |
| 72 | <DefaultLayout> |
| 73 | <SettingsLayout title="general">{page}</SettingsLayout> |
| 74 | </DefaultLayout> |
| 75 | ) |
| 76 | export default ProjectSettings |