This commit is contained in:
Ryan McKinley committed 2024-11-25 09:18:29 +03:00
1 parent ac998121e4
commit c899c15525
6 files changed
+47 -27

No files matched your search

+13
View File
@@ -2071,6 +2071,11 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
],
"public/app/features/dashboard-scene/saving/SaveDashboardDrawer.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
],
"public/app/features/dashboard-scene/saving/SaveDashboardForm.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
@@ -3697,6 +3702,14 @@ exports[`better eslint`] = {
"public/app/features/provisioning/api/index.ts:5381": [
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"]
],
"public/app/features/provisioning/api/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/features/provisioning/dashboard.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/query/components/QueryEditorRow.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -89,29 +89,39 @@ export class SaveDashboardDrawer extends SceneObjectBase<SaveDashboardDrawerStat
// Preview (eg, NOT saved in grafana database)
if (provisioning) {
return <div>
<h1>Loaded from external repository</h1>
<h3>{provisioning.repo}</h3>
<a href={provisioning.file}>{provisioning.file}</a>
return (
<div>
<Button onClick={() => {
getBackendSrv().put(provisioning.file, changedSaveModel, {
params: provisioning.ref ? { ref: provisioning.ref } : undefined,
}).then(v => {
console.log('WROTE', v)
alert('WROTE value')
})
}}>SAVE</Button>
<h1>Loaded from external repository</h1>
<h3>{provisioning.repo}</h3>
<a href={provisioning.file}>{provisioning.file}</a>
<div>
<Button
onClick={() => {
getBackendSrv()
.put(provisioning.file, changedSaveModel, {
params: provisioning.ref ? { ref: provisioning.ref } : undefined,
})
.then((v) => {
console.log('WROTE', v);
alert('WROTE value');
});
}}
>
SAVE
</Button>
</div>
</div>
</div>
);
}
// Saved in grafana database, BUT must write to a remote repo for edit
if (meta.k8s?.annotations?.[AnnoKeyRepoName]) {
return <div>
<h1>Saved from external repository</h1>
<pre>{JSON.stringify(meta.k8s.annotations, null, ' ')}</pre>
</div>
return (
<div>
<h1>Saved from external repository</h1>
<pre>{JSON.stringify(meta.k8s.annotations, null, ' ')}</pre>
</div>
);
}
if (saveAsCopy || changeInfo.isNew) {
@@ -54,7 +54,7 @@ export class DashboardLoaderSrv {
return this._dashboardLoadFailed('Snapshot not found', true);
});
} else if (type === 'provisioning') {
promise = loadDashboardFromProvisioning(slug!, uid!)
promise = loadDashboardFromProvisioning(slug!, uid!);
} else if (type === 'public' && uid) {
promise = backendSrv
.getPublicDashboardByUid(uid)
@@ -17,11 +17,11 @@ export async function loadDashboardFromProvisioning(repo: string, path: string):
// Load the results from dryRun
const dryRun = v.resource.dryRun as Resource<DashboardDataDTO, 'Dashboard'>;
if (!dryRun) {
return Promise.reject("failed to read provisioned dashboard")
return Promise.reject('failed to read provisioned dashboard');
}
if (!dryRun.apiVersion.startsWith("dashboard.grafana.app")) {
return Promise.reject("unexpected resource type: "+dryRun.apiVersion)
if (!dryRun.apiVersion.startsWith('dashboard.grafana.app')) {
return Promise.reject('unexpected resource type: ' + dryRun.apiVersion);
}
return {
@@ -43,9 +43,9 @@ export async function loadDashboardFromProvisioning(repo: string, path: string):
file: url,
ref: ref,
repo: repo,
}
},
},
dashboard: dryRun.spec
}
dashboard: dryRun.spec,
};
});
}
@@ -5,7 +5,6 @@ export type RepositoryFormData = GitHubRepositoryConfig &
LocalRepositoryConfig &
Omit<RepositorySpec, 'github' | 's3' | 'local'>;
// Added to DashboardDTO to help editor
export interface ProvisioningPreview {
repo: string;
-2
View File
@@ -83,8 +83,6 @@ export interface DashboardMeta {
reloadOnParamsChange?: boolean;
}
export interface AnnotationActions {
canAdd: boolean;
canEdit: boolean;