* Add a global /post_events page that shows the history of all approvals, disapprovals, flags, appeals, and replacements on a single page. * Redesign the /posts/:id/events page to show all approval, disapproval, flag, appeal, and replacement events for a single post (before it only showed approvals, flags, and appeals). * Remove the replacement history link from the post show page. Replacements are now included in the post events page (closes #4948: Highlighed replacements). * Add /post_approvals/:id and /post_replacements/:id routes (these are used by the "Details" link on the post events page).
107 lines
5.7 KiB
Plaintext
107 lines
5.7 KiB
Plaintext
<div id="c-post-events">
|
|
<div id="a-index">
|
|
<% if @post %>
|
|
<h1>Events: <%= link_to @post.dtext_shortlink, @post %></h1>
|
|
<%= link_to "« Back", post_events_path, class: "text-xs" %>
|
|
<% else %>
|
|
<h1>Events</h1>
|
|
<% end %>
|
|
|
|
<% unless @post %>
|
|
<%= search_form_for(post_events_path) do |f| %>
|
|
<%= f.input :creator_name, label: "User", input_html: { value: params[:search][:creator_name], "data-autocomplete": "user" } %>
|
|
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], "data-autocomplete": "tag-query" } %>
|
|
<%= f.input :model_type, label: "Category", collection: PostEvent.model_types.map { |type| [type.titleize.delete_prefix("Post "), type] }, include_blank: true, selected: params[:search][:model_type] %>
|
|
<%= f.input :order, collection: [%w[Newest event_at], %w[Oldest event_at_asc]], include_blank: true, selected: params[:search][:order] %>
|
|
<%= f.submit "Search" %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%= table_for @post_events, class: "striped autofit mt-4", width: "100%" do |t| %>
|
|
<% t.column "Event", td: { class: "col-expand" } do |event| %>
|
|
<% post = event.post %>
|
|
<% model = event.model %>
|
|
<% creator = event.creator %>
|
|
|
|
<% case event.model_type %>
|
|
<% when "Post" %>
|
|
<%= link_to post.dtext_shortlink, post %> was uploaded by <%= link_to_user creator %>.
|
|
<% when "PostAppeal" %>
|
|
<div class="prose">
|
|
<%= link_to post.dtext_shortlink, post %> was appealed by <%= link_to_user creator %><%= " (#{format_text(model.reason.strip.chomp("."), inline: true)})".html_safe if model.reason.present? %>.
|
|
</div>
|
|
<% when "PostApproval" %>
|
|
<%= link_to post.dtext_shortlink, post %> was approved by <%= link_to_user creator %>.
|
|
<% when "PostDisapproval" %>
|
|
<div class="prose">
|
|
<% if policy(model).can_view_creator? %>
|
|
<%= link_to post.dtext_shortlink, post %> was disapproved by <%= link_to_user creator %> (<%= model.reason.titleize.downcase %><%= ": ".html_safe + format_text(model.message.strip.chomp("."), inline: true) if model.message.present? %>).
|
|
<% else %>
|
|
<%= link_to post.dtext_shortlink, post %> was disapproved (<%= model.reason.titleize.downcase %><%= ": ".html_safe + format_text(model.message.strip.chomp("."), inline: true) if model.message.present? %>).
|
|
<% end %>
|
|
</div>
|
|
<% when "PostFlag" %>
|
|
<div class="prose">
|
|
<% if policy(model).can_view_flagger? %>
|
|
<%= link_to post.dtext_shortlink, post %> was flagged by <%= link_to_user creator %> (<%= format_text(model.reason.strip.chomp("."), inline: true) %>).
|
|
<% else %>
|
|
<%= link_to post.dtext_shortlink, post %> was flagged (<%= format_text(model.reason.strip.chomp("."), inline: true) %>).
|
|
<% end %>
|
|
</div>
|
|
<% when "PostReplacement" %>
|
|
<% if model.old_file_size && model.old_file_ext && model.old_image_width && model.old_image_height && model.file_size && model.file_ext && model.image_width && model.image_height %>
|
|
<%= link_to post.dtext_shortlink, post %> was replaced by <%= link_to_user creator %>
|
|
(<%= external_link_to model.original_url.presence || "none", Source::URL.site_name(model.original_url) || model.original_url %>,
|
|
<%= model.old_file_size.to_formatted_s(:human_size, precision: 4) %> .<%= model.old_file_ext %>, <%= model.old_image_width %>x<%= model.old_image_height %> ->
|
|
<%= external_link_to model.replacement_url, Source::URL.site_name(model.replacement_url) || model.replacement_url %>,
|
|
<%= model.file_size.to_formatted_s(:human_size, precision: 4) %> .<%= model.file_ext %>, <%= model.image_width %>x<%= model.image_height %>).
|
|
<% else %>
|
|
<%= link_to post.dtext_shortlink, post %> was replaced by <%= link_to_user creator %>
|
|
(<%= external_link_to model.original_url.presence || "none", Source::URL.site_name(model.original_url) || model.original_url %> ->
|
|
<%= external_link_to model.replacement_url, Source::URL.site_name(model.replacement_url) || model.replacement_url %>).
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% t.column "Category" do |event| %>
|
|
<%= link_to event.model_type.titleize.delete_prefix("Post "), post_events_path(search: { model_type: event.model_type, **search_params }) %>
|
|
<% end %>
|
|
|
|
<% t.column "User" do |event| %>
|
|
<% if policy(event).can_see_creator? %>
|
|
<%= link_to_user event.creator %> <%= link_to "»", post_events_path(search: { **search_params, creator_name: event.creator.name }) %>
|
|
<% else %>
|
|
<i>hidden</i>
|
|
<% end %>
|
|
<div><%= time_ago_in_words_tagged(event.event_at) %></div>
|
|
<% end %>
|
|
|
|
<% t.column column: "control" do |event| %>
|
|
<%= render PopupMenuComponent.new do |menu| %>
|
|
<% unless @post %>
|
|
<% menu.item do %>
|
|
<%= link_to "Post history", post_post_events_path(event.post) %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% if policy(event).can_see_creator? %>
|
|
<% menu.item do %>
|
|
<%= link_to "User history", post_events_path(search: { creator_name: event.creator.name }) %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% if policy(event).can_see_creator? %>
|
|
<% menu.item do %>
|
|
<%= link_to "Details", event.model %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%= numbered_paginator(@post_events) %>
|
|
</div>
|
|
</div>
|
|
|
|
<%= render "secondary_links" %>
|