Skip to content

Commit

Permalink
Merge pull request #7570 from h-kataria/conditions_de-explorization
Browse files Browse the repository at this point in the history
Conditions de explorization
  • Loading branch information
gtanzillo authored Feb 5, 2021
2 parents 77a8c80 + c301899 commit a4d5676
Show file tree
Hide file tree
Showing 30 changed files with 395 additions and 656 deletions.
441 changes: 107 additions & 334 deletions app/controllers/condition_controller.rb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app/controllers/mixins/policy_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def send_button_changes
page.replace("alert_snmp_div", :partial => "alert_snmp")
elsif @alert_mgmt_event_refresh
page.replace("alert_mgmt_event_div", :partial => "alert_mgmt_event")
elsif params[:towhat]
page.replace("form_div", :partial => "form")
end
elsif @assign
if params.key?(:chosen_assign_to) || params.key?(:chosen_cat)
Expand Down
1 change: 0 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,6 @@ def pdf_page_size_style
cloud_volume_backup
cloud_volume_snapshot
cloud_volume_type
condition
configuration_job
configuration_profile
configuration_script_source
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper/button/condition.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationHelper::Button::Condition < ApplicationHelper::Button::ReadOnly
def role_allows_feature?
@view_context.x_active_tree == :condition_tree && role_allows?(:feature => self[:child_id])
role_allows?(:feature => self[:child_id])
end
end
2 changes: 1 addition & 1 deletion app/helpers/application_helper/button/condition_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class ApplicationHelper::Button::ConditionPolicy < ApplicationHelper::Button::Re
needs :@sb

def role_allows_feature?
@view_context.x_active_tree != :condition_tree && role_allows?(:feature => self[:child_id])
role_allows?(:feature => self[:child_id])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class ApplicationHelper::Button::ConditionPolicyCopy < ApplicationHelper::Button
needs :@sb

