From 78f74b4e05c7ac9366dfe083a055b87728bcf991 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Wed, 25 Feb 2026 14:04:30 +0800 Subject: [PATCH] Remove org slug and project ref filters for GET notifications --- .../ui/AdvisorPanel/AdvisorPanel.tsx | 14 +++++-------- .../notifications/notifications-v2-query.ts | 21 ++++++++++--------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/apps/studio/components/ui/AdvisorPanel/AdvisorPanel.tsx b/apps/studio/components/ui/AdvisorPanel/AdvisorPanel.tsx index 3b80bd22c0d..9116d27ac79 100644 --- a/apps/studio/components/ui/AdvisorPanel/AdvisorPanel.tsx +++ b/apps/studio/components/ui/AdvisorPanel/AdvisorPanel.tsx @@ -1,6 +1,3 @@ -import dayjs from 'dayjs' -import { useMemo, useRef } from 'react' - import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider' import { Lint, useProjectLintsQuery } from 'data/lint/lint-query' import { @@ -9,12 +6,15 @@ import { useNotificationsV2Query, } from 'data/notifications/notifications-v2-query' import { useNotificationsV2UpdateMutation } from 'data/notifications/notifications-v2-update-mutation' +import dayjs from 'dayjs' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { IS_PLATFORM } from 'lib/constants' import { useTrack } from 'lib/telemetry/track' +import { useMemo, useRef } from 'react' import { AdvisorSeverity, AdvisorTab, useAdvisorStateSnapshot } from 'state/advisor-state' import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state' + import { AdvisorDetail } from './AdvisorDetail' import { AdvisorFilters } from './AdvisorFilters' import type { AdvisorItem } from './AdvisorPanel.types' @@ -98,12 +98,8 @@ export const AdvisorPanel = () => { // Memoize filters to prevent query key changes on every render // Use selected organization and project if they exist const notificationFilters = useMemo( - () => ({ - priority: notificationFilterPriorities, - organizations: selectedOrganization?.slug ? [selectedOrganization.slug] : [], - projects: project?.ref ? [project.ref] : [], - }), - [notificationFilterPriorities, selectedOrganization?.slug, project?.ref] + () => ({ priority: notificationFilterPriorities }), + [notificationFilterPriorities] ) const { diff --git a/apps/studio/data/notifications/notifications-v2-query.ts b/apps/studio/data/notifications/notifications-v2-query.ts index 3590a163d94..b79ebf6cc90 100644 --- a/apps/studio/data/notifications/notifications-v2-query.ts +++ b/apps/studio/data/notifications/notifications-v2-query.ts @@ -1,8 +1,8 @@ import { InfiniteData, useInfiniteQuery } from '@tanstack/react-query' -import { get, handleError } from 'data/fetchers' - import type { components } from 'data/api' +import { get, handleError } from 'data/fetchers' import type { ResponseError, UseCustomInfiniteQueryOptions } from 'types' + import { notificationKeys } from './keys' const NOTIFICATIONS_PAGE_LIMIT = 10 @@ -12,9 +12,9 @@ export type NotificationVariables = { limit?: number status?: 'new' | 'seen' | 'archived' filters: { - priority: readonly string[] - organizations: readonly string[] - projects: readonly string[] + priority?: readonly string[] + organizations?: readonly string[] + projects?: readonly string[] } } @@ -37,16 +37,17 @@ export type NotificationData = { export async function getNotifications(options: NotificationVariables, signal?: AbortSignal) { const { status, filters, page = 0, limit = NOTIFICATIONS_PAGE_LIMIT } = options + const { priority = [], organizations = [], projects = [] } = filters + const { data, error } = await get('/platform/notifications', { params: { query: { offset: page * limit, limit, - // [Alaister]: 'as any' is needed because the API types don't reflect an array of strings - ...(status !== undefined ? { status } : { status: ['new', 'seen'].join(',') as any }), - ...(filters.priority.length > 0 ? { priority: filters.priority.join(',') as any } : {}), - ...(filters.organizations.length > 0 ? { org_slug: filters.organizations.join(',') } : {}), - ...(filters.projects.length > 0 ? { project_ref: filters.projects.join(',') } : {}), + ...(status !== undefined ? { status } : { status: ['new', 'seen'].join(',') }), + ...(priority.length > 0 ? { priority: priority.join(',') } : {}), + ...(organizations.length > 0 ? { org_slug: organizations.join(',') } : {}), + ...(projects.length > 0 ? { project_ref: projects.join(',') } : {}), }, }, headers: { Version: '2' },