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

Add class decorator support #237

Merged
merged 11 commits into from
Feb 24, 2017
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def listicon_item(view, id = nil)
# Return the icon classname for the list view icon of a db,id pair
# this always supersedes listicon_image if not nil
def listicon_icon(item)
item.decorate.try(:fonticon) if item.decorator_class?
item.decorate.try(:fonticon)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my other comments addressed, this now becomes a non-patched call, entirely dependent on the UI's own code, with MiqDecorator.decorate(item). You of course can feel free to create a top level controller helper like decorate_model that does the same thing without MiqDecorator explicitly.

end

# Return the image name for the list view icon of a db,id pair
Expand All @@ -977,7 +977,7 @@ def listicon_image(item, view)
when ManageIQ::Providers::CloudManager::AuthKeyPair
"100/auth_key_pair.png"
else
item.decorate.try(:listicon_image) if item.decorator_class?
item.decorate.try(:listicon_image)
end

image || default
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/auth_private_key_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class AuthPrivateKeyDecorator < Draper::Decorator
delegate_all

class AuthPrivateKeyDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/configuration_profile_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ConfigurationProfileDecorator < Draper::Decorator
delegate_all

class ConfigurationProfileDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/configuration_script_source_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ConfigurationScriptSourceDecorator < Draper::Decorator
delegate_all

class ConfigurationScriptSourceDecorator < MiqDecorator
def fonticon
"pficon pficon-repository"
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/configured_system_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ConfiguredSystemDecorator < Draper::Decorator
delegate_all

class ConfiguredSystemDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/ext_management_system_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ExtManagementSystemDecorator < Draper::Decorator
delegate_all

class ExtManagementSystemDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
5 changes: 1 addition & 4 deletions app/decorators/filesystem_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class FilesystemDecorator < Draper::Decorator
delegate_all

class FilesystemDecorator < MiqDecorator
def fonticon
convert = {
"dll" => "fa fa-cogs",
Expand All @@ -15,5 +13,4 @@ def fonticon
}
convert[name.downcase] || "fa fa-file-o"
end

end
4 changes: 1 addition & 3 deletions app/decorators/host_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class HostDecorator < Draper::Decorator
delegate_all

class HostDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScriptDecorator < Draper::Decorator
delegate_all
module ManageIQ::Providers::AnsibleTower
class AutomationManager::ConfigurationScriptDecorator < MiqDecorator
def fonticon
'product product-template'
end

def fonticon
'product product-template'.freeze
end

def listicon_image
'100/configuration_script.png'
def listicon_image
'100/configuration_script.png'
end
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class ManageIQ::Providers::AnsibleTower::AutomationManager::JobDecorator < Draper::Decorator
delegate_all
module ManageIQ::Providers::AnsibleTower
class AutomationManager::JobDecorator < MiqDecorator
def fonticon
'product product-orchestration_stack'
end

def fonticon
'product product-orchestration_stack'.freeze
end

def listicon_image
'100/orchestration_stack.png'
def listicon_image
'100/orchestration_stack.png'
end
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class ManageIQ::Providers::AnsibleTower::AutomationManager::PlaybookDecorator < Draper::Decorator
delegate_all
module ManageIQ::Providers::AnsibleTower
class AutomationManager::PlaybookDecorator < MiqDecorator
def fonticon
nil
end

def fonticon
nil
end

def listicon_image
'svg/vendor-ansible_tower_automation.svg'
def listicon_image
'svg/vendor-ansible_tower_automation.svg'
end
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class ManageIQ::Providers::AutomationManager::InventoryGroupDecorator < Draper::Decorator
delegate_all
module ManageIQ::Providers::AutomationManager
class InventoryGroupDecorator < MiqDecorator
def fonticon
'pficon pficon-folder-close'
end

def fonticon
'pficon pficon-folder-close'.freeze
end

def listicon_image
'100/inventory_group.png'
def listicon_image
'100/inventory_group.png'
end
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class ManageIQ::Providers::AutomationManager::InventoryRootGroupDecorator < Draper::Decorator
delegate_all
module ManageIQ::Providers::AutomationManager
class InventoryRootGroupDecorator < MiqDecorator
def fonticon
'pficon pficon-folder-close'
end

def fonticon
'pficon pficon-folder-close'.freeze
end

def listicon_image
'100/inventory_group.png'
def listicon_image
'100/inventory_group.png'
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module ManageIQ::Providers
class AutomationManagerDecorator < Draper::Decorator
delegate_all

class AutomationManagerDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
class ManageIQ::Providers::CloudManager::OrchestrationStackDecorator < Draper::Decorator
def fonticon
'product product-orchestration_stack'.freeze
end
module ManageIQ::Providers
class CloudManager::OrchestrationStackDecorator < MiqDecorator
def fonticon
'product product-orchestration_stack'
end

def listicon_image
"100/orchestration_stack.png"
def listicon_image
"100/orchestration_stack.png"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module ManageIQ::Providers
class ConfigurationManagerDecorator < Draper::Decorator
delegate_all

class ConfigurationManagerDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ManageIQ::Providers::Hawkular
class MiddlewareManagerDecorator < Draper::Decorator
class MiddlewareManagerDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ManageIQ::Providers::Kubernetes::ContainerManagerDecorator < Draper::Decorator
delegate_all

def listicon_image
"svg/vendor-kubernetes.svg"
module ManageIQ::Providers::Kubernetes
class ContainerManagerDecorator < MiqDecorator
def listicon_image
"svg/vendor-kubernetes.svg"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ManageIQ::Providers::Openshift::ContainerManagerDecorator < Draper::Decorator
delegate_all

def listicon_image
"svg/vendor-openshift.svg"
module ManageIQ::Providers::Openshift
class ContainerManagerDecorator < MiqDecorator
def listicon_image
"svg/vendor-openshift.svg"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ManageIQ::Providers::OpenshiftEnterprise::ContainerManagerDecorator < Draper::Decorator
delegate_all

def listicon_image
"svg/vendor-openshift_enterprise.svg"
module ManageIQ::Providers::OpenshiftEnterprise
class ContainerManagerDecorator < MiqDecorator
def listicon_image
"svg/vendor-openshift_enterprise.svg"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ManageIQ::Providers::StorageManager::CinderManagerDecorator < Draper::Decorator
delegate_all

def listicon_image
"svg/vendor-openstack.svg"
module ManageIQ::Providers
class StorageManager::CinderManagerDecorator < MiqDecorator
def listicon_image
"svg/vendor-openstack.svg"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ManageIQ::Providers::StorageManager::SwiftManagerDecorator < Draper::Decorator
delegate_all

def listicon_image
"svg/vendor-openstack.svg"
module ManageIQ::Providers
class StorageManager::SwiftManagerDecorator < MiqDecorator
def listicon_image
"svg/vendor-openstack.svg"
end
end
end
6 changes: 2 additions & 4 deletions app/decorators/middleware_datasource_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class MiddlewareDatasourceDecorator < Draper::Decorator
delegate_all

class MiddlewareDatasourceDecorator < MiqDecorator
def fonticon
'fa fa-database'.freeze
'fa fa-database'
end

def listicon_image
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/middleware_deployment_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiddlewareDeploymentDecorator < Draper::Decorator
delegate_all

class MiddlewareDeploymentDecorator < MiqDecorator
def fonticon
if name.end_with? '.ear'
'product product-file-ear-o'
Expand Down
6 changes: 2 additions & 4 deletions app/decorators/middleware_domain_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class MiddlewareDomainDecorator < Draper::Decorator
delegate_all

class MiddlewareDomainDecorator < MiqDecorator
def fonticon
'pficon-domain'.freeze
'pficon-domain'
end

def listicon_image
Expand Down
6 changes: 2 additions & 4 deletions app/decorators/middleware_messaging_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class MiddlewareMessagingDecorator < Draper::Decorator
delegate_all

class MiddlewareMessagingDecorator < MiqDecorator
def fonticon
'fa fa-exchange'.freeze
'fa fa-exchange'
end

def listicon_image
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/middleware_server_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiddlewareServerDecorator < Draper::Decorator
delegate_all

class MiddlewareServerDecorator < MiqDecorator
def fonticon
nil
end
Expand Down
6 changes: 2 additions & 4 deletions app/decorators/middleware_server_group_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class MiddlewareServerGroupDecorator < Draper::Decorator
delegate_all

class MiddlewareServerGroupDecorator < MiqDecorator
def fonticon
'pficon-server-group'.freeze
'pficon-server-group'
end

def listicon_image
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/miq_action_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiqActionDecorator < Draper::Decorator
delegate_all

class MiqActionDecorator < MiqDecorator
def fonticon
case action_type
when 'assign_scan_profile'
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/miq_ae_class_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiqAeClassDecorator < Draper::Decorator
delegate_all

class MiqAeClassDecorator < MiqDecorator
def fonticon
'product product-ae_class'
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/miq_ae_instance_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiqAeInstanceDecorator < Draper::Decorator
delegate_all

class MiqAeInstanceDecorator < MiqDecorator
def fonticon
'fa fa-file-text-o'
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/miq_ae_method_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiqAeMethodDecorator < Draper::Decorator
delegate_all

class MiqAeMethodDecorator < MiqDecorator
def fonticon
'product product-method'
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/miq_ae_namespace_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiqAeNamespaceDecorator < Draper::Decorator
delegate_all

class MiqAeNamespaceDecorator < MiqDecorator
def fonticon
'pficon pficon-folder-close'
end
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/miq_event_definition_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MiqEventDefinitionDecorator < Draper::Decorator
delegate_all

class MiqEventDefinitionDecorator < MiqDecorator
def fonticon
convert = {
"after_assigned_company_tag" => "fa fa-tag",
Expand Down
Loading