A platform for community discussion. Free, open, simple.
FEATURE: Add a checkbox for users to confirm before flagging as illegal (#25762)
Ted Johansson533b91dec6db
diff --git a/app/assets/javascripts/discourse/app/components/flag-action-type.hbs b/app/assets/javascripts/discourse/app/components/flag-action-type.hbsindex 517f11cfcd5..96a8b5c6b7e 100644--- a/app/assets/javascripts/discourse/app/components/flag-action-type.hbs+++ b/app/assets/javascripts/discourse/app/components/flag-action-type.hbs@@ -69,6 +69,16 @@{{/if}}</div></label>+ {{#if this.showConfirmation}}+ <label class="checkbox-label flag-confirmation">+ <Input+ name="confirmation"+ @type="checkbox"+ @checked={{this.isConfirmed}}+ />+ <span>{{i18n "flagging.confirmation_illegal"}}</span>+ </label>+ {{/if}}</div>{{/if}}</div>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/flag-action-type.js b/app/assets/javascripts/discourse/app/components/flag-action-type.jsindex 4e4d8cc89aa..0041814118b 100644--- a/app/assets/javascripts/discourse/app/components/flag-action-type.js+++ b/app/assets/javascripts/discourse/app/components/flag-action-type.js@@ -32,6 +32,7 @@ export default Component.extend({},showMessageInput: and("flag.is_custom_flag", "selected"),+ showConfirmation: and("flag.isIllegal", "selected"),showDescription: not("showMessageInput"),isNotifyUser: equal("flag.name_key", "notify_user"),diff --git a/app/assets/javascripts/discourse/app/components/modal/flag.hbs b/app/assets/javascripts/discourse/app/components/modal/flag.hbsindex b8ebc6d6750..69097cde4c8 100644--- a/app/assets/javascripts/discourse/app/components/modal/flag.hbs+++ b/app/assets/javascripts/discourse/app/components/modal/flag.hbs@@ -16,6 +16,7 @@<FlagActionType@flag={{f}}@message={{this.message}}+ @isConfirmed={{this.isConfirmed}}@isWarning={{this.isWarning}}@selectedFlag={{this.selected}}@username={{@model.flagModel.username}}diff --git a/app/assets/javascripts/discourse/app/components/modal/flag.js b/app/assets/javascripts/discourse/app/components/modal/flag.jsindex 701a70e83e4..e0c59fa1186 100644--- a/app/assets/javascripts/discourse/app/components/modal/flag.js+++ b/app/assets/javascripts/discourse/app/components/modal/flag.js@@ -19,6 +19,7 @@ export default class Flag extends Component {@tracked userDetails;@tracked selected;@tracked message;+ @tracked isConfirmed = false;@tracked isWarning = false;@tracked spammerDetails;@@ -100,6 +101,10 @@ export default class Flag extends Component {return true;}+ if (this.selected.isIllegal && !this.isConfirmed) {+ return false;+ }+const len = this.message?.length || 0;return (len >= this.siteSettings.min_personal_message_post_length &&diff --git a/app/assets/javascripts/discourse/app/models/post-action-type.js b/app/assets/javascripts/discourse/app/models/post-action-type.jsindex 2ab8b85969a..6864d891a08 100644--- a/app/assets/javascripts/discourse/app/models/post-action-type.js+++ b/app/assets/javascripts/discourse/app/models/post-action-type.js@@ -1,8 +1,9 @@-import { not } from "@ember/object/computed";+import { equal, not } from "@ember/object/computed";import RestModel from "discourse/models/rest";export const MAX_MESSAGE_LENGTH = 500;export default class PostActionType extends RestModel {@not("is_custom_flag") notCustomFlag;+ @equal("name_key", "illegal") isIllegal;}diff --git a/app/assets/stylesheets/common/base/modal.scss b/app/assets/stylesheets/common/base/modal.scssindex 01826e1fa1b..63c51aaa503 100644--- a/app/assets/stylesheets/common/base/modal.scss+++ b/app/assets/stylesheets/common/base/modal.scss@@ -623,6 +623,10 @@// max-width: 500px;line-height: var(--line-height-large);}+ .flag-confirmation {+ margin-top: 0.5em;+ padding-left: 1.125em;+ }}.flag-message {diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 866e63b3430..2a37c872f8a 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3950,6 +3950,7 @@ en:custom_placeholder_notify_moderators: "Let us know specifically what you are concerned about, and provide relevant links and examples where possible."notify_moderators_textarea_label: "Message for the moderators"custom_placeholder_illegal: "Let us know specifically why you believe this content is illegal, and provide relevant links and examples where possible."+ confirmation_illegal: "What I’ve written above is accurate and complete."custom_message:at_least:one: "enter at least %{count} character"diff --git a/spec/system/flagging_post_spec.rb b/spec/system/flagging_post_spec.rbindex 111ba260f6a..978b9ef6719 100644--- a/spec/system/flagging_post_spec.rb+++ b/spec/system/flagging_post_spec.rb@@ -32,4 +32,22 @@ describe "Flagging post", type: :system doexpect(page).to have_css(".reviewable-meta-data .status .approved")endend++ describe "As Illegal" do+ it do+ topic_page.visit_topic(post_to_flag.topic)+ topic_page.expand_post_actions(post_to_flag)+ topic_page.click_post_action_button(post_to_flag, :flag)+ flag_modal.choose_type(:illegal)++ expect(flag_modal).to have_css(".flag-confirmation")++ flag_modal.fill_message("This looks totally illegal to me.")+ flag_modal.check_confirmation++ flag_modal.confirm_flag++ expect(page).to have_content(I18n.t("js.post.actions.by_you.illegal"))+ end+ endenddiff --git a/spec/system/page_objects/modals/flag.rb b/spec/system/page_objects/modals/flag.rbindex 4188b260712..742b5fcd04a 100644--- a/spec/system/page_objects/modals/flag.rb+++ b/spec/system/page_objects/modals/flag.rb@@ -20,6 +20,14 @@ module PageObjectsselect_kit.expandselect_kit.select_row_by_value(action)end++ def fill_message(message)+ body.fill_in("message", with: message)+ end++ def check_confirmation+ body.check("confirmation")+ endendendend