Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify and remove #show functionality from middeware controllers. #590

Merged
merged 1 commit into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions app/controllers/middleware_domain_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions app/controllers/middleware_server_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions app/controllers/middleware_server_group_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 0 additions & 49 deletions app/controllers/mixins/middleware_common_mixin.rb
Original file line number Diff line number Diff line change
@@ -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