From dcceac49a327d4eb35e2e3182af4941c32fa232b Mon Sep 17 00:00:00 2001 From: Martin Povolny Date: Wed, 1 Mar 2017 09:25:53 +0100 Subject: [PATCH] Unify and remove #show functionality from middeware controllers. --- app/controllers/ems_common.rb | 6 +-- .../middleware_domain_controller.rb | 9 +--- .../middleware_server_controller.rb | 11 +---- .../middleware_server_group_controller.rb | 9 +--- .../mixins/middleware_common_mixin.rb | 49 ------------------- 5 files changed, 9 insertions(+), 75 deletions(-) diff --git a/app/controllers/ems_common.rb b/app/controllers/ems_common.rb index aa34e00ad0d..ca7ea6ead2c 100644 --- a/app/controllers/ems_common.rb +++ b/app/controllers/ems_common.rb @@ -5,14 +5,14 @@ module EmsCommon include Mixins::GenericSessionMixin include Mixins::MoreShowActions - helper_method :textual_group_list - private :textual_group_list - # This is a temporary hack ensuring that @ems will be set. # Once we use @record in place of @ems, this can be removed # together with init_show_ems alias_method :init_show_generic, :init_show alias_method :init_show, :init_show_ems + + helper_method :textual_group_list + private :textual_group_list end def init_show_ems diff --git a/app/controllers/middleware_domain_controller.rb b/app/controllers/middleware_domain_controller.rb index 659dee134ae..989f46ffbe1 100644 --- a/app/controllers/middleware_domain_controller.rb +++ b/app/controllers/middleware_domain_controller.rb @@ -9,13 +9,8 @@ class MiddlewareDomainController < ApplicationController after_action :cleanup_action after_action :set_session_data - def show - return unless init_show - @display = params[:display] unless params[:display].nil? - case @display - when 'middleware_server_groups' then show_middleware_entities(MiddlewareServerGroup) - else show_middleware - end + def self.display_methods + %i(middleware_server_groups) end menu_section :cnt diff --git a/app/controllers/middleware_server_controller.rb b/app/controllers/middleware_server_controller.rb index 86f6eeb7334..d8ae7f7c795 100644 --- a/app/controllers/middleware_server_controller.rb +++ b/app/controllers/middleware_server_controller.rb @@ -154,15 +154,8 @@ def add_datasource end end - def show - return unless init_show - @display = params[:display] unless params[:display].nil? - case @display - when 'middleware_datasources' then show_middleware_entities(MiddlewareDatasource) - when 'middleware_deployments' then show_middleware_entities(MiddlewareDeployment) - when 'middleware_messagings' then show_middleware_entities(MiddlewareMessaging) - else show_middleware - end + def self.display_methods + %i(middleware_datasources middleware_deployments middleware_messagings) end def button diff --git a/app/controllers/middleware_server_group_controller.rb b/app/controllers/middleware_server_group_controller.rb index c6f9b3d1a6a..36feb6f460a 100644 --- a/app/controllers/middleware_server_group_controller.rb +++ b/app/controllers/middleware_server_group_controller.rb @@ -34,13 +34,8 @@ def self.operations OPERATIONS end - def show - return unless init_show - @display = params[:display] unless params[:display].nil? - case @display - when 'middleware_servers' then show_middleware_entities(MiddlewareServer) - else show_middleware - end + def self.display_methods + %i(middleware_servers) end def textual_group_list diff --git a/app/controllers/mixins/middleware_common_mixin.rb b/app/controllers/mixins/middleware_common_mixin.rb index 6f203d68b0a..40c0f2ff0e8 100644 --- a/app/controllers/mixins/middleware_common_mixin.rb +++ b/app/controllers/mixins/middleware_common_mixin.rb @@ -1,53 +1,4 @@ module MiddlewareCommonMixin extend ActiveSupport::Concern include Mixins::MiddlewareOperationsMixin - - def show - return unless init_show - @ems = @record - clear_topology_breadcrumb - - show_middleware - end - - private - - def display_name(display = nil) - if display.blank? - ui_lookup(:tables => @record.class.base_class.name) - else - ui_lookup(:tables => display) - end - end - - def listicon_image(item, _view) - item.decorate.try(:listicon_image) - end - - def clear_topology_breadcrumb - # fix breadcrumbs - remove displaying 'topology' in breadcrumb when navigating to a middleware related entity summary page - if @breadcrumbs.present? && (@breadcrumbs.last[:name].eql? 'Topology') - @breadcrumbs.clear - end - end - - def show_middleware - drop_breadcrumb({:name => display_name, - :url => show_list_link(@record, :page => @current_page, :refresh => 'y') - }, true) - case @display - when 'main' then show_main - when 'summary_only' then show_download - when 'timeline' then show_timeline - when 'performance' then show_performance - end - end - - def show_middleware_entities(klass) - @showtype = @display = params[:display] unless params[:display].nil? - breadcrumb_title = _("%{name} (All %{title})") % {:name => @record.name, - :title => display_name(@display)} - drop_breadcrumb(:name => breadcrumb_title, :url => show_link(@record, :display => @display)) - @view, @pages = get_view(klass, :parent => @record) - end end