summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreschcam <cameron.scholes@est.tech>2023-02-01 12:17:18 +0000
committerMichael Morris <michael.morris@est.tech>2023-02-22 12:25:11 +0000
commit59e446fb77ccf05aeae9b7046bd80e10124707c0 (patch)
tree26c21256e5734685646c7c0ce93112cd099429ea
parent3eb6f41297cedc038d18582d31d65dab05b351b8 (diff)
Disable editing the name of existing attributes
Also added a patch to fix an exception been thrown when editing existing attributes Issue-ID: SDC-3384 Signed-off-by: eschcam <cameron.scholes@est.tech> Change-Id: I524bad3046699baf66f407d1cf0c36394a66b623
-rw-r--r--catalog-ui/src/app/models/attributes-outputs/attribute-be-model.ts6
-rw-r--r--catalog-ui/src/app/models/attributes.ts34
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html5
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts6
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AttributeModal.java2
5 files changed, 33 insertions, 20 deletions
diff --git a/catalog-ui/src/app/models/attributes-outputs/attribute-be-model.ts b/catalog-ui/src/app/models/attributes-outputs/attribute-be-model.ts
index 6af23a55ae..a6966cd799 100644
--- a/catalog-ui/src/app/models/attributes-outputs/attribute-be-model.ts
+++ b/catalog-ui/src/app/models/attributes-outputs/attribute-be-model.ts
@@ -64,7 +64,11 @@ export class AttributeBEModel {
this.password = attribute.password;
this.required = attribute.required;
this.schema = attribute.schema;
- this.schemaType = attribute.schemaType;
+
+ if (attribute.schemaType) {
+ this.schemaType = attribute.schemaType;
+ }
+
this.type = attribute.type;
this.uniqueId = attribute.uniqueId;
this.value = attribute.value;
diff --git a/catalog-ui/src/app/models/attributes.ts b/catalog-ui/src/app/models/attributes.ts
index ae5eac0281..711e5b3c49 100644
--- a/catalog-ui/src/app/models/attributes.ts
+++ b/catalog-ui/src/app/models/attributes.ts
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,14 +19,14 @@
*/
'use strict';
-import * as _ from "lodash";
-import {SchemaAttribute, SchemaAttributeGroupModel} from "./schema-attribute";
-import {AttributeOutputDetail} from "app/models/attributes-outputs/attribute-output-detail";
-import {AttributeBEModel} from "app/models/attributes-outputs/attribute-be-model";
+import { AttributeBEModel } from 'app/models/attributes-outputs/attribute-be-model';
+import { AttributeOutputDetail } from 'app/models/attributes-outputs/attribute-output-detail';
+import * as _ from 'lodash';
+import { SchemaAttribute, SchemaAttributeGroupModel } from './schema-attribute';
export class AttributesGroup {
constructor(attributesObj?: AttributesGroup) {
- _.forEach(attributesObj, (attributes: Array<AttributeModel>, instance) => {
+ _.forEach(attributesObj, (attributes: AttributeModel[], instance) => {
this[instance] = [];
_.forEach(attributes, (attribute: AttributeModel): void => {
attribute.resourceInstanceUniqueId = instance;
@@ -39,7 +39,7 @@ export class AttributesGroup {
export interface IAttributeModel {
- //server data
+ // server data
uniqueId: string;
name: string;
_default: string;
@@ -49,7 +49,7 @@ export interface IAttributeModel {
status: string;
value: string;
parentUniqueId: string;
- //custom data
+ // custom data
resourceInstanceUniqueId: string;
readonly: boolean;
valueUniqueUid: string;
@@ -57,7 +57,7 @@ export interface IAttributeModel {
export class AttributeModel extends AttributeBEModel implements IAttributeModel {
- //server data
+ // server data
uniqueId: string;
name: string;
_default: string;
@@ -67,7 +67,7 @@ export class AttributeModel extends AttributeBEModel implements IAttributeModel
status: string;
value: string;
parentUniqueId: string;
- //custom data
+ // custom data
resourceInstanceUniqueId: string;
readonly: boolean;
valueUniqueUid: string;
@@ -102,7 +102,7 @@ export class AttributeModel extends AttributeBEModel implements IAttributeModel
if (!this.schema || !this.schema.property) {
this.schema = new SchemaAttributeGroupModel(new SchemaAttribute());
} else {
- //forcing creating new object, so editing different one than the object in the table
+ // forcing creating new object, so editing different one than the object in the table
this.schema = new SchemaAttributeGroupModel(new SchemaAttribute(this.schema.property));
}
@@ -116,21 +116,20 @@ export class AttributeModel extends AttributeBEModel implements IAttributeModel
if (this._default && this.type === 'list') {
this._default = '[' + this._default + ']';
}
- this._default = this._default != "" && this._default != "[]" && this._default != "{}" ? this._default : null;
+ this._default = this._default != '' && this._default != '[]' && this._default != '{}' ? this._default : null;
return JSON.stringify(this);
}
-
public convertValueToView() {
- //unwrapping value {} or [] if type is complex
+ // unwrapping value {} or [] if type is complex
if (this._default && (this.type === 'map' || this.type === 'list') &&
['[', '{'].indexOf(this._default.charAt(0)) > -1 &&
[']', '}'].indexOf(this._default.slice(-1)) > -1) {
this._default = this._default.slice(1, -1);
}
- //also for value - for the modal in canvas
+ // also for value - for the modal in canvas
if (this.value && (this.type === 'map' || this.type === 'list') &&
['[', '{'].indexOf(this.value.charAt(0)) > -1 &&
[']', '}'].indexOf(this.value.slice(-1)) > -1) {
@@ -144,6 +143,7 @@ export class AttributeModel extends AttributeBEModel implements IAttributeModel
}
this.readonly = undefined;
this.resourceInstanceUniqueId = undefined;
+
return this;
- };
+ }
}
diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html
index 590217d0a5..d94fb546dc 100644
--- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html
+++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html
@@ -36,7 +36,10 @@
<div class="attributeType">
<!-- ATTRIBUTE TYPE - MANDATORY -->
- <sdc-dropdown #attributeType [disabled]="false" label="Type" [required]="true"
+ <sdc-dropdown #attributeType
+ [disabled]="isEdit"
+ label="Type"
+ [required]="true"
[selectedOption]="toDropDownOption(this.attributeToEdit.type)" placeHolder="Choose Type"
testId="attributeType"
[options]="types" (changed)="onTypeSelected($event)">
diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts
index 426ed4063e..e851bafc1d 100644
--- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts
+++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts
@@ -32,6 +32,7 @@ export class AttributeModalComponent implements OnInit {
// The current effective default value pattern
public defaultValuePattern: string;
public defaultValueErrorMessage: string;
+ public isEdit: boolean;
// Attribute being Edited
public attributeToEdit: AttributeModel;
@@ -41,6 +42,11 @@ export class AttributeModalComponent implements OnInit {
}
ngOnInit() {
+ // Disable editing the name of existing attributes
+ if (this.attributeToEdit && this.attributeToEdit.name) {
+ this.isEdit = true;
+ }
+
this.revalidateDefaultValue();
}
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AttributeModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AttributeModal.java
index bd1330d8cf..037d7e4d49 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AttributeModal.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AttributeModal.java
@@ -46,9 +46,9 @@ public class AttributeModal extends AbstractPageObject {
public void fillForm(final AttributeData attributeData, final boolean isUpdate) {
if (!isUpdate) {
editName(attributeData.getAttributeName());
+ editType(attributeData.getAttributeType());
}
editDescription(attributeData.getDescription());
- editType(attributeData.getAttributeType());
editDefaultValue(attributeData.getDefaultValue());
}