Skip to content

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

adds pausing state

Alaister Young9b55f9323210
diff --git a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
index a22a0682b94..13ee057ed92 100644
--- a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
+++ b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
@@ -1,20 +1,19 @@
-import { FC } from 'react'
-import { Badge, IconLoader, IconPauseCircle } from 'ui'
-
-import { Project } from 'types'
import CardButton from 'components/ui/CardButton'
import { PROJECT_STATUS } from 'lib/constants'
+import { Project } from 'types'
+import { Badge, IconLoader, IconPauseCircle } from 'ui'
-interface Props {
+export interface ProjectCardProps {
project: Project
rewriteHref?: string
}
-const ProjectCard: FC<Props> = ({ project, rewriteHref }) => {
+const ProjectCard = ({ project, rewriteHref }: ProjectCardProps) => {
const { name, ref: projectRef } = project
const desc = `${project.cloud_provider} | ${project.region}`
- const isPausing = project.status === PROJECT_STATUS.GOING_DOWN
+ const isPausing =
+ project.status === PROJECT_STATUS.GOING_DOWN || project.status === PROJECT_STATUS.PAUSING
const isPaused = project.status === PROJECT_STATUS.INACTIVE
const isRestoring = project.status === PROJECT_STATUS.RESTORING
diff --git a/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx b/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
index dc774a29d4c..55f1736fccd 100644
--- a/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
+++ b/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
@@ -54,7 +54,7 @@ const PauseProjectButton: FC<Props> = observer(({ projectRef, projectId }) => {
})
setLoading(false)
} else {
- setProjectStatus(queryClient, projectRef, PROJECT_STATUS.GOING_DOWN)
+ setProjectStatus(queryClient, projectRef, PROJECT_STATUS.PAUSING)
ui.setNotification({ category: 'success', message: 'Pausing project' })
router.push(`/project/${projectRef}`)
diff --git a/studio/components/layouts/ProjectLayout/PausingState.tsx b/studio/components/layouts/ProjectLayout/PausingState.tsx
index 1e19e5cf3b6..ddd078ccf28 100644
--- a/studio/components/layouts/ProjectLayout/PausingState.tsx
+++ b/studio/components/layouts/ProjectLayout/PausingState.tsx
@@ -1,12 +1,11 @@
-import { FC } from 'react'
-import { Badge, IconLoader, IconCircle } from 'ui'
import { Project } from 'types'
+import { Badge, IconCircle, IconLoader } from 'ui'
-interface Props {
+export interface PausingStateProps {
project: Project
}
-const PausingState: FC<Props> = ({ project }) => {
+const PausingState = ({ project }: PausingStateProps) => {
return (
<div className="mx-auto my-16 w-full max-w-7xl space-y-16">
<div className="mx-6 space-y-16">
diff --git a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
index 4bf38e4c26c..e2dae22e23c 100644
--- a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
+++ b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
@@ -1,6 +1,6 @@
import Head from 'next/head'
import { useRouter } from 'next/router'
-import { Fragment, ReactNode } from 'react'
+import { Fragment, PropsWithChildren, ReactNode } from 'react'
import { useParams } from 'common/hooks'
import Connecting from 'components/ui/Loading'
@@ -24,7 +24,6 @@ export interface ProjectLayoutProps {
productMenu?: ReactNode
hideHeader?: boolean
hideIconBar?: boolean
- children: ReactNode
selectedTable?: string
}
@@ -37,7 +36,7 @@ const ProjectLayout = ({
hideHeader = false,
hideIconBar = false,
selectedTable,
-}: ProjectLayoutProps) => {
+}: PropsWithChildren<ProjectLayoutProps>) => {
const router = useRouter()
const { ref: projectRef } = useParams()
const ongoingIncident = useFlag('ongoingIncident')
@@ -149,7 +148,9 @@ const ContentWrapper = ({ isLoading, children }: ContentWrapperProps) => {
const isProjectUpgrading = selectedProject?.status === PROJECT_STATUS.UPGRADING
const isProjectRestoring = selectedProject?.status === PROJECT_STATUS.RESTORING
const isProjectBuilding = selectedProject?.status === PROJECT_STATUS.COMING_UP
- const isProjectPausing = selectedProject?.status === PROJECT_STATUS.GOING_DOWN
+ const isProjectPausing =
+ selectedProject?.status === PROJECT_STATUS.GOING_DOWN ||
+ selectedProject?.status === PROJECT_STATUS.PAUSING
const isProjectOffline = selectedProject?.postgrestStatus === 'OFFLINE'
return (
@@ -185,7 +186,7 @@ export const ProjectLayoutNonBlocking = ({
children,
hideHeader = false,
hideIconBar = false,
-}: ProjectLayoutProps) => {
+}: PropsWithChildren<ProjectLayoutProps>) => {
const selectedProject = useSelectedProject()
const router = useRouter()
const { ref: projectRef } = useParams()
diff --git a/studio/data/projects/project-detail-query.ts b/studio/data/projects/project-detail-query.ts
index 552ede409d3..4e7acae201d 100644
--- a/studio/data/projects/project-detail-query.ts
+++ b/studio/data/projects/project-detail-query.ts
@@ -26,6 +26,7 @@ export const useProjectDetailQuery = <TData = ProjectDetailData>(
({ signal }) => getProjectDetail({ ref }, signal),
{
enabled: enabled && typeof ref !== 'undefined',
+ staleTime: 30 * 1000, // 30 seconds
...options,
}
)
diff --git a/studio/data/projects/projects-query.ts b/studio/data/projects/projects-query.ts
index f8497dea766..3a59cb7218b 100644
--- a/studio/data/projects/projects-query.ts
+++ b/studio/data/projects/projects-query.ts
@@ -60,22 +60,30 @@ export function setProjectStatus(
projectRef: Project['ref'],
status: Project['status']
) {
- client.setQueriesData<Project[] | undefined>(projectKeys.list(), (old) => {
- if (!old) return old
-
- return old.map((project) => {
- if (project.ref === projectRef) {
- return { ...project, status }
- }
- return project
- })
- })
-
- client.setQueriesData<Project>(projectKeys.detail(projectRef), (old) => {
- if (!old) return old
-
- return { ...old, status }
- })
+ client.setQueriesData<Project[] | undefined>(
+ projectKeys.list(),
+ (old) => {
+ if (!old) return old
+
+ return old.map((project) => {
+ if (project.ref === projectRef) {
+ return { ...project, status }
+ }
+ return project
+ })
+ },
+ { updatedAt: Date.now() }
+ )
+
+ client.setQueriesData<Project>(
+ projectKeys.detail(projectRef),
+ (old) => {
+ if (!old) return old
+
+ return { ...old, status }
+ },
+ { updatedAt: Date.now() }
+ )
}
export function setProjectPostgrestStatus(
@@ -83,9 +91,13 @@ export function setProjectPostgrestStatus(
projectRef: Project['ref'],
status: Project['postgrestStatus']
) {
- client.setQueriesData<Project>(projectKeys.detail(projectRef), (old) => {
- if (!old) return old
-
- return { ...old, postgrestStatus: status }
- })
+ client.setQueriesData<Project>(
+ projectKeys.detail(projectRef),
+ (old) => {
+ if (!old) return old
+
+ return { ...old, postgrestStatus: status }
+ },
+ { updatedAt: Date.now() }
+ )
}
diff --git a/studio/lib/constants/infrastructure.ts b/studio/lib/constants/infrastructure.ts
index e283bf68e19..e6d02193b3d 100644
--- a/studio/lib/constants/infrastructure.ts
+++ b/studio/lib/constants/infrastructure.ts
@@ -54,7 +54,8 @@ export const PRICING_TIER_PRODUCT_IDS = {
export const PRICING_TIER_FREE_KEY = 'FREE'
export const PRICING_TIER_DEFAULT_KEY = 'FREE'
-export const DEFAULT_PROVIDER: CloudProvider = process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' ? 'FLY' : 'AWS'
+export const DEFAULT_PROVIDER: CloudProvider =
+ process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' ? 'FLY' : 'AWS'
export const PROVIDERS = {
FLY: {
@@ -135,6 +136,7 @@ export const PROJECT_STATUS = {
RESTORING: 'RESTORING',
RESTORATION_FAILED: 'RESTORATION_FAILED',
UPGRADING: 'UPGRADING',
+ PAUSING: 'PAUSING',
}
export const DEFAULT_MINIMUM_PASSWORD_STRENGTH = 4
diff --git a/studio/lib/profile.tsx b/studio/lib/profile.tsx
index 6d38af7af4d..6e9ae6a7ce1 100644
--- a/studio/lib/profile.tsx
+++ b/studio/lib/profile.tsx
@@ -4,6 +4,7 @@ import { PropsWithChildren, createContext, useContext, useMemo } from 'react'
import { useTelemetryProps } from 'common'
import { invalidateOrganizationsQuery } from 'data/organizations/organizations-query'
+import { usePermissionsQuery } from 'data/permissions/permissions-query'
import { useProfileCreateMutation } from 'data/profile/profile-create-mutation'
import { useProfileQuery } from 'data/profile/profile-query'
import { Profile } from 'data/profile/types'
@@ -26,7 +27,7 @@ export const ProfileProvider = ({ children }: PropsWithChildren<{}>) => {
const router = useRouter()
const telemetryProps = useTelemetryProps()
- const { mutate: createProfile, isLoading: isCreating } = useProfileCreateMutation({
+ const { mutate: createProfile, isLoading: isCreatingProfile } = useProfileCreateMutation({
async onSuccess() {
Telemetry.sendEvent(
{ category: 'conversion', action: 'sign_up', label: '' },
@@ -57,14 +58,16 @@ export const ProfileProvider = ({ children }: PropsWithChildren<{}>) => {
},
})
+ const { isLoading: isLoadingPermissions } = usePermissionsQuery()
+
const value = useMemo(() => {
- const isLoading = isLoadingProfile || isCreating
+ const isLoading = isLoadingProfile || isCreatingProfile || isLoadingPermissions
return {
profile,
isLoading,
}
- }, [isLoadingProfile, isCreating, profile])
+ }, [isLoadingProfile, isCreatingProfile, isLoadingPermissions, profile])
return <ProfileContext.Provider value={value}>{children}</ProfileContext.Provider>
}