Add filters to /mod (#20179)
* Add filters to /mod * Adjust cypress to look for proper text * Adjust cypress to be less sensitive
This commit is contained in:
parent
8268a59ae5
commit
456a5e61d2
9 changed files with 91 additions and 25 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
.mod-index-header {
|
||||
@media (min-width: $breakpoint-m) {
|
||||
padding: var(--su-2) 0 var(--su-6);
|
||||
padding: var(--su-2) 0 var(--su-2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,17 +133,24 @@
|
|||
|
||||
.iframes-container {
|
||||
display: flex;
|
||||
height: 650px;
|
||||
height: 780px;
|
||||
width: 100%;
|
||||
background-color: var(--base-0);
|
||||
max-height: calc(100vh - 180px);
|
||||
|
||||
.article-iframe {
|
||||
width: 100%;
|
||||
height: 650px; // height is arbitrary, will be removed for modal-esque view
|
||||
height: 780px; // height is arbitrary, will be removed for modal-esque view
|
||||
max-height: calc(100vh - 180px);
|
||||
border: 2px solid var(--base-40);
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.actions-panel-iframe {
|
||||
width: 60%;
|
||||
height: 650px; // height is arbitrary, will be removed for modal-esque view
|
||||
width: 40%;
|
||||
height: 780px; // height is arbitrary, will be removed for modal-esque view
|
||||
max-height: calc(100vh - 180px);
|
||||
border: 2px solid var(--base-40);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
class ModerationsController < ApplicationController
|
||||
after_action :verify_authorized
|
||||
|
||||
SCORE_MIN = -10
|
||||
SCORE_MAX = 5
|
||||
|
||||
JSON_OPTIONS = {
|
||||
only: %i[id title published_at cached_tag_list path],
|
||||
include: {
|
||||
|
|
@ -12,9 +15,17 @@ class ModerationsController < ApplicationController
|
|||
skip_authorization
|
||||
return unless current_user&.trusted?
|
||||
|
||||
@feed = params[:state] == "latest" ? "latest" : "inbox"
|
||||
articles = Article.published
|
||||
.order(published_at: :desc).limit(70)
|
||||
articles = articles.cached_tagged_with(params[:tag]) if params[:tag].present?
|
||||
if @feed == "inbox"
|
||||
articles = articles
|
||||
.joins("LEFT OUTER JOIN reactions ON articles.id = reactions.reactable_id AND
|
||||
reactions.reactable_type = 'Article' AND reactions.user_id = #{current_user.id}")
|
||||
.where("articles.score >= ? AND articles.score <= ?", SCORE_MIN, SCORE_MAX)
|
||||
.where(reactions: { id: nil })
|
||||
end
|
||||
if params[:state] == "new-authors"
|
||||
articles = articles.where("nth_published_by_author > 0 AND nth_published_by_author < 4 AND published_at > ?",
|
||||
7.days.ago)
|
||||
|
|
|
|||
|
|
@ -77,11 +77,13 @@
|
|||
<%= 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>
|
||||
<% unless is_mod_center %>
|
||||
<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>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="other-things-container">
|
||||
|
|
|
|||
|
|
@ -5,16 +5,22 @@
|
|||
<div id="moderation-page" aria-hidden="true"></div>
|
||||
|
||||
<% if current_user&.trusted? %>
|
||||
<div class="crayons-layout crayons-layout--2-cols" id="mod-center">
|
||||
<div class="crayons-layout crayons-layout--2-cols" style="max-width: 1700px" id="mod-center">
|
||||
<%= render "moderations/mod_sidebar_left" %>
|
||||
<main class="mod-index-container articles-list crayons-layout__content">
|
||||
|
||||
<header class="mod-index-header hidden m:block">
|
||||
<h2 class="crayons-subtitle-1">
|
||||
<%= @tag ? "##{@tag.accessible_name}" : t("views.moderations.all") %>
|
||||
</h2>
|
||||
<div class="crayons-subtitle-1 flex">
|
||||
<% if @tag %>
|
||||
<span class="p-4 py-2">#<%= @tag.accessible_name %>:</span>
|
||||
<% end %>
|
||||
<a class="crayons-navigation__item p-4 py-2 <%= "crayons-navigation__item--current" if @feed == "inbox" %>" href="<%= request.path %>?state=inbox"><%= t("views.moderations.feed.inbox_filter") %></a>
|
||||
<a class="crayons-navigation__item p-4 py-2 ml-2 <%= "crayons-navigation__item--current" if @feed == "latest" %>" href="<%= request.path %>?state=latest"><%= t("views.moderations.feed.latest_filter") %></a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="crayons-notice mb-4 border-2 border-solid border-accent-brand">
|
||||
<%= t("views.moderations.feed.#{@feed}_html") %>
|
||||
</div>
|
||||
<section class="mod-index-body">
|
||||
<div class="mod-index-list-header lh-tight hidden m:grid">
|
||||
<h2 class="mod-index-list-header__label"><%= t("views.moderations.post") %></h2>
|
||||
|
|
|
|||
|
|
@ -141,7 +141,11 @@ en:
|
|||
featured_past_day:
|
||||
one: '%{count} post from the past day is featured.'
|
||||
other: '%{count} posts from the past day are featured.'
|
||||
all: All topics
|
||||
feed:
|
||||
inbox_filter: Inbox
|
||||
latest_filter: Latest
|
||||
inbox_html: <strong>Inbox</strong> is a chronological list of posts which have not yet been scrutinized by multiple mods or members.
|
||||
latest_html: <strong>Latest</strong> shows all posts in chronological order regardless of whether they have been scrutinized.
|
||||
article:
|
||||
approved: Approved
|
||||
author_id: Author ID
|
||||
|
|
@ -164,7 +168,7 @@ en:
|
|||
user_warned: User warned
|
||||
view_details: View details
|
||||
aside:
|
||||
all: All topics
|
||||
all: All tags
|
||||
code_of_conduct: Code of Conduct
|
||||
external: External link
|
||||
feedback:
|
||||
|
|
|
|||
|
|
@ -140,7 +140,11 @@ fr:
|
|||
featured_past_day:
|
||||
one: '%{count} des articles de la journée précédente sont mis en avant.'
|
||||
other: '%{count} des articles de la journée précédente sont mis en avant.'
|
||||
all: Tous les sujets
|
||||
feed:
|
||||
inbox_filter: Inbox
|
||||
latest_filter: Récent
|
||||
inbox_html: <strong>Inbox</strong> est une liste chronologique des publications qui n'ont pas encore été examinées par plusieurs modérateurs ou membres.
|
||||
latest_html: <strong>Récent</strong> montre tous les posts dans l'ordre chronologique, indépendamment de s'ils ont été examinés ou non.
|
||||
article:
|
||||
approved: Approuvée
|
||||
author_id: Identifiant de l'auteur
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ describe('Adjust post tags', () => {
|
|||
.should('not.exist');
|
||||
|
||||
cy.getIframeBody('.actions-panel-iframe').within(() => {
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click();
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click({
|
||||
force: true,
|
||||
});
|
||||
cy.findByTestId('add-tag-button').click();
|
||||
cy.findByPlaceholderText('Add a tag').type('tag2');
|
||||
cy.findByPlaceholderText('Reason to add tag (optional)').type(
|
||||
|
|
@ -38,7 +40,9 @@ describe('Adjust post tags', () => {
|
|||
});
|
||||
|
||||
cy.getIframeBody('.actions-panel-iframe').within(() => {
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click();
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click({
|
||||
force: true,
|
||||
});
|
||||
cy.findByText('tag1').click();
|
||||
cy.findByPlaceholderText('Reason to remove tag (optional)').type(
|
||||
'testing',
|
||||
|
|
@ -141,7 +145,9 @@ describe('Adjust post tags', () => {
|
|||
.should('not.exist');
|
||||
|
||||
cy.getIframeBody('.actions-panel-iframe').within(() => {
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click();
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click({
|
||||
force: true,
|
||||
});
|
||||
cy.findByTestId('add-tag-button').click();
|
||||
cy.findByPlaceholderText('Add a tag').type('tag2');
|
||||
cy.findByPlaceholderText('Reason to add tag (optional)').type(
|
||||
|
|
@ -163,7 +169,9 @@ describe('Adjust post tags', () => {
|
|||
});
|
||||
|
||||
cy.getIframeBody('.actions-panel-iframe').within(() => {
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click();
|
||||
cy.findByRole('button', { name: 'Open adjust tags section' }).click({
|
||||
force: true,
|
||||
});
|
||||
|
||||
cy.findByText('tag1').click();
|
||||
cy.findByPlaceholderText('Reason to remove tag (optional)').type(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe('Moderation navigation', () => {
|
|||
cy.findByRole('navigation', {
|
||||
name: 'Mod center inbox navigation',
|
||||
}).within(() => {
|
||||
cy.findByRole('link', { name: 'All topics' }).should(
|
||||
cy.findByRole('link', { name: 'All tags' }).should(
|
||||
'have.attr',
|
||||
'aria-current',
|
||||
'page',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require "rails_helper"
|
|||
|
||||
RSpec.shared_examples "an elevated privilege required request" do |path|
|
||||
context "when not logged-in" do
|
||||
it "does not grant access", proper_status: true do
|
||||
it "does not grant access", :proper_status do
|
||||
get path
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
|
@ -15,7 +15,7 @@ RSpec.shared_examples "an elevated privilege required request" do |path|
|
|||
context "when user is not trusted" do
|
||||
before { sign_in create(:user) }
|
||||
|
||||
it "does not grant access", proper_status: true do
|
||||
it "does not grant access", :proper_status do
|
||||
get path
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
|
@ -171,6 +171,30 @@ RSpec.describe "Moderations" do
|
|||
expect(response.body).to include logged_out_copy
|
||||
end
|
||||
end
|
||||
|
||||
context "when user is trusted" do
|
||||
before do
|
||||
sign_in trusted_user
|
||||
end
|
||||
|
||||
it "does not show articles the user has already reacted to for inbox" do
|
||||
first_article = create(:article)
|
||||
second_article = create(:article, score: -12)
|
||||
get "/mod"
|
||||
|
||||
expect(response.body).to include(CGI.escapeHTML(first_article.title))
|
||||
expect(response.body).not_to include(CGI.escapeHTML(second_article.title))
|
||||
end
|
||||
|
||||
it "shows all articles on latest" do
|
||||
first_article = create(:article)
|
||||
second_article = create(:article, score: -12)
|
||||
get "/mod?state=latest"
|
||||
|
||||
expect(response.body).to include(CGI.escapeHTML(first_article.title))
|
||||
expect(response.body).to include(CGI.escapeHTML(second_article.title))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Super moderator Note & AuditLog" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue