import { PermissionAction } from '@supabase/shared-types/out/constants' import { BarChart2 } from 'lucide-react' import Link from 'next/link' import { toast } from 'sonner' import { FormActions } from 'components/ui/Forms/FormActions' import { FormPanel } from 'components/ui/Forms/FormPanel' import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection' import Panel from 'components/ui/Panel' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useProjectUpdateMutation } from 'data/projects/project-update-mutation' import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useProjectByRefQuery, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, Form, Input, WarningIcon, } from 'ui' import PauseProjectButton from './Infrastructure/PauseProjectButton' import RestartServerButton from './Infrastructure/RestartServerButton' const General = () => { const { data: project } = useSelectedProjectQuery() const { data: organization } = useSelectedOrganizationQuery() const { data: parentProject } = useProjectByRefQuery(project?.parent_project_ref) const isBranch = parentProject !== undefined const formId = 'project-general-settings' const initialValues = { name: project?.name ?? '', ref: project?.ref ?? '' } const { can: canUpdateProject } = useAsyncCheckProjectPermissions( PermissionAction.UPDATE, 'projects', { resource: { project_id: project?.id, }, } ) const { mutate: updateProject, isLoading: isUpdating } = useProjectUpdateMutation() const onSubmit = async (values: any, { resetForm }: any) => { if (!project?.ref) return console.error('Ref is required') updateProject( { ref: project.ref, name: values.name.trim() }, { onSuccess: ({ name }) => { resetForm({ values: { name }, initialValues: { name } }) toast.success('Successfully saved settings') }, } ) } return (
{isBranch && ( You are currently on a preview branch of your project Certain settings are not available while you're on a preview branch. To adjust your project settings, you may return to your{' '} main branch . )} {project === undefined ? ( ) : (
{({ handleReset, values, initialValues }: any) => { const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues) return (
} > General settings}> ) }} )} {!isBranch && ( <>

Restart project

Your project will not be available for a few minutes.

Pause project

Your project will not be accessible while it is paused.

Project usage statistics have been moved

You may view your project's usage under your organization's settings

)} ) } export default General