mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 04:00:55 +08:00
Provisioning: Load dashboard in state manager (#102194)
MergeProvisioning: Load dashboard in state manager
This commit is contained in:
@ -314,6 +314,9 @@ export class DashboardScenePageStateManager extends DashboardScenePageStateManag
|
||||
}
|
||||
|
||||
break;
|
||||
case DashboardRoutes.Provisioning: {
|
||||
return await dashboardLoaderSrv.loadDashboard('provisioning', slug, uid);
|
||||
}
|
||||
case DashboardRoutes.Public: {
|
||||
return await dashboardLoaderSrv.loadDashboard('public', '', uid);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import { VariablesChanged } from 'app/features/variables/types';
|
||||
import { DashboardDTO, DashboardMeta, KioskMode, SaveDashboardResponseDTO } from 'app/types';
|
||||
import { ShowConfirmModalEvent } from 'app/types/events';
|
||||
|
||||
import { AnnoKeyManagerIdentity, AnnoKeyManagerKind, AnnoKeySourcePath, ManagerKind } from '../../apiserver/types';
|
||||
import { AnnoKeyManagerKind, AnnoKeySourcePath, ManagerKind } from '../../apiserver/types';
|
||||
import { DashboardEditPane } from '../edit-pane/DashboardEditPane';
|
||||
import { PanelEditor } from '../panel-edit/PanelEditor';
|
||||
import { DashboardSceneChangeTracker } from '../saving/DashboardSceneChangeTracker';
|
||||
@ -766,19 +766,6 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> impleme
|
||||
getPath() {
|
||||
return this.state.meta.k8s?.annotations?.[AnnoKeySourcePath];
|
||||
}
|
||||
|
||||
setManager(kind: ManagerKind, id: string) {
|
||||
this.setState({
|
||||
meta: {
|
||||
k8s: {
|
||||
annotations: {
|
||||
[AnnoKeyManagerKind]: kind,
|
||||
[AnnoKeyManagerIdentity]: id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class DashboardVariableDependency implements SceneVariableDependencyConfigLike {
|
||||
|
@ -11,7 +11,7 @@ import { BASE_URL } from './api/baseAPI';
|
||||
*/
|
||||
export async function loadDashboardFromProvisioning(repo: string, path: string): Promise<DashboardDTO> {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const ref = params.get('ref'); // commit hash or branch
|
||||
const ref = params.get('ref') ?? undefined; // commit hash or branch
|
||||
|
||||
const url = `${BASE_URL}/repositories/${repo}/files/${path}`;
|
||||
return getBackendSrv()
|
||||
|
@ -3,6 +3,8 @@ import { Dashboard, DataSourceRef } from '@grafana/schema';
|
||||
import { ObjectMeta } from 'app/features/apiserver/types';
|
||||
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||
|
||||
import { ProvisioningPreview } from '../features/provisioning/types';
|
||||
|
||||
export interface HomeDashboardRedirectDTO {
|
||||
redirectUri: string;
|
||||
}
|
||||
@ -78,6 +80,9 @@ export interface DashboardMeta {
|
||||
// until we use the resource as the main container
|
||||
k8s?: Partial<ObjectMeta>;
|
||||
|
||||
// If the dashboard was loaded from a remote repository
|
||||
provisioning?: ProvisioningPreview;
|
||||
|
||||
// This is a property added specifically for edge cases where dashboards should be reloaded on scopes, time range or variables changes
|
||||
// This property is not persisted in the DB but its existence is controlled by the API
|
||||
reloadOnParamsChange?: boolean;
|
||||
@ -105,6 +110,7 @@ export enum DashboardRoutes {
|
||||
Home = 'home-dashboard',
|
||||
New = 'new-dashboard',
|
||||
Normal = 'normal-dashboard',
|
||||
Provisioning = 'provisioning-dashboard',
|
||||
Scripted = 'scripted-dashboard',
|
||||
Public = 'public-dashboard',
|
||||
Embedded = 'embedded-dashboard',
|
||||
|
Reference in New Issue
Block a user