@@ -80,6 +80,17 @@ export const loadDashboardThunk = (uuid, text) => (dispatch: any, getState: any)
8080 dashboard = dashboard . dashboard ;
8181 }
8282
83+ let patched ;
84+ [ dashboard , patched ] = patchDashboardVersion ( dashboard , dashboard . version ) ;
85+ if ( patched ) {
86+ dispatch (
87+ createNotificationThunk (
88+ 'Successfully patched dashboard' ,
89+ `Your old dashboard has been patched. You might need to refresh this page and reactivate extensions.`
90+ )
91+ ) ;
92+ }
93+
8394 // Attempt upgrade if dashboard version is outdated.
8495 while ( VERSION_TO_MIGRATE [ dashboard . version ] ) {
8596 const upgradedDashboard = upgradeDashboardVersion (
@@ -540,6 +551,29 @@ export const assignDashboardUuidIfNotPresentThunk = () => (dispatch: any, getSta
540551 dispatch ( setDashboardUuid ( createUUID ( ) ) ) ;
541552 }
542553} ;
554+ export function patchDashboardVersion ( dashboard : any , version : any ) {
555+ let patched = false ;
556+ if ( version == '2.4' ) {
557+ dashboard . pages . forEach ( ( p ) => {
558+ p . reports . forEach ( ( r ) => {
559+ if ( r . type == 'graph' || r . type == 'map' || r . type == 'graph3d' ) {
560+ r . settings ?. actionsRules . forEach ( ( rule ) => {
561+ if (
562+ rule ?. field &&
563+ ( rule ?. condition === 'onNodeClick' || rule ?. condition == 'Click' ) &&
564+ rule . value . includes ( '.' )
565+ ) {
566+ let val = rule . value . split ( '.' ) ;
567+ rule . value = val [ val . length - 1 ] || rule . value ;
568+ patched = true ;
569+ }
570+ } ) ;
571+ }
572+ } ) ;
573+ } ) ;
574+ }
575+ return [ dashboard , patched ] ;
576+ }
543577
544578export function upgradeDashboardVersion ( dashboard : any , origin : string , target : string ) {
545579 if ( origin == '2.3' && target == '2.4' ) {
@@ -549,6 +583,19 @@ export function upgradeDashboardVersion(dashboard: any, origin: string, target:
549583 r . y *= 2 ;
550584 r . width *= 2 ;
551585 r . height *= 2 ;
586+
587+ if ( r . type == 'graph' || r . type == 'map' || r . type == 'graph3d' ) {
588+ r . settings ?. actionsRules . forEach ( ( rule ) => {
589+ if (
590+ rule ?. field &&
591+ ( rule ?. condition === 'onNodeClick' || rule ?. condition == 'Click' ) &&
592+ rule . value . includes ( '.' )
593+ ) {
594+ let val = rule . value . split ( '.' ) ;
595+ rule . value = val [ val . length - 1 ] || rule . value ;
596+ }
597+ } ) ;
598+ }
552599 } ) ;
553600 } ) ;
554601 dashboard . version = '2.4' ;
0 commit comments