From 8f2774075ae39a16594245e26e287d2f503fc9e8 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 26 Jun 2022 15:19:10 -0500 Subject: [PATCH] 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. --- app/views/ai_tags/_preview.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/ai_tags/_preview.html.erb b/app/views/ai_tags/_preview.html.erb index b55eee7e4..37ede2758 100644 --- a/app/views/ai_tags/_preview.html.erb +++ b/app/views/ai_tags/_preview.html.erb @@ -15,7 +15,7 @@ - <% 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" %>