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

Fixes #34515, #34516 - Add host owner and comment on host list page #9182

Merged
merged 2 commits into from
Apr 28, 2022

Conversation

pkoprda
Copy link
Contributor

@pkoprda pkoprda commented Apr 7, 2022

Add two columns in host list page - owner of the host and host comment

@theforeman-bot
Copy link
Member

Issues: #34516

@pkoprda pkoprda changed the title Fixes #34515, #34516 - Add host owner and comment on host list page Fixes #34515, #34516 - Add host owner and comment on host list page Apr 7, 2022
@ares
Copy link
Member

ares commented Apr 8, 2022

I've tried to apply this to get the screenshot from the instance with real data. I encountered the following issue though, let me know once fixed, I'm happy to retest.

2022-04-08T17:49:33 [W|app|b191f852] undefined method `truncate' for nil:NilClass
2022-04-08T17:49:33 [I|app|b191f852] Backtrace for 'undefined method `truncate' for nil:NilClass' error (ActionView::Template::Error): undefined method `truncate' for nil:
NilClass
 b191f852 | /usr/share/foreman/app/views/hosts/_list.html.erb:47:in `block in _cafb7050f0bc78f5d174aa704ac89300'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in `each'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in `each'
 b191f852 | /usr/share/foreman/app/views/hosts/_list.html.erb:23:in `_cafb7050f0bc78f5d174aa704ac89300'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/base.rb:274:in `_run'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/template.rb:185:in `block in render'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:182:in `instrument'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/template.rb:385:in `instrument_render_template'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/template.rb:183:in `render'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/renderer/partial_renderer.rb:357:in `block in render_partial'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:180:in `block in instrument'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:180:in `instrument'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/renderer/partial_renderer.rb:346:in `render_partial'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/renderer/partial_renderer.rb:317:in `render'
 b191f852 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.3.7/lib/action_view/renderer/renderer.rb:65:in `render_partial_to_object'

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

Thanks, @pkoprda! Some comments/suggestions inline. Also, I've noticed that a user doesn't have to actually hover over the icon to see the full comment, which is... just weird :) Moreover, when the full text is shown, I don't have much time to read it, so not sure if it's useful for long descriptions, maybe we could disable autofading? Here is a gif:
gif

<td class="hidden-tablet hidden-xs"><%= label_with_link host.hostgroup, 23, @hostgroup_authorizer %></td>
<td class="hidden-tablet hidden-xs ellipsis"><%= last_report_column(host) %></td>
<td class="hidden-tablet hidden-xs" title="<%= host.comment.truncate(255) %>"><%= icon_text('comment', '') unless host.comment.empty? %></td>
Copy link
Member

@ofedoren ofedoren Apr 8, 2022

Choose a reason for hiding this comment

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

Suggested change
<td class="hidden-tablet hidden-xs" title="<%= host.comment.truncate(255) %>"><%= icon_text('comment', '') unless host.comment.empty? %></td>
<td class="hidden-tablet hidden-xs" title="<%= host.comment&.truncate(255) %>"><%= icon_text('comment', '') unless host.comment.empty? %></td>

You can use safe navigation in Ruby, so in case there is no comment for the host, it won't raise an exception. Probably this why the tests are failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ofedoren for suggestion. I am not sure how to fix that autofading, because in my environment seems like that it does not fade. So when I hover over the icon, the tooltip stays there until I move away my cursor.

<td class="hidden-tablet hidden-xs"><%= label_with_link host.hostgroup, 23, @hostgroup_authorizer %></td>
<td class="hidden-tablet hidden-xs ellipsis"><%= last_report_column(host) %></td>
<td class="hidden-tablet hidden-xs" title="<%= host.comment.truncate(255) %>"><%= icon_text('comment', '') unless host.comment.empty? %></td>
Copy link
Member

Choose a reason for hiding this comment

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

Since we use icon only and we cannot shrink the column a bit more, maybe it's better to actually put text there? Truncated, of course, and leave the full text to be shown on hover.

Or at least we could center the icon like with Power column.

app/views/hosts/_list.html.erb Outdated Show resolved Hide resolved
@ofedoren
Copy link
Member

Thanks for the updates. What do you think about moving comment to be the last column in the table? I think not so many hosts have comments, thus we could have an empty column between other relevant information. Moreover, this table is expandable, so having an empty column in the middle is not so... attractive. And the issue with autofading still persists for me :sad_panda:

Also, I've played a bit and I guess a simple centered icon looks better:
ScreenShot-1649701397502

But I'd better ask more competent people regarding this: @MariaAga, @Ron-Lavi, @ares

Copy link
Member

@Ron-Lavi Ron-Lavi left a comment

Choose a reason for hiding this comment

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

Nice addition @pkoprda !
I tend to agree with @ofedoren about moving the comment column to be last (after the render_pagelets_for extension points)

Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

Adding a screen of both versions presented here from the system with more data:
hosts1
hosts2

I like the second option more. I also agree we should do something about the auto-hiding of the tooltip. Ideally it should still until hover out. If that's not possible, I'd consider clicking the icon to open the modal.

@MariSvirik any thoughts? We're adding two new columns here, the host owner and the comment.

app/views/hosts/_list.html.erb Outdated Show resolved Hide resolved
Copy link
Member

@Ron-Lavi Ron-Lavi left a comment

Choose a reason for hiding this comment

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

Looks good to me, @ofedoren any other thoughts on this?

@ofedoren
Copy link
Member

[test katello]

@Ron-Lavi Ron-Lavi merged commit ba18463 into theforeman:develop Apr 28, 2022
@Ron-Lavi
Copy link
Member

Thanks @pkoprda @ofedoren !

@pkoprda pkoprda deleted the host-owner branch May 4, 2022 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants