From b0d4f4a16c8fa9e3684d3f13d4c0fdd37e75ba39 Mon Sep 17 00:00:00 2001 From: JEFFREY-Bonson Date: Mon, 26 Feb 2024 18:15:03 +0530 Subject: [PATCH] Fix styles for control action summary and form pages --- app/controllers/miq_action_controller.rb | 2 +- app/helpers/miq_action_helper.rb | 37 +++++++---- .../action-form/action-form.schema.js | 3 + .../miq-structured-list-object.jsx | 2 +- .../__snapshots__/action-form.spec.js.snap | 63 +++++++++++++++++++ app/stylesheet/ddf_override.scss | 25 ++++++++ app/stylesheet/miq-structured-list.scss | 3 + app/views/miq_action/show.html.haml | 6 +- 8 files changed, 123 insertions(+), 18 deletions(-) diff --git a/app/controllers/miq_action_controller.rb b/app/controllers/miq_action_controller.rb index 91511cad1a1..3f25550ece9 100644 --- a/app/controllers/miq_action_controller.rb +++ b/app/controllers/miq_action_controller.rb @@ -384,7 +384,7 @@ def validate_playbook_options(options) end def get_session_data - @action = MiqAction.find_by(:id => params[:miq_grid_checks]) + @action = MiqAction.find_by(:id => params[:id] || params[:miq_grid_checks]) @title = if @action.present? _("Editing Action \"%{name}\"") % {:name => @action.description} else diff --git a/app/helpers/miq_action_helper.rb b/app/helpers/miq_action_helper.rb index 8f4e60a7fd1..15220b8573a 100644 --- a/app/helpers/miq_action_helper.rb +++ b/app/helpers/miq_action_helper.rb @@ -1,4 +1,15 @@ module MiqActionHelper + def control_action_summary(record, alert_guids, cats, action_policies) + safe_join([ + miq_summary_action_info(record), + miq_summary_action_type(record, alert_guids, cats), + miq_summary_attribute_value_pair(record), + miq_summary_action_policies(action_policies) + ]) + end + + private + def miq_summary_action_info(record) data = {:title => _("Basic Information"), :mode => "miq_action_info"} rows = [] @@ -25,17 +36,6 @@ def miq_summary_action_type(record, alert_guids, cats) rows.push({:cells => {:label => _('Starting Message'), :value => record_options[:ae_message]}}) rows.push({:cells => {:label => _('Request'), :value => record_options[:ae_request]}}) - value_pair = [] - if record_options[:ae_hash].present? - record_options[:ae_hash].each do |k, v| - value_pair.push({:label => k}) - value_pair.push({:label => v}) - end - else - value_pair.push({:label => _('No Attribute/Value Pairs found')}) - end - rows.push({:cells => {:label => _('Attribute/Value Pairs'), :value => value_pair}}) - when "email" data[:title] = _('E-mail Settings') rows.push({:cells => {:label => _('From E-mail Address'), :value => record_options[:from]}}) @@ -129,6 +129,21 @@ def miq_summary_action_type(record, alert_guids, cats) end end + def miq_summary_attribute_value_pair(record) + record_options = record.options + rows = [] + if record_options[:ae_hash].present? + record_options[:ae_hash].each do |k, v| + rows.push({:cells => [{:value => k}, {:value => v}]}) + end + end + miq_structured_list( + :title => _('Attribute/Value Pairs'), + :mode => "control_action_attribute_value_pairs", + :rows => rows + ) + end + def miq_summary_action_policies(action_policies) rows = [] data = {:title => _("Assigned to Policies"), :mode => "miq_action"} diff --git a/app/javascript/components/action-form/action-form.schema.js b/app/javascript/components/action-form/action-form.schema.js index 4fe151bcd72..969ce794a2b 100644 --- a/app/javascript/components/action-form/action-form.schema.js +++ b/app/javascript/components/action-form/action-form.schema.js @@ -171,6 +171,7 @@ function createSchema(recordId, promise, inheritTags, evaluateAlert, tags, ansib id: 'subform-7', name: 'subform-7', title: __('Attribute/Value Pairs'), + className: 'attribute_value_pair_wrapper', condition: { when: 'action_type', is: 'custom_automation', @@ -190,6 +191,7 @@ function createSchema(recordId, promise, inheritTags, evaluateAlert, tags, ansib fields: [ { component: componentTypes.TEXT_FIELD, + className: 'attribute_value_field_wrapper', name: 'attribute', id: 'attribute', label: 'attribute', @@ -198,6 +200,7 @@ function createSchema(recordId, promise, inheritTags, evaluateAlert, tags, ansib }, { component: componentTypes.TEXT_FIELD, + className: 'attribute_value_field_wrapper', name: 'value', id: 'value', label: 'value', diff --git a/app/javascript/components/miq-structured-list/miq-structured-list-body/value-types/miq-structured-list-object.jsx b/app/javascript/components/miq-structured-list/miq-structured-list-body/value-types/miq-structured-list-object.jsx index 131d1aa1d22..bce904b3189 100644 --- a/app/javascript/components/miq-structured-list/miq-structured-list-body/value-types/miq-structured-list-object.jsx +++ b/app/javascript/components/miq-structured-list/miq-structured-list-body/value-types/miq-structured-list-object.jsx @@ -4,7 +4,7 @@ import classNames from 'classnames'; import { StructuredListCell } from 'carbon-components-react'; import MiqStructuredListConditionalTag from '../value-tags/miq-structured-list-conditional-tag'; -/** Usage eg: Automation / Embeded Automate / Generic Objects / item +/** Usage eg: Automation / Embedded Automate / Generic Objects / item * Properties has no links & Relationships have links */ const MiqStructuredListObject = ({ row, clickEvents, onClick }) => { const isContent = row.label || (row.value && row.value.input); diff --git a/app/javascript/spec/action-form/__snapshots__/action-form.spec.js.snap b/app/javascript/spec/action-form/__snapshots__/action-form.spec.js.snap index 02ea491c270..abed0d2b855 100644 --- a/app/javascript/spec/action-form/__snapshots__/action-form.spec.js.snap +++ b/app/javascript/spec/action-form/__snapshots__/action-form.spec.js.snap @@ -387,6 +387,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -404,6 +405,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -416,6 +418,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -1089,6 +1092,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -1106,6 +1110,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -1118,6 +1123,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -1784,6 +1790,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -1801,6 +1808,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -1813,6 +1821,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -2479,6 +2488,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -2496,6 +2506,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -2508,6 +2519,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -3138,6 +3150,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -3155,6 +3168,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -3167,6 +3181,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -3808,6 +3823,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -3825,6 +3841,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -3837,6 +3854,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -4473,6 +4491,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -4490,6 +4509,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -4502,6 +4522,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -5158,6 +5179,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -5175,6 +5197,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -5187,6 +5210,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -5823,6 +5847,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -5840,6 +5865,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -5852,6 +5878,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -6499,6 +6526,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -6516,6 +6544,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -6528,6 +6557,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -7152,6 +7182,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -7169,6 +7200,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -7181,6 +7213,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -7809,6 +7842,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "title": "Custom Automation", }, Object { + "className": "attribute_value_pair_wrapper", "component": "sub-form", "condition": Object { "is": "custom_automation", @@ -7826,6 +7860,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` "fieldKey": "field_array", "fields": Array [ Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "attribute", "isRequired": true, @@ -7838,6 +7873,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` ], }, Object { + "className": "attribute_value_field_wrapper", "component": "text-field", "id": "value", "isRequired": true, @@ -10283,6 +10319,7 @@ exports[`Action Form Component should render adding a new action 1`] = ` div { + display: flex; + flex-direction: row; + gap: 20px; + align-items: center; + + .attribute_value_field_wrapper { + flex-grow: 1; + } + } +} diff --git a/app/stylesheet/miq-structured-list.scss b/app/stylesheet/miq-structured-list.scss index 2a142017ca9..da3aca74943 100644 --- a/app/stylesheet/miq-structured-list.scss +++ b/app/stylesheet/miq-structured-list.scss @@ -65,6 +65,9 @@ } .content_value { + &.array_item:first-child { + width: 250px; + } .content { display: flex; flex-direction: row; diff --git a/app/views/miq_action/show.html.haml b/app/views/miq_action/show.html.haml index 8be12381845..4ec9ab3c427 100644 --- a/app/views/miq_action/show.html.haml +++ b/app/views/miq_action/show.html.haml @@ -1,9 +1,5 @@ #action-details-div = render :partial => "layouts/flash_msg" - - = miq_summary_action_info(@record) - = miq_summary_action_type(@record, @alert_guids, @cats) - - = miq_summary_action_policies(@action_policies) + = control_action_summary(@record, @alert_guids, @cats, @action_policies)