-
Notifications
You must be signed in to change notification settings - Fork 14
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
Clone Reports #5011
Clone Reports #5011
Conversation
@ttoomey and @dtgreiner if this looks like a good pattern for the action menu I'll add it to |
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.
looks good, thanks!
- items = [{ link_to: { path: "#{report.index_path}?#{{filters: filter}.to_query}"}, class: ['btn', 'btn-sm', 'btn-secondary', 'btn-icon-only'], icon: :copy, label: 'New report from this universe'}] | ||
- unless report.running? | ||
- items << { link_to: { path: report.show_path, method: :delete, data: {confirm: "Are you sure you want to delete this report?"}}, class: ['btn', 'btn-sm', 'btn-danger', 'btn-icon-only'], label: 'Delete report'} | ||
= render 'common/action_menu_or_button', items: items |
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 think if we want this to become a pervasive pattern, it's worth it to wrap in a helper method. I think this has advantages over calling render directly:
- the params to the view are formalized (unlike render, which has no formal params)
- it's clear what partial is called (it's not relative to current controller)
- easier to swap out the rendering for something else that's more performant (a view component or content tags)
- more discoverable(?)
- could let us split the view in to 'action_menu' and 'action_button' to keep partials single-purpose and more maintainable
module ApplicationHelper
# ...
def action_menu_or_button(items:)
return if items.empty?
return render('/common/action_menu', items: items) if items.many?
render('/common/action_button', item: items.sole)
end
= render 'common/action_menu_or_button', items: items | |
= action_menu_or_button(items: items) |
Merging this PR
Description
Type of change
Checklist before requesting review