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

Replace images with icons in root nodes #128

Merged
merged 1 commit into from
Jan 19, 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
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_belongs_to_vat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def override(node, object, _pid, options)
end
if object.kind_of?(EmsFolder)
if blue?(object)
node[:icon] = ActionController::Base.helpers.image_path("100/blue_folder.png")
node[:icon] = "pficon pficon-folder-close-blue"
else
node[:hideCheckbox] = true
end
Expand Down
10 changes: 5 additions & 5 deletions app/presenters/tree_builder_buttons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def x_get_tree_roots(_count_only, _options)
@sb[:target_classes] = resolve.invert
resolve = Array(resolve.invert).sort
resolve.collect do |typ|
{:id => "ab_#{typ[1]}", :text => typ[0], :image => buttons_node_image(typ[1]), :tip => typ[0]}
{:id => "ab_#{typ[1]}", :text => typ[0], :tip => typ[0]}.merge(buttons_node_image(typ[1]))
end
end

Expand Down Expand Up @@ -69,10 +69,10 @@ def x_get_tree_aset_kids(object, count_only)

def buttons_node_image(node)
case node
when "ExtManagementSystem" then '100/ext_management_system.png'
when "MiqTemplate" then '100/vm.png'
when 'CloudTenant' then '100/cloud_tenant.png'
else "100/#{node.downcase}.png"
when "ExtManagementSystem" then {:icon => 'pficon pficon-server'}
when "MiqTemplate" then {:icon => 'pficon-virtual-machine'}
when 'CloudTenant' then {:icon => 'pficon-cloud-tenant'}
else {:image => '100/#{node.downcase}.png'}
end
end
end
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_compliance_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def x_get_compliance_kids(parent, count_only)
def get_policy_elm(parent, node)
{:id => "#{parent.id}-p_#{node.miq_policy_id}",
:text => prefixed_title(_('Condition'), node.condition_desc),
:image => node.condition_result ? "100/check.png" : "100/x.png",
:icon => node.condition_result ? "pficon pficon-ok" : "pficon pficon-error-circle-o",
:tip => nil,
:cfmeNoClick => true}
end
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/tree_builder_datacenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def root_options
{
:title => @root.name,
:tooltip => _("Cluster: %{name}") % {:name => @root.name},
:image => "100/cluster.png"
:icon => "pficon pficon-cluster"
}
elsif @root.kind_of?(ResourcePool)
{
:title => @root.name,
:tooltip => _("Resource Pool: %{name}") % {:name => @root.name},
:image => @root.vapp ? "100/vapp.png" : "100/resource_pool.png"
:icon => "pficon-resource-pool"
}
end
end
Expand Down
5 changes: 2 additions & 3 deletions app/presenters/tree_builder_miq_action_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ class TreeBuilderMiqActionCategory < TreeBuilder

def override(node, object, _pid, _options)
leaf = !object.category?
image = leaf ? nil : "100/tag.png"
node[:cfmeNoClick] = !leaf
node[:image] = image && ActionController::Base.helpers.image_path(image)
node[:icon] = leaf ? nil : "fa fa-tag"
node
end

