Skip to content

Commit 8f9ae40

Browse files
committed
revert, just do the check inline
1 parent 3bda12f commit 8f9ae40

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

static/app/views/dashboards/detail.tsx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -440,21 +440,28 @@ class DashboardDetail extends Component<Props, State> {
440440
};
441441

442442
isWidgetBuilder = (path?: string) => {
443-
const {location} = this.props;
443+
const {organization, location, params} = this.props;
444+
const {dashboardId, widgetIndex} = params;
444445

445446
const widgetBuilderRoutes = [
446-
/^\/organizations\/.+\/dashboards\/new\/widget-builder\/widget\//,
447-
/^\/organizations\/.+\/dashboard\/\d+\/widget-builder\/widget\//,
447+
`/organizations/${organization.slug}/dashboards/new/widget-builder/widget/new/`,
448+
`/organizations/${organization.slug}/dashboards/new/widget-builder/widget/${widgetIndex}/edit/`,
449+
`/organizations/${organization.slug}/dashboard/${dashboardId}/widget-builder/widget/new/`,
450+
`/organizations/${organization.slug}/dashboard/${dashboardId}/widget-builder/widget/${widgetIndex}/edit/`,
448451
];
449452

450453
if (USING_CUSTOMER_DOMAIN) {
451454
widgetBuilderRoutes.push(
452-
/^\/dashboards\/new\/widget-builder\/widget\//,
453-
/^\/dashboard\/\d+\/widget-builder\/widget\//
455+
...[
456+
`/dashboards/new/widget-builder/widget/new/`,
457+
`/dashboards/new/widget-builder/widget/${widgetIndex}/edit/`,
458+
`/dashboard/${dashboardId}/widget-builder/widget/new/`,
459+
`/dashboard/${dashboardId}/widget-builder/widget/${widgetIndex}/edit/`,
460+
]
454461
);
455462
}
456463

457-
return widgetBuilderRoutes.some(route => route.test(path ?? location.pathname));
464+
return widgetBuilderRoutes.includes(path ?? location.pathname);
458465
};
459466

460467
onEdit = () => {
@@ -1108,9 +1115,24 @@ class DashboardDetail extends Component<Props, State> {
11081115
when={locationChange => {
11091116
// The widget builder uses its own pathname at the moment, so check if we're navigating
11101117
// between the dashboard and the widget builder
1118+
const checkDashboardRoute = (path: string) => {
1119+
const widgetBuilderRoutes = [
1120+
// Legacy routes
1121+
/^\/organizations\/.+\/dashboards\/new\/widget-builder\/widget\//,
1122+
/^\/organizations\/.+\/dashboard\/\d+\/widget-builder\/widget\//,
1123+
1124+
// Customer domain routes
1125+
/^\/dashboards\/new\/widget-builder\/widget\//,
1126+
/^\/dashboard\/\d+\/widget-builder\/widget\//,
1127+
];
1128+
1129+
return widgetBuilderRoutes.some(route =>
1130+
route.test(path ?? location.pathname)
1131+
);
1132+
};
11111133
const navigatingWithinDashboards =
1112-
this.isWidgetBuilder(locationChange.nextLocation.pathname) ||
1113-
(this.isWidgetBuilder(locationChange.currentLocation.pathname) &&
1134+
checkDashboardRoute(locationChange.nextLocation.pathname) ||
1135+
(checkDashboardRoute(locationChange.currentLocation.pathname) &&
11141136
[`/dashboard/${dashboard.id}/`, `/dashboards/new/`].includes(
11151137
locationChange.nextLocation.pathname
11161138
));

0 commit comments

Comments
 (0)