mirror of https://github.com/rancher/dashboard.git
Add a managed by warning when editing resources with matching labels
rancher/dashboard#992
This commit is contained in:
parent
ec436f9c8e
commit
fd922642d6
|
|
@ -940,6 +940,7 @@ resourceDetail:
|
||||||
overview: Overview
|
overview: Overview
|
||||||
project: Project
|
project: Project
|
||||||
yaml: YAML
|
yaml: YAML
|
||||||
|
managedWarning: This {type} is managed by the {managedBy} app {appName}; changes made here will likely be overwritten the next time the app is changed.
|
||||||
|
|
||||||
resourceList:
|
resourceList:
|
||||||
head:
|
head:
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import { createYaml } from '@/utils/create-yaml';
|
||||||
import Masthead from '@/components/ResourceDetail/Masthead';
|
import Masthead from '@/components/ResourceDetail/Masthead';
|
||||||
import DetailTop from '@/components/DetailTop';
|
import DetailTop from '@/components/DetailTop';
|
||||||
import FileSelector from '@/components/form/FileSelector';
|
import FileSelector from '@/components/form/FileSelector';
|
||||||
|
import { KUBERNETES } from '@/config/labels-annotations';
|
||||||
|
import Banner from '@/components/Banner';
|
||||||
import GenericResourceDetail from './Generic';
|
import GenericResourceDetail from './Generic';
|
||||||
|
|
||||||
// Components can't have asyncData, only pages.
|
// Components can't have asyncData, only pages.
|
||||||
|
|
@ -159,7 +161,7 @@ export const watchQuery = [MODE, AS_YAML];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
DetailTop, FileSelector, ResourceYaml, Masthead, GenericResourceDetail
|
Banner, DetailTop, FileSelector, ResourceYaml, Masthead, GenericResourceDetail
|
||||||
},
|
},
|
||||||
mixins: [CreateEditView],
|
mixins: [CreateEditView],
|
||||||
|
|
||||||
|
|
@ -262,6 +264,27 @@ export default {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showManagedWarning() {
|
||||||
|
const { value: model, mode } = this;
|
||||||
|
const managedLabel = model?.metadata?.labels ? model.metadata.labels[KUBERNETES.MANAGED_BY] : false;
|
||||||
|
|
||||||
|
if (mode === _EDIT && managedLabel && managedLabel.toLowerCase() === 'helm') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
managedWarningOptions() {
|
||||||
|
const { value } = this;
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: value?.kind || '',
|
||||||
|
managedBy: value?.metadata?.labels[KUBERNETES.MANAGED_BY] || '',
|
||||||
|
appName: value?.metadata?.labels?.release || '',
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
|
@ -289,6 +312,11 @@ export default {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<Banner
|
||||||
|
v-if="showManagedWarning"
|
||||||
|
color="warning"
|
||||||
|
:label="t('resourceDetail.masthead.managedWarning', managedWarningOptions)"
|
||||||
|
/>
|
||||||
<Masthead
|
<Masthead
|
||||||
:value="originalModel"
|
:value="originalModel"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ export const CONTAINER_DEFAULT_RESOURCE_LIMIT = 'field.cattle.io/containerDefaul
|
||||||
|
|
||||||
export const KUBERNETES = {
|
export const KUBERNETES = {
|
||||||
SERVICE_ACCOUNT_UID: 'kubernetes.io/service-account.uid',
|
SERVICE_ACCOUNT_UID: 'kubernetes.io/service-account.uid',
|
||||||
SERVICE_ACCOUNT_NAME: 'kubernetes.io/service-account.name'
|
SERVICE_ACCOUNT_NAME: 'kubernetes.io/service-account.name',
|
||||||
|
MANAGED_BY: 'app.kubernetes.io/managed-by',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RIO = { STACK: 'rio.cattle.io/stack' };
|
export const RIO = { STACK: 'rio.cattle.io/stack' };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue