Skip to content

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

Merge branch 'master' into generic-migrate

Han Qiaof8bb65e07b32
diff --cc studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx
index 54ba244d184,2e88bbd09a4..d566e255a4f
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRow.tsx
@@@ -1,16 -1,15 +1,13 @@@
import * as Tooltip from '@radix-ui/react-tooltip'
import { Notification, NotificationStatus } from '@supabase/shared-types/out/notifications'
- import { useQueryClient } from '@tanstack/react-query'
-import { useQuery } from '@tanstack/react-query'
import dayjs from 'dayjs'
- import { useState } from 'react'
+ import { Button, IconArchive, IconX } from 'ui'
- import { notificationKeys } from 'data/notifications/keys'
+ import { useNotificationsDismissMutation } from 'data/notifications/notifications-dismiss-mutation'
import { useProjectsQuery } from 'data/projects/projects-query'
import { useStore } from 'hooks'
- import { delete_ } from 'lib/common/fetch'
-import { get } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
import { Project } from 'types'
- import { Button, IconX } from 'ui'
import NotificationActions from './NotificationActions'
import { formatNotificationCTAText, formatNotificationText } from './NotificationRows.utils'
@@@ -39,21 -36,34 +34,22 @@@ const NotificationRow = (
const changelogLink = (notification.data as any).changelog_link
const availableActions = notification.meta?.actions_available ?? []
+ const { mutate: dismissNotifications, isLoading: isDismissing } = useNotificationsDismissMutation(
+ {
+ onError: (error) => {
+ ui.setNotification({
+ error,
+ category: 'error',
+ message: `Failed to dismiss notification: ${error.message}`,
+ duration: 4000,
+ })
+ },
+ }
+ )
+
- // [Joshen TODO] This should be removed after the env of Feb when the migration notifications
- // have been removed, double check with Qiao before removing.
- // Relevant PR: https://github.com/supabase/supabase/pull/9229
- const { data: ownerReassignStatus } = useQuery(
- ['projects', project?.ref, 'owner-reassign'],
- ({ signal }) => get(`${API_URL}/database/${project?.ref}/owner-reassign`, { signal }),
- {
- enabled:
- (notification.data as any).upgrade_type === 'schema-migration' && project !== undefined,
- }
- )
-
const dismissNotification = async (notificationId: string) => {
if (!notificationId) return
- setDismissing(true)
- const { error } = await delete_(`${API_URL}/notifications`, { ids: [notificationId] })
- if (error) {
- ui.setNotification({
- category: 'error',
- message: 'Failed to dismiss notification',
- error,
- duration: 4000,
- })
- } else {
- await queryClient.invalidateQueries(notificationKeys.list())
- }
- setDismissing(false)
+ dismissNotifications({ ids: [notificationId] })
}
if (!project) return null