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

Quadicon improvements #3046

Merged
merged 3 commits into from
Jan 19, 2018
Merged

Conversation

karelhala
Copy link
Contributor

@karelhala karelhala commented Dec 13, 2017

Introduces

New method to decorators

This PR adds new method to decorators which is responsible for generating quadicons. This feature is used only for ExtManagementSystem providers:

CloudManager

Before

screenshot from 2017-12-14 13-41-24

After

screenshot from 2017-12-14 13-41-18

ContainerManager

Before

screenshot from 2017-12-14 13-43-33

After

screenshot from 2017-12-14 13-45-00

DataWarehouseManager

Not a provider, but since it inherits from ExtManagementSystem it can generate quadicon

InfraManager

Before

screenshot from 2017-12-14 13-48-52

After

screenshot from 2017-12-14 13-47-49

MiddlewareManager

Before

screenshot from 2017-12-14 15-03-28

After

screenshot from 2017-12-13 12-49-22

MonitoringManager

Not a provider, but since it inherits from ExtManagementSystem it can generate quadicon

NetworkManager

Before

screenshot from 2017-12-14 13-50-44

After

screenshot from 2017-12-14 13-54-12

PhysicalInfraManager

New methods to quadion helper

New methods inside quadicon helper furthermore simplifies generation of quadicon

  • render_quadicon_text - for rendering text inside quadion, every text with more than 3 characters will use smaller font
  • render_quad_image - for rendering images and fonticons, it will use either flobj_img_small or flobj_img_simple based on type provided in quad descritption
  • transform_quadicon - method for transforming quadicon hash to array of strings with location where these strings should be rendered.

GH issue #3036

This PR follows GH issue #3036 to implement correctly format which is produced by quadicon method.

What to look out for

Font size for any quad has been unified with top left. Only top left had change on font if length of string was bigger than 2, so this PR unifies it that any text in quad longer than 2 chars has this font change.

UI changes

Adds new fields to quadicon for MW provider

Domains Servers
Icon Auth

screenshot from 2017-12-13 12-49-22

@karelhala
Copy link
Contributor Author

@miq-bot add_label gaprindashvili/no, enhancement
@skateman please review and test

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.

The AssetsMapper is in general a confusing name, can't you just omit it?

@@ -0,0 +1,14 @@
module QuadiconHelper
class AssetsMapper
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 a confusing name

Copy link
Member

Choose a reason for hiding this comment

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

also why is this a class?

module QuadiconHelper
class AssetsMapper
class << self
def img_status(item)
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 an even more confusing name inside

output << flobj_img_simple("svg/vendor-#{h(item.image_name)}.svg", "c72")
output << flobj_img_simple(img_for_auth_status(item), "d72")
top_left = quadicon[:top_left][:text]
top_right = quadicon[:top_right][:text]
Copy link
Member

Choose a reason for hiding this comment

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

👍

@martinpovolny
Copy link
Member

@karelhala : I think that this is exactly the direction we need to folllow with quadicons. It attacks the technical debt, allows pluggability and also makes a step towards the client side (client side quadicon rendering).

I'd love to get a very good consensus on this.

@AparnaKarve: would you like to participate in this effort?

@karelhala karelhala changed the title Quadion improvements Quadixon improvements Dec 13, 2017
@karelhala karelhala changed the title Quadixon improvements Quadicon improvements Dec 13, 2017
@karelhala karelhala force-pushed the quadionImprovements branch 4 times, most recently from fcca3a8 to 8a42d62 Compare December 13, 2017 14:30
@abonas
Copy link
Member

abonas commented Dec 13, 2017

what providers are the datawarehouse and monitoring manager? do they use quadicons?

