Skip to content

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

UX: Explain DSA classification in reviewable handling (#45486)

Alan Guo Xiang Tan4b36feff16f1
diff --git a/app/assets/stylesheets/common/base/dsa-classification.scss b/app/assets/stylesheets/common/base/dsa-classification.scss
index 15ef309056d..f4ba5568ddc 100644
--- a/app/assets/stylesheets/common/base/dsa-classification.scss
+++ b/app/assets/stylesheets/common/base/dsa-classification.scss
@@ -58,3 +58,11 @@ html:has(.dsa-moderation-action) .fk-d-menu[data-identifier="usercard"] {
}
}
}
+
+.dsa-moderation-help {
+ color: var(--primary-medium);
+}
+
+.dsa-moderation-title-help {
+ margin-inline: var(--space-2) auto;
+}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index c93f71ab1f0..031ce0462e3 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1010,11 +1010,13 @@ en:
dsa_statements:
title: "DSA classification"
- help_title: "About DSA classification"
- help: "Select the community rule and category that explain this moderation decision. These are saved with its Digital Services Act statement of reasons."
+ help_title: "About EU Digital Services Act classification"
+ help: "The EU Digital Services Act asks platforms to record why content was moderated.<br><a href='https://digital-strategy.ec.europa.eu/en/policies/dsa-impact-platforms' rel='noopener noreferrer' target='_blank'>Learn more…</a>"
rule: "Community rule"
+ rule_help: "Select the community rule this moderation decision is based on."
rule_prompt: "Choose a community rule"
category: "Category"
+ category_help: "Select the EU Digital Services Act category that best describes the violation. <a href='https://transparency.dsa.ec.europa.eu/page/documentation#16.-category-%26-specification' rel='noopener noreferrer' target='_blank'>View category definitions…</a>"
category_prompt: "Choose a category"
save: "Save classification"
review:
diff --git a/frontend/discourse/app/components/dsa-moderation-details.gjs b/frontend/discourse/app/components/dsa-moderation-details.gjs
index 0924ae85e66..c8cb1b64491 100644
--- a/frontend/discourse/app/components/dsa-moderation-details.gjs
+++ b/frontend/discourse/app/components/dsa-moderation-details.gjs
@@ -1,7 +1,21 @@
import Component from "@glimmer/component";
+import { trustHTML } from "@ember/template";
import Form from "discourse/components/form";
+import DTooltip from "discourse/float-kit/components/d-tooltip";
import { i18n } from "discourse-i18n";
+const CategoryHelp = <template>
+ <DTooltip
+ class="form-kit__tooltip"
+ @icon="circle-question"
+ @interactive={{true}}
+ >
+ <:content>
+ <div>{{trustHTML (i18n "dsa_statements.category_help")}}</div>
+ </:content>
+ </DTooltip>
+</template>;
+
export function defaultClassification(options) {
const rules = options?.community_rules;
return rules?.length === 1 ? { community_rule: rules[0].id } : {};
@@ -23,6 +37,7 @@ export default class DsaModerationDetails extends Component {
@format="full"
@name="community_rule"
@title={{i18n "dsa_statements.rule"}}
+ @tooltip={{i18n "dsa_statements.rule_help"}}
@type="select"
@validation="required"
as |field|
@@ -40,6 +55,7 @@ export default class DsaModerationDetails extends Component {
@format="full"
@name="category"
@title={{i18n "dsa_statements.category"}}
+ @tooltip={{component CategoryHelp}}
@type="select"
@validation="required"
as |field|
diff --git a/frontend/discourse/app/components/dsa-moderation.gjs b/frontend/discourse/app/components/dsa-moderation.gjs
index 9c2f30a1466..b1084b92148 100644
--- a/frontend/discourse/app/components/dsa-moderation.gjs
+++ b/frontend/discourse/app/components/dsa-moderation.gjs
@@ -4,20 +4,38 @@ import { hash } from "@ember/helper";
import { action } from "@ember/object";
import { guidFor } from "@ember/object/internals";
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
+import { trustHTML } from "@ember/template";
import DsaModerationDetails from "discourse/components/dsa-moderation-details";
+import DTooltip from "discourse/float-kit/components/d-tooltip";
import DButton from "discourse/ui-kit/d-button";
import dIcon from "discourse/ui-kit/helpers/d-icon";
import { i18n } from "discourse-i18n";
+const Help = <template>
+ <DTooltip
+ aria-label={{i18n "dsa_statements.help_title"}}
+ class="dsa-moderation-help"
+ tabindex="0"
+ ...attributes
+ @icon="circle-question"
+ @interactive={{true}}
+ >
+ <:content>
+ <div>{{trustHTML (i18n "dsa_statements.help")}}</div>
+ </:content>
+ </DTooltip>
+</template>;
+
const Steps = <template>
{{#if @flow.nextStepLabel}}
<ol
aria-label={{i18n "review.moderation_steps.label"}}
class="dsa-moderation-steps"
>
- <li aria-current="step" class="--current">{{i18n
- "dsa_statements.title"
- }}</li>
+ <li aria-current="step" class="--current">
+ {{i18n "dsa_statements.title"}}
+ <Help />
+ </li>
<li>
{{dIcon "angle-right"}}
{{@flow.nextStepLabel}}
@@ -52,6 +70,7 @@ const Steps = <template>
>
{{dIcon "angle-right"}}
{{i18n "dsa_statements.title"}}
+ <Help />
</li>
</ol>
{{/if}}
@@ -136,6 +155,10 @@ export default class DsaModeration extends Component {
return this.args.options;
}
+ get showTitleHelp() {
+ return this.enabled && !this.hasActionDetails && !this.nextStepLabel;
+ }
+
get showContinue() {
return this.enabled && this.hasActionDetails && !this.classificationStep;
}
@@ -172,6 +195,8 @@ export default class DsaModeration extends Component {
<template>
{{yield
(hash
+ Help=Help
+ showTitleHelp=this.showTitleHelp
Body=(component Body flow=this)
Footer=(component Footer flow=this)
Steps=(component Steps flow=this)
diff --git a/frontend/discourse/app/components/modal/dsa-moderation-action.gjs b/frontend/discourse/app/components/modal/dsa-moderation-action.gjs
index 38a960b9fe5..f207170a39b 100644
--- a/frontend/discourse/app/components/modal/dsa-moderation-action.gjs
+++ b/frontend/discourse/app/components/modal/dsa-moderation-action.gjs
@@ -77,6 +77,11 @@ export default class DsaModerationAction extends Component {
@flash={{this.flash}}
@title={{this.title}}
>
+ <:headerBelowTitle>
+ {{#if flow.showTitleHelp}}
+ <flow.Help class="dsa-moderation-title-help" />
+ {{/if}}
+ </:headerBelowTitle>
<:belowHeader>
<flow.Steps @disabled={{this.saving}} />
</:belowHeader>
diff --git a/spec/system/page_objects/modals/dsa_moderation.rb b/spec/system/page_objects/modals/dsa_moderation.rb
index 094cd840734..7cc0537eff2 100644
--- a/spec/system/page_objects/modals/dsa_moderation.rb
+++ b/spec/system/page_objects/modals/dsa_moderation.rb
@@ -10,6 +10,18 @@ module PageObjects
super(modal_selector: MODAL_SELECTOR)
end
+ def open_dsa_help
+ within(full_modal_selector) { find(".dsa-moderation-help").hover }
+ end
+
+ def has_classification_help?(text)
+ has_css?("[role='tooltip']", text: text)
+ end
+
+ def has_dsa_learn_more_link?(url)
+ has_css?("[role='tooltip'] a[href='#{url}'][target='_blank']", text: "Learn more…")
+ end
+
def select_rule(ground)
within(full_modal_selector) { select(ground, from: "Community rule") }
end
diff --git a/spec/system/review_dsa_moderation_spec.rb b/spec/system/review_dsa_moderation_spec.rb
index 4ac71c3792c..849a92a51f8 100644
--- a/spec/system/review_dsa_moderation_spec.rb
+++ b/spec/system/review_dsa_moderation_spec.rb
@@ -52,6 +52,15 @@ describe "Classifying reviewable moderation" do
expect(modal).to have_focused_step("DSA classification")
expect(modal).to have_no_cancel_button
+ modal.open_dsa_help
+
+ expect(modal).to have_classification_help(
+ "The EU Digital Services Act asks platforms to record why content was moderated.",
+ )
+ expect(modal).to have_dsa_learn_more_link(
+ "https://digital-strategy.ec.europa.eu/en/policies/dsa-impact-platforms",
+ )
+
modal.confirm("Suspend")
expect(modal).to have_required_errors
@@ -131,6 +140,12 @@ describe "Classifying reviewable moderation" do
expect(modal).to have_steps("DSA classification", "Edit post")
expect(modal).to have_selected_rule("Choose a community rule")
+ modal.open_dsa_help
+
+ expect(modal).to have_classification_help(
+ "The EU Digital Services Act asks platforms to record why content was moderated.",
+ )
+
modal.select_rule(rule[:ground])
modal.select_category(category)
modal.confirm("Continue to editor")