docbrown/app/views/moderations/actions_panel.html.erb
Rajat Talesra 992ced1908
Tag moderation UI changes (#19906)
* Basic add remove functionality with few tests

* Updated cypress test and added more unit tests

* Rename display ads vars in the views (#19877)

* Renamed display_ads vars to billboards

* Rename local vars in the feed view

* Renamed display-ad in the comment

Co-authored-by: Rajat Talesra <rajattalesra4914@gmail.com>

* Renamed variables in the views

---------

Co-authored-by: Rajat Talesra <rajattalesra4914@gmail.com>

* Update js-routes to version 2.2.7 (#19883)

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>

* add field for billboard target geolocations, with unit and e2e tests (#19855)

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Co-authored-by: Duke Greene <dukegreene@gmail.com>
Co-authored-by: PJ <pj@forem.com>
Co-authored-by: Anna Buianova <lightallloy@gmail.com>
Co-authored-by: Mac Siri <mac@forem.com>
Co-authored-by: zhangted <tedcbook@gmail.com>
Co-authored-by: Josh Klar <jklar@forem.com>

* Added autocomplete value off (#19882)

* Bust cache of organization page when new member is added (#19861)

* Remove unused freezeScrolling (#19808)

* Remove unused freezeScrolling

* chore: try see if this helps to skip the flakey test that wasn't being skipped

* chore: try see if this helps to skip the flakey test that wasn't being skipped

* oops: revert the gemfile changes

---------

Co-authored-by: Mai Irie <mai@forem.com>
Co-authored-by: Mac Siri <mac@forem.com>
Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>

* ci: Allow workflow_dispatch runs to log in to GHCR. (#19885)

* ci: Fix base image builder... the right way... (#19889)

* Update postcss to version 8.4.27 (#19888)

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>

* Replace uses of toBeDefined with toExist  (#19862)

* Replaced toBeDefined with toExist

* Revert db changes

* Rename display ads to billboards: css and js code (#19887)

* Renamed js vars/css names

* Renamed display_ads to billboards in js functions, variables, components

* [ruby] Update sidekiq-unique-jobs 7.1.29 → 7.1.30 (patch) (#19902)

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>

* Update oj to version 3.15.1 (#19901)

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>

* Updated failing cypress test

* Removed commented code

* Attempt at fixing tests

* Fixed failing tests

* Added more tests

* Basic color and design changes part -1

* Disable/Enable buttons correctly

* Various design updates in Tag adjustement mod UI

* I18N and documentation

* Updated mod panel

* Fixed mod related cypress tests

* Minor design fixes

* Dark mode designs

* Test update

* Mod UI with some bugs

* Updated/simplified code fully-working

* Updated tests

* Added more tests

* Accessibility improvements

* hr line code fix

* Close mod icon bug fix

* Nit fixes

* Design fixes as suggested by Anuj.

* Design fixes

* Dark mode file usage

* Design fixes

* Nit fixes

---------

Co-authored-by: Anna Buianova <lightallloy@gmail.com>
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Co-authored-by: Duke Greene <dukegreene@gmail.com>
Co-authored-by: PJ <pj@forem.com>
Co-authored-by: Mac Siri <mac@forem.com>
Co-authored-by: zhangted <tedcbook@gmail.com>
Co-authored-by: Josh Klar <jklar@forem.com>
Co-authored-by: Joshua Wehner <joshua@forem.com>
Co-authored-by: Mai Irie <mai@forem.com>
Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2023-08-24 00:31:21 +05:30

315 lines
17 KiB
Text

<% title t("views.moderations.actions.meta.title", title: @moderatable.title) %>
<% cache(release_adjusted_cache_key("mod-styling")) do %>
<style>
<%= Rails.application.assets["moderators.css"].to_s.html_safe %>
</style>
<% end %>
<%= javascript_packs_with_chunks_tag "actionsPanel", defer: true %>
<% author_suspended = @moderatable.user.suspended? %>
<% author_username = @moderatable.username %>
<div class="container mod-container">
<header class="top-header">
<h1><%= t("views.moderations.actions.heading") %></h1>
<h2><%= t("views.moderations.actions.subtitle") %></h2>
<button class="crayons-btn crayons-btn--secondary crayons-btn--icon-rounded close-actions-panel hidden" type="button" title="<%= t("views.moderations.actions.close") %>">
<%= crayons_icon_tag(:x, title: t("views.moderations.actions.close")) %>
</button>
</header>
<div class="reactions-container">
<div class="thumb-reactions-container">
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "thumbsup") ? "reacted" : "" %>"
data-reactable-id="<%= @moderatable.id %>"
data-category="thumbsup"
data-reactable-type="<%= @moderatable.class.name %>">
<div class="reaction-button-circle">
<%= crayons_icon_tag("twemoji/thumb-up", native: true, title: t("views.moderations.actions.thumb_up")) %>
<%= crayons_icon_tag(:checkmark, class: "reaction-checkmark", title: t("views.moderations.actions.checkmark")) %>
</div>
<span class="vote-text"><%= t("views.moderations.actions.vote_up") %></span>
</button>
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "thumbsdown") ? "reacted" : "" %>"
data-reactable-id="<%= @moderatable.id %>"
data-category="thumbsdown"
data-reactable-type="<%= @moderatable.class.name %>">
<div class="reaction-button-circle">
<%= crayons_icon_tag("twemoji/thumb-down", native: true, title: t("views.moderations.actions.thumb_down")) %>
<%= crayons_icon_tag(:checkmark, class: "reaction-checkmark", title: t("views.moderations.actions.checkmark")) %>
</div>
<span class="vote-text"><%= t("views.moderations.actions.vote_down") %></span>
</button>
</div>
<button class="reaction-vomit-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "vomit") ? "reacted" : "" %>"
data-reactable-id="<%= @moderatable.id %>"
data-category="vomit"
data-reactable-type="<%= @moderatable.class.name %>">
<%= crayons_icon_tag("twemoji/suspicious", native: true, class: "mr-1", title: "Suspicious...") %>
<span></span>
<%= crayons_icon_tag(:checkmark, class: "vomit-checkmark", title: t("views.moderations.actions.checkmark")) %>
</button>
<% if policy(@moderatable).revoke_publication? %>
<button
class="c-btn c-btn--primary c-btn--destructive w-100 my-4 <%= is_mod_center == "true" ? "hidden" : "" %>"
id="unpublish-article-btn"
data-article-id="<%= @moderatable.id %>"
data-author-username="<%= author_username %>"
data-article-slug="<%= @moderatable.slug %>"
data-modal-content-selector="#unpublish-post-modal">
<%= t("views.moderations.actions.unpublish") %>
</button>
<% end %>
<% if policy(@moderatable).toggle_featured_status? %>
<button
class="c-btn c-btn--primary w-100"
id="feature-article-btn"
data-article-featured="<%= @moderatable.featured %>"
data-article-id="<%= @moderatable.id %>"
data-article-author="<%= author_username %>"
data-article-slug="<%= @moderatable.slug %>">
<%= @moderatable.featured ? t("views.moderations.actions.unfeature") : t("views.moderations.actions.feature") %>
</button>
<div class="additional-subtext-section py-4 pt-2">
<% recent_featured_count = Article.featured.published.where(published_at: 1.day.ago..).size %>
<%= t("views.moderations.actions.featured_past_day", count: recent_featured_count) %>
</div>
<% end %>
<a href="<%= URL.url %>/community-moderation#using-the-quick-reactions-to-moderate-content" target="_blank" rel="noopener">
<span class="additional-subtext-section py-3">
<%= t("views.moderations.actions.how") %>
</span>
</a>
</div>
<div class="other-things-container">
<header class="other-things">
<h3>
<%= t("views.moderations.actions.other") %>
</h3>
</header>
<%# Checking if the user should see the "Adjust tags" dropdown %>
<% if policy(@moderatable).allow_tag_adjustment? %>
<button id="adjust-tags-button" aria-haspopup="true" aria-expanded="false" aria-controls="adjust-tags-options" class="other-things-btn adjust-tags" type="button" data-other-things-type="adjust-tags" aria-label="<%= t("views.moderations.actions.adjust.aria_label") %>">
<div class="label-wrapper">
<div class="icon circle centered-icon">
<%= crayons_icon_tag("mod-filled", title: t("views.moderations.actions.adjust.icon")) %>
</div>
<header>
<h2><%= t("views.moderations.actions.adjust.heading") %></h2>
<h3><%= t("views.moderations.actions.adjust.subtitle") %></h3>
</header>
</div>
<div class="toggle-chevron-container">
<%= crayons_icon_tag("arrow-down-fill", title: t("views.moderations.actions.toggle")) %>
</div>
</button>
<div id="adjust-tags-options" class="adjust-tags-options dropdown-options hidden">
<% @moderatable.tags.each do |tag| %>
<% moderatable_tag = @tag_moderator_tags.pluck(:name).include?(tag.name) || policy(@moderatable).can_adjust_any_tag? %>
<button
id="remove-tag-button-<%= tag.name %>"
class="adjustable-tag" type="button"
data-adjustment-type="subtract"
data-tag-name="<%= tag.name %>"
data-article-id="<%= @moderatable.id %>"
title="<%= moderatable_tag ? "" : "Not allowed to adjust this tag" %>">
<span class="num-sign">#</span><%= tag.name %>
<% if moderatable_tag %>
<div id="remove-tag-icon-<%= tag.name %>" class="circle centered-icon remove-icon hidden">
<%= crayons_icon_tag(:minus, title: t("views.moderations.actions.adjust.remove")) %>
</div>
<% end %>
</button>
<% if moderatable_tag %>
<div id="remove-tag-container-<%= tag.name %>" class="hidden">
<div id="adjustment-reason-container-<%= tag.name %>" class="reason-container">
<textarea class="crayons-textfield" placeholder="<%= t("views.moderations.actions.adjust.reason.remove_tag") %>" id="tag-removal-reason-<%= tag.name %>"></textarea>
<div class="flex gap-3 align-items-stretch">
<button class="w-100 c-btn c-btn--primary c-btn--destructive" id="remove-tag-submit-<%= tag.name %>"><%= t("views.moderations.actions.adjust.remove") %></button>
<button class="w-100 c-btn" id="cancel-remove-tag-button-<%= tag.name %>" type="button"><%= t("views.moderations.actions.adjust.cancel") %></button>
</div>
</div>
</div>
<% end %>
<% end %>
<% if @moderatable.tag_list.size < Article::MAX_TAG_LIST_SIZE %>
<% if policy(@moderatable).can_adjust_any_tag? %>
<hr />
<button id="add-tag-button" data-testid="add-tag-button" class="add-tag" type="button">
<%= t("views.moderations.actions.adjust.add_tag.button_text") %>
<div class="circle centered-icon add-icon">
<%= crayons_icon_tag(:plus, title: t("views.moderations.actions.adjust.add_tag.icon")) %>
</div>
</button>
<div id="add-tag-container" class="hidden">
<div id="add-reason-container" class="reason-container">
<div class="add-tag-header"><%= t("views.moderations.actions.adjust.add_tag.header") %></div>
<input id="admin-add-tag" class="crayons-textfield mt-3" type="text" autocomplete="off" placeholder="<%= t("views.moderations.actions.adjust.add_placeholder") %>" data-article-id="<%= @moderatable.id %>" data-adjustment-type="plus">
<textarea id="tag-add-reason" class="crayons-textfield mt-3" placeholder="<%= t("views.moderations.actions.adjust.reason.add_tag") %>"></textarea>
<div class="flex gap-3">
<button class="w-100 c-btn c-btn--primary" disabled="disabled" id="tag-add-submit"><%= t("views.moderations.actions.adjust.add") %></button>
<button class="w-100 c-btn" id="cancel-add-tag-button" type="button"><%= t("views.moderations.actions.adjust.cancel") %></button>
</div>
</div>
</div>
<% else %>
<% count = 0 %>
<% @tag_moderator_tags.each do |tag| %>
<% if !@moderatable.tags.pluck(:name).include?(tag.name) %>
<% count += 1 %>
<% end %>
<% end %>
<% if count > 0 %>
<hr />
<% end %>
<% @tag_moderator_tags.each do |tag| %>
<% if !@moderatable.tags.pluck(:name).include?(tag.name) %>
<button
id="add-tag-button-<%= tag.name %>"
class="adjustable-tag add-tag" type="button"
data-adjustment-type="plus"
data-tag-name="<%= tag.name %>"
data-article-id="<%= @moderatable.id %>">
<span class="num-sign">#</span><%= tag.name %>
<div id="add-tag-icon-<%= tag.name %>" class="circle centered-icon add-icon">
<%= crayons_icon_tag(:plus, title: t("views.moderations.actions.adjust.add")) %>
</div>
</button>
<div id="add-tag-container-<%= tag.name %>" class="hidden">
<div id="add-reason-container-<%= tag.name %>" class="reason-container">
<textarea id="tag-add-reason-<%= tag.name %>" class="crayons-textfield mt-3" placeholder="<%= t("views.moderations.actions.adjust.reason.add_tag") %>"></textarea>
<div class="flex gap-3">
<button class="w-100 c-btn c-btn--primary" id="tag-add-submit-<%= tag.name %>"><%= t("views.moderations.actions.adjust.add") %></button>
<button class="w-100 c-btn" id="cancel-add-tag-button-<%= tag.name %>" type="button"><%= t("views.moderations.actions.adjust.cancel") %></button>
</div>
</div>
</div>
<% end %>
<% end %>
<% end %>
<hr />
<% else %>
<hr />
<span class="max-tags-text">
<%= crayons_icon_tag(:info, title: t("views.moderations.actions.adjust.maximum_tags.icon"), width: 18, height: 18) %>
<span>
<%= t("views.moderations.actions.adjust.maximum_tags.text") %>
</span>
</span>
<% end %>
<a href="<%= URL.url %>/tag-moderation#how-to-remove-or-add-tags" target="_blank" rel="noopener">
<span class="additional-subtext-section py-3">
<%= t("views.moderations.actions.how") %>
</span>
</a>
</div>
<% end %>
<% @rating_vote = RatingVote.where(article_id: @moderatable.id, user_id: current_user.id).first %>
<button aria-haspopup="true" aria-expanded="false" aria-controls="set-experience-options" class="other-things-btn set-experience" type="button" data-other-things-type="set-experience" aria-label="<%= t("views.moderations.actions.experience.aria_label") %>">
<div class="label-wrapper">
<div class="icon circle centered-icon">
<%= crayons_icon_tag(:book, title: t("views.moderations.actions.experience.icon")) %>
</div>
<header>
<h2><%= t("views.moderations.actions.experience.heading") %></h2>
<h3><%= t("views.moderations.actions.experience.subtitle") %></h3>
</header>
</div>
<div class="toggle-chevron-container">
<%= crayons_icon_tag("arrow-down-fill", title: t("views.moderations.actions.toggle")) %>
</div>
</button>
<div id="set-experience-options" class="set-experience-options dropdown-options hidden">
<% rating_hash = { "Expert" => [10, 5], "Advanced" => [8, 4], "Mid-level" => [5, 3], "Beginner" => [3, 2], "Novice" => [1, 1] } %>
<% current_rating_value = @rating_vote.rating.round(0) if @rating_vote %>
<% rating_hash.each do |rating_name, rating_level| %>
<button
value="<%= rating_level[0] %>"
name="rating_vote_<%= rating_level[0] %>"
id="js__rating__vote__<%= rating_level[0] %>"
class="level-rating-button <%= " selected" if current_rating_value == rating_level[0] %>"
data-user-id="<%= current_user.id %>"
data-article-id="<%= @moderatable.id %>"
data-group="experience_level">
<div class="level-rating-content">
<span class="level-rating-number"><%= rating_level[1] %></span>
<span class="level-rating-text"><%= t("views.moderations.actions.experience.level.#{rating_name}") %></span>
</div>
<%= crayons_icon_tag(:checkmark, title: t("views.moderations.actions.checkmark")) %>
</button>
<% end %>
<a href="<%= URL.url %>/community-moderation#how-to-rate-the-experience-level-of-a-post" target="_blank" rel="noopener">
<span class="additional-subtext-section py-3">
<%= t("views.moderations.actions.how") %>
</span>
</a>
</div>
<button
aria-haspopup="true"
aria-expanded="false"
aria-controls="admin-action-options"
class="other-things-btn admin-action <%= is_mod_center == "true" ? "hidden" : "" %>"
type="button"
data-other-things-type="admin-action"
aria-label="<%= t("views.moderations.actions.admin.aria_label") %>">
<div class="label-wrapper">
<div class="icon circle centered-icon">
<%= inline_svg_tag("admin.svg", aria_hidden: true, title: t("views.moderations.actions.admin.icon")) %>
</div>
<header>
<h2><%= t("views.moderations.actions.admin.heading") %></h2>
<h3><%= t("views.moderations.actions.admin.subtitle", user: author_username) %></h3>
</header>
</div>
<div class="toggle-chevron-container">
<%= inline_svg_tag("arrow-down-fill.svg", aria: true, title: t("views.moderations.actions.toggle")) %>
</div>
</button>
<div id="admin-action-options" class="admin-action-options dropdown-options mt-4 hidden">
<button
type="button"
id="toggle-flag-user-modal"
class="c-btn <%= @author_flagged ? "" : "c-btn--destructive" %> align-center fs-s"
data-modal-title="<%= @author_flagged ? "Unflag" : "Flag" %> <%= author_username %>"
data-modal-size="small"
data-modal-content-selector="#<%= @author_flagged ? "unflag" : "flag" %>-user-modal-content">
<% if @author_flagged %>
<%= t("views.moderations.actions.unflag", username: author_username) %>
<% else %>
<%= t("views.moderations.actions.flag", username: author_username) %>
<% end %>
</button>
<% if policy(@moderatable).can_perform_moderator_actions? %>
<button
type="button"
id="<%= author_suspended ? "unsuspend" : "suspend" %>-user-btn"
class="js-suspend-unsuspend-flow-btn c-btn <%= author_suspended ? "" : "c-btn--destructive" %> align-center fs-s"
data-modal-title="<%= t("views.moderations.actions.suspend.#{author_suspended ? 'unsuspend' : 'suspend'}_title", username: author_username) %>"
data-modal-size="small" data-modal-content-selector="#<%= author_suspended ? "unsuspend" : "suspend" %>-modal-content" data-username="<%= author_username %>">
<%= t("views.moderations.actions.suspend.#{author_suspended ? 'unsuspend' : 'suspend'}_user", username: author_username) %>
</button>
<button
type="button"
id="unpublish-all-posts-btn"
class="c-btn c-btn--destructive align-center fs-s"
data-modal-title="<%= t("views.moderations.actions.unpublish_all.title") %>"
data-modal-size="small"
data-modal-content-selector="#unpublish-all-posts"
data-username="<%= author_username %>">
<%= t("views.moderations.actions.unpublish_all.button", username: author_username) %>
</button>
<% end %>
</div>
</div>
</div>