rename sync with main
This commit is contained in:
1 parent
6e950f38b1
commit
384fb7f6c3
6 files changed
+32
-28
No files matched your search
@@ -43,11 +43,11 @@ export const AnnoKeyFolderUrl = 'grafana.app/folderUrl';
|
||||
export const AnnoKeyMessage = 'grafana.app/message';
|
||||
export const AnnoKeySlug = 'grafana.app/slug';
|
||||
|
||||
// Identify where values came from
|
||||
export const AnnoKeyRepoName = 'grafana.app/repoName';
|
||||
export const AnnoKeyRepoPath = 'grafana.app/repoPath';
|
||||
export const AnnoKeyRepoHash = 'grafana.app/repoHash';
|
||||
export const AnnoKeyRepoTimestamp = 'grafana.app/repoTimestamp';
|
||||
export const AnnoKeyManagerKind = 'grafana.app/managedBy';
|
||||
export const AnnoKeyManagerIdentity = 'grafana.app/managerId';
|
||||
export const AnnoKeySourcePath = 'grafana.app/sourcePath';
|
||||
export const AnnoKeySourceChecksum = 'grafana.app/sourceChecksum';
|
||||
export const AnnoKeySourceTimestamp = 'grafana.app/sourceTimestamp';
|
||||
|
||||
export const AnnoKeySavedFromUI = 'grafana.app/saved-from-ui';
|
||||
export const AnnoKeyDashboardNotFound = 'grafana.app/dashboard-not-found';
|
||||
@@ -66,10 +66,11 @@ type GrafanaAnnotations = {
|
||||
[AnnoKeyFolder]?: string;
|
||||
[AnnoKeySlug]?: string;
|
||||
|
||||
[AnnoKeyRepoName]?: string;
|
||||
[AnnoKeyRepoPath]?: string;
|
||||
[AnnoKeyRepoHash]?: string;
|
||||
[AnnoKeyRepoTimestamp]?: string;
|
||||
[AnnoKeyManagerKind]?: string;
|
||||
[AnnoKeyManagerIdentity]?: string;
|
||||
[AnnoKeySourcePath]?: string;
|
||||
[AnnoKeySourceChecksum]?: string;
|
||||
[AnnoKeySourceTimestamp]?: string;
|
||||
};
|
||||
|
||||
// Annotations provided by the front-end client
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Button, Input, Switch, Field, Label, TextArea, Stack, Alert, Box } from
|
||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||
import { validationSrv } from 'app/features/manage-dashboards/services/ValidationSrv';
|
||||
|
||||
import { AnnoKeyRepoName } from '../../apiserver/types';
|
||||
import { AnnoKeyManagerIdentity } from '../../apiserver/types';
|
||||
import { RepositoryView } from '../../provisioning/api';
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
|
||||
@@ -140,7 +140,7 @@ export function SaveDashboardAsForm({ dashboard, changeInfo }: Props) {
|
||||
setHasFolderChanged(uid !== folderUid);
|
||||
dashboard.setState({
|
||||
meta: {
|
||||
k8s: name ? { annotations: { [AnnoKeyRepoName]: name } } : undefined,
|
||||
k8s: name ? { annotations: { [AnnoKeyManagerIdentity]: name } } : undefined,
|
||||
folderUid: uid,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getAppEvents, locationService } from '@grafana/runtime';
|
||||
import { Alert, Button, Field, Input, RadioButtonGroup, Stack, TextArea } from '@grafana/ui';
|
||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||
import { useUrlParams } from 'app/core/navigation/hooks';
|
||||
import { AnnoKeyRepoName } from 'app/features/apiserver/types';
|
||||
import { AnnoKeyManagerIdentity } from 'app/features/apiserver/types';
|
||||
import { validationSrv } from 'app/features/manage-dashboards/services/ValidationSrv';
|
||||
import { RepositoryView } from 'app/features/provisioning/api';
|
||||
import { PROVISIONING_URL } from 'app/features/provisioning/constants';
|
||||
@@ -167,7 +167,7 @@ export function SaveProvisionedDashboard({ drawer, changeInfo, dashboard }: Prop
|
||||
}
|
||||
dashboard.setState({
|
||||
meta: {
|
||||
k8s: name ? { annotations: { [AnnoKeyRepoName]: name } } : undefined,
|
||||
k8s: name ? { annotations: { [AnnoKeyManagerIdentity]: name } } : undefined,
|
||||
folderUid: uid,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Chance } from 'chance';
|
||||
|
||||
import { dateTime } from '@grafana/data';
|
||||
import { AnnoKeyRepoName, AnnoKeyRepoPath } from 'app/features/apiserver/types';
|
||||
import { AnnoKeyManagerIdentity, AnnoKeyManagerKind, AnnoKeySourcePath } from 'app/features/apiserver/types';
|
||||
import { useGetResourceRepository } from 'app/features/provisioning/hooks';
|
||||
import { DashboardMeta } from 'app/types';
|
||||
|
||||
@@ -25,10 +25,12 @@ function generatePath(timestamp: string, pathFromAnnotation?: string, slug?: str
|
||||
|
||||
export function useDefaultValues({ meta, defaultTitle, defaultDescription }: UseDefaultValuesParams) {
|
||||
const annotations = meta.k8s?.annotations;
|
||||
const annoName = annotations?.[AnnoKeyRepoName];
|
||||
const annoPath = annotations?.[AnnoKeyRepoPath];
|
||||
const managerKind = annotations?.[AnnoKeyManagerKind];
|
||||
const managerIdentity = annotations?.[AnnoKeyManagerIdentity];
|
||||
const sourcePath = annotations?.[AnnoKeySourcePath];
|
||||
// Get config by resource name or folder UID for new resources
|
||||
const repositoryConfig = useGetResourceRepository({ name: annoName, folderUid: meta.folderUid });
|
||||
const repositoryConfig =
|
||||
managerKind === 'repo' ? useGetResourceRepository({ name: managerIdentity, folderUid: meta.folderUid }) : undefined;
|
||||
const repository = repositoryConfig?.spec;
|
||||
|
||||
const random = Chance(1);
|
||||
@@ -37,8 +39,8 @@ export function useDefaultValues({ meta, defaultTitle, defaultDescription }: Use
|
||||
return {
|
||||
values: {
|
||||
ref: `dashboard/${timestamp}`,
|
||||
path: generatePath(timestamp, annoPath, meta.slug),
|
||||
repo: annoName || repositoryConfig?.metadata?.name || '',
|
||||
path: generatePath(timestamp, sourcePath, meta.slug),
|
||||
repo: managerIdentity || repositoryConfig?.metadata?.name || '',
|
||||
comment: '',
|
||||
folder: {
|
||||
uid: meta.folderUid,
|
||||
@@ -48,7 +50,7 @@ export function useDefaultValues({ meta, defaultTitle, defaultDescription }: Use
|
||||
description: defaultDescription ?? '',
|
||||
workflow: getDefaultWorkflow(repository),
|
||||
},
|
||||
isNew: !annoName,
|
||||
isNew: !managerIdentity,
|
||||
repositoryConfig: repository,
|
||||
isGitHub: repository?.type === 'github',
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ import { VariablesChanged } from 'app/features/variables/types';
|
||||
import { DashboardDTO, DashboardMeta, KioskMode, SaveDashboardResponseDTO } from 'app/types';
|
||||
import { ShowConfirmModalEvent } from 'app/types/events';
|
||||
|
||||
import { AnnoKeyRepoName, AnnoKeyRepoPath } from '../../apiserver/types';
|
||||
import { AnnoKeyManagerIdentity, AnnoKeySourcePath } from '../../apiserver/types';
|
||||
import { DashboardEditPane } from '../edit-pane/DashboardEditPane';
|
||||
import { PanelEditor } from '../panel-edit/PanelEditor';
|
||||
import { DashboardSceneChangeTracker } from '../saving/DashboardSceneChangeTracker';
|
||||
@@ -747,7 +747,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> impleme
|
||||
* Provisioned dashboards helpers
|
||||
*/
|
||||
getRepoName() {
|
||||
return this.state.meta.k8s?.annotations?.[AnnoKeyRepoName];
|
||||
return this.state.meta.k8s?.annotations?.[AnnoKeyManagerIdentity];
|
||||
}
|
||||
|
||||
isProvisioned() {
|
||||
@@ -755,13 +755,13 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> impleme
|
||||
}
|
||||
|
||||
getPath() {
|
||||
return this.state.meta.k8s?.annotations?.[AnnoKeyRepoPath];
|
||||
return this.state.meta.k8s?.annotations?.[AnnoKeySourcePath];
|
||||
}
|
||||
|
||||
setRepoName(name: string) {
|
||||
this.setState({
|
||||
meta: {
|
||||
k8s: { annotations: { [AnnoKeyRepoName]: name } },
|
||||
k8s: { annotations: { [AnnoKeyManagerIdentity]: name } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { DashboardDTO } from 'app/types';
|
||||
|
||||
import { AnnoKeyRepoName, AnnoKeyRepoPath } from '../apiserver/types';
|
||||
import { AnnoKeyManagerIdentity, AnnoKeyManagerKind, AnnoKeySourcePath } from '../apiserver/types';
|
||||
|
||||
import { BASE_URL } from './api/baseAPI';
|
||||
|
||||
@@ -32,10 +32,11 @@ export async function loadDashboardFromProvisioning(repo: string, path: string):
|
||||
if (!anno) {
|
||||
dryRun.metadata.annotations = anno = {};
|
||||
}
|
||||
anno[AnnoKeyRepoName] = repo;
|
||||
anno[AnnoKeyRepoPath] = path;
|
||||
anno[AnnoKeyManagerKind] = 'repo';
|
||||
anno[AnnoKeyManagerIdentity] = repo;
|
||||
anno[AnnoKeySourcePath] = path;
|
||||
if (ref) {
|
||||
anno[AnnoKeyRepoPath] = path + '#' + ref;
|
||||
anno[AnnoKeySourcePath] = path + '#' + ref;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user