Expand Down Expand Up @@ -36,7 +35,7 @@ def root_options
{
:title => @tenant_name,
:tooltip => @tenant_name,
:image => "100/tag.png"
:icon => "fa fa-tag"
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def root_options
{
:title => @root.name,
:tooltip => _("Host: %{name}") % {:name => @root.name},
:image => '100/host.png',
:icon => 'pficon pficon-screen',
:cfmeNoClick => true
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_ops_diagnostics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def root_options
{
:title => title,
:tooltip => title,
:image => '100/miq_region.png'
:icon => 'pficon pficon-regions'
}
end
end
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_ops_rbac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def root_options
{
:title => title,
:tooltip => title,
:image => '100/miq_region.png'
:icon => 'pficon pficon-regions'
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_ops_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def root_options
{
:title => title,
:tooltip => title,
:image => '100/miq_region.png'
:icon => 'pficon pficon-regions'
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_ops_vmdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def root_options
{
:title => t = _("VMDB"),
:tooltip => t,
:image => '100/miq_database.png'
:icon => 'fa fa-database'
}
end

Expand Down
18 changes: 9 additions & 9 deletions app/presenters/tree_builder_policy_simulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def root_options
{
:title => ViewHelper.content_tag(:strong, @root_name),
:tooltip => @root_name,
:image => '100/vm.png',
:icon => 'pficon pficon-virtual-machine',
:cfmeNoClick => true
}
end
Expand All @@ -51,7 +51,7 @@ def x_get_tree_roots(count_only = false, _options = {})
nodes = reject_na_nodes(@data).map do |node|
{:id => node['id'],
:text => prefixed_title(_('Policy Profile'), node['description']),
:image => node_icon(node["result"]),
:icon => node_icon(node["result"]),
:tip => node['description'],
:cfmeNoClick => true,
:policies => node['policies']}
Expand Down Expand Up @@ -85,9 +85,9 @@ def get_active_caption(node)
def policy_nodes(parent)
parent[:policies].reject { |node| skip_node?(node) }.sort_by { |a| a["description"] }.map do |node|
active_caption = get_active_caption(node)
{:id => node['id'],
{:id => node['id'],
:text => prefixed_title(_('Policy%{caption}') % {:caption => active_caption}, node['description']),
:image => node_icon(node["result"]),
:icon => node_icon(node["result"]),
:tip => node['description'],
:scope => node['scope'],
:conditions => node['conditions'],
Expand All @@ -100,7 +100,7 @@ def condition_node(parent)
nodes = nodes.sort_by { |a| a["description"] }.map do |node|
{:id => node['id'],
:text => prefixed_title(_('Condition'), node['description']),
:image => node_icon(node["result"]),
:icon => node_icon(node["result"]),
:tip => node['description'],
:scope => node['scope'],
:expression => node["expression"],
Expand All @@ -110,15 +110,15 @@ def condition_node(parent)
end

def scope_node(parent)
icon = parent[:scope]["result"] ? "100/checkmark.png" : "100/na.png"
icon = parent[:scope]["result"] ? "pficon pficon-ok" : "fa fa-ban"
text, tip = exp_build_string(parent[:scope])
{:id => nil, :text => prefixed_title(_('Scope'), text), :image => icon, :tip => tip, :cfmeNoClick => true}
{:id => nil, :text => prefixed_title(_('Scope'), text), :icon => icon, :tip => tip, :cfmeNoClick => true}
end

def expression_node(parent)
icon = parent[:expression]["result"] ? "100/checkmark.png" : "100/na.png"
icon = parent[:expression]["result"] ? "pficon pficon-ok" : "fa fa-ban"
text, tip = exp_build_string(parent[:expression])
{:id => nil, :text => prefixed_title(_('Expression'), text), :image => icon, :tip => tip, :cfmeNoClick => true}
{:id => nil, :text => prefixed_title(_('Expression'), text), :icon => icon, :tip => tip, :cfmeNoClick => true}
end

def get_correct_node(parent, node_name)
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/tree_builder_policy_simulation_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def root_options
event = MiqEventDefinition.find(@root[:event_value])
{
:title => _("Policy Simulation Results for Event [%{description}]") % {:description => event.description},
:image => "100/event-#{event.name}.png",
:icon => event.decorate.fonticon,
:cfmeNoClick => true
}
end
Expand All @@ -41,7 +41,7 @@ def vm_nodes(data)
data.sort_by! { |a| a[:name].downcase }.map do |node|
{:id => node[:id],
:text => prefixed_title(_('VM'), node[:name]),
:image => '100/vm.png',
:icon => 'pficon pficon-virtual-machine',
:profiles => node[:profiles],
:cfmeNoClick => true}
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_report_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def root_options
{
:title => t = _("Import / Export"),
:tooltip => t,
:image => '100/report.png'
:icon => 'product product-report'
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_report_roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def root_options
{
:title => title,
:tooltip => title,
:image => '100/miq_group.png'
:icon => 'product product-group'
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_report_schedules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def root_options
{
:title => t = _("All Schedules"),
:tooltip => t,
:image => '100/miq_schedule.png'
:icon => 'fa fa-clock-o'
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_snapshots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def root_options
{
:title => @record.name,
:tooltip => @record.name,
:image => '100/vm.png',
:icon => 'pficon pficon-virtual-machine',
:cfmeNoClick => true
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_storage_adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def root_options
{
:title => @root.name,
:tooltip => _("Host: %{name}") % {:name => @root.name},
:image => "100/host.png"
:icon => "pficon pficon-screen"
}
end

Expand Down
6 changes: 3 additions & 3 deletions app/presenters/tree_builder_utilization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ def set_locals_for_render
def root_options
if MiqEnterprise.my_enterprise.is_enterprise?
title = _("Enterprise")
icon = '100/enterprise.png'
icon = 'pficon pficon-enterprise'
else
title = _("%{product} Region: %{region_description} [%{region}]") % {:region_description => MiqRegion.my_region.description,
:region => MiqRegion.my_region.region,
:product => I18n.t('product.name')}
icon = '100/miq_region.png'
icon = 'pficon pficon-regions'
end
{
:title => title,
:tooltip => title,
:image => icon
:icon => icon
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_vat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def root_options
{
:title => @root.name,
:tooltip => @root.name,
:image => "100/vendor-#{@root.image_name}.png"
:image => "svg/vendor-#{@root.image_name}.svg"
}
end

Expand Down
9 changes: 6 additions & 3 deletions app/presenters/tree_node/miq_action.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module TreeNode
class MiqAction < Node
set_attribute(:title, &:description)
set_attribute(:image) do
set_attributes(:icon, :image) do
if @options[:tree] != :action_tree
if @options[:tree] == :policy_profile_tree
policy_id = @parent_id.split('-')[2].split('_').first
Expand All @@ -13,10 +13,13 @@ class MiqAction < Node
p = ::MiqPolicy.find_by_id(ApplicationRecord.uncompress_id(policy_id))
ev = ::MiqEventDefinition.find_by_id(ApplicationRecord.uncompress_id(event_id))

p.action_result_for_event(@object, ev) ? "100/check.png" : "100/x.png"
icon = p.action_result_for_event(@object, ev) ? "pficon pficon-ok" : "pficon pficon-error-circle-o"
elsif @object.action_type == "default"
icon = "product product-action"
else
@object.action_type == "default" ? "100/miq_action.png" : "100/miq_action_#{@object.action_type}.png"
image = "100/miq_action_#{@object.action_type}.png"
end
[icon, image]
end
end
end
13 changes: 7 additions & 6 deletions app/presenters/tree_node/miq_ae_namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ module TreeNode
class MiqAeNamespace < MiqAeNode
include MiqAeClassHelper

set_attribute(:image) do
set_attributes(:icon, :image) do
# Having a "flat" case here makes the code more readable
# rubocop:disable LiteralInCondition
case true
when [email protected]?
'svg/ae_namespace.svg'
icon = 'pficon pficon-folder-close'
when @object.git_enabled?
'svg/ae_git_domain.svg'
image = 'svg/ae_git_domain.svg'
when @object.name == MiqAeDatastore::MANAGEIQ_DOMAIN
'100/miq.png'
icon = 'product product-product'
when [email protected]_level_namespace
'100/ae_domain.png'
icon = 'fa fa-globe'
else
"svg/vendor-#{@object.top_level_namespace.downcase}.svg"
image = "svg/vendor-#{@object.top_level_namespace.downcase}.svg"
end
# rubocop:enable LiteralInCondition
[icon, image]
end

set_attribute(:klass) { @object.domain? && @object.enabled? ? nil : 'striketrough' }
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/tree_builder_datacenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def resource_pools
expect(root).to eq(
:title => @datacenter_tree.instance_variable_get(:@root).name,
:tooltip => "Cluster: #{@datacenter_tree.instance_variable_get(:@root).name}",
:image => "100/cluster.png"
:icon => "pficon pficon-cluster"
)
end

Expand Down Expand Up @@ -58,7 +58,7 @@ def vms
expect(root).to eq(
:title => @datacenter_tree.instance_variable_get(:@root).name,
:tooltip => "Resource Pool: #{@datacenter_tree.instance_variable_get(:@root).name}",
:image => @datacenter_tree.instance_variable_get(:@root).vapp ? '100/vapp.png' : '100/resource_pool.png'
:icon => "pficon-resource-pool"
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/tree_builder_miq_action_category_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
expect(subject.send(:root_options)).to eq(
:title => tenant,
:tooltip => tenant,
:image => "100/tag.png"
:icon => "fa fa-tag"
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/tree_builder_network_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
expect(root).to eq(
:title => @network_tree.instance_variable_get(:@root).name,
:tooltip => _("Host: %{name}") % {:name => @network_tree.instance_variable_get(:@root).name},
:image => '100/host.png',
:icon => 'pficon pficon-screen',
:cfmeNoClick => true
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
root_options = @rsop_tree.send(:root_options)
expect(root_options).to eq(
:title => _("Policy Simulation Results for Event [%{description}]") % {:description => @event.description},
:image => "100/event-#{@event.name}.png",
:icon => @event.decorate.fonticon,
:cfmeNoClick => true
)
end
Expand All @@ -44,7 +44,7 @@
original_vms = @data[:results].sort_by { |a| a[:name].downcase }
vms.each_with_index do |vm, i|
expect(vm[:text]).to eq("<strong>VM:</strong> #{original_vms[i][:name]}")
expect(vm[:image]).to eq('100/vm.png')
expect(vm[:icon]).to eq('pficon pficon-virtual-machine')
expect(vm[:profiles]).to eq(original_vms[i][:profiles])
end
end
Expand Down
Loading