@@ -440,21 +440,28 @@ class DashboardDetail extends Component<Props, State> {
440
440
} ;
441
441
442
442
isWidgetBuilder = ( path ?: string ) => {
443
- const { location} = this . props ;
443
+ const { organization, location, params} = this . props ;
444
+ const { dashboardId, widgetIndex} = params ;
444
445
445
446
const widgetBuilderRoutes = [
446
- / ^ \/ o r g a n i z a t i o n s \/ .+ \/ d a s h b o a r d s \/ n e w \/ w i d g e t - b u i l d e r \/ w i d g e t \/ / ,
447
- / ^ \/ o r g a n i z a t i o n s \/ .+ \/ d a s h b o a r d \/ \d + \/ w i d g e t - b u i l d e r \/ w i d g e t \/ / ,
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/` ,
448
451
] ;
449
452
450
453
if ( USING_CUSTOMER_DOMAIN ) {
451
454
widgetBuilderRoutes . push (
452
- / ^ \/ d a s h b o a r d s \/ n e w \/ w i d g e t - b u i l d e r \/ w i d g e t \/ / ,
453
- / ^ \/ d a s h b o a r d \/ \d + \/ w i d g e t - b u i l d e r \/ w i d g e t \/ /
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
+ ]
454
461
) ;
455
462
}
456
463
457
- return widgetBuilderRoutes . some ( route => route . test ( path ?? location . pathname ) ) ;
464
+ return widgetBuilderRoutes . includes ( path ?? location . pathname ) ;
458
465
} ;
459
466
460
467
onEdit = ( ) => {
@@ -1108,9 +1115,24 @@ class DashboardDetail extends Component<Props, State> {
1108
1115
when = { locationChange => {
1109
1116
// The widget builder uses its own pathname at the moment, so check if we're navigating
1110
1117
// between the dashboard and the widget builder
1118
+ const checkDashboardRoute = ( path : string ) => {
1119
+ const widgetBuilderRoutes = [
1120
+ // Legacy routes
1121
+ / ^ \/ o r g a n i z a t i o n s \/ .+ \/ d a s h b o a r d s \/ n e w \/ w i d g e t - b u i l d e r \/ w i d g e t \/ / ,
1122
+ / ^ \/ o r g a n i z a t i o n s \/ .+ \/ d a s h b o a r d \/ \d + \/ w i d g e t - b u i l d e r \/ w i d g e t \/ / ,
1123
+
1124
+ // Customer domain routes
1125
+ / ^ \/ d a s h b o a r d s \/ n e w \/ w i d g e t - b u i l d e r \/ w i d g e t \/ / ,
1126
+ / ^ \/ d a s h b o a r d \/ \d + \/ w i d g e t - b u i l d e r \/ w i d g e t \/ / ,
1127
+ ] ;
1128
+
1129
+ return widgetBuilderRoutes . some ( route =>
1130
+ route . test ( path ?? location . pathname )
1131
+ ) ;
1132
+ } ;
1111
1133
const navigatingWithinDashboards =
1112
- this . isWidgetBuilder ( locationChange . nextLocation . pathname ) ||
1113
- ( this . isWidgetBuilder ( locationChange . currentLocation . pathname ) &&
1134
+ checkDashboardRoute ( locationChange . nextLocation . pathname ) ||
1135
+ ( checkDashboardRoute ( locationChange . currentLocation . pathname ) &&
1114
1136
[ `/dashboard/${ dashboard . id } /` , `/dashboards/new/` ] . includes (
1115
1137
locationChange . nextLocation . pathname
1116
1138
) ) ;
0 commit comments