From d3f61d561803f4e8a17b364e02d945316498e960 Mon Sep 17 00:00:00 2001 From: Pavlo Shchelokovskyy Date: Wed, 14 Feb 2024 15:29:46 +0200 Subject: [PATCH] Fix template generated by Template Generator do not stringify get_resource and get_attr, these must continue to be objects so that they are correctly rendered to YAML. As a result, `get_resource_string` was removed as no longer used. Change-Id: I621c55dd9a0c59f7eb8a87ef1f85557bd38b05d1 Story: 2005120 Task: 29769 --- .../js/components/modal-node.controller.js | 2 +- .../js/components/modal-template.controller.js | 2 +- .../template_generator/js/components/utils.module.js | 7 ++----- .../template_generator/js/components/utils.module.spec.js | 6 ------ 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-node.controller.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-node.controller.js index 6d41a416..7e1eb45b 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-node.controller.js +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-node.controller.js @@ -128,7 +128,7 @@ connected_options[property] = []; } connected_options[property].push({ - value: hotgenUtils.get_resource_string(hotgenStates.get_label_by_uuid(node.id)), + value: { 'get_resource': hotgenStates.get_label_by_uuid(node.id) }, id: node.id, resource_type: node.title, edge: edge diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js index 3691d62d..f744d4e5 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js @@ -131,7 +131,7 @@ var output_key = resource_name + '_' + output_detail[idx].property; outputs_root[output_key] = { description: 'The ' + output_detail[idx].property + ' of ' + resource_name +'.', - value: '{ get_attr: ['+resource_name+', '+output_detail[idx].property+'] }', + value: { 'get_attr': [resource_name, output_detail[idx].property] }, }; } diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.js index 30ac74eb..fb7d12bf 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.js +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.js @@ -94,9 +94,6 @@ } }]) .factory('hotgenUtils', function(){ - var get_resource_string = function(identity){ - return '{ get_resource: '+identity+' }'; - } var filter_and_return_get_resource_element = function(array, property){ var return_val = []; var idx = array.length-1; @@ -201,7 +198,8 @@ } var strip_property = function check_property(resource_data, property){ - if (resource_data[property] == null || resource_data[property] == ''){ + // remove empty properties or private Angular properties (start with $$) + if (resource_data[property] == null || resource_data[property] == '' || property.lastIndexOf("$$",0) === 0){ delete resource_data[property]; } else if (resource_data[property].constructor && resource_data[property].constructor == Object){ extract_dict(resource_data[property]); @@ -217,7 +215,6 @@ } return { - get_resource_string: get_resource_string, escape_characters: escape_characters, extract_keyvalue: extract_keyvalue, extract_list_of_keyvalue: extract_list_of_keyvalue, diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.spec.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.spec.js index d67e669b..2f7cb79e 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.spec.js +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/utils.module.spec.js @@ -169,12 +169,6 @@ expect(hotgenUtils).toBeDefined(); }); - it('should return string contains get_resource', function(){ - var returnValue = hotgenUtils.get_resource_string('identity'); - - expect(returnValue).toEqual('{ get_resource: identity }'); - }); - it('should filter elements', function(){ var property = 'name'; var array = ['ignore me', 1, '{ get_resource: find me }',