Skip to content

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

Fix service checks coming up state (#35705)

Joshen Lim363b976e9477
diff --git a/apps/studio/components/interfaces/Home/ServiceStatus.tsx b/apps/studio/components/interfaces/Home/ServiceStatus.tsx
index 2c3381b054b..41aae7700a8 100644
--- a/apps/studio/components/interfaces/Home/ServiceStatus.tsx
+++ b/apps/studio/components/interfaces/Home/ServiceStatus.tsx
@@ -25,20 +25,20 @@ const SERVICE_STATUS_THRESHOLD = 5 // minutes
const StatusMessage = ({
status,
isLoading,
- isSuccess,
+ isHealthy,
isProjectNew,
}: {
isLoading: boolean
- isSuccess: boolean
+ isHealthy: boolean
isProjectNew: boolean
status?: ProjectServiceStatus
}) => {
+ if (isHealthy) return 'Healthy'
if (isLoading) return 'Checking status'
if (status === 'UNHEALTHY') return 'Unhealthy'
if (status === 'COMING_UP') return 'Coming up...'
if (status === 'ACTIVE_HEALTHY') return 'Healthy'
if (isProjectNew) return 'Coming up...'
- if (isSuccess) return 'Healthy'
return 'Unable to connect'
}
@@ -52,21 +52,21 @@ const CheckIcon = () => <CheckCircle2 {...iconProps} className="text-brand" />
const StatusIcon = ({
isLoading,
- isSuccess,
+ isHealthy,
isProjectNew,
projectStatus,
}: {
isLoading: boolean
- isSuccess: boolean
+ isHealthy: boolean
isProjectNew: boolean
projectStatus?: ProjectServiceStatus
}) => {
+ if (isHealthy) return <CheckIcon />
if (isLoading) return <LoaderIcon />
if (projectStatus === 'UNHEALTHY') return <AlertIcon />
if (projectStatus === 'COMING_UP') return <LoaderIcon />
if (projectStatus === 'ACTIVE_HEALTHY') return <CheckIcon />
if (isProjectNew) return <LoaderIcon />
- if (isSuccess) return <CheckIcon />
return <AlertIcon />
}
@@ -124,17 +124,17 @@ export const ServiceStatus = () => {
error?: string
docsUrl?: string
isLoading: boolean
- isSuccess?: boolean
+ isHealthy: boolean
+ status: ProjectServiceStatus
logsUrl: string
- status?: ProjectServiceStatus
}[] = [
{
name: 'Database',
error: undefined,
docsUrl: undefined,
isLoading: isLoading,
- isSuccess: dbStatus?.healthy,
- status: dbStatus?.status,
+ isHealthy: !!dbStatus?.healthy,
+ status: dbStatus?.status ?? 'UNHEALTHY',
logsUrl: '/logs/postgres-logs',
},
{
@@ -142,8 +142,8 @@ export const ServiceStatus = () => {
error: restStatus?.error,
docsUrl: undefined,
isLoading,
- isSuccess: restStatus?.healthy,
- status: restStatus?.status,
+ isHealthy: !!restStatus?.healthy,
+ status: restStatus?.status ?? 'UNHEALTHY',
logsUrl: '/logs/postgrest-logs',
},
...(authEnabled
@@ -153,8 +153,8 @@ export const ServiceStatus = () => {
error: authStatus?.error,
docsUrl: undefined,
isLoading,
- isSuccess: authStatus?.healthy,
- status: authStatus?.status,
+ isHealthy: !!authStatus?.healthy,
+ status: authStatus?.status ?? 'UNHEALTHY',
logsUrl: '/logs/auth-logs',
},
]
@@ -166,8 +166,8 @@ export const ServiceStatus = () => {
error: realtimeStatus?.error,
docsUrl: undefined,
isLoading,
- isSuccess: realtimeStatus?.healthy,
- status: realtimeStatus?.status,
+ isHealthy: !!realtimeStatus?.healthy,
+ status: realtimeStatus?.status ?? 'UNHEALTHY',
logsUrl: '/logs/realtime-logs',
},
]
@@ -179,8 +179,8 @@ export const ServiceStatus = () => {
error: storageStatus?.error,
docsUrl: undefined,
isLoading,
- isSuccess: storageStatus?.healthy,
- status: storageStatus?.status,
+ isHealthy: !!storageStatus?.healthy,
+ status: storageStatus?.status ?? 'UNHEALTHY',
logsUrl: '/logs/storage-logs',
},
]
@@ -192,7 +192,12 @@ export const ServiceStatus = () => {
error: undefined,
docsUrl: 'https://supabase.com/docs/guides/functions/troubleshooting',
isLoading,
- isSuccess: edgeFunctionsStatus?.healthy,
+ isHealthy: !!edgeFunctionsStatus?.healthy,
+ status: edgeFunctionsStatus?.healthy
+ ? 'ACTIVE_HEALTHY'
+ : isLoading
+ ? 'COMING_UP'
+ : ('UNHEALTHY' as ProjectServiceStatus),
logsUrl: '/logs/edge-functions-logs',
},
]
@@ -200,7 +205,7 @@ export const ServiceStatus = () => {
]
const isLoadingChecks = services.some((service) => service.isLoading)
- const allServicesOperational = services.every((service) => service.isSuccess)
+ const allServicesOperational = services.every((service) => service.isHealthy)
// If the project is less than 5 minutes old, and status is not operational, then it's likely the service is still starting up
const isProjectNew =
@@ -234,7 +239,7 @@ export const ServiceStatus = () => {
<Button
type="default"
icon={
- isLoadingChecks || isProjectNew ? (
+ isLoadingChecks || (!allServicesOperational && isProjectNew) ? (
<LoaderIcon />
) : (
<div
@@ -258,7 +263,7 @@ export const ServiceStatus = () => {
<div className="flex gap-x-2">
<StatusIcon
isLoading={service.isLoading}
- isSuccess={!!service.isSuccess}
+ isHealthy={!!service.isHealthy}
isProjectNew={isProjectNew}
projectStatus={service.status}
/>
@@ -267,7 +272,7 @@ export const ServiceStatus = () => {
<p className="text-foreground-light flex items-center gap-1">
<StatusMessage
isLoading={service.isLoading}
- isSuccess={!!service.isSuccess}
+ isHealthy={!!service.isHealthy}
isProjectNew={isProjectNew}
status={service.status}
/>
diff --git a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx
index 189c30097b7..bc8c94655cf 100644
--- a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx
+++ b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx
@@ -3,12 +3,14 @@ import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
+import { LOCAL_STORAGE_KEYS } from 'common'
import { CANCELLATION_REASONS } from 'components/interfaces/Billing/Billing.constants'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useSendDowngradeFeedbackMutation } from 'data/feedback/exit-survey-send'
import { useProjectDeleteMutation } from 'data/projects/project-delete-mutation'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { Input } from 'ui'
import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
@@ -18,6 +20,11 @@ const DeleteProjectModal = ({ visible, onClose }: { visible: boolean; onClose: (
const { project } = useProjectContext()
const organization = useSelectedOrganization()
+ const [lastVisitedOrganization] = useLocalStorageQuery(
+ LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION,
+ ''
+ )
+
const projectRef = project?.ref
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })
const projectPlan = subscription?.plan?.id ?? 'free'
@@ -43,7 +50,9 @@ const DeleteProjectModal = ({ visible, onClose }: { visible: boolean; onClose: (
}
toast.success(`Successfully deleted ${project?.name}`)
- router.push(`/projects`)
+
+ if (lastVisitedOrganization) router.push(`/org/${lastVisitedOrganization}`)
+ else router.push('/organizations')
},
})
const { mutateAsync: sendExitSurvey, isLoading: isSending } = useSendDowngradeFeedbackMutation()
diff --git a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectPanel.tsx b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectPanel.tsx
index 8739db2979a..051ad436698 100644
--- a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectPanel.tsx
+++ b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectPanel.tsx
@@ -1,18 +1,11 @@
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { FormHeader } from 'components/ui/Forms/FormHeader'
-import Panel from 'components/ui/Panel'
-import {
- Alert,
- Alert_Shadcn_,
- AlertDescription_Shadcn_,
- AlertTitle_Shadcn_,
- CriticalIcon,
-} from 'ui'
-import DeleteProjectButton from './DeleteProjectButton'
-import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import PartnerManagedResource from 'components/ui/PartnerManagedResource'
+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
+import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, CriticalIcon } from 'ui'
+import DeleteProjectButton from './DeleteProjectButton'
-const DeleteProjectPanel = () => {
+export const DeleteProjectPanel = () => {
const selectedOrganization = useSelectedOrganization()
const { project } = useProjectContext()
@@ -21,35 +14,29 @@ const DeleteProjectPanel = () => {
return (
<section id="delete-project">
<FormHeader title="Delete Project" description="" />
- <Panel>
- <Panel.Content>
- {selectedOrganization?.managed_by !== 'vercel-marketplace' ? (
- <Alert_Shadcn_ variant="destructive">
- <CriticalIcon />
- <AlertTitle_Shadcn_>
- Deleting this project will also remove your database.
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- Make sure you have made a backup if you want to keep your data.
- </AlertDescription_Shadcn_>
- <div className="mt-2">
- <DeleteProjectButton />
- </div>
- </Alert_Shadcn_>
- ) : (
- <PartnerManagedResource
- partner="vercel-marketplace"
- resource="Projects"
- cta={{
- installationId: selectedOrganization?.partner_id,
- message: 'Delete project in Vercel Marketplace',
- }}
- />
- )}
- </Panel.Content>
- </Panel>
+ {selectedOrganization?.managed_by !== 'vercel-marketplace' ? (
+ <Alert_Shadcn_ variant="destructive">
+ <CriticalIcon />
+ <AlertTitle_Shadcn_>
+ Deleting this project will also remove your database.
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ Make sure you have made a backup if you want to keep your data.
+ </AlertDescription_Shadcn_>
+ <div className="mt-2">
+ <DeleteProjectButton />
+ </div>
+ </Alert_Shadcn_>
+ ) : (
+ <PartnerManagedResource
+ partner="vercel-marketplace"
+ resource="Projects"
+ cta={{
+ installationId: selectedOrganization?.partner_id,
+ message: 'Delete project in Vercel Marketplace',
+ }}
+ />
+ )}
</section>
)
}
-
-export default DeleteProjectPanel
diff --git a/apps/studio/components/interfaces/Settings/General/index.ts b/apps/studio/components/interfaces/Settings/General/index.ts
index bfc7871528a..a211542638e 100644
--- a/apps/studio/components/interfaces/Settings/General/index.ts
+++ b/apps/studio/components/interfaces/Settings/General/index.ts
@@ -1,7 +1,6 @@
-export { default as General } from './General'
+export { default as ComplianceConfig } from './ComplianceConfig/ProjectComplianceMode'
export { default as CustomDomainConfig } from './CustomDomainConfig/CustomDomainConfig'
-export { default as DeleteProjectPanel } from './DeleteProjectPanel/DeleteProjectPanel'
export { default as DeleteProjectButton } from './DeleteProjectPanel/DeleteProjectButton'
+export { default as General } from './General'
export { default as TransferProjectButton } from './TransferProjectPanel/TransferProjectButton'
export { default as TransferProjectPanel } from './TransferProjectPanel/TransferProjectPanel'
-export { default as ComplianceConfig } from './ComplianceConfig/ProjectComplianceMode'
diff --git a/apps/studio/pages/project/[ref]/settings/general.tsx b/apps/studio/pages/project/[ref]/settings/general.tsx
index ce096e96ced..6f0f7e92364 100644
--- a/apps/studio/pages/project/[ref]/settings/general.tsx
+++ b/apps/studio/pages/project/[ref]/settings/general.tsx
@@ -2,10 +2,10 @@ import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscri
import {
ComplianceConfig,
CustomDomainConfig,
- DeleteProjectPanel,
General,
TransferProjectPanel,
} from 'components/interfaces/Settings/General'
+import { DeleteProjectPanel } from 'components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectPanel'
import DefaultLayout from 'components/layouts/DefaultLayout'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'