Skip to content

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

chore: support for additional notification types

Div Arora2b158cb93963
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
index 3de594635e8..4ffc35756c3 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
@@ -5,9 +5,6 @@ import {
ExtensionsUpgrade,
Notification,
NotificationName,
- PostgresqlUpgradeData,
- ProjectExceedingTierLimitData,
- ProjectUpdateData,
ServerUpgrade,
ServiceUpgrade,
ViolatedLimit,
@@ -15,17 +12,16 @@ import {
export const formatNotificationText = (project: Project, notification: Notification) => {
const projectName = project.name
- const notificationName = notification.notification_name
- if (notificationName === NotificationName.ProjectExceedingTierLimit) {
- const { violations } = notification.data as ProjectExceedingTierLimitData
+ if (notification.data.name === NotificationName.ProjectExceedingTierLimit) {
+ const { violations } = notification.data
const violationsText = violations
.map((violation: ViolatedLimit) => violation.dimension as string)
.reduce((a: string, b: string) => `${a}, ${b}`)
return `Your project "${projectName}" has exceeded its limits in the following areas: ${violationsText}.`
- } else if (notificationName === NotificationName.PostgresqlUpgradeAvailable) {
- const { upgrade_type, additional } = notification.data as PostgresqlUpgradeData
+ } else if (notification.data.name === NotificationName.PostgresqlUpgradeAvailable) {
+ const { upgrade_type, additional } = notification.data
if (upgrade_type === 'postgresql-server') {
const { version_to } = additional as ServerUpgrade
@@ -35,24 +31,26 @@ export const formatNotificationText = (project: Project, notification: Notificat
return `New version of "${name}" (${version_to}) is now available for project "${projectName}".`
}
return ''
- } else if (notificationName === NotificationName.PostgresqlUpgradeCompleted) {
- const { upgrade_type, additional } = notification.data as PostgresqlUpgradeData
+ } else if (notification.data.name === NotificationName.PostgresqlUpgradeCompleted) {
+ const { upgrade_type, additional } = notification.data
if (upgrade_type === 'postgresql-server') {
const { version_to } = additional as ServerUpgrade
return `Postgres (${version_to}) has been successfully updated to ${version_to} for project "${projectName}".`
} else if (upgrade_type === 'extensions') {
const { name, version_to } = additional as ExtensionsUpgrade
- return `The extension "${name}" has been successfully updated to ${version_to} for project "${projectName}`
+ return `The extension "${name}" has been successfully updated to ${version_to} for project "${projectName}".`
}
- } else if (notificationName === 'project.update-completed') {
- const { upgrades } = notification.data as ProjectUpdateData
+ } else if (notification.data.name === NotificationName.ProjectUpdateCompleted) {
+ const { upgrades } = notification.data
const upgradesText = upgrades
.map((upgrade: ServiceUpgrade) => upgrade.name)
.reduce((a: string, b: string) => `${a}, ${b}`)
- return `The following services have been successfully updated for project "${projectName}": ${upgradesText}`
+ return `The following services have been successfully updated for project "${projectName}": ${upgradesText}.`
+ } else if (notification.data.name === NotificationName.ProjectInformational) {
+ return notification.data.message
} else {
- return `Unknown notification type: ${notification.notification_name} - Please reach out to support for more information`
+ return `Unknown notification type: ${notification.notification_name} - Please reach out to support for more information.`
}
}
@@ -65,6 +63,8 @@ export const formatNotificationCTAText = (availableActions: Action[]) => {
return 'Restart your project to get the latest updates.'
case ActionType.UpgradeProjectToPro:
return 'Upgrade your project to ensure continued availability.'
+ case ActionType.PgBouncerRestart:
+ return 'Restart your connection pooler to get the latest updates.'
default:
return ''
}
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
index d29b63e6eea..b1edc82c6ae 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
@@ -1,7 +1,7 @@
import { FC, Fragment, useState } from 'react'
import { useRouter } from 'next/router'
import { Button, IconBell, Popover } from '@supabase/ui'
-import { Notification, NotificationStatus } 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'
@@ -44,12 +44,21 @@ const NotificationsPopover: FC<Props> = () => {
if (!projectToRestart || !targetNotification) return
const { id } = targetNotification
+
const { id: projectId, ref, region } = projectToRestart
+ const serviceNamesByActionName: Record<string, string> = {
+ [ActionType.PgBouncerRestart]: 'pgbouncer',
+ [ActionType.SchedulePostgresRestart]: 'postgresql'
+ }
+ const services: string[] = targetNotification.meta.actions_available
+ .map((action) => action.action_type)
+ .filter((actionName) => Object.keys(serviceNamesByActionName).indexOf(actionName) !== -1)
+ .map((actionName) => serviceNamesByActionName[actionName])
const { error } = await post(`${API_URL}/projects/${ref}/restart-services`, {
restartRequest: {
region,
source_notification_id: id,
- services: ['postgresql'],
+ services: services,
},
})
@@ -61,7 +70,7 @@ const NotificationsPopover: FC<Props> = () => {
})
} else {
app.onProjectPostgrestStatusUpdated(projectId, 'OFFLINE')
- ui.setNotification({ category: 'success', message: `Restarting project` })
+ ui.setNotification({ category: 'success', message: `Restarting services` })
router.push(`/project/${ref}`)
}
diff --git a/studio/package-lock.json b/studio/package-lock.json
index 6def253517d..346948ff30f 100644
--- a/studio/package-lock.json
+++ b/studio/package-lock.json
@@ -20,7 +20,7 @@
"@stripe/stripe-js": "^1.25.0",
"@supabase/postgres-meta": "^0.26.1",
"@supabase/react-data-grid": "^7.1.0-beta.7",
- "@supabase/shared-types": "^0.1.21",
+ "@supabase/shared-types": "^0.1.24",
"@supabase/supabase-js": "^1.35.3",
"@supabase/ui": "0.37.0-alpha.58",
"ajv": "^8.6.3",
@@ -8338,9 +8338,9 @@
}
},
"node_modules/@supabase/shared-types": {
- "version": "0.1.21",
- "resolved": "https://registry.npmjs.org/@supabase/shared-types/-/shared-types-0.1.21.tgz",
- "integrity": "sha512-iF6XMy2cYPm7p3hximwuDmQOFZuVHVKr/uKcrtQlFrQIYjmMMrF/7Qm20muq2+oH8WNxcj29AZJ6oBx6mYzEqQ=="
+ "version": "0.1.24",
+ "resolved": "https://registry.npmjs.org/@supabase/shared-types/-/shared-types-0.1.24.tgz",
+ "integrity": "sha512-zvGWWLLh5ZAeiSR4VfJGBY9KbRb1Jh8//gJVmZwiaRv0i6F4i9qTsFOmWjpFgLY5+grAqwSfyIfB+jG8rxcidQ=="
},
"node_modules/@supabase/storage-js": {
"version": "1.7.0",
@@ -35112,9 +35112,9 @@
}
},
"@supabase/shared-types": {
- "version": "0.1.21",
- "resolved": "https://registry.npmjs.org/@supabase/shared-types/-/shared-types-0.1.21.tgz",
- "integrity": "sha512-iF6XMy2cYPm7p3hximwuDmQOFZuVHVKr/uKcrtQlFrQIYjmMMrF/7Qm20muq2+oH8WNxcj29AZJ6oBx6mYzEqQ=="
+ "version": "0.1.24",
+ "resolved": "https://registry.npmjs.org/@supabase/shared-types/-/shared-types-0.1.24.tgz",
+ "integrity": "sha512-zvGWWLLh5ZAeiSR4VfJGBY9KbRb1Jh8//gJVmZwiaRv0i6F4i9qTsFOmWjpFgLY5+grAqwSfyIfB+jG8rxcidQ=="
},
"@supabase/storage-js": {
"version": "1.7.0",
diff --git a/studio/package.json b/studio/package.json
index 3e6d9fe0220..1fec1a275f3 100644
--- a/studio/package.json
+++ b/studio/package.json
@@ -24,7 +24,7 @@
"@stripe/stripe-js": "^1.25.0",
"@supabase/postgres-meta": "^0.26.1",
"@supabase/react-data-grid": "^7.1.0-beta.7",
- "@supabase/shared-types": "^0.1.21",
+ "@supabase/shared-types": "^0.1.24",
"@supabase/supabase-js": "^1.35.3",
"@supabase/ui": "0.37.0-alpha.58",
"ajv": "^8.6.3",