Skip to content

Commit

Permalink
Move the textual_zone method into a separate mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jan 8, 2019
1 parent dcbf7d1 commit b02fad8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 54 deletions.
10 changes: 1 addition & 9 deletions app/helpers/ems_cloud_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsCloudHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -145,15 +146,6 @@ def textual_security_groups
h
end

def textual_zone
zone = if @record.zone == Zone.maintenance_zone
_("%{m_zone} (originally in %{o_zone})") % {:m_zone => @record.zone.name, :o_zone => @record.zone_before_pause.name}
else
@record.zone.name
end
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => zone}
end

def textual_topology
{:label => _('Topology'),
:icon => "pficon pficon-topology",
Expand Down
10 changes: 1 addition & 9 deletions app/helpers/ems_container_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module EmsContainerHelper::TextualSummary
include TextualMixins::TextualMetricsStatus
include TextualMixins::TextualDataCollectionState
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -70,15 +71,6 @@ def textual_port
@record.supports_port? ? @record.port : nil
end

def textual_zone
zone = if @record.zone == Zone.maintenance_zone
_("%{m_zone} (originally in %{o_zone})") % {:m_zone => @record.zone.name, :o_zone => @record.zone_before_pause.name}
else
@record.zone.name
end
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => zone}
end

def textual_topology
{:label => _('Topology'),
:icon => "pficon pficon-topology",
Expand Down
10 changes: 1 addition & 9 deletions app/helpers/ems_infra_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module EmsInfraHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -169,15 +170,6 @@ def textual_orchestration_stacks
@record.orchestration_stacks
end

def textual_zone
zone = if @record.zone == Zone.maintenance_zone
_("%{m_zone} (originally in %{o_zone})") % {:m_zone => @record.zone.name, :o_zone => @record.zone_before_pause.name}
else
@record.zone.name
end
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => zone}
end

def textual_host_default_vnc_port_range
return nil if @record.host_default_vnc_port_start.blank?
value = "#{@record.host_default_vnc_port_start} - #{@record.host_default_vnc_port_end}"
Expand Down
10 changes: 1 addition & 9 deletions app/helpers/ems_network_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsNetworkHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -102,15 +103,6 @@ def textual_topology
:title => _("Show topology")}
end

def textual_zone
zone = if @record.zone == Zone.maintenance_zone
_("%{m_zone} (originally in %{o_zone})") % {:m_zone => @record.zone.name, :o_zone => @record.zone_before_pause.name}
else
@record.zone.name
end
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => zone}
end

def textual_cloud_tenants
textual_link(
@record.try(:cloud_tenants),
Expand Down
10 changes: 1 addition & 9 deletions app/helpers/ems_physical_infra_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsPhysicalInfraHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -105,15 +106,6 @@ def textual_vms
textual_link(@record.vms, :label => _("Virtual Machines"))
end

def textual_zone
zone = if @record.zone == Zone.maintenance_zone
_("%{m_zone} (originally in %{o_zone})") % {:m_zone => @record.zone.name, :o_zone => @record.zone_before_pause.name}
else
@record.zone.name
end
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => zone}
end

def textual_topology
{:label => _('Topology'),
:icon => "pficon pficon-topology",
Expand Down
10 changes: 1 addition & 9 deletions app/helpers/ems_storage_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module EmsStorageHelper::TextualSummary
include TextualMixins::TextualRefreshStatus
include TextualMixins::TextualCustomButtonEvents
include TextualMixins::TextualZone
#
# Groups
#
Expand Down Expand Up @@ -61,15 +62,6 @@ def textual_parent_ems_cloud
textual_link(@record.try(:parent_manager), :label => _("Parent Cloud Provider"))
end

def textual_zone
zone = if @record.zone == Zone.maintenance_zone
_("%{m_zone} (originally in %{o_zone})") % {:m_zone => @record.zone.name, :o_zone => @record.zone_before_pause.name}
else
@record.zone.name
end
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => zone}
end

def textual_cloud_volumes
textual_link(@record.try(:cloud_volumes), :label => _('Cloud Volumes'))
end
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/textual_mixins/textual_zone.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module TextualMixins::TextualZone
def textual_zone
zone = if @record.zone == Zone.maintenance_zone
_("%{m_zone} (originally in %{o_zone})") % {:m_zone => @record.zone.name, :o_zone => @record.zone_before_pause.name}
else
@record.zone.name
end
{:label => _("Managed by Zone"), :icon => "pficon pficon-zone", :value => zone}
end
end

0 comments on commit b02fad8

Please sign in to comment.