From ddfd5841ffd1de5c23cfb1563859e4284a73df6a Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 27 Nov 2025 11:16:02 -0500 Subject: [PATCH 1/5] Prevents rendering edit and save ui on prebuilt insights dashboards --- static/app/views/dashboards/controls.tsx | 10 +++- static/app/views/dashboards/detail.spec.tsx | 30 ++++++++++ static/app/views/dashboards/detail.tsx | 1 + static/app/views/dashboards/filtersBar.tsx | 62 +++++++++++---------- 4 files changed, 73 insertions(+), 30 deletions(-) diff --git a/static/app/views/dashboards/controls.tsx b/static/app/views/dashboards/controls.tsx index 89291cebcdeaf6..32ecefaf22d2e8 100644 --- a/static/app/views/dashboards/controls.tsx +++ b/static/app/views/dashboards/controls.tsx @@ -83,6 +83,9 @@ function Controls({ const currentUser = useUser(); const {teams: userTeams} = useUserTeams(); const api = useApi(); + + const isPrebuiltDashboard = dashboard.prebuiltId !== undefined; + if ([DashboardState.EDIT, DashboardState.PENDING_DELETE].includes(dashboardState)) { return ( @@ -199,6 +202,9 @@ function Controls({ if (!hasFeature) { return null; } + if (isPrebuiltDashboard) { + return null; + } const isDisabled = !hasFeature || hasUnsavedFilters || !hasEditAccess || isSaving; const toolTipMessage = isSaving ? DASHBOARD_SAVING_MESSAGE @@ -247,7 +253,7 @@ function Controls({ /> - {dashboard.id !== 'default-overview' && ( + {dashboard.id !== 'default-overview' && !isPrebuiltDashboard && ( )} {renderEditButton(hasFeature)} - {hasFeature ? ( + {hasFeature && !isPrebuiltDashboard ? ( Detail', () => { expect(await screen.findByLabelText('Star')).toBeInTheDocument(); }); + it('does not render save or edit features on prebuilt insights dashboards', async () => { + render( + {}} + />, + { + organization: initialData.organization, + deprecatedRouterMocks: true, + } + ); + + await userEvent.click(await screen.findByText('14D')); + await userEvent.click(screen.getByText('Last 7 days')); + await screen.findByText('7D'); + + expect(screen.queryByTestId('filter-bar-cancel')).not.toBeInTheDocument(); + expect(screen.queryByText('Save')).not.toBeInTheDocument(); + expect(screen.queryByText('Editors:')).not.toBeInTheDocument(); + expect(screen.queryByText('Add Widget')).not.toBeInTheDocument(); + }); + describe('widget builder redesign', () => { let mockUpdateDashboard!: jest.SpyInstance; beforeEach(() => { diff --git a/static/app/views/dashboards/detail.tsx b/static/app/views/dashboards/detail.tsx index 561eecacccf99d..eda8567257c963 100644 --- a/static/app/views/dashboards/detail.tsx +++ b/static/app/views/dashboards/detail.tsx @@ -1187,6 +1187,7 @@ class DashboardDetail extends Component { isPreview={this.isPreview} onDashboardFilterChange={this.handleChangeFilter} shouldBusySaveButton={this.state.isSavingDashboardFilters} + isPrebuiltDashboard={!!dashboard.prebuiltId} onCancel={() => { resetPageFilters(dashboard, location); trackAnalytics('dashboards2.filter.cancel', { diff --git a/static/app/views/dashboards/filtersBar.tsx b/static/app/views/dashboards/filtersBar.tsx index 620e1b33d1df99..1bba81779b887e 100644 --- a/static/app/views/dashboards/filtersBar.tsx +++ b/static/app/views/dashboards/filtersBar.tsx @@ -44,6 +44,7 @@ type FiltersBarProps = { onDashboardFilterChange: (activeFilters: DashboardFilters) => void; dashboardCreator?: User; dashboardPermissions?: DashboardPermissions; + isPrebuiltDashboard?: boolean; onCancel?: () => void; onSave?: () => Promise; shouldBusySaveButton?: boolean; @@ -62,6 +63,7 @@ export default function FiltersBar({ onDashboardFilterChange, onSave, shouldBusySaveButton, + isPrebuiltDashboard, }: FiltersBarProps) { const {selection} = usePageFilters(); const organization = useOrganization(); @@ -195,34 +197,38 @@ export default function FiltersBar({ /> )} - {!hasTemporaryFilters && hasUnsavedChanges && !isEditingDashboard && !isPreview && ( - - - - - )} + {!hasTemporaryFilters && + hasUnsavedChanges && + !isEditingDashboard && + !isPreview && + !isPrebuiltDashboard && ( + + + + + )} ); From 08ed808d2fc11acb71630203113b23a4974599f1 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 27 Nov 2025 11:41:37 -0500 Subject: [PATCH 2/5] fix test --- static/app/views/dashboards/detail.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app/views/dashboards/detail.spec.tsx b/static/app/views/dashboards/detail.spec.tsx index cb343304aebeab..81c3b5f330c23b 100644 --- a/static/app/views/dashboards/detail.spec.tsx +++ b/static/app/views/dashboards/detail.spec.tsx @@ -2305,7 +2305,7 @@ describe('Dashboards > Detail', () => { } ); - await userEvent.click(await screen.findByText('14D')); + await userEvent.click(await screen.findByText('24H')); await userEvent.click(screen.getByText('Last 7 days')); await screen.findByText('7D'); From d789713307e3ea7d6a34285950c067b15cb99036 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 27 Nov 2025 13:44:02 -0500 Subject: [PATCH 3/5] maybe fix? --- static/app/views/dashboards/detail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app/views/dashboards/detail.tsx b/static/app/views/dashboards/detail.tsx index eda8567257c963..da79d302472b31 100644 --- a/static/app/views/dashboards/detail.tsx +++ b/static/app/views/dashboards/detail.tsx @@ -1187,7 +1187,7 @@ class DashboardDetail extends Component { isPreview={this.isPreview} onDashboardFilterChange={this.handleChangeFilter} shouldBusySaveButton={this.state.isSavingDashboardFilters} - isPrebuiltDashboard={!!dashboard.prebuiltId} + isPrebuiltDashboard={dashboard.prebuiltId !== undefined} onCancel={() => { resetPageFilters(dashboard, location); trackAnalytics('dashboards2.filter.cancel', { From 4b4cad25587dd04ba103a94875e82fa33d0a9895 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 27 Nov 2025 14:07:18 -0500 Subject: [PATCH 4/5] maybe fix 2? --- tests/acceptance/test_organization_dashboards.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/acceptance/test_organization_dashboards.py b/tests/acceptance/test_organization_dashboards.py index 134807136d5993..0b72f3ac347b47 100644 --- a/tests/acceptance/test_organization_dashboards.py +++ b/tests/acceptance/test_organization_dashboards.py @@ -123,6 +123,7 @@ def test_move_existing_widget_on_existing_dashboard(self) -> None: ) with self.feature(FEATURE_NAMES + EDIT_FEATURE): self.page.visit_dashboard_detail() + self.page.wait_until_loaded() self.page.enter_edit_state() # Drag to the right @@ -316,6 +317,7 @@ def test_resize_big_number_widget(self) -> None: ) with self.feature(FEATURE_NAMES + EDIT_FEATURE): self.page.visit_dashboard_detail() + self.page.wait_until_loaded() self.page.enter_edit_state() # Resize existing widget @@ -481,6 +483,7 @@ def test_deleting_stacked_widgets_by_context_menu_does_not_trigger_confirm_on_ed ) with self.feature(FEATURE_NAMES + EDIT_FEATURE): self.page.visit_dashboard_detail() + self.page.wait_until_loaded() # Hover over the widget to show widget actions self.browser.move_to('[aria-label="Widget panel"]') From ac0d1625ed114efbdc6f93bf690c5b971366c1dd Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 27 Nov 2025 14:36:17 -0500 Subject: [PATCH 5/5] fix please --- static/app/views/dashboards/controls.tsx | 3 ++- static/app/views/dashboards/detail.tsx | 2 +- tests/acceptance/test_organization_dashboards.py | 3 --- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/static/app/views/dashboards/controls.tsx b/static/app/views/dashboards/controls.tsx index 32ecefaf22d2e8..16441fd70732cd 100644 --- a/static/app/views/dashboards/controls.tsx +++ b/static/app/views/dashboards/controls.tsx @@ -15,6 +15,7 @@ import {IconAdd, IconDownload, IconEdit, IconStar} from 'sentry/icons'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization} from 'sentry/types/organization'; +import {defined} from 'sentry/utils'; import {trackAnalytics} from 'sentry/utils/analytics'; import {useQueryClient} from 'sentry/utils/queryClient'; import useApi from 'sentry/utils/useApi'; @@ -84,7 +85,7 @@ function Controls({ const {teams: userTeams} = useUserTeams(); const api = useApi(); - const isPrebuiltDashboard = dashboard.prebuiltId !== undefined; + const isPrebuiltDashboard = defined(dashboard.prebuiltId); if ([DashboardState.EDIT, DashboardState.PENDING_DELETE].includes(dashboardState)) { return ( diff --git a/static/app/views/dashboards/detail.tsx b/static/app/views/dashboards/detail.tsx index da79d302472b31..a57b11b5e82406 100644 --- a/static/app/views/dashboards/detail.tsx +++ b/static/app/views/dashboards/detail.tsx @@ -1187,7 +1187,7 @@ class DashboardDetail extends Component { isPreview={this.isPreview} onDashboardFilterChange={this.handleChangeFilter} shouldBusySaveButton={this.state.isSavingDashboardFilters} - isPrebuiltDashboard={dashboard.prebuiltId !== undefined} + isPrebuiltDashboard={defined(dashboard.prebuiltId)} onCancel={() => { resetPageFilters(dashboard, location); trackAnalytics('dashboards2.filter.cancel', { diff --git a/tests/acceptance/test_organization_dashboards.py b/tests/acceptance/test_organization_dashboards.py index 0b72f3ac347b47..134807136d5993 100644 --- a/tests/acceptance/test_organization_dashboards.py +++ b/tests/acceptance/test_organization_dashboards.py @@ -123,7 +123,6 @@ def test_move_existing_widget_on_existing_dashboard(self) -> None: ) with self.feature(FEATURE_NAMES + EDIT_FEATURE): self.page.visit_dashboard_detail() - self.page.wait_until_loaded() self.page.enter_edit_state() # Drag to the right @@ -317,7 +316,6 @@ def test_resize_big_number_widget(self) -> None: ) with self.feature(FEATURE_NAMES + EDIT_FEATURE): self.page.visit_dashboard_detail() - self.page.wait_until_loaded() self.page.enter_edit_state() # Resize existing widget @@ -483,7 +481,6 @@ def test_deleting_stacked_widgets_by_context_menu_does_not_trigger_confirm_on_ed ) with self.feature(FEATURE_NAMES + EDIT_FEATURE): self.page.visit_dashboard_detail() - self.page.wait_until_loaded() # Hover over the widget to show widget actions self.browser.move_to('[aria-label="Widget panel"]')