-
Notifications
You must be signed in to change notification settings - Fork 24
Fix compatibility with Administrate v1.0.0 #57
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ ATTRIBUTE_TYPES = { | |
| By default the gem adds the Export button to the partial `views/admin/application/_index_header.html.erb`. But if you have your own Administrate `index` views or override that partial in your application you can add the link manually: | ||
|
|
||
| ```ruby | ||
| link_to('Export', [:export, namespace.to_sym, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], class: 'button') if valid_action?(:export) | ||
| link_to('Export', [:export, namespace.to_sym, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], class: 'button') if existing_action?(resource_class, :export) | ||
| ``` | ||
|
|
||
| Example: | ||
|
|
@@ -78,13 +78,13 @@ Example: | |
| ), | ||
| [:new, namespace.to_sym, page.resource_path.to_sym], | ||
| class: "button", | ||
| ) if valid_action?(:new) && show_action?(:new, new_resource) %> | ||
| ) if existing_action?(resource_class, :new) && authorized_action?(new_resource, :new) %> | ||
|
||
|
|
||
| <%= link_to( | ||
| 'Export', | ||
| [:export, namespace.to_sym, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], | ||
| class: 'button' | ||
| ) if valid_action?(:export) %> | ||
| ) if existing_action?(resource_class, :export) %> | ||
|
||
| </div> | ||
| .... | ||
| ``` | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,6 @@ | |||||
| [:export, namespace, page.resource_name.to_s.pluralize.to_sym, sanitized_order_params(page, :id).to_h.merge(format: :csv)], | ||||||
| class: 'button', | ||||||
| target: '_blank' | ||||||
| ) if valid_action?(:export) && show_action?(:export, resource_name) %> | ||||||
| ) if existing_action?(resource_class, :export) && authorized_action?(resource_name, :export) %> | ||||||
|
||||||
| ) if existing_action?(resource_class, :export) && authorized_action?(resource_name, :export) %> | |
| ) if accessible_action?(resource_name, :export) %> |
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.
README: the manual Export link now uses
existing_action?(resource_class, :export)but the shipped_index_headerpartial also checks authorization. To avoid showing an Export button to users who aren’t allowed to export, align the README snippet with the view’s authorization check (or document why the authorization check is intentionally omitted).