-
Notifications
You must be signed in to change notification settings - Fork 982
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
Conversation
Issues: #22049 |
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.
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.
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 |
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.
Ok, I guess this is an overall improvement. A few minor comments inline (same apply to the second function as well).
app/helpers/audits_helper.rb
Outdated
base = audit.locations.authorized(:view_locations) | ||
authorizer = Authorizer.new(User.current, base) | ||
if base.empty? | ||
_('none') |
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 may also be "all" if the auditable isn't taxable or has taxonomies, we might want to also accommodate that case?
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, you can return _('none') if base.empty?
before you build the authorizer and reduce the nesting and unneeded creation.
app/helpers/audits_helper.rb
Outdated
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 |
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 very long line, maybe break it into a do...end
block so it 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.
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.
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? |
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.
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.
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.
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.
repushed with extracted "all" check into separate method |
app/helpers/audits_helper.rb
Outdated
|
||
def affected_taxonomies(audit) | ||
begin | ||
return _('all') unless audit.auditable_type.constantize.included_modules.include?(Taxonomix) |
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 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
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.
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
app/helpers/audits_helper.rb
Outdated
def affected_taxonomies(audit) | ||
begin | ||
return _('all') unless audit.auditable_type.constantize.included_modules.include?(Taxonomix) | ||
rescue => e |
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.
When might we get an exception here?
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.
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> |
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.
Note that this leads to all audits by this user, not the user itself, not sure if this was intentional or not
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 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
app/helpers/audits_helper.rb
Outdated
end.to_sentence.html_safe | ||
end | ||
|
||
def affected_taxonomies(audit) |
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 function name is misleading
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.
please suggest better one :-) how about "all_affected_taxonomies_string"?
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.
Thanks @ares !
LGTM. |
This is a follow up of #5359
before
after
@tbrisker and @Rohoover, your comments would be appreciated, I'd like to get this into 1.18