From e5caedabf6f73a89fe5c24c85235ce15b8657df2 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Fri, 28 Nov 2025 13:10:35 -0500 Subject: [PATCH 1/2] Filter out prebuilt dashboards from dropdown options --- .../addToDashboardModal.spec.tsx | 43 +++++++++++++++++++ .../widgetBuilder/addToDashboardModal.tsx | 1 + 2 files changed, 44 insertions(+) diff --git a/static/app/components/modals/widgetBuilder/addToDashboardModal.spec.tsx b/static/app/components/modals/widgetBuilder/addToDashboardModal.spec.tsx index f192fb95b20c0b..63f233fffb4d1b 100644 --- a/static/app/components/modals/widgetBuilder/addToDashboardModal.spec.tsx +++ b/static/app/components/modals/widgetBuilder/addToDashboardModal.spec.tsx @@ -687,4 +687,47 @@ describe('add to dashboard modal', () => { ) ).toBeInTheDocument(); }); + + it('does not show prebuilt dashboards in the list of options', async () => { + MockApiClient.addMockResponse({ + url: '/organizations/org-slug/dashboards/', + body: [ + {...testDashboardListItem, widgetDisplay: [DisplayType.AREA]}, + { + ...testDashboardListItem, + title: 'Other Dashboard', + id: '2', + widgetDisplay: [DisplayType.AREA], + }, + { + ...testDashboardListItem, + title: 'Prebuilt Dashboard', + id: '3', + widgetDisplay: [DisplayType.AREA], + prebuiltId: 1, + }, + ], + }); + render( + undefined} + organization={initialData.organization} + widget={widget} + selection={defaultSelection} + location={LocationFixture()} + /> + ); + + await waitFor(() => { + expect(screen.getByText('Select Dashboard')).toBeEnabled(); + }); + await selectEvent.openMenu(screen.getByText('Select Dashboard')); + expect(screen.queryByText('Prebuilt Dashboard')).not.toBeInTheDocument(); + expect(screen.getByText('Test Dashboard')).toBeInTheDocument(); + expect(screen.getByText('Other Dashboard')).toBeInTheDocument(); + }); }); diff --git a/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx b/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx index 95a66e5c194b16..7a6ef493fad277 100644 --- a/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx +++ b/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx @@ -261,6 +261,7 @@ function AddToDashboardModal({ tooltipOptions: {position: 'right', isHoverable: true}, }, ...dashboards + .filter(dashboard => dashboard.prebuiltId === undefined) // Cannot add to prebuilt dashboards .filter(dashboard => // if adding from a dashboard, currentDashboardId will be set and we'll remove it from the list of options currentDashboardId ? dashboard.id !== currentDashboardId : true From 954496aa531c37911fc3d3a0b13943ba6efe4a8b Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Fri, 28 Nov 2025 13:41:53 -0500 Subject: [PATCH 2/2] use defined util instead --- .../components/modals/widgetBuilder/addToDashboardModal.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx b/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx index 7a6ef493fad277..229facf19cc7af 100644 --- a/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx +++ b/static/app/components/modals/widgetBuilder/addToDashboardModal.tsx @@ -19,6 +19,7 @@ import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {PageFilters, SelectValue} from 'sentry/types/core'; import type {Organization} from 'sentry/types/organization'; +import {defined} from 'sentry/utils'; import type {Sort} from 'sentry/utils/discover/fields'; import {MetricsCardinalityProvider} from 'sentry/utils/performance/contexts/metricsCardinality'; import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting'; @@ -261,7 +262,7 @@ function AddToDashboardModal({ tooltipOptions: {position: 'right', isHoverable: true}, }, ...dashboards - .filter(dashboard => dashboard.prebuiltId === undefined) // Cannot add to prebuilt dashboards + .filter(dashboard => !defined(dashboard.prebuiltId)) // Cannot add to prebuilt dashboards .filter(dashboard => // if adding from a dashboard, currentDashboardId will be set and we'll remove it from the list of options currentDashboardId ? dashboard.id !== currentDashboardId : true