-
Notifications
You must be signed in to change notification settings - Fork 356
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
Convert PNGs to font icons and SVGs in trees #79
Conversation
@miq-bot add_label ui, technical debt, wip |
@epwinchell Cannot apply the following label because they are not recognized: ui |
@@ -21,7 +21,7 @@ def x_get_tree_roots(count_only, options) | |||
else | |||
objects = [] | |||
rate_types.sort.each do |rtype| | |||
img = rtype.downcase == "compute" ? "100/hardware-processor.png" : "100/hardware-disk.png" | |||
img = rtype.downcase == "compute" ? "product product-memory" : "fa fa-hdd-o" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is converted to an icon, but it's still used as an image on line 28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skateman fixed
@@ -30,7 +30,7 @@ def x_get_tree_roots(count_only, options) | |||
objects.push( | |||
:id => i.to_s, | |||
:text => r[0], | |||
:image => (@grp_title == r[0] ? '100/blue_folder.png' : '100/folder.png'), | |||
:icon => (@grp_title == r[0] ? 'pficon pficon-folder-close-blue' : 'pficon pficon-folder-close'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you can remove the redundancy:
:icon => "pficon pficon-folder-close#{@grp_title == r[0] ? '-blue' : ''}",
@@ -47,7 +47,7 @@ def x_get_tree_custom_kids(object, count_only, _options) | |||
objects.push( | |||
:id => "#{nodes.last.split('-').last}-#{i}", | |||
:text => r[0], | |||
:image => (@grp_title == @rpt_menu[nodes.last.to_i][0] ? '100/blue_folder.png' : '100/folder.png'), | |||
:icon => (@grp_title == @rpt_menu[nodes.last.to_i][0] ? 'pficon pficon-folder-close-blue' : 'pficon pficon-folder-close'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -12,7 +12,7 @@ def initialize(name, type, sandbox, build = true, root = nil, vat = nil) | |||
private | |||
|
|||
def root_options | |||
image = "100/vendor-#{@root.image_name}.png" | |||
image = "svg/vendor-#{@root.image_name}.svg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will have to rethink these root_options
because on some places it's an image, on some place it's an icon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, it should go into the same separate PR as add_root_node
.
@@ -7,6 +7,6 @@ class Compliance < Node | |||
end | |||
end | |||
|
|||
set_attribute(:image) { "100/#{@object.compliant ? "check" : "x"}.png" } | |||
set_attribute(:icon) { "pficon pficon-#{@object.compliant ? 'pficon pficon-ok' : 'pficon pficon-error-circle-o'}" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't duplicate the prefix:
set_attribute(:icon) { "pficon pficon-#{@object.compliant ? 'ok' : 'error-circle-o'}" }
@@ -7,6 +7,6 @@ class ComplianceDetail < Node | |||
end | |||
end | |||
|
|||
set_attribute(:image) { "100/#{@object.miq_policy_result ? "check" : "x"}.png" } | |||
set_attribute(:icon) { "pficon pficon-#{@object.miq_policy_result ? 'pficon pficon-ok' : 'pficon pficon-error-circle-o'}" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't duplicate the prefix:
set_attribute(:icon) { "pficon pficon-#{@object.miq_policy_result ? 'ok' : 'error-circle-o'}" }
set_attribute(:image) do | ||
@object.options && @object.options[:button_image] ? "100/custom-#{@object.options[:button_image]}.png" : '100/leaf.gif' | ||
set_attribute(:icon) do | ||
@object.options && @object.options[:button_image] ? "product product-custom-#{@object.options[:button_image]}" : 'fa fa-file-o' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you 100% sure that product-custom-xxx
always exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skateman I'm not sure what you mean. We have fonticon equivalents of the 15 custom icons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good enough for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'd prefer to see another map here, but for now.. :)
tooltip = _("Datacenter: %{datacenter_name}") % {:datacenter_name => @object.name} | ||
else | ||
icon = %i(vandt vat).include?(@options[:type]) ? '100/blue_folder.png' : '100/folder.png' | ||
icon = %i(vandt vat).include?(@options[:type]) ? 'pficon pficon-folder-close-blue' : 'pficon pficon-folder-close' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove redundancy here:
icon = "pficon pficon-folder-close#{%i(vandt vat).include?(@options[:type]) ? '-blue' : ''}"
@@ -3,15 +3,15 @@ class MiqReportResult < Node | |||
set_attribute(:image) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_attribute(:icon)
suffix = @object.class.name.underscore.split("_").last.downcase | ||
suffix = 'vapp' if suffix == 'template' | ||
"100/orchestration_template_#{suffix}.png" | ||
"product product-template" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the suffix here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skateman That was calling copies of the same "T" image - redundant.
This pull request is not mergeable. Please rebase and repush. |
This pull request is not mergeable. Please rebase and repush. |
@miq-bot rm_label wip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except of the changes related to the root node it's all good. Nice job!
@@ -176,7 +176,7 @@ def add_to_sandbox | |||
def add_root_node(nodes) | |||
root = nodes.first | |||
root[:title], root[:tooltip], icon, options = root_options | |||
root[:image] = ActionController::Base.helpers.image_path(icon || "100/folder.png") | |||
root[:icon] = icon || "pficon pficon-folder-close" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in a separate PR, so remove this change please.
@@ -58,7 +58,7 @@ def get_element_title(el) | |||
|
|||
def get_element_icon(el) | |||
icons = { | |||
:MiqAeObject => "100/q.png", | |||
:MiqAeObject => "svg/vendor-redhat.svg", | |||
:MiqAeAttribute => "100/attribute.png", | |||
:not_blank => "100/#{el.name.underscore}.png", | |||
:other => "100/#{el.name.underscore.sub(/^miq_ae_service_/, '')}.png", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting these would require something like:
def get_element_icon(el)
icons = {
:MiqAeObject => { :image => "svg/vendor-redhat.svg" },
:MiqAeAttribute => { :icon => "some fonticon" },
:not_blank => { :image => "100/#{el.name.underscore}.png" },
:other => {:image => "100/#{el.name.underscore.sub(/^miq_ae_service_/, '')}.png" },
}
choose_correct_attr(el, icons)
end
And then on lines 71-77:
object = {:id => "e_#{idx}",
:text => title,
:tip => title,
:elements => el.each_element { |e| e },
:cfmeNoClick => true
}.merge(get_element_icon(el))
@himdel what do you think?
@@ -12,7 +12,7 @@ def initialize(name, type, sandbox, build = true, root = nil, vat = nil) | |||
private | |||
|
|||
def root_options | |||
image = "100/vendor-#{@root.image_name}.png" | |||
image = "svg/vendor-#{@root.image_name}.svg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, it should go into the same separate PR as add_root_node
.
@@ -21,7 +21,7 @@ def image_name | |||
|
|||
it 'returns EmsCluster as root' do | |||
root = @vat_tree.send(:root_options) | |||
image = "100/vendor-#{@vat_tree.instance_variable_get(:@root).image_name}.png" | |||
image = "svg/vendor-#{@vat_tree.instance_variable_get(:@root).image_name}.svg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change, same as add_root_node
This pull request is not mergeable. Please rebase and repush. |
This pull request is not mergeable. Please rebase and repush. |
Checked commit https://github.com/epwinchell/manageiq-ui-classic/commit/b578497c5cfc51f41c81f7178face3a1573490f3 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/presenters/tree_builder_catalog_items.rb
app/presenters/tree_builder_chargeback_reports.rb
app/presenters/tree_builder_iso_datastores.rb
app/presenters/tree_builder_orchestration_templates.rb
app/presenters/tree_builder_policy.rb
app/presenters/tree_builder_provisioning_dialogs.rb
app/presenters/tree_builder_pxe_customization_templates.rb
app/presenters/tree_builder_pxe_servers.rb
app/presenters/tree_builder_report_export.rb
app/presenters/tree_builder_report_reports.rb
app/presenters/tree_builder_report_widgets.rb
app/presenters/tree_builder_smartproxy_affinity.rb
app/presenters/tree_builder_storage.rb
app/presenters/tree_builder_utilization.rb
app/presenters/tree_builder_vms_filter.rb
app/presenters/tree_node/custom_button.rb
app/presenters/tree_node/custom_button_set.rb
app/presenters/tree_node/service_resource.rb
spec/presenters/tree_builder_report_widgets_spec.rb
spec/presenters/tree_builder_servers_by_role_spec.rb
spec/presenters/tree_builder_smartproxy_affinity_spec.rb
|
@himdel I think this is good to go! |
suffix = 'vapp' if suffix == 'template' | ||
"100/orchestration_template_#{suffix}.png" | ||
set_attribute(:icon) do | ||
"product product-template" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wanted to say we're losing the type distinction here .. but looking at 100/orchestration_template_*.png
they all look the same, so not saying anything :)
LGTM, merging :) |
more core ext's on 4.1.0 update for update sake https://github.com/ManageIQ/more_core_extensions/compare/179bf40..e5b4501 - Added Ruby 2.7 support [[ManageIQ#79](ManageIQ/more_core_extensions#79)] - Added Process#pause, Process#resume, and Process#alive? [[ManageIQ#73](ManageIQ/more_core_extensions#73)] array added * `#compact_map` - Collect non-nil results from the block array added `#tabular_sort` - Sorts an Array of Hashes by specific columns hierarchy added `#descendant_get` - Returns the descendant with a given name the two breaking changes: - **BREAKING**: Moved Object#descendant_get to Class#descendant_get [[ManageIQ#75](ManageIQ/more_core_extensions#75)] - **BREAKING**: Removed deprecated Enumerable#stable_sort_by [[ManageIQ#76](ManageIQ/more_core_extensions#76)] a minor header output change was made that hasn't been released yet to make tableize more markdown compliant see ManageIQ/linux_admin#221
more core ext's on 4.1.0 update for update sake https://github.com/ManageIQ/more_core_extensions/compare/179bf40..e5b4501 - Added Ruby 2.7 support [[ManageIQ#79](ManageIQ/more_core_extensions#79)] - Added Process#pause, Process#resume, and Process#alive? [[ManageIQ#73](ManageIQ/more_core_extensions#73)] array added * `#compact_map` - Collect non-nil results from the block array added `#tabular_sort` - Sorts an Array of Hashes by specific columns hierarchy added `#descendant_get` - Returns the descendant with a given name the two breaking changes: - **BREAKING**: Moved Object#descendant_get to Class#descendant_get [[ManageIQ#75](ManageIQ/more_core_extensions#75)] - **BREAKING**: Removed deprecated Enumerable#stable_sort_by [[ManageIQ#76](ManageIQ/more_core_extensions#76)] a minor header output change was made that hasn't been released yet to make tableize more markdown compliant see ManageIQ/linux_admin#221
This PR is a followup to: #8 , replacing images with font icons managed by TreeBuilder, where possible. https://www.pivotaltracker.com/story/show/129371557