Skip to content

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

Use restart-services endpoint for restart server button in project settings

Joshen Lim1871181b7333
diff --git a/studio/components/interfaces/Settings/General/RestartServerButton.tsx b/studio/components/interfaces/Settings/General/RestartServerButton.tsx
index b981b68d0ad..dcd90ef9ad0 100644
--- a/studio/components/interfaces/Settings/General/RestartServerButton.tsx
+++ b/studio/components/interfaces/Settings/General/RestartServerButton.tsx
@@ -3,28 +3,37 @@ import { useRouter } from 'next/router'
import { observer } from 'mobx-react-lite'
import { Button, IconRefreshCcw } from '@supabase/ui'
+import { Project } from 'types'
import { useStore } from 'hooks'
import { post } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'
interface Props {
- projectId: number
- projectRef: string
+ project: Project
}
-const RestartServerButton: FC<Props> = observer(({ projectRef, projectId }) => {
+const RestartServerButton: FC<Props> = observer(({ project }) => {
const { ui, app } = useStore()
const router = useRouter()
const [loading, setLoading] = useState(false)
const [isModalOpen, setIsModalOpen] = useState(false)
+ const projectId = project.id
+ const projectRef = project.ref
+ const projectRegion = project.region
+
const openModal = () => setIsModalOpen(true)
const closeModal = () => setIsModalOpen(false)
const requestServerRestart = async () => {
setLoading(true)
- const res = await post(`${API_URL}/projects/${projectRef}/restart`, {})
+ const res = await post(`${API_URL}/projects/${projectRef}/restart-services`, {
+ restartRequest: {
+ region: projectRegion,
+ services: ['postgresql'],
+ },
+ })
if (res.error) {
ui.setNotification({
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
index b1edc82c6ae..29f19f4a857 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
@@ -1,7 +1,11 @@
import { FC, Fragment, useState } from 'react'
import { useRouter } from 'next/router'
import { Button, IconBell, Popover } from '@supabase/ui'
-import { Notification, NotificationStatus, ActionType } from '@supabase/shared-types/out/notifications'
+import {
+ Notification,
+ NotificationStatus,
+ ActionType,
+} from '@supabase/shared-types/out/notifications'
import { Project } from 'types'
import { useNotifications, useStore } from 'hooks'
@@ -48,7 +52,7 @@ const NotificationsPopover: FC<Props> = () => {
const { id: projectId, ref, region } = projectToRestart
const serviceNamesByActionName: Record<string, string> = {
[ActionType.PgBouncerRestart]: 'pgbouncer',
- [ActionType.SchedulePostgresRestart]: 'postgresql'
+ [ActionType.SchedulePostgresRestart]: 'postgresql',
}
const services: string[] = targetNotification.meta.actions_available
.map((action) => action.action_type)
diff --git a/studio/pages/project/[ref]/settings/general.tsx b/studio/pages/project/[ref]/settings/general.tsx
index a696d037af6..235cb3e8ccd 100644
--- a/studio/pages/project/[ref]/settings/general.tsx
+++ b/studio/pages/project/[ref]/settings/general.tsx
@@ -102,7 +102,7 @@ const GeneralSettings = observer(() => {
</p>
</div>
</div>
- {project && <RestartServerButton projectId={project.id} projectRef={project.ref} />}
+ {project && <RestartServerButton project={project} />}
</div>
</Panel.Content>
{isProjectPauseEnabled && isFreeProject && (