Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove the separate reviewable classification form (#45485)

Alan Guo Xiang Tanba57e2babca9
diff --git a/app/assets/stylesheets/common/base/dsa-classification.scss b/app/assets/stylesheets/common/base/dsa-classification.scss
index 8f2e38b8621..15ef309056d 100644
--- a/app/assets/stylesheets/common/base/dsa-classification.scss
+++ b/app/assets/stylesheets/common/base/dsa-classification.scss
@@ -1,54 +1,5 @@
@use "lib/viewport";
-.dsa-classification {
- min-width: 0;
- overflow-wrap: anywhere;
-
- &__heading {
- display: flex;
- align-items: center;
- gap: 0.5em;
- margin-block-end: 0.5em;
- }
-
- h2 {
- font-size: var(--font-up-2);
- margin: 0;
- }
-}
-
-.dsa-classification-confirmation {
- &__label {
- font-weight: bold;
- }
-
- &__value {
- margin: 0 0 var(--space-4);
- overflow-wrap: anywhere;
- }
-}
-
-.review-item__aside.--dsa-classification {
- padding-block-start: 0;
-}
-
-.review-item__classify {
- margin-block-end: var(--space-4);
- margin-inline-start: var(--review-item-padding);
-
- &.--pending-notice {
- inline-size: calc(100% - 2 * var(--review-item-padding));
- justify-content: flex-start;
- background: var(--highlight-low);
- color: var(--primary);
- border: 1px solid var(--highlight-medium);
- }
-}
-
-.dsa-classification-modal__help {
- margin-inline-end: auto;
-}
-
.dsa-moderation-action__user {
white-space: nowrap;
vertical-align: baseline;
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index d68b594a33d..c93f71ab1f0 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1016,12 +1016,7 @@ en:
rule_prompt: "Choose a community rule"
category: "Category"
category_prompt: "Choose a category"
- pending: "DSA classification pending"
- confirm_title: "Save DSA classification?"
- confirm_message: "Check the community rule and category. This classification cannot be changed after saving."
save: "Save classification"
- saving: "Saving…"
- saved: "Classification saved"
review:
continue_to_editor: "Continue to editor"
moderation_steps:
diff --git a/frontend/discourse/app/components/dialog-messages/dsa-classification-confirmation.gjs b/frontend/discourse/app/components/dialog-messages/dsa-classification-confirmation.gjs
deleted file mode 100644
index e38c7b4fa93..00000000000
--- a/frontend/discourse/app/components/dialog-messages/dsa-classification-confirmation.gjs
+++ /dev/null
@@ -1,17 +0,0 @@
-import { i18n } from "discourse-i18n";
-
-const DsaClassificationConfirmation = <template>
- <p>{{i18n "dsa_statements.confirm_message"}}</p>
- <dl class="dsa-classification-confirmation">
- <dt class="dsa-classification-confirmation__label">{{i18n
- "dsa_statements.rule"
- }}</dt>
- <dd class="dsa-classification-confirmation__value">{{@model.rule}}</dd>
- <dt class="dsa-classification-confirmation__label">{{i18n
- "dsa_statements.category"
- }}</dt>
- <dd class="dsa-classification-confirmation__value">{{@model.category}}</dd>
- </dl>
-</template>;
-
-export default DsaClassificationConfirmation;
diff --git a/frontend/discourse/app/components/dsa-statement-classification.gjs b/frontend/discourse/app/components/dsa-statement-classification.gjs
deleted file mode 100644
index d79c94890dd..00000000000
--- a/frontend/discourse/app/components/dsa-statement-classification.gjs
+++ /dev/null
@@ -1,169 +0,0 @@
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import DsaClassificationConfirmation from "discourse/components/dialog-messages/dsa-classification-confirmation";
-import { defaultClassification } from "discourse/components/dsa-moderation-details";
-import Form from "discourse/components/form";
-import { ajax } from "discourse/lib/ajax";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import DButton from "discourse/ui-kit/d-button";
-import { i18n } from "discourse-i18n";
-
-export default class DsaStatementClassification extends Component {
- @service dialog;
- @service toasts;
-
- @tracked saving = false;
-
- formData = defaultClassification(this.args.classificationOptions);
-
- get classification() {
- return this.args.reviewable.dsa_classification;
- }
-
- @action
- cancel() {
- this.args.onCancel?.();
- }
-
- @action
- showHelp() {
- this.dialog.alert(i18n("dsa_statements.help"));
- }
-
- @action
- async save(data) {
- const reviewable = this.args.reviewable;
-
- const statementIds = [...this.classification.statement_ids];
- const rule = this.args.classificationOptions.community_rules.find(
- (entry) => entry.id === data.community_rule
- );
- const category = this.args.classificationOptions.categories.find(
- (entry) => entry.id === data.category
- );
- const confirmed = await this.dialog.confirm({
- title: i18n("dsa_statements.confirm_title"),
- bodyComponent: DsaClassificationConfirmation,
- bodyComponentModel: { rule: rule.ground, category: category.name },
- confirmButtonLabel: "dsa_statements.save",
- });
-
- if (!confirmed || this.isDestroying) {
- return;
- }
-
- this.saving = true;
- this.args.onSavingChange?.(true);
-
- try {
- const response = await ajax(
- `/review/${reviewable.id}/dsa-classification`,
- {
- type: "PUT",
- data: {
- ...data,
- statement_ids: statementIds,
- },
- }
- );
- reviewable.set("reviewable_notes", response.reviewable_notes);
-
- if (!this.isDestroying) {
- this.cancel();
- }
-
- reviewable.set("dsa_classification", response.dsa_classification);
- this.toasts.success({
- duration: "short",
- data: { message: i18n("dsa_statements.saved") },
- });
- } catch (error) {
- popupAjaxError(error);
- } finally {
- this.saving = false;
- this.args.onSavingChange?.(false);
- }
- }
-
- <template>
- <section class="dsa-classification" ...attributes>
- {{#unless @hideHeading}}
- <div class="dsa-classification__heading">
- <h2>{{i18n "dsa_statements.title"}}</h2>
- <DButton
- class="btn-transparent"
- @action={{this.showHelp}}
- @icon="circle-question"
- @title="dsa_statements.help_title"
- />
- </div>
- {{/unless}}
-
- {{#if this.classification.statement_ids.length}}
- <Form @data={{this.formData}} @onSubmit={{this.save}} as |form|>
- <form.Field
- @disabled={{this.saving}}
- @format="full"
- @name="community_rule"
- @title={{i18n "dsa_statements.rule"}}
- @type="select"
- @validation="required"
- as |field|
- >
- <field.Control
- @nonePlaceholder={{i18n "dsa_statements.rule_prompt"}}
- as |select|
- >
- {{#each @classificationOptions.community_rules as |rule|}}
- <select.Option
- @value={{rule.id}}
- >{{rule.ground}}</select.Option>
- {{/each}}
- </field.Control>
- </form.Field>
-
- <form.Field
- @disabled={{this.saving}}
- @format="full"
- @name="category"
- @title={{i18n "dsa_statements.category"}}
- @type="select"
- @validation="required"
- as |field|
- >
- <field.Control
- @nonePlaceholder={{i18n "dsa_statements.category_prompt"}}
- as |select|
- >
- {{#each @classificationOptions.categories as |category|}}
- <select.Option
- @value={{category.id}}
- >{{category.name}}</select.Option>
- {{/each}}
- </field.Control>
- </form.Field>
-
- <form.Actions>
- <form.Submit
- @disabled={{this.saving}}
- @label={{if
- this.saving
- "dsa_statements.saving"
- "dsa_statements.save"
- }}
- />
- {{#if @showCancel}}
- <DButton
- @action={{this.cancel}}
- @disabled={{this.saving}}
- @label="cancel"
- />
- {{/if}}
- </form.Actions>
- </Form>
- {{/if}}
- </section>
- </template>
-}
diff --git a/frontend/discourse/app/components/modal/dsa-classification.gjs b/frontend/discourse/app/components/modal/dsa-classification.gjs
deleted file mode 100644
index f091f70ec10..00000000000
--- a/frontend/discourse/app/components/modal/dsa-classification.gjs
+++ /dev/null
@@ -1,52 +0,0 @@
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import DsaStatementClassification from "discourse/components/dsa-statement-classification";
-import DButton from "discourse/ui-kit/d-button";
-import DModal from "discourse/ui-kit/d-modal";
-import { i18n } from "discourse-i18n";
-
-export default class DsaClassificationModal extends Component {
- @service dialog;
-
- @tracked saving = false;
-
- @action
- savingChanged(saving) {
- this.saving = saving;
- }
-
- @action
- showHelp() {
- this.dialog.alert(i18n("dsa_statements.help"));
- }
-
- <template>
- <DModal
- class="dsa-classification-modal"
- @closeModal={{@closeModal}}
- @dismissable={{not this.saving}}
- @title={{i18n "dsa_statements.title"}}
- >
- <:headerBelowTitle>
- <DButton
- class="btn-transparent dsa-classification-modal__help"
- @action={{this.showHelp}}
- @icon="circle-question"
- @title="dsa_statements.help_title"
- />
- </:headerBelowTitle>
- <:body>
- <DsaStatementClassification
- @classificationOptions={{@model.classificationOptions}}
- @hideHeading={{true}}
- @onCancel={{@closeModal}}
- @onSavingChange={{this.savingChanged}}
- @reviewable={{@model.reviewable}}
- @showCancel={{true}}
- />
- </:body>
- </DModal>
- </template>
-}
diff --git a/frontend/discourse/app/components/reviewable/item.gjs b/frontend/discourse/app/components/reviewable/item.gjs
index 7226d81f7e5..e9cc57be111 100644
--- a/frontend/discourse/app/components/reviewable/item.gjs
+++ b/frontend/discourse/app/components/reviewable/item.gjs
@@ -1,6 +1,6 @@
import Component from "@glimmer/component";
import { cached, tracked } from "@glimmer/tracking";
-import { array, fn, get } from "@ember/helper";
+import { fn, get } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { getOwner } from "@ember/owner";
@@ -8,8 +8,6 @@ import { trackedObject } from "@ember/reactive/collections";
import { service } from "@ember/service";
import { classify, dasherize } from "@ember/string";
import ScrubRejectedUserModal from "discourse/admin/components/modal/scrub-rejected-user";
-import DsaStatementClassification from "discourse/components/dsa-statement-classification";
-import DsaClassificationModal from "discourse/components/modal/dsa-classification";
import RejectReasonReviewableModal from "discourse/components/modal/reject-reason-reviewable";
import ReviseAndRejectPostReviewable from "discourse/components/modal/revise-and-reject-post-reviewable";
import ReviewableFlagReason from "discourse/components/reviewable/flag-reason";
@@ -102,7 +100,6 @@ export function registerReviewableTypeLabel(reviewableType, labelKey) {
export default class ReviewableItem extends Component {
@service dialog;
- @service capabilities;
@service modal;
@service siteSettings;
@service currentUser;
@@ -300,16 +297,6 @@ export default class ReviewableItem extends Component {
return resolveReviewableComponent(getOwner(this), type);
}
- @action
- openClassification() {
- this.modal.show(DsaClassificationModal, {
- model: {
- classificationOptions: this.args.classificationOptions,
- reviewable: this.args.reviewable,
- },
- });
- }
-
@action
clientScrub() {
this.modal.show(ScrubRejectedUserModal, {
@@ -864,21 +851,6 @@ export default class ReviewableItem extends Component {
{{/if}}
</div>
- {{#if
- (and
- (not this.capabilities.viewport.sm)
- @reviewable.dsa_classification.statement_ids.length
- )
- }}
- <DButton
- class="review-item__classify --pending-notice"
- @action={{this.openClassification}}
- @icon="clock"
- @label="dsa_statements.pending"
- @suffixIcon="chevron-right"
- />
- {{/if}}
-
<div class="review-item__insights">
<div class="d-nav-submenu">
<DHorizontalOverflowNav
@@ -930,16 +902,7 @@ export default class ReviewableItem extends Component {
</div>
</div>
- <div
- class={{dConcatClass
- "review-item__aside"
- (if
- @reviewable.dsa_classification.statement_ids.length
- "--dsa-classification"
- )
- }}
- >
-
+ <div class="review-item__aside">
{{#unless @reviewable.last_performing_username}}
{{#if this.canPerform}}
<div class="review-item__moderator-actions">
@@ -1025,19 +988,7 @@ export default class ReviewableItem extends Component {
</div>
{{/if}}
- {{#if
- (and
- this.capabilities.viewport.sm
- @reviewable.dsa_classification.statement_ids.length
- )
- }}
- {{#each (array @reviewable) as |reviewable|}}
- <DsaStatementClassification
- @classificationOptions={{@classificationOptions}}
- @reviewable={{reviewable}}
- />
- {{/each}}
- {{else if @showHelp}}
+ {{#if @showHelp}}
<ReviewableHelpResources />
{{/if}}
</div>
diff --git a/spec/system/page_objects/components/dsa_classification.rb b/spec/system/page_objects/components/dsa_classification.rb
deleted file mode 100644
index 24bdcf11cf1..00000000000
--- a/spec/system/page_objects/components/dsa_classification.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-module PageObjects
- module Components
- class DsaClassification < PageObjects::Components::Base
- def select_rule(ground)
- within(".dsa-classification") { select(ground, from: "Community rule") }
- end
-
- def select_category(category)
- within(".dsa-classification") { select(category, from: "Category") }
- end
-
- def save
- within(".dsa-classification") { click_button("Save classification") }
- end
-
- def has_selected_rule?(ground)
- within(".dsa-classification") { has_select?("Community rule", selected: ground) }
- end
-
- def has_selected_category?(category)
- within(".dsa-classification") { has_select?("Category", selected: category) }
- end
-
- def has_no_sidebar?
- has_no_css?(".dsa-classification")
- end
- end
- end
-end
diff --git a/spec/system/page_objects/pages/review.rb b/spec/system/page_objects/pages/review.rb
index 6d511f298d5..a740b78c262 100644
--- a/spec/system/page_objects/pages/review.rb
+++ b/spec/system/page_objects/pages/review.rb
@@ -5,6 +5,10 @@ module PageObjects
class Review < PageObjects::Pages::Base
REVIEWABLE_ACTION_DROPDOWN = ".reviewable-action-dropdown"
+ def has_no_standalone_classification?
+ has_no_css?(".review-item__classify, .dsa-classification")
+ end
+
def visit_reviewable(reviewable)
page.visit("/review/#{reviewable.id}")
self
diff --git a/spec/system/review_dsa_moderation_spec.rb b/spec/system/review_dsa_moderation_spec.rb
index 37046930104..4ac71c3792c 100644
--- a/spec/system/review_dsa_moderation_spec.rb
+++ b/spec/system/review_dsa_moderation_spec.rb
@@ -25,11 +25,13 @@ describe "Classifying reviewable moderation" do
post = Fabricate(:post, topic: topic)
flagger = Fabricate(:user, trust_level: TrustLevel[3])
reviewable = PostActionCreator.create(flagger, post, :inappropriate).reviewable
+ Fabricate(:dsa_statement_of_record, reviewable_id: reviewable.id)
penalty_modal = PageObjects::Modals::PenalizeUser.new("suspend")
review_page.visit_reviewable(reviewable)
expect(review_page).to have_context_question(reviewable, "Is this post inappropriate?")
+ expect(review_page).to have_no_standalone_classification
review_page.select_bundled_action(reviewable, "post-agree_and_suspend", bundle_index: 1)
diff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rb
index 2aa62b89302..6b53d9eed2a 100644
--- a/spec/system/viewing_reviewable_spec.rb
+++ b/spec/system/viewing_reviewable_spec.rb
@@ -21,75 +21,6 @@ describe "Viewing reviewable item" do
sign_in(admin)
end
- context "when dsa_reporting_enabled is enabled" do
- let(:classification) { PageObjects::Components::DsaClassification.new }
- let(:toasts) { PageObjects::Components::Toasts.new }
- let(:rule) do
- {
- ground: "Terms of Service, section 3: Personal attacks",
- explanation: "The content targets another person with insults.",
- }
- end
-
- let(:other_rule) do
- {
- ground: "Terms of Service, section 4: Unsolicited advertising",
- explanation: "The content promotes unrelated products.",
- }
- end
-
- before do
- SiteSetting.dsa_reporting_enabled = true
- SiteSetting.dsa_community_rules = [rule, other_rule].to_json
- reviewable_flagged_post.perform(admin, :delete_and_agree)
- end
-
- it "lets staff confirm the DSA classification of a flagged post removal after loading more reviewed items" do
- dialog = PageObjects::Components::Dialog.new
- note =
- "Classified this moderation decision for DSA reporting. Community rule: #{other_rule[:ground]} Category: Other violation of terms and conditions"
- reviewable_user = Fabricate(:reviewable_user, status: :rejected)
-
- stub_const(ReviewablesController, "PER_PAGE", 1) do
- visit("/review?status=reviewed&sort_order=created_at")
- expect(page).to have_css(".review-item[data-reviewable-id='#{reviewable_user.id}']")
- page.scroll_to(:bottom)
- expect(page).to have_css(".review-item[data-reviewable-id='#{reviewable_flagged_post.id}']")
- end
-
- classification.select_rule(rule[:ground])
- classification.select_category("Illegal or harmful speech")
- classification.save
-
- expect(dialog).to have_content(rule[:ground])
- expect(dialog).to have_content("Illegal or harmful speech")
-
- dialog.click_no
-
- expect(classification).to have_selected_rule(rule[:ground])
- expect(classification).to have_selected_category("Illegal or harmful speech")
-
- review_page.visit_reviewable(reviewable_flagged_post)
- classification.select_rule(other_rule[:ground])
- classification.select_category("Other violation of terms and conditions")
- classification.save
-
- expect(dialog).to have_content(other_rule[:ground])
- expect(dialog).to have_content("Other violation of terms and conditions")
-
- dialog.click_yes
-
- expect(toasts).to have_success(I18n.t("js.dsa_statements.saved"))
- expect(classification).to have_no_sidebar
- expect(review_page).to have_note(note)
-
- page.refresh
-
- expect(classification).to have_no_sidebar
- expect(review_page).to have_note(note)
- end
- end
-
describe "when the reviewable item is a flagged post" do
it "shows the new reviewable UI" do
review_page.visit_reviewable(reviewable_flagged_post)