def role_allows_feature?
@view_context.x_active_tree != :condition_tree && role_allows?(:feature => self[:child_id])
role_allows?(:feature => self[:child_id])
end
end
1 change: 1 addition & 0 deletions app/helpers/application_helper/page_layouts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def layout_uses_listnav?
chargeback_assignment
chargeback_rate
chargeback_report
condition
configuration
container_dashboard
container_topology
Expand Down
37 changes: 6 additions & 31 deletions app/helpers/application_helper/toolbar/condition_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,15 @@ class ApplicationHelper::Toolbar::ConditionCenter < ApplicationHelper::Toolbar::
'pficon pficon-edit fa-lg',
t = N_('Edit this Condition'),
t,
:url_parms => "?type=basic",
:klass => ApplicationHelper::Button::ReadOnly),
:url => "/edit",
:klass => ApplicationHelper::Button::ReadOnly),
button(
:condition_copy,
'fa fa-files-o fa-lg',
t = N_('Copy this Condition to a new Condition'),
t,
:url_parms => "?copy=true",
:klass => ApplicationHelper::Button::Condition),
button(
:condition_policy_copy,
'fa fa-files-o fa-lg',
t = proc do
_('Copy this Condition to a new Condition assigned to Policy [%{condition_policy_description}]') %
{:condition_policy_description => @condition_policy.try(:description)}
end,
t,
:url_parms => "?copy=true",
:klass => ApplicationHelper::Button::ConditionPolicyCopy),
:url => "/copy",
:klass => ApplicationHelper::Button::Condition),
button(
:condition_delete,
'pficon pficon-delete fa-lg',
Expand All @@ -40,25 +30,10 @@ class ApplicationHelper::Toolbar::ConditionCenter < ApplicationHelper::Toolbar::
:klass => ApplicationHelper::Button::ConditionDelete,
:data => {'function' => 'sendDataWithRx',
'function-data' => {:api_url => 'conditions',
:redirect_url => '/condition/show_list',
:component_name => 'RemoveGenericItemModal',
:controller => 'provider_dialogs',
:display_field => 'description',
:ajax_reload => true}}),
button(
:condition_remove,
'pficon pficon-delete fa-lg',
t = proc do
_('Remove this Condition from Policy [%{condition_policy_description}]') %
{:condition_policy_description => @condition_policy.try(:description)}
end,
t,
:url_parms => "?policy_id=\#{@condition_policy.try(:id)}",
:klass => ApplicationHelper::Button::ConditionPolicy,
:confirm => proc do
_("Are you sure you want to remove this Condition from Policy [%{condition_policy_description}]?") %
{:condition_policy_description => @condition_policy.try(:description)}
end
),
:display_field => 'description'}}),
]),
])
end
36 changes: 27 additions & 9 deletions app/helpers/application_helper/toolbar/conditions_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,35 @@ class ApplicationHelper::Toolbar::ConditionsCenter < ApplicationHelper::Toolbar:
button(
:condition_new,
'pficon pficon-add-circle-o fa-lg',
t = proc do
if @sb[:folder].upcase == "VM"
_('Add a New VM Condition')
else
_('Add a New %{condition_type} Condition') % {
:condition_type => ui_lookup(:model => @sb[:folder].camelize)
}
end
end,
t = _('Add a New Condition'),
t,
:url => "/new",
:klass => ApplicationHelper::Button::ButtonNewDiscover),
button(
:condition_edit,
'pficon pficon-edit fa-lg',
t = N_('Edit the selected Condition'),
t,
:url => "/edit",
:url_parms => "main_div",
:send_checked => true,
:enabled => false,
:onwhen => "1"),
button(
:condition_delete,
'pficon pficon-delete fa-lg',
N_('Delete selected Conditions'),
N_('Delete Conditions'),
:enabled => false,
:onwhen => "1+",
:data => {'function' => 'sendDataWithRx',
'function-data' => {:api_url => 'conditions',
:redirect_url => '/condition/show_list',
:component_name => 'RemoveGenericItemModal',
:controller => 'provider_dialogs',
:display_field => 'description',
:modal_text => N_("Are you sure you want to delete selected Conditions?"),
:modal_title => N_("Delete Conditions")}})
]
),
])
Expand Down
9 changes: 6 additions & 3 deletions app/helpers/application_helper/toolbar_chooser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def view_toolbar_filename
'dashboard_summary_toggle_view_tb'
elsif %w[container_project].include?(@layout)
'container_project_view_tb'
elsif !%w[all_tasks timeline diagnostics miq_policy my_tasks miq_server usage].include?(@layout) &&
elsif !%w[all_tasks condition timeline diagnostics miq_policy my_tasks miq_server usage].include?(@layout) &&
!@layout.starts_with?("miq_request") && @display == "main" &&
@showtype == "main" && !@in_a_form
'summary_view_tb'
Expand Down Expand Up @@ -102,7 +102,7 @@ def center_toolbar_filename_explorer
center_toolbar_filename_chargeback_report
elsif @layout == "miq_ae_tools"
super_admin_user? ? "miq_ae_tools_simulate_center_tb" : nil
elsif %w[condition miq_action miq_alert miq_alert_set miq_event].include?(@layout)
elsif %w[miq_action miq_alert miq_alert_set miq_event].include?(@layout)
center_toolbar_filename_miq_policy
elsif @layout == "ops"
center_toolbar_filename_ops
Expand Down Expand Up @@ -218,7 +218,9 @@ def center_toolbar_filename_chargeback_report

def center_toolbar_filename_miq_policy
if @nodetype == "xx"
if @conditions
if @policies || (@view && @sb[:tree_typ] == "policies")
return "miq_policies_center_tb"
elsif @conditions
return "conditions_center_tb"
elsif @alert_profiles
return "miq_alert_sets_center_tb"
Expand All @@ -230,6 +232,7 @@ def center_toolbar_filename_miq_policy
when :action_tree then "miq_actions_center_tb"
when :alert_tree then "miq_alerts_center_tb"
end
when "p" then "miq_policy_center_tb"
when "co" then "condition_center_tb"
when "ev" then "miq_event_center_tb"
when "a" then "miq_action_center_tb"
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/menu/default_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def control_menu_section
Menu::Item.new('miq_policy_set', N_('Policy Profiles'), 'miq_policy_set', {:feature => 'miq_policy_set_show_list'}, '/miq_policy_set/show_list'),
Menu::Item.new('miq_policy', N_('Policies'), 'miq_policy', {:feature => 'miq_policy_show_list'}, '/miq_policy/show_list'),
Menu::Item.new('miq_event', N_('Events'), 'miq_event', {:feature => 'miq_event', :any => true}, '/miq_event/explorer'),
Menu::Item.new('condition', N_('Conditions'), 'condition', {:feature => 'condition', :any => true}, '/condition/explorer'),
Menu::Item.new('condition', N_('Conditions'), 'condition', {:feature => 'condition_show_list'}, '/condition/show_list'),
Menu::Item.new('miq_action', N_('Actions'), 'miq_action', {:feature => 'miq_action', :any => true}, '/miq_action/explorer'),
Menu::Item.new('miq_alert_set', N_('Alert Profiles'), 'miq_alert_set', {:feature => 'miq_alert_set', :any => true}, '/miq_alert_set/explorer'),
Menu::Item.new('miq_alert', N_('Alerts'), 'miq_alert', {:feature => 'miq_alert', :any => true}, '/miq_alert/explorer'),
Expand Down
2 changes: 0 additions & 2 deletions app/presenters/tree_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ def prefixed_title(prefix, title)
:policy => "TreeBuilderPolicy",
### Events
:event => "TreeBuilderEvent",
### Conditions
:condition => "TreeBuilderCondition",
### Actions
:action => "TreeBuilderAction",
### Alert Profiles
Expand Down
55 changes: 0 additions & 55 deletions app/presenters/tree_builder_condition.rb
Original file line number Diff line number Diff line change
@@ -1,55 +0,0 @@
class TreeBuilderCondition < TreeBuilder
private

def tree_init_options
{:full_ids => true}
end

# level 0 - root
def root_options
{
:text => t = _("All Conditions"),
:tooltip => t
}
end

# not using decorators for now because there are some inconsistencies
def self.folder_icon(klassname)
klassname.safe_constantize.try(:decorate).try(:fonticon)
end

# level 1 - host / vm
def x_get_tree_roots
text_i18n = {:Host => _("Host Conditions"),
:Vm => _("VM and Instance Conditions"),
:ContainerReplicator => _("Replicator Conditions"),
:ContainerGroup => _("Pod Conditions"),
:ContainerNode => _("Container Node Conditions"),
:ContainerImage => _("Container Image Conditions"),
:ContainerProject => _("Container Project Conditions"),
:ExtManagementSystem => _("Provider Conditions"),
:PhysicalServer => _("Physical Infrastructure Conditions")}

objects = ConditionController::UI_FOLDERS.collect do |model|
text = text_i18n[model.name.to_sym]
icon = self.class.folder_icon(model.to_s)

{
:id => model.name.camelize(:lower),
:icon => icon,
:text => text,
:tip => text
}
end
count_only_or_objects(false, objects)
end

# level 2 - conditions
def x_get_tree_custom_kids(parent, count_only)
towhat = parent[:id].camelize
return super unless ConditionController::UI_FOLDERS.collect(&:name).include?(towhat)

objects = Condition.where(:towhat => towhat)
count_only_or_objects(count_only, objects, :description)
end
end
5 changes: 0 additions & 5 deletions app/presenters/tree_node/condition.rb

This file was deleted.

111 changes: 0 additions & 111 deletions app/views/condition/_condition_details.html.haml

This file was deleted.

12 changes: 0 additions & 12 deletions app/views/condition/_condition_folders.html.haml

This file was deleted.

Loading

0 comments on commit a4d5676

Please sign in to comment.