Skip to content

Commit 50140ce

Browse files
authored
fix(dashboards): use location dashboard filters over saved dashboard filters (#92320)
### Changes Pull out the dashboard filters from the current location and prioritize them over the saved dashboard filters. This way the user can share hardcoded links to view specific filters without overrides from saved filter. ### Before https://github.com/user-attachments/assets/8b6e3920-0624-4579-aa56-2fd0c106ec88 ### After If the user has edit access, the save button will appear: https://github.com/user-attachments/assets/71992050-e1c8-41fe-a585-a2715dbaad44 If they do not have edit access, the save button is greyed out: https://github.com/user-attachments/assets/edc1338f-3981-4ac2-b2b9-09f3a9767430
1 parent 63554d1 commit 50140ce

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

static/app/views/dashboards/orgDashboards.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {useParams} from 'sentry/utils/useParams';
1818

1919
import {assignTempId} from './layoutUtils';
2020
import type {DashboardDetails, DashboardListItem} from './types';
21-
import {hasSavedPageFilters} from './utils';
21+
import {getCurrentPageFilters, hasSavedPageFilters} from './utils';
2222

2323
type OrgDashboardsChildrenProps = {
2424
dashboard: DashboardDetails | null;
@@ -93,11 +93,15 @@ function OrgDashboards(props: Props) {
9393
useEffect(() => {
9494
// Only redirect if there are saved filters and none of the filters
9595
// appear in the query params
96+
97+
// current filters based on location
98+
const locationFilters = getCurrentPageFilters(location);
9699
if (
97100
!selectedDashboard ||
98101
!hasSavedPageFilters(selectedDashboard) ||
99102
// Apply redirect once for each dashboard id
100-
dashboardRedirectRef.current === selectedDashboard.id
103+
dashboardRedirectRef.current === selectedDashboard.id ||
104+
hasSavedPageFilters(locationFilters)
101105
) {
102106
return;
103107
}

static/app/views/dashboards/utils.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,12 @@ export function isWidgetUsingTransactionName(widget: Widget) {
454454
);
455455
}
456456

457-
export function hasSavedPageFilters(dashboard: DashboardDetails) {
457+
export function hasSavedPageFilters(
458+
dashboard: Pick<
459+
DashboardDetails,
460+
'projects' | 'environment' | 'period' | 'start' | 'end' | 'utc'
461+
>
462+
) {
458463
return !(
459464
(dashboard.projects === undefined || dashboard.projects.length === 0) &&
460465
dashboard.environment === undefined &&

0 commit comments

Comments
 (0)