-
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
Quadicon improvements #3046
Quadicon improvements #3046
Conversation
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.
The AssetsMapper
is in general a confusing name, can't you just omit it?
@@ -0,0 +1,14 @@ | |||
module QuadiconHelper | |||
class AssetsMapper |
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 a confusing name
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.
also why is this a class?
module QuadiconHelper | ||
class AssetsMapper | ||
class << self | ||
def img_status(item) |
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 an even more confusing name inside
app/helpers/quadicon_helper.rb
Outdated
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] |
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.
👍
86b821b
to
92e137b
Compare
@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? |
fcca3a8
to
8a42d62
Compare
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 }, |
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.
why container nodes are in the cloud manager?
|
||
def quadicon(_n = nil) | ||
{ | ||
:top_left => { :text => try(:hosts).try(:size) || 0 }, |
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.
isn't the ext_mgmt the top level? does it have hosts as an entity? or it's a default fallback?
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 just deafult fallback.
:fileicon => fileicon, | ||
:tooltip => type | ||
}, | ||
:bottom_right => { |
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.
can the bottom right part = auth status be extracted as a default? it seems repeating
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.
@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 }, |
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.
why are there vms in container manager quadicon?
when "None" then "100/unknown.png" | ||
else "100/exclamationpoint.png" | ||
end | ||
status_img(item) |
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.
why does this belong to refactoring of the quadicons?
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.
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.
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.
@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.
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.
@martinpovolny this does not touches urls, these are just paths to images.
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 the same 😉
@@ -224,7 +221,7 @@ def img_tag_reflection | |||
end | |||
|
|||
# Renders a quadicon for PhysicalServer | |||
# | |||
# TODO: use quadicon decorator |
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 all the todos? is it for followup PR? to be fixed by provider teams?
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.
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.
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.
Marking the methods is ok. We cannot do all cleanups at once. Thx!
76a34fd
to
21574e8
Compare
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 |
0377160
to
fb32b42
Compare
def quadicon(_n = nil) | ||
{ | ||
:top_left => { :text => container_nodes.size }, | ||
:top_right => { :text => enabled? ? "on" : "paused" }, |
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.
Where is the on/paused taken from? I don't see the original code from before the refactoring, so I wonder...
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 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" |
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.
can the "100" be not repeated/gotten from somewhere else? it might be changed tomorrow to 150 :) and this hardcoding will cause a regression
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 question probably for @skateman since it's related to assets pipeline and it used to be in this exact format.
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.
@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 }, |
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.
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?
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.
Well, this comes from app/helpers/quadicon_helper.rb:570 and EmsInfra
is alias to ManageIQ::Providers::InfraManager
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 |
fb32b42
to
1a3a27a
Compare
All providers checked and they look same with this PR, except |
def quadicon(_n = nil) | ||
{ | ||
:top_left => {:text => container_nodes.size}, | ||
:top_right => {:state_icon => enabled? ? "on" : "paused"}, |
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.
where is the on/paused info taken from?
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.
#3046 (comment) it's from refactored code quadicon_helper.rb:571
1a3a27a
to
93cac0d
Compare
@karelhala The Before and After for PhysicalInfraManager look the same. |
@karelhala 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. |
Restarting travis. |
93cac0d
to
e1f241e
Compare
e1f241e
to
fe44388
Compare
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 |
@martinpovolny can we merge this? Or are we waiting with this untill G release? |
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
After
ContainerManager
Before
After
DataWarehouseManager
Not a provider, but since it inherits from ExtManagementSystem it can generate quadicon
InfraManager
Before
After
MiddlewareManager
Before
After
MonitoringManager
Not a provider, but since it inherits from ExtManagementSystem it can generate quadicon
NetworkManager
Before
After
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 fontrender_quad_image
- for rendering images and fonticons, it will use eitherflobj_img_small
orflobj_img_simple
based on type provided in quad descritptiontransform_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