Skip to content

Commit de9d73f

Browse files
authored
fix(dashboards): dashboard links not perserving selection (#104176)
1 parent 01f12c9 commit de9d73f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

static/app/utils/discover/fieldRenderers.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {Theme} from '@emotion/react';
33
import styled from '@emotion/styled';
44
import type {Location} from 'history';
55
import partial from 'lodash/partial';
6+
import pick from 'lodash/pick';
67
import * as qs from 'query-string';
78

89
import {Tag} from 'sentry/components/core/badge/tag';
@@ -1396,12 +1397,13 @@ function wrapFieldRendererInDashboardLink(
13961397
dashboardFilters: DashboardFilters | undefined = undefined
13971398
): FieldFormatterRenderFunctionPartial {
13981399
return function (data, baggage) {
1399-
const {organization} = baggage;
1400+
const {organization, location} = baggage;
14001401
const value = data[field];
14011402
const dashboardUrl = getDashboardUrl(
14021403
field,
14031404
value,
14041405
organization,
1406+
location,
14051407
widget,
14061408
dashboardFilters
14071409
);
@@ -1416,6 +1418,7 @@ function getDashboardUrl(
14161418
field: string,
14171419
value: any,
14181420
organization: Organization,
1421+
location: Location,
14191422
widget: Widget | undefined = undefined,
14201423
dashboardFilters: DashboardFilters | undefined = undefined
14211424
) {
@@ -1438,8 +1441,20 @@ function getDashboardUrl(
14381441
tag: {key: field, name: field, kind: FieldKind.TAG},
14391442
value: formattedValue,
14401443
});
1444+
1445+
// Preserve project, environment, and time range query params
1446+
const filterParams = pick(location.query, [
1447+
'release',
1448+
'environment',
1449+
'project',
1450+
'statsPeriod',
1451+
'start',
1452+
'end',
1453+
]);
1454+
14411455
const url = `/organizations/${organization.slug}/dashboard/${dashboardLink.dashboardId}/?${qs.stringify(
14421456
{
1457+
...filterParams,
14431458
[DashboardFilterKeys.TEMPORARY_FILTERS]: newTemporaryFilters.map(filter =>
14441459
JSON.stringify(filter)
14451460
),

0 commit comments

Comments
 (0)