Make readonly metadata properties unable to edit
Image metadata properties os_hash_algo and os_hash_value are readonly, and attempts to edit them fail with unclear message. This patch makes these fields readonly in update metadata form. Also, if the existing metadata property is null, Horizon should consider it optional too, in addition to empty field fix: https://review.opendev.org/c/openstack/horizon/+/812009 Change-Id: I892465ca4688fce9f7123682d02f11c92c7d2c5c
This commit is contained in:
parent
c319118d7d
commit
892080ec0f
horizon/static/framework/widgets/metadata/tree
@ -16,6 +16,8 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var READONLY_PROPERTIES = ['os_hash_algo', 'os_hash_value'];
|
||||
|
||||
angular
|
||||
.module('horizon.framework.widgets.metadata.tree')
|
||||
.controller('MetadataTreeItemController', MetadataTreeItemController);
|
||||
@ -33,6 +35,12 @@
|
||||
ctrl.opened = false;
|
||||
|
||||
this.$onInit = function init() {
|
||||
if ('item' in ctrl && 'leaf' in ctrl.item &&
|
||||
READONLY_PROPERTIES.includes(ctrl.item.leaf.name)) {
|
||||
ctrl.item.leaf.readonly = true;
|
||||
ctrl.item.leaf.required = false;
|
||||
}
|
||||
|
||||
if ('item' in ctrl && 'leaf' in ctrl.item && ctrl.item.leaf.type === 'array') {
|
||||
ctrl.values = ctrl.item.leaf.items.enum.filter(filter).sort();
|
||||
|
||||
|
@ -71,6 +71,8 @@
|
||||
Property.prototype.setValue = function (value) {
|
||||
if (value === null) {
|
||||
this.value = this.type !== 'array' ? null : [];
|
||||
// if the existing property is null, make the field not required
|
||||
this.required = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user