diff --git a/lib/shared/addon/components/form-key-value/component.js b/lib/shared/addon/components/form-key-value/component.js
index d798fa282..d6d4df7dd 100644
--- a/lib/shared/addon/components/form-key-value/component.js
+++ b/lib/shared/addon/components/form-key-value/component.js
@@ -63,6 +63,7 @@ export default Component.extend(Upload, {
initialMap: null,
initialArray: null,
requiredIfAny: null,
+ readonlyArray: null,
ary: null,
allowEmptyValue: false,
allowAdd: true,
@@ -89,12 +90,14 @@ export default Component.extend(Upload, {
var ary = [];
var map = get(this, 'initialMap');
+ const readonlyArray = get(this, 'readonlyArray') || [];
if ( map ) {
Object.keys(map).forEach((key) => {
ary.push({
key,
- value: map[key]
+ value: map[key],
+ editable: readonlyArray.indexOf(key) === -1
});
});
} else if ( get(this, 'initialStr') ) {
diff --git a/lib/shared/addon/components/form-key-value/template.hbs b/lib/shared/addon/components/form-key-value/template.hbs
index 7d8e5a9f3..a02c7dacf 100644
--- a/lib/shared/addon/components/form-key-value/template.hbs
+++ b/lib/shared/addon/components/form-key-value/template.hbs
@@ -27,7 +27,7 @@
{{#each ary as |row|}}
|
- {{#if (and editing allowEditKey (not-eq row.editable false))}}
+ {{#if editing}}
{{input-paste
separators=separators
pasted=(action "pastedValues")
@@ -35,6 +35,7 @@
type="text"
value=row.key
placeholder=keyPlaceholder
+ disabled=(not (and allowEditKey (not-eq row.editable false)))
}}
{{else}}
{{row.key}}
@@ -61,7 +62,7 @@
| |
{{#if (and editing allowRemove)}}
-
+
{{/if}}
|
diff --git a/lib/shared/addon/components/form-labels-annotations/component.js b/lib/shared/addon/components/form-labels-annotations/component.js
index f60d4346c..3cf860d7d 100644
--- a/lib/shared/addon/components/form-labels-annotations/component.js
+++ b/lib/shared/addon/components/form-labels-annotations/component.js
@@ -1,5 +1,5 @@
import { next } from '@ember/runloop';
-import { set } from '@ember/object';
+import { get, set } from '@ember/object';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import ManageLabels from 'shared/mixins/manage-labels';
@@ -9,6 +9,7 @@ import {
classForStatus
} from 'shared/components/accordion-list-item/component';
import layout from './template';
+import C from 'ui/utils/constants';
export default Component.extend(ManageLabels, {
intl: service(),
@@ -16,12 +17,13 @@ export default Component.extend(ManageLabels, {
layout,
classNames: ['accordion-wrapper'],
- detailKey: 'formLabelsAnnotations.detail',
- annotationsCount: 0,
- labelsCount: 0,
- expandAll: null,
- editing: true,
- readonlyLabels: null,
+ detailKey: 'formLabelsAnnotations.detail',
+ annotationsCount: 0,
+ labelsCount: 0,
+ expandAll: null,
+ editing: true,
+ readonlyLabels: null,
+ readonlyAnnotations: null,
// Inputs
initialLabels: null,
@@ -32,10 +34,9 @@ export default Component.extend(ManageLabels, {
init() {
this._super(...arguments);
- this.initLabels(this.get('initialLabels'), 'user', null, this.get('readonlyLabels'));
- this.labelsChanged();
- this.initCounts();
+ this.initLablesAndAnnotations();
},
+
didReceiveAttrs() {
if (!this.get('expandFn')) {
this.set('expandFn', (item) => {
@@ -82,6 +83,29 @@ export default Component.extend(ManageLabels, {
return this.get('intl').t(`${ STATUS_INTL_KEY }.${ k }`, { count });
}.property('labelsCount', 'annotationsCount'),
+
+ initLablesAndAnnotations() {
+ const readonlyLabels = get(this, 'readonlyLabels') || [];
+ let readonlyAnnotations = get(this, 'readonlyAnnotations') || [];
+
+ Object.keys((get(this, 'initialLabels') || {})).forEach((key) => {
+ if ( C.LABEL_PREFIX_TO_IGNORE.find((L) => key.startsWith(L))) {
+ readonlyLabels.push(key);
+ }
+ })
+
+ Object.keys((get(this, 'model.annotations') || {})).forEach((key) => {
+ if ( C.ANNOTATIONS_TO_IGNORE.find((L) => key.indexOf(L) > -1)) {
+ readonlyAnnotations.push(key);
+ }
+ })
+ set(this, 'readonlyAnnotations', readonlyAnnotations);
+
+ this.initLabels(this.get('initialLabels'), 'user', null, readonlyLabels);
+ this.labelsChanged();
+ this.initCounts();
+ },
+
initCounts(){
let labels = this.get('model.labels');
let annotations = this.get('model.annotations');
diff --git a/lib/shared/addon/components/form-labels-annotations/template.hbs b/lib/shared/addon/components/form-labels-annotations/template.hbs
index 1524cb745..c30317abd 100644
--- a/lib/shared/addon/components/form-labels-annotations/template.hbs
+++ b/lib/shared/addon/components/form-labels-annotations/template.hbs
@@ -80,6 +80,7 @@
{{form-key-value
header=(t "formAnnotations.title")
editing=editing
+ readonlyArray=readonlyAnnotations
initialMap=model.annotations
changed=(action "annotationsChange")
addActionLabel="formAnnotations.addActionLabel"
diff --git a/lib/shared/addon/utils/constants.js b/lib/shared/addon/utils/constants.js
index dc20d1518..be8a1e345 100644
--- a/lib/shared/addon/utils/constants.js
+++ b/lib/shared/addon/utils/constants.js
@@ -566,10 +566,17 @@ C.LABEL_PREFIX_TO_IGNORE = [
'node-role.kubernetes.io/',
'kubernetes.io/',
'cattle.io/',
+ 'authz.management.cattle.io',
'rke.cattle.io',
'field.cattle.io',
];
+C.ANNOTATIONS_TO_IGNORE = [
+ 'coreos.com/',
+ 'kubernetes.io/',
+ 'cattle.io/',
+]
+
C.SYSTEM_LABELS_WITH_CONTROL = [
C.LABEL.SCHED_GLOBAL,
C.LABEL.HOSTNAME_OVERRIDE,