Skip to content

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

Fix notification row org slug (#22021)

Joshen Lim37e83af2e7b1
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
index a423c544eea..395d1e0d1c0 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
@@ -1,11 +1,10 @@
import * as Tooltip from '@radix-ui/react-tooltip'
-import clsx from 'clsx'
import dayjs from 'dayjs'
import { ArchiveRestoreIcon } from 'lucide-react'
import Link from 'next/link'
import { useEffect, useRef } from 'react'
import { useInView } from 'react-intersection-observer'
-import { Button, IconArchive, IconExternalLink } from 'ui'
+import { Button, IconArchive, IconExternalLink, cn } from 'ui'
import { Markdown } from 'components/interfaces/Markdown'
import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'
@@ -17,7 +16,8 @@ import type { Organization } from 'types'
interface NotificationRowProps {
setRowHeight: (idx: number, height: number) => void
getProject: (ref: string) => ProjectInfo
- getOrganization: (id: number) => Organization
+ getOrganizationById: (id: number) => Organization
+ getOrganizationBySlug: (slug: string) => Organization
onUpdateNotificationStatus: (id: string, status: 'archived' | 'seen') => void
queueMarkRead: (id: string) => void
}
@@ -28,7 +28,8 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
item: notification,
setRowHeight,
getProject,
- getOrganization,
+ getOrganizationById,
+ getOrganizationBySlug,
onUpdateNotificationStatus,
queueMarkRead,
}) => {
@@ -38,7 +39,12 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
const data = notification.data as NotificationData
const project = data.project_ref !== undefined ? getProject(data.project_ref) : undefined
- const organization = project !== undefined ? getOrganization(project.organization_id) : undefined
+ const organization =
+ data.org_slug !== undefined
+ ? getOrganizationBySlug(data.org_slug)
+ : project !== undefined
+ ? getOrganizationById(project.organization_id)
+ : undefined
const daysFromNow = dayjs().diff(dayjs(notification.inserted_at), 'day')
const formattedTimeFromNow = dayjs(notification.inserted_at).fromNow()
@@ -65,7 +71,7 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
return (
<div
ref={ref}
- className={clsx(
+ className={cn(
`p-4 flex justify-between gap-x-3 group`,
index !== 0 ? 'border-t border-overlay' : '',
status === 'new' ? 'bg-surface-100/50' : 'bg-background'
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
index 36c83ea74c9..e055d2b2620 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
@@ -206,7 +206,10 @@ const NotificationsPopoverV2 = () => {
}
},
getProject: (ref: string) => projects?.find((project) => project.ref === ref)!,
- getOrganization: (id: number) => organizations?.find((org) => org.id === id)!,
+ getOrganizationById: (id: number) =>
+ organizations?.find((org) => org.id === id)!,
+ getOrganizationBySlug: (slug: string) =>
+ organizations?.find((org) => org.slug === slug)!,
onUpdateNotificationStatus: (id: string, status: 'archived' | 'seen') => {
updateNotifications({ ids: [id], status })
},