class CloudManagerDecorator < MiqDecorator
def quadicon(_n = nil)
{
:top_left => { :text => container_nodes.size },
Copy link
Member

Choose a reason for hiding this comment

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

why container nodes are in the cloud manager?


def quadicon(_n = nil)
{
:top_left => { :text => try(:hosts).try(:size) || 0 },
Copy link
Member

Choose a reason for hiding this comment

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

isn't the ext_mgmt the top level? does it have hosts as an entity? or it's a default fallback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just deafult fallback.

:fileicon => fileicon,
:tooltip => type
},
:bottom_right => {
Copy link
Member

Choose a reason for hiding this comment

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

can the bottom right part = auth status be extracted as a default? it seems repeating

Copy link
Member

@skateman skateman Dec 14, 2017

Choose a reason for hiding this comment

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

@abonas I agree with you as I'm a fan of the DRY philosophy, but decorators are an exception. Think about them as a place to specify the UI sugar for each DB model. Eventually it will get simplified to a DSL that can be easily edited by designers:

class SomethingDecorator
  quadicon :top_left, :fileicon => '100/something.png', :tooltip => 'yay'
  quadicon :top_right, :text => 3
end

I think it's understandable that we don't want to pull shared definitions on such places...


def quadicon(_n = nil)
{
:top_left => { :text => total_vms },
Copy link
Member

Choose a reason for hiding this comment

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

why are there vms in container manager quadicon?

when "None" then "100/unknown.png"
else "100/exclamationpoint.png"
end
status_img(item)
Copy link
Member

Choose a reason for hiding this comment

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

why does this belong to refactoring of the quadicons?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well we need to return url for item's status, and it is better to move these to seperate file which is imported and is easier to read.

Copy link
Member

Choose a reason for hiding this comment

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

@karelhala : do we really need the URL?

I mean we figured when working on the GTLs that the URLs are calculated on 2 places and that really matters is the single URL that is actually not part of the quadicon.

What about removing all the URL logic here? Instead of refactoring that part. That might actually save some time and code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martinpovolny this does not touches urls, these are just paths to images.

Copy link
Member

Choose a reason for hiding this comment

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

wanted to say the same 😉

@@ -224,7 +221,7 @@ def img_tag_reflection
end

# Renders a quadicon for PhysicalServer
#
# TODO: use quadicon decorator
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 all the todos? is it for followup PR? to be fixed by provider teams?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's to mark methods which can use quadicon decorator. I can refactor them now, or in follow up PR. Decision is on @martinpovolny or @skateman.

Copy link
Member

Choose a reason for hiding this comment

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

Marking the methods is ok. We cannot do all cleanups at once. Thx!

@karelhala karelhala force-pushed the quadionImprovements branch 4 times, most recently from 76a34fd to 21574e8 Compare December 13, 2017 15:31
@abonas
Copy link
Member

abonas commented Dec 13, 2017

I am also concerned this refactors all providers without proper checks available to ensure there are no regressions. Afaik there are no tests and I assume that there wont be a real env check for all providers by @karelhala

@karelhala karelhala force-pushed the quadionImprovements branch 4 times, most recently from 0377160 to fb32b42 Compare December 13, 2017 16:20
def quadicon(_n = nil)
{
:top_left => { :text => container_nodes.size },
:top_right => { :text => enabled? ? "on" : "paused" },
Copy link
Member

Choose a reason for hiding this comment

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

Where is the on/paused taken from? I don't see the original code from before the refactoring, so I wonder...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comes from app/helpers/quadicon_helper.rb:571. However this is incorrect because it should be icon and not text.


def status_img(item = nil)
case item.authentication_status
when "Invalid" then "100/x.png"
Copy link
Member

Choose a reason for hiding this comment

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

can the "100" be not repeated/gotten from somewhere else? it might be changed tomorrow to 150 :) and this hardcoding will cause a regression

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is question probably for @skateman since it's related to assets pipeline and it used to be in this exact format.

Copy link
Member

@skateman skateman Dec 14, 2017

Choose a reason for hiding this comment

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

@abonas we have the 100 everywhere and we want to keep it consistent. Eventually, we're going to replace all these things with fonticons (that aren't yet supported by quadicons) and SVGs (in progress).

def quadicon(_n = nil)
{
:top_left => { :text => hosts.size },
:top_right => { :text => total_vms },
Copy link
Member

Choose a reason for hiding this comment

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

I don't see the original code, so I am wondering why hosts.size is called, and then total_vms (without the call to size method) ? does it work in openstack provider too where there are instances? or they are also called vms in miq?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, this comes from app/helpers/quadicon_helper.rb:570 and EmsInfra is alias to ManageIQ::Providers::InfraManager

@abonas
Copy link
Member

abonas commented Dec 13, 2017

what providers are the datawarehouse and monitoring manager? do they use quadicons? I am not sure they are providers at all

@karelhala
Copy link
Contributor Author

what providers are the datawarehouse and monitoring manager? do they use quadicons? I am not sure they are providers at all

They inherit from ext_management_system.rb and since we have decorator for this manager it automatically enables generation of quadicons for any manager which inherits from ExtManagementSystem (or BaseManager). However that does not mean they use quadicons.

@karelhala
Copy link
Contributor Author

All providers checked and they look same with this PR, except PhysicalInfraManager since I don't have any provider can you @AparnaKarve please check it?

def quadicon(_n = nil)
{
:top_left => {:text => container_nodes.size},
:top_right => {:state_icon => enabled? ? "on" : "paused"},
Copy link
Member

Choose a reason for hiding this comment

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

where is the on/paused info taken from?

Copy link
Contributor Author

@karelhala karelhala Dec 14, 2017

Choose a reason for hiding this comment

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

#3046 (comment) it's from refactored code quadicon_helper.rb:571

@AparnaKarve
Copy link
Contributor

All providers checked and they look same with this PR, except PhysicalInfraManager since I don't have any provider can you @AparnaKarve please check it?

@karelhala The Before and After for PhysicalInfraManager look the same.
screen shot 2017-12-14 at 12 48 50 pm

@epwinchell
Copy link
Contributor

@karelhala Something went wrong with the font size on the 3-digit "after"
screen shot 2017-12-14 at 11 22 06 pm

@karelhala
Copy link
Contributor Author

Something went wrong with the font size on the 3-digit "after"

That's actually wanted. Before only top left quad with 3+ texts had smaller font size, so I unified it accross all quads. If you want I can get rid of it completely.

@karelhala karelhala closed this Dec 15, 2017
@karelhala
Copy link
Contributor Author

Restarting travis.

@karelhala karelhala reopened this Dec 15, 2017
@miq-bot
Copy link
Member

miq-bot commented Dec 15, 2017

Checked commits karelhala/manageiq-ui-classic@6a7c018~...fe44388 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
11 files checked, 0 offenses detected
Everything looks fine. ⭐

@karelhala
Copy link
Contributor Author

@martinpovolny can we merge this? Or are we waiting with this untill G release?

@martinpovolny martinpovolny added this to the Sprint 78 Ending Jan 29, 2018 milestone Jan 19, 2018
@martinpovolny martinpovolny merged commit 15cf2f3 into ManageIQ:master Jan 19, 2018
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.

7 participants