The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
UI support for dismissing of notifications
Joshen Lim8ce2e91d8970
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsxindex d9f170f626c..e2b50d032ee 100644--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx@@ -1,6 +1,7 @@import dayjs from 'dayjs'import useSWR from 'swr'import { FC } from 'react'+import * as Tooltip from '@radix-ui/react-tooltip'import { Notification, NotificationStatus } from '@supabase/shared-types/out/notifications'import { useStore } from 'hooks'@@ -9,9 +10,11 @@ import { formatNotificationCTAText, formatNotificationText } from './Notificatioimport NotificationActions from './NotificationActions'import { get } from 'lib/common/fetch'import { API_URL } from 'lib/constants'+import { Button, IconX } from 'ui'interface Props {notification: Notification+ onSelectDismissNotification: (notificationId: string) => voidonSelectRestartProject: (project: Project, notification: Notification) => voidonSelectApplyMigration: (project: Project, notification: Notification) => voidonSelectRollbackMigration: (project: Project, notification: Notification) => void@@ -20,6 +23,7 @@ interface Props {const NotificationRow: FC<Props> = ({notification,+ onSelectDismissNotification,onSelectRestartProject,onSelectApplyMigration,onSelectRollbackMigration,@@ -49,26 +53,60 @@ const NotificationRow: FC<Props> = ({<div className="mt-1.5 h-2 w-2 rounded-full bg-green-900" />)}</div>- <div className="flex-grow mr-8 flex items-center space-x-4">- <div className="w-[70%] space-y-2">- {formatNotificationText(project, notification, ownerReassignStatus)}- {formatNotificationCTAText(availableActions, ownerReassignStatus)}- <p className="text-scale-1100 text-sm !mt-2">{insertedAt}</p>- </div>- <div className="w-[30%] col-span-3 flex items-center justify-end">- {availableActions.length > 0 && (- <NotificationActions- project={project}- changelogLink={changelogLink}- ownerReassignStatus={ownerReassignStatus}- availableActions={availableActions}- onSelectRestartProject={() => onSelectRestartProject(project, notification)}- onSelectApplyMigration={() => onSelectApplyMigration(project, notification)}- onSelectRollbackMigration={() => onSelectRollbackMigration(project, notification)}- onSelectFinalizeMigration={() => onSelectFinalizeMigration(project, notification)}- />- )}+ <div className="flex-grow mr-8 flex flex-col gap-4">+ <div className="w-full flex justify-end">+ <div className="w-9/10 space-y-2">+ {formatNotificationText(project, notification, ownerReassignStatus)}+ {formatNotificationCTAText(availableActions, ownerReassignStatus)}+ <p className="text-scale-1100 text-sm !mt-2">{insertedAt}</p>+ </div>+ <div className="w-1/10 flex justify-end">+ <div>+ <Tooltip.Root delayDuration={0}>+ <Tooltip.Trigger>+ <Button+ className="!px-1 group"+ type="text"+ icon={+ <IconX+ size={14}+ strokeWidth={2}+ className="text-scale-1100 group-hover:text-scale-1200 transition"+ />+ }+ onClick={() => onSelectDismissNotification(notification.id)}+ />+ </Tooltip.Trigger>+ <Tooltip.Content side="bottom">+ <Tooltip.Arrow className="radix-tooltip-arrow" />+ <div+ className={[+ 'rounded bg-scale-100 py-1 px-2 leading-none shadow',+ 'border border-scale-200',+ ].join(' ')}+ >+ <span className="text-xs text-scale-1200">Dismiss</span>+ </div>+ </Tooltip.Content>+ </Tooltip.Root>+ </div>+ </div></div>+ {availableActions.length > 0 ||+ (changelogLink !== undefined && (+ <div className="flex items-center">+ <NotificationActions+ project={project}+ changelogLink={changelogLink}+ ownerReassignStatus={ownerReassignStatus}+ availableActions={availableActions}+ onSelectRestartProject={() => onSelectRestartProject(project, notification)}+ onSelectApplyMigration={() => onSelectApplyMigration(project, notification)}+ onSelectRollbackMigration={() => onSelectRollbackMigration(project, notification)}+ onSelectFinalizeMigration={() => onSelectFinalizeMigration(project, notification)}+ />+ </div>+ ))}</div></div>)diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.tsxindex be32b086b81..86cfec34ec1 100644--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.tsx+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.tsx@@ -146,7 +146,7 @@ export const formatNotificationText = (</div>)} else if (notification.data.name === NotificationName.ProjectInformational) {- return notification.data.message+ return <p className="text-sm">{notification.data.message}</p>} else {return (<p className="text-sm">@@ -177,7 +177,9 @@ export const formatNotificationCTAText = (return (<p className="text-sm space-x-1">This patch was applied on{' '}- {dayjs(new Date(ownerReassignStatus.migrated_at ?? action.deadline)).format('DD MMM YYYY, HH:mma')}+ {dayjs(new Date(ownerReassignStatus.migrated_at ?? action.deadline)).format(+ 'DD MMM YYYY, HH:mma'+ )}</p>)} else if (ownerReassignStatus?.desired === 'temp_role') {diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsxindex 6252cf60567..675312a8bc5 100644--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx@@ -49,6 +49,16 @@ const NotificationsPopover: FC<Props> = () => {}}+ const dismissNotification = async (notificationId: string) => {+ if (!notificationId) return+ const { error } = await delete_(`${API_URL}/notifications`, { ids: [notificationId] })+ if (error) {+ ui.setNotification({ category: 'error', message: 'Failed to dismiss notification', error })+ } else {+ refresh()+ }+ }+const onConfirmProjectRestart = async () => {if (!projectToRestart || !targetNotification) return@@ -99,7 +109,9 @@ const NotificationsPopover: FC<Props> = () => {if (!projectToApplyMigration) returnconst res = await post(`${API_URL}/database/${projectToApplyMigration.ref}/owner-reassign`, {})if (!res.error) {- await app.projects.fetchDetail(projectToApplyMigration.ref, (project) => meta.setProjectDetails(project))+ await app.projects.fetchDetail(projectToApplyMigration.ref, (project) =>+ meta.setProjectDetails(project)+ )ui.setNotification({category: 'success',message: `Successfully applied migration for project "${projectToApplyMigration.name}"`,@@ -121,7 +133,9 @@ const NotificationsPopover: FC<Props> = () => {{})if (!res.error) {- await app.projects.fetchDetail(projectToRollbackMigration.ref, (project) => meta.setProjectDetails(project))+ await app.projects.fetchDetail(projectToRollbackMigration.ref, (project) =>+ meta.setProjectDetails(project)+ )ui.setNotification({category: 'success',message: `Successfully rolled back migration for project "${projectToRollbackMigration.name}"`,@@ -143,7 +157,9 @@ const NotificationsPopover: FC<Props> = () => {{})if (!res.error) {- await app.projects.fetchDetail(projectToFinalizeMigration.ref, (project) => meta.setProjectDetails(project))+ await app.projects.fetchDetail(projectToFinalizeMigration.ref, (project) =>+ meta.setProjectDetails(project)+ )ui.setNotification({category: 'success',message: `Successfully finalized migration for project "${projectToFinalizeMigration.name}"`,@@ -187,6 +203,7 @@ const NotificationsPopover: FC<Props> = () => {<Fragment key={notification.id}><NotificationRownotification={notification}+ onSelectDismissNotification={dismissNotification}onSelectRestartProject={(project, notification) => {setProjectToRestart(project)setTargetNotification(notification)diff --git a/studio/hooks/misc/useNotifications.tsx b/studio/hooks/misc/useNotifications.tsxindex 23b8f35d3dd..c302d58ff65 100644--- a/studio/hooks/misc/useNotifications.tsx+++ b/studio/hooks/misc/useNotifications.tsx@@ -3,6 +3,7 @@ import { Notification } from '@supabase/shared-types/out/notifications'import { get } from 'lib/common/fetch'import { API_URL } from 'lib/constants'+import { ActionType } from '@supabase/shared-types/out/notifications'export const useNotifications = () => {const { data, error, mutate } = useSWR<Notification[]>(`${API_URL}/notifications`, get)