comments: add dtext shortlink option to comment menu.
Add a Shortlink menu option to the comment menu. Clicking this will copy a DText comment shortlink (e.g. `comment #12345`) to the clipboard. You can middle-click or right-click the menu option to get the full URL. The menu option is called Shortlink instead of `comment #1234` because show the full comment ID in the menu makes the menu look too unbalanced. Note that the `navigator.clipboard` API can only be used in a https:// environment. It won't work in non-HTTPS development environments. ngrok can help with this.
This commit is contained in:
@@ -83,36 +83,41 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if policy(comment).update? || policy(comment).reportable? %>
|
||||
<%= render PopupMenuComponent.new do |menu| %>
|
||||
<% if policy(comment).update? %>
|
||||
<%= menu.item do %>
|
||||
<%= link_to edit_comment_path(comment.id), id: "edit_comment_link_#{comment.id}", class: "edit_comment_link" do %>
|
||||
<%= edit_icon %> Edit
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= menu.item do %>
|
||||
<% if comment.is_deleted? %>
|
||||
<%= link_to undelete_comment_path(comment.id), method: :post, remote: true do %>
|
||||
<%= undelete_icon %> Undelete
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to comment_path(comment.id), "data-confirm": "Are you sure you want to delete this comment?", method: :delete, remote: true do %>
|
||||
<%= delete_icon %> Delete
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render PopupMenuComponent.new do |menu| %>
|
||||
<% if policy(comment).update? %>
|
||||
<%= menu.item do %>
|
||||
<%= link_to edit_comment_path(comment.id), id: "edit_comment_link_#{comment.id}", class: "edit_comment_link" do %>
|
||||
<%= edit_icon %> Edit
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if policy(comment).reportable? %>
|
||||
<%= menu.item do %>
|
||||
<%= link_to new_moderation_report_path(moderation_report: { model_type: "Comment", model_id: comment.id }), remote: true do %>
|
||||
<%= flag_icon %> Report
|
||||
<%= menu.item do %>
|
||||
<% if comment.is_deleted? %>
|
||||
<%= link_to undelete_comment_path(comment.id), method: :post, remote: true do %>
|
||||
<%= undelete_icon %> Undelete
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to comment_path(comment.id), "data-confirm": "Are you sure you want to delete this comment?", method: :delete, remote: true do %>
|
||||
<%= delete_icon %> Delete
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if policy(comment).reportable? %>
|
||||
<%= menu.item do %>
|
||||
<%= link_to new_moderation_report_path(moderation_report: { model_type: "Comment", model_id: comment.id }), remote: true do %>
|
||||
<%= flag_icon %> Report
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= menu.item do %>
|
||||
<%= link_to comment_path(comment.id), class: "comment-copy-link" do %>
|
||||
<%= link_icon %> Shortlink
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</menu>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user