ai tags: disable "Add" button if user doesn't have permission to edit the post.

Disable the "Add" button on the /ai_tags page when the current user doesn't have
permission to edit the post, for example if they're not logged in.
This commit is contained in:
evazion
2022-06-26 15:19:10 -05:00
parent f35bc60e51
commit 8f2774075a

View File

@@ -15,7 +15,7 @@
</div>
</div>
<% if ai_tag.post.nil? %>
<% if ai_tag.post.nil? || !policy(ai_tag).update? %>
<%= button_to "Add", nil, class: "button-primary button-sm", disabled: true %>
<% elsif ai_tag.post_tagged? %>
<%= button_to "Remove", tag_ai_tag_path(media_asset_id: ai_tag.media_asset, tag_id: ai_tag.tag), remote: true, method: :put, params: { mode: "remove" }, class: "button-outline-danger button-sm" %>