@@ -35,8 +35,7 @@ export class DashboardLoaderSrv {
35
35
} ;
36
36
}
37
37
38
- loadDashboard ( type : UrlQueryValue , slug : string | undefined , uid : string | undefined ) : Promise < DashboardDTO > {
39
- const stateManager = getDashboardScenePageStateManager ( ) ;
38
+ loadDashboard ( type : UrlQueryValue , slug : any , uid : any , version : any ) {
40
39
let promise ;
41
40
42
41
if ( type === 'script' && slug ) {
@@ -76,15 +75,23 @@ export class DashboardLoaderSrv {
76
75
} ,
77
76
} ;
78
77
} ) ;
79
- } else if ( uid ) {
80
- const cachedDashboard = stateManager . getDashboardFromCache ( uid ) ;
81
- if ( cachedDashboard ) {
82
- return Promise . resolve ( cachedDashboard ) ;
83
- }
84
-
85
- promise = getDashboardAPI ( )
86
- . getDashboardDTO ( uid )
87
- . then ( ( result ) => {
78
+ } else if ( version !== undefined ) {
79
+ promise = backendSrv
80
+ . getDashboardByUidVersion ( uid , version )
81
+ . then ( ( result : any ) => {
82
+ if ( result . meta . isFolder ) {
83
+ appEvents . emit ( AppEvents . alertError , [ 'Dashboard with version not found' ] ) ;
84
+ throw new Error ( 'Dashboard with version not found' ) ;
85
+ }
86
+ return result ;
87
+ } )
88
+ . catch ( ( ) => {
89
+ return this . _dashboardLoadFailed ( 'Not found' , true ) ;
90
+ } ) ;
91
+ } else {
92
+ promise = backendSrv
93
+ . getDashboardByUid ( uid )
94
+ . then ( ( result : any ) => {
88
95
if ( result . meta . isFolder ) {
89
96
appEvents . emit ( AppEvents . alertError , [ 'Dashboard not found' ] ) ;
90
97
throw new Error ( 'Dashboard not found' ) ;
0 commit comments