From 27b18190e252f5e1f57ecf7a70ccc78bacea71fa Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Tue, 7 May 2024 16:03:59 -0230 Subject: [PATCH] Investigating --- .../NotificationRow.tsx | 3 +- .../NotificationsPopover.tsx | 5 +- .../notifications/notifications-v2-query.ts | 51 ++++++++++++++----- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx index 395d1e0d1c0..bd64f369a51 100644 --- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx +++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx @@ -36,7 +36,7 @@ const NotificationRow: ItemRenderer = ({ const ref = useRef(null) const { ref: viewRef, inView } = useInView() const { status, priority } = notification - + console.log('the', { notification }) const data = notification.data as NotificationData const project = data.project_ref !== undefined ? getProject(data.project_ref) : undefined const organization = @@ -133,6 +133,7 @@ const NotificationRow: ItemRenderer = ({ {data.actions.map((action, idx) => { const key = `${notification.id}-action-${idx}` if (action.url !== undefined) { + console.log({ action }, project) const url = action.url.includes('[ref]') ? action.url.replace('[ref]', project?.ref ?? '_') : action.url.includes('[slug]') diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx index 533d082aa95..a76b40b60bc 100644 --- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx +++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx @@ -41,6 +41,7 @@ const NotificationsPopoverV2 = () => { const rowHeights = useRef<{ [key: number]: number }>({}) const { data: projects } = useProjectsQuery() + console.log({ projects }) const { data: organizations } = useOrganizationsQuery() const { data, @@ -70,7 +71,7 @@ const NotificationsPopoverV2 = () => { useNotificationsArchiveAllMutation({ onSuccess: () => toast.success('Successfully archived all notifications'), }) - + console.log({ projects }) const notifications = useMemo(() => data?.pages.flatMap((page) => page) ?? [], [data?.pages]) const hasNewNotifications = summary?.unread_count ?? 0 > 0 const hasWarning = summary?.has_warning @@ -81,7 +82,7 @@ const NotificationsPopoverV2 = () => { updateNotifications({ ids: markedRead.current, status: 'seen' }) } } - + console.log({ notifications }) return ( 0 ? { priority: filters.priority } : {}), - ...(filters.organizations.length > 0 ? { org_slug: filters.organizations } : {}), - ...(filters.projects.length > 0 ? { project_ref: filters.projects } : {}), + // const { data, error } = await get('/platform/notifications', { + // params: { + // // @ts-ignore + // query: { + // offset: page * limit, + // limit, + // ...(status !== undefined ? { status } : { status: ['new', 'seen'] }), + // ...(filters.priority.length > 0 ? { priority: filters.priority } : {}), + // ...(filters.organizations.length > 0 ? { org_slug: filters.organizations } : {}), + // ...(filters.projects.length > 0 ? { project_ref: filters.projects } : {}), + // }, + // }, + // headers: { Version: '2' }, + // signal, + // }) + + // if (error) throw error + + const data = [ + { + status: 'seen', + priority: 'Warning', + data: { + title: 'Security Recommendation', + actions: [{ url: '/project/[ref]/database/security-advisor', label: 'Security Advisor' }], + message: + 'The way you have configured your database is open to the public, please check the notifications in the Security Advisor page.', + project_ref: 'yxrbshyrkjhbbglmsqyj', }, }, - headers: { Version: '2' }, - signal, - }) - if (error) throw error + // { + // title: 'Security Recommendation', + // actions: [{ url: '/project/[ref]/database/security-advisor', label: 'Security Advisor' }], + // message: + // 'The way you have configured your database is open to the public, please check the notifications in the Security Advisor page.', + // project_ref: 'pnlhfnllpxpapxrdkihw', + // }, + // Add more notifications as needed + ] return data }