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

Convert PNGs to font icons and SVGs in trees #79

Merged
merged 1 commit into from
Jan 10, 2017
Merged

Convert PNGs to font icons and SVGs in trees #79

merged 1 commit into from
Jan 10, 2017

Conversation

epwinchell
Copy link
Contributor

@epwinchell epwinchell commented Jan 5, 2017

This PR is a followup to: #8 , replacing images with font icons managed by TreeBuilder, where possible. https://www.pivotaltracker.com/story/show/129371557

@epwinchell
Copy link
Contributor Author

@miq-bot add_label ui, technical debt, wip

@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2017

@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"
Copy link
Member

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

Copy link
Contributor Author

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'),
Copy link
Member

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'),
Copy link
Member

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"
Copy link
Member

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

Copy link
Member

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'}" }
Copy link
Member

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'}" }
Copy link
Member

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'
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

good enough for me

Copy link
Contributor

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'
Copy link
Member

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
Copy link
Member

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"
Copy link
Member

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?

Copy link
Contributor Author

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.

@miq-bot
Copy link
Member

miq-bot commented Jan 6, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jan 6, 2017

This pull request is not mergeable. Please rebase and repush.

@epwinchell epwinchell changed the title [WIP] convert PNGs to font icons and SVGs in trees Convert PNGs to font icons and SVGs in trees Jan 6, 2017
@epwinchell
Copy link
Contributor Author

@miq-bot rm_label wip

@miq-bot miq-bot removed the wip label Jan 6, 2017
@epwinchell
Copy link
Contributor Author

@miq-bot assign @himdel

Copy link
Member

@skateman skateman left a 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"
Copy link
Member

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",
Copy link
Member

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"
Copy link
Member

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"
Copy link
Member

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

@miq-bot
Copy link
Member

miq-bot commented Jan 9, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jan 9, 2017

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jan 9, 2017

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
151 files checked, 61 offenses detected

app/presenters/tree_builder_catalog_items.rb

app/presenters/tree_builder_chargeback_reports.rb

  • ❗ - Line 31, Col 11 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/presenters/tree_builder_iso_datastores.rb

  • ❗ - Line 36, Col 11 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/presenters/tree_builder_orchestration_templates.rb

  • ❗ - Line 23, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 28, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 33, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 38, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 43, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/presenters/tree_builder_policy.rb

app/presenters/tree_builder_provisioning_dialogs.rb

  • ❗ - Line 18, Col 9 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/presenters/tree_builder_pxe_customization_templates.rb

app/presenters/tree_builder_pxe_servers.rb

  • ❗ - Line 38, Col 22 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 45, Col 22 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/presenters/tree_builder_report_export.rb

  • ❗ - Line 26, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 29, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/presenters/tree_builder_report_reports.rb

app/presenters/tree_builder_report_widgets.rb

app/presenters/tree_builder_smartproxy_affinity.rb

  • ❗ - Line 42, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 56, Col 8 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/presenters/tree_builder_storage.rb

app/presenters/tree_builder_utilization.rb

  • ❗ - Line 47, Col 9 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

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

  • ❗ - Line 59, Col 17 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

spec/presenters/tree_builder_smartproxy_affinity_spec.rb

  • ❗ - Line 57, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 58, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 59, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 60, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 61, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 62, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 64, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 65, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 66, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 67, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 68, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 69, Col 33 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 71, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 72, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 73, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 74, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 75, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 76, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 78, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 79, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 80, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 81, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 82, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 83, Col 32 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

@epwinchell epwinchell closed this Jan 10, 2017
@epwinchell epwinchell reopened this Jan 10, 2017
@skateman
Copy link
Member

@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"
Copy link
Contributor

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 :)

@himdel
Copy link
Contributor

himdel commented Jan 10, 2017

LGTM, merging :)

@himdel himdel merged commit c3cd859 into ManageIQ:master Jan 10, 2017
@himdel himdel added the euwe/no label Jan 10, 2017
@himdel himdel added this to the Sprint 52 Ending Jan 16, 2017 milestone Jan 10, 2017
@epwinchell epwinchell deleted the tree_node_icons branch October 25, 2017 18:12
d-m-u added a commit to d-m-u/manageiq-ui-classic that referenced this pull request Jun 29, 2020
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
d-m-u added a commit to d-m-u/manageiq-ui-classic that referenced this pull request Jul 14, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants