mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 12:25:05 +03:00
Remove org slug and project ref filters for GET notifications
This commit is contained in:
1 parent
9017bbf057
commit
78f74b4e05
2 files changed
+16
-19
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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' },
|
||||
|
||||
Reference in new issue
Block a user