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

Refs #22049 - improve metadata usability #5378

Merged
merged 1 commit into from
Apr 4, 2018

Conversation

ares
Copy link
Member

@ares ares commented Mar 29, 2018

This is a follow up of #5359

before
screenshot_20180329_152522

after
screenshot_20180329_152049
screenshot_20180329_152040

@tbrisker and @Rohoover, your comments would be appreciated, I'd like to get this into 1.18

@theforeman-bot
Copy link
Member

Issues: #22049

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

tbh, i'm not sure I understand the workflow this is meant to support.
When viewing an audit, why would the next step be editing one of the location affected or the user who made the change? It might make some sense if we had show pages for those objects that provide further information, but i am not sure how much this is needed, and it significantly increases the code complexity.

@ares
Copy link
Member Author

ares commented Apr 1, 2018

As a User, if I want to see information about org/loc in which the event happend I only can see that on edit page. If we had show pages, I'd link to those. It's simply "give me more information" about the resource. But at least from edit page, once can find out what other resources are assigned.

I don't understand the code complexity concern. The link construction is the same as with any other link. Methods for generating all links contain if condition to nicely display the information, that there's no org/loc to be displayed, instead of white space. IMHO better user experience.

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Ok, I guess this is an overall improvement. A few minor comments inline (same apply to the second function as well).

base = audit.locations.authorized(:view_locations)
authorizer = Authorizer.new(User.current, base)
if base.empty?
_('none')
Copy link
Member

Choose a reason for hiding this comment

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

This may also be "all" if the auditable isn't taxable or has taxonomies, we might want to also accommodate that case?

Copy link
Member

Choose a reason for hiding this comment

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

also, you can return _('none') if base.empty? before you build the authorizer and reduce the nesting and unneeded creation.

if base.empty?
_('none')
else
base.map { |location| link_to_if_authorized location.name, hash_for_edit_location_path(location).merge(:auth_object => location, :permission => 'edit_locations', :authorizer => authorizer) }.to_sentence.html_safe
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 very long line, maybe break it into a do...end block so it is easier to read?

Copy link

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `S...
Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `Style/TrailingCommaInArrayLiteral` and/or `Style/TrailingCommaInHashLiteral` instead.
(obsolete configuration found in .rubocop.yml, please update it)
The `Performance/HashEachMethods` cop has been removed since it no longer provides performance benefits in modern rubies.

@ares
Copy link
Member Author

ares commented Apr 3, 2018

Thanks @tbrisker, all comments addressed. we display all now in case Taxonomix is not included in the audited resource. I also added missing org/loc association into API template, that should have been added when we started to display the metadata. Could you please take another look?

Copy link

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `S...
Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `Style/TrailingCommaInArrayLiteral` and/or `Style/TrailingCommaInHashLiteral` instead.
(obsolete configuration found in .rubocop.yml, please update it)
The `Performance/HashEachMethods` cop has been removed since it no longer provides performance benefits in modern rubies.

Copy link

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `S...
Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `Style/TrailingCommaInArrayLiteral` and/or `Style/TrailingCommaInHashLiteral` instead.
(obsolete configuration found in .rubocop.yml, please update it)
The `Performance/HashEachMethods` cop has been removed since it no longer provides performance benefits in modern rubies.

@ares
Copy link
Member Author

ares commented Apr 3, 2018

repushed with extracted "all" check into separate method


def affected_taxonomies(audit)
begin
return _('all') unless audit.auditable_type.constantize.included_modules.include?(Taxonomix)
Copy link
Member

Choose a reason for hiding this comment

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

This will return all for hosts and taxonomies, since they don't include Taxonomix, and might be true for other resources as well that have different ways of linking to taxonomies

Copy link
Member Author

Choose a reason for hiding this comment

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

is there a better way to detect on your mind? I think it's be better if we don't display all at all, there's no proper link between audit and taxonomies in this case and it might be confusing if people search for audits using organization attribute, they would expect to see it even if they search for organization = Default but the audit only appears if we search for null? organization

def affected_taxonomies(audit)
begin
return _('all') unless audit.auditable_type.constantize.included_modules.include?(Taxonomix)
rescue => e
Copy link
Member

Choose a reason for hiding this comment

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

When might we get an exception here?

Copy link
Member Author

Choose a reason for hiding this comment

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

if we have audit for resource that no longer exists (plugin uninstallation, refactoring, etc), we can't rely on constantize to succeed

</div>
<div class="row">
<strong class="col-md-2"><%= _("User Name:")%></strong>
<div class="col-md-10"><%= @audit.username %></div>
<div class="col-md-10"><%= audit_user(@audit) %></div>
Copy link
Member

Choose a reason for hiding this comment

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

Note that this leads to all audits by this user, not the user itself, not sure if this was intentional or not

Copy link
Member Author

Choose a reason for hiding this comment

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

it is, because it's the same thing we link on audits list, I though it would be better to be consistent and change the helper when we improve the UI

end.to_sentence.html_safe
end

def affected_taxonomies(audit)
Copy link
Member

Choose a reason for hiding this comment

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

the function name is misleading

Copy link
Member Author

Choose a reason for hiding this comment

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

please suggest better one :-) how about "all_affected_taxonomies_string"?

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Thanks @ares !

@tbrisker tbrisker added this to the 1.18.0 milestone Apr 4, 2018
@tbrisker tbrisker merged commit af09d63 into theforeman:develop Apr 4, 2018
@Rohoover
Copy link

Rohoover commented Apr 9, 2018

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants