Skip to content

Commit

Permalink
Merge pull request #9014 from amalvijayan03/ot-summary-conversion
Browse files Browse the repository at this point in the history
Orchestration template summary conversion from HAML to React
  • Loading branch information
jeffibm authored Jan 11, 2024
2 parents 5a2fc8f + 72c9199 commit 745d91d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 47 deletions.
1 change: 1 addition & 0 deletions app/helpers/catalog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module CatalogHelper
include_concern 'TextualSummary'
include RequestInfoHelper
include Mixins::AutomationMixin
include OrchestrationTemplateHelper

def miq_catalog_resource(resources)
headers = ["", _("Name"), _("Description"), _("Action Order"), _("Provision Order"), _("Action Start"), _("Action Stop"), _("Delay (mins) Start"), _("Delay (mins) Stop")]
Expand Down
52 changes: 52 additions & 0 deletions app/helpers/catalog_helper/orchestration_template_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module CatalogHelper::OrchestrationTemplateHelper
private

def orchestration_template_summary(record)
summary = [
orchestration_template_basic_info(record),
orchestration_template_tags(record),
orchestration_template_content(record),
]
safe_join(summary)
end

def orchestration_template_basic_info(record)
rows = [
row_data(_('Name'), record.name),
row_data(_('Description'), record.description),
row_data(_('Draft'), record.draft ? _("True") : _("False")),
row_data(_('Read Only'), record.in_use? ? _("True") : _("False")),
row_data(_('Created On'), record.created_at),
row_data(_('Updated On'), record.updated_at),
]
miq_structured_list({
:title => _('Basic Information'),
:mode => "orchestration_template_summary",
:rows => rows
})
end

def orchestration_template_tags(record)
smart_mgnt = textual_tags_render_data(record)
data = {:title => smart_mgnt[:title], :mode => "orchestration_template_tags"}
rows = []
smart_mgnt[:items].each do |item|
row = row_data(item[:label], item[:value])
row[:cells][:icon] = item[:icon] if item[:icon]
rows.push(row)
end
data[:rows] = rows
miq_structured_list(data)
end

def orchestration_template_content(record)
rows = [
row_data('', {:input => 'code_mirror', :props => {:mode => 'yaml', :payload => record.content}})
]
miq_structured_list({
:title => _('Content'),
:mode => "method_built_in_data",
:rows => rows
})
end
end
48 changes: 1 addition & 47 deletions app/views/catalog/_ot_tree_show.html.haml
Original file line number Diff line number Diff line change
@@ -1,48 +1,2 @@
= render :partial => "layouts/flash_msg"
.form-horizontal
.form-group
%label.col-md-2.control-label
= _('Name')
.col-md-8
= @record.name
.form-group
%label.col-md-2.control-label
= _('Description')
.col-md-8
= @record.description
.form-group
%label.col-md-2.control-label
= _('Draft')
.col-md-8
= @record.draft ? _("True") : _("False")
.form-group
%label.col-md-2.control-label
= _('Read Only')
.col-md-8
= @record.in_use? ? _("True") : _("False")
.form-group
%label.col-md-2.control-label
= _('Created On')
.col-md-8
= @record.created_at
.form-group
%label.col-md-2.control-label
= _('Updated On')
.col-md-8
= @record.updated_at
.form-group
.col-md-10
#tag_group
:javascript
ManageIQ.component.componentFactory('TagGroup', '#tag_group', #{textual_tags_render_data(@record).to_json});

%hr
#form_div
= text_area_tag("template_content", @record.content, :style => "display:none;")
= render :partial => "/layouts/my_code_mirror",
:locals => {:text_area_id => "template_content",
:mode => "yaml",
:line_numbers => true,
:read_only => true}
:javascript
ManageIQ.editor.refresh();
= orchestration_template_summary(@record)

0 comments on commit 745d91d

Please sign in to comment.