Skip to content

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

Tidy up

Joshen Limf667bbdc24ee
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx
index 88a89373271..ae0675d8a56 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx
@@ -4,7 +4,7 @@ import { Notification, NotificationStatus } from '@supabase/shared-types/out/not
import { useStore } from 'hooks'
import { Project } from 'types'
-import { formatNotificationText } from './NotificationRows.utils'
+import { formatNotificationCTAText, formatNotificationText } from './NotificationRows.utils'
import NotificationActions from './NotificationActions'
interface Props {
@@ -19,22 +19,24 @@ const NotificationRow: FC<Props> = ({ notification }) => {
const availableActions = notification.meta?.actions_available ?? []
return (
- <div className="grid grid-cols-12 py-2">
- <div className="col-span-1 flex justify-center">
+ <div className="flex py-2">
+ <div className="flex w-[50px] justify-center">
{notification.notification_status !== NotificationStatus.Seen && (
<div className="mt-1.5 h-2 w-2 rounded-full bg-green-900" />
)}
</div>
- <div className={availableActions.length > 0 ? 'col-span-7' : 'col-span-10'}>
+ <div className="mr-8 flex items-center space-x-4">
<div className="space-y-1">
<p className="text-sm">{formatNotificationText(project, notification)}</p>
+ <p className="text-sm">{formatNotificationCTAText(availableActions)}</p>
<p className="text-scale-1000 text-sm">{insertedAt}</p>
</div>
+ <div className="col-span-3 flex items-center justify-end">
+ {availableActions.length > 0 && (
+ <NotificationActions availableActions={availableActions} />
+ )}
+ </div>
</div>
- <div className="col-span-3 flex items-center justify-end">
- {availableActions.length > 0 && <NotificationActions availableActions={availableActions} />}
- </div>
- <div className="col-span-1" />
</div>
)
}
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
index e6441325024..3de594635e8 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
@@ -1,5 +1,7 @@
import { Project } from 'types'
import {
+ Action,
+ ActionType,
ExtensionsUpgrade,
Notification,
NotificationName,
@@ -11,7 +13,6 @@ import {
ViolatedLimit,
} from '@supabase/shared-types/out/notifications'
-// Switch to proper typing with NotificationName after PR is in
export const formatNotificationText = (project: Project, notification: Notification) => {
const projectName = project.name
const notificationName = notification.notification_name
@@ -22,16 +23,16 @@ export const formatNotificationText = (project: Project, notification: Notificat
.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}. Please upgrade your project to ensure continued availability.`
+ 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
if (upgrade_type === 'postgresql-server') {
const { version_to } = additional as ServerUpgrade
- return `A new version of Postgres (${version_to}) is now available for project "${projectName}". You may restart your project to get this update.`
+ return `New version of Postgres (${version_to}) is now available for project "${projectName}".`
} else if (upgrade_type === 'extensions') {
const { name, version_to } = additional as ExtensionsUpgrade
- return `A new version of the extension "${name}" (${version_to}) is now available for project "${projectName}". You may restart your project to get this update.`
+ return `New version of "${name}" (${version_to}) is now available for project "${projectName}".`
}
return ''
} else if (notificationName === NotificationName.PostgresqlUpgradeCompleted) {
@@ -54,3 +55,17 @@ export const formatNotificationText = (project: Project, notification: Notificat
return `Unknown notification type: ${notification.notification_name} - Please reach out to support for more information`
}
}
+
+export const formatNotificationCTAText = (availableActions: Action[]) => {
+ const [action] = availableActions
+ if (!action) return ''
+
+ switch (action.action_type) {
+ case ActionType.SchedulePostgresRestart:
+ return 'Restart your project to get the latest updates.'
+ case ActionType.UpgradeProjectToPro:
+ return 'Upgrade your project to ensure continued availability.'
+ default:
+ return ''
+ }
+}
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
index 2775e794dd0..973452b55e0 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx
@@ -24,8 +24,10 @@ const NotificationsPopover: FC<Props> = () => {
const notificationIds = notifications
?.filter((notification) => notification.notification_status === NotificationStatus.New)
.map((notification) => notification.id)
- const { data, error } = await patch(`${API_URL}/notifications`, { ids: notificationIds })
- console.log(data, error)
+ if (notificationIds.length > 0) {
+ const { data, error } = await patch(`${API_URL}/notifications`, { ids: notificationIds })
+ console.log(data, error)
+ }
}
}
@@ -37,7 +39,7 @@ const NotificationsPopover: FC<Props> = () => {
sideOffset={8}
onOpenChange={onOpenChange}
overlay={
- <div className="w-[550px]">
+ <div className="w-[540px]">
<div className="flex items-center justify-between border-b border-gray-500 bg-gray-400 px-4 py-2">
<p className="text-sm">Notifications</p>
{/* Area for improvement: Paginate notifications and show in a side panel */}
@@ -47,12 +49,20 @@ const NotificationsPopover: FC<Props> = () => {
</p> */}
</div>
<div className="max-h-[380px] overflow-y-auto py-2">
- {notifications.map((notification, i: number) => (
- <Fragment key={notification.id}>
- <NotificationRow notification={notification} />
- {i !== notifications.length - 1 && <Popover.Seperator />}
- </Fragment>
- ))}
+ {notifications.length === 0 ? (
+ <div className="py-2 px-4">
+ <p className="text-scale-1000 text-sm">No notifications available</p>
+ </div>
+ ) : (
+ <>
+ {notifications.map((notification, i: number) => (
+ <Fragment key={notification.id}>
+ <NotificationRow notification={notification} />
+ {i !== notifications.length - 1 && <Popover.Seperator />}
+ </Fragment>
+ ))}
+ </>
+ )}
</div>
</div>
}