A platform for community discussion. Free, open, simple.
FIX: Allow DSA classification on later review queue pages (#44623)
Alan Guo Xiang Tane5fab0adcc05
diff --git a/frontend/discourse/app/components/dsa-statement-classification.gjs b/frontend/discourse/app/components/dsa-statement-classification.gjsindex 110235e4fe7..10c68889ada 100644--- a/frontend/discourse/app/components/dsa-statement-classification.gjs+++ b/frontend/discourse/app/components/dsa-statement-classification.gjs@@ -21,10 +21,6 @@ export default class DsaStatementClassification extends Component {return this.args.reviewable.dsa_classification;}- get classificationOptions() {- return this.args.reviewable.extras.dsa_classification;- }-@actioncancel() {this.args.onCancel?.();@@ -40,10 +36,10 @@ export default class DsaStatementClassification extends Component {const reviewable = this.args.reviewable;const statementIds = [...this.classification.statement_ids];- const rule = this.classificationOptions.community_rules.find(+ const rule = this.args.classificationOptions.community_rules.find((entry) => entry.id === data.community_rule);- const category = this.classificationOptions.categories.find(+ const category = this.args.classificationOptions.categories.find((entry) => entry.id === data.category);const confirmed = await this.dialog.confirm({@@ -119,7 +115,7 @@ export default class DsaStatementClassification extends Component {@nonePlaceholder={{i18n "dsa_statements.rule_prompt"}}as |select|>- {{#each this.classificationOptions.community_rules as |rule|}}+ {{#each @classificationOptions.community_rules as |rule|}}<select.Option@value={{rule.id}}>{{rule.ground}}</select.Option>@@ -140,7 +136,7 @@ export default class DsaStatementClassification extends Component {@nonePlaceholder={{i18n "dsa_statements.category_prompt"}}as |select|>- {{#each this.classificationOptions.categories as |category|}}+ {{#each @classificationOptions.categories as |category|}}<select.Option@value={{category.id}}>{{category.name}}</select.Option>diff --git a/frontend/discourse/app/components/modal/dsa-classification.gjs b/frontend/discourse/app/components/modal/dsa-classification.gjsindex be2792ee4b7..f8989fee1c8 100644--- a/frontend/discourse/app/components/modal/dsa-classification.gjs+++ b/frontend/discourse/app/components/modal/dsa-classification.gjs@@ -40,6 +40,7 @@ export default class DsaClassificationModal extends Component {</:headerBelowTitle><:body><DsaStatementClassification+ @classificationOptions={{@model.classificationOptions}}@hideHeading={{true}}@onCancel={{@closeModal}}@onSavingChange={{this.savingChanged}}diff --git a/frontend/discourse/app/components/reviewable/index.gjs b/frontend/discourse/app/components/reviewable/index.gjsindex 855cc60b207..75ac5d863c8 100644--- a/frontend/discourse/app/components/reviewable/index.gjs+++ b/frontend/discourse/app/components/reviewable/index.gjs@@ -13,6 +13,7 @@ const ReviewableIndex = <template><div class="reviewables">{{#each @controller.reviewables.content as |r|}}<ReviewableItem+ @classificationOptions={{@controller.reviewables.extras.dsa_classification}}@reviewable={{r}}@showHelp={{false}}@updateStatuses={{@controller.updateStatuses}}diff --git a/frontend/discourse/app/components/reviewable/item.gjs b/frontend/discourse/app/components/reviewable/item.gjsindex ac4742b259c..c463e44d085 100644--- a/frontend/discourse/app/components/reviewable/item.gjs+++ b/frontend/discourse/app/components/reviewable/item.gjs@@ -310,7 +310,10 @@ export default class ReviewableItem extends Component {@actionopenClassification() {this.modal.show(DsaClassificationModal, {- model: { reviewable: this.args.reviewable },+ model: {+ classificationOptions: this.args.classificationOptions,+ reviewable: this.args.reviewable,+ },});}@@ -973,7 +976,10 @@ export default class ReviewableItem extends Component {)}}{{#each (array @reviewable) as |reviewable|}}- <DsaStatementClassification @reviewable={{reviewable}} />+ <DsaStatementClassification+ @classificationOptions={{@classificationOptions}}+ @reviewable={{reviewable}}+ />{{/each}}{{else if (and @showHelp (not @reviewable.dsa_classification))}}<ReviewableHelpResources />diff --git a/frontend/discourse/app/templates/review/show.gjs b/frontend/discourse/app/templates/review/show.gjsindex 6d456c88ce6..35d9a675800 100644--- a/frontend/discourse/app/templates/review/show.gjs+++ b/frontend/discourse/app/templates/review/show.gjs@@ -10,7 +10,11 @@ const ReviewShow = <template>{{i18n "review.back_to_queue"}}</LinkTo></div>- <ReviewableItem @reviewable={{@controller.reviewable}} @showHelp={{true}} />+ <ReviewableItem+ @classificationOptions={{@controller.reviewable.extras.dsa_classification}}+ @reviewable={{@controller.reviewable}}+ @showHelp={{true}}+ /></template>;export default ReviewShow;diff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rbindex f4ec8642aa1..2aa62b89302 100644--- a/spec/system/viewing_reviewable_spec.rb+++ b/spec/system/viewing_reviewable_spec.rb@@ -44,11 +44,19 @@ describe "Viewing reviewable item" doreviewable_flagged_post.perform(admin, :delete_and_agree)end- it "lets staff double check and confirm the DSA classification of a flagged post removal" do+ it "lets staff confirm the DSA classification of a flagged post removal after loading more reviewed items" dodialog = PageObjects::Components::Dialog.newnote ="Classified this moderation decision for DSA reporting. Community rule: #{other_rule[:ground]} Category: Other violation of terms and conditions"- review_page.visit_reviewable(reviewable_flagged_post)+ 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@@ -61,6 +69,7 @@ describe "Viewing reviewable item" doexpect(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