diff --git a/src/lib/report_manager.tsx b/src/lib/report_manager.tsx index d0ec5eba67..faca071b1f 100644 --- a/src/lib/report_manager.tsx +++ b/src/lib/report_manager.tsx @@ -352,11 +352,17 @@ class ReportManager extends EventEmitter { return res; } - public vote(report_id: number, voted_action: string, escalation_note: string): Promise { + public vote( + report_id: number, + voted_action: string, + escalation_note: string, + dissenter_note: string, + ): Promise { return post(`moderation/incident/${report_id}`, { action: "vote", voted_action: voted_action, escalation_note: escalation_note, + ...(dissenter_note && { dissenter_note }), }) .then((res) => { toast( diff --git a/src/lib/report_util.ts b/src/lib/report_util.ts index 796c7c0b48..eab0463084 100644 --- a/src/lib/report_util.ts +++ b/src/lib/report_util.ts @@ -67,6 +67,7 @@ export interface Report { vote_counts: { [action: string]: number }; voters: Vote[]; // votes from community moderators on this report escalation_note: string; + dissenter_note: string; unclaim: () => void; claim: () => void; diff --git a/src/views/ReportsCenter/ModerationActionSelector.styl b/src/views/ReportsCenter/ModerationActionSelector.styl index 59306ce98c..4972507748 100644 --- a/src/views/ReportsCenter/ModerationActionSelector.styl +++ b/src/views/ReportsCenter/ModerationActionSelector.styl @@ -2,7 +2,7 @@ .action-buttons { display: flex; - justify-content: flex-end; + justify-content: flex-end; } } \ No newline at end of file diff --git a/src/views/ReportsCenter/ModerationActionSelector.tsx b/src/views/ReportsCenter/ModerationActionSelector.tsx index b779497130..eee05bcebd 100644 --- a/src/views/ReportsCenter/ModerationActionSelector.tsx +++ b/src/views/ReportsCenter/ModerationActionSelector.tsx @@ -27,8 +27,7 @@ interface ModerationActionSelectorProps { vote_counts: { [action: string]: number }; enable: boolean; report: Report; - claim: () => void; - submit: (action: string, note: string) => void; + submit: (action: string, note: string, dissenter_note: string) => void; } // Translatable versions of the prompts for Community Moderators. @@ -152,19 +151,19 @@ export function ModerationActionSelector({ vote_counts, enable, report, - claim, submit, }: ModerationActionSelectorProps): JSX.Element { const user = useUser(); const reportedBySelf = user.id === report.reporting_user.id; + const [voted, setVoted] = React.useState(false); + const [selectedOption, setSelectedOption] = React.useState(""); const [escalation_note, setEscalationNote] = React.useState(""); - const [voted, setVoted] = React.useState(false); + const [dissenter_note, setDissenterNote] = React.useState(""); const updateSelectedAction = (e: React.ChangeEvent) => { setSelectedOption(e.target.value); - claim(); }; const { registerTargetItem } = React.useContext(DynamicHelp.Api); @@ -174,6 +173,14 @@ export function ModerationActionSelector({ // If for some reason we didn't get any actions to offer, we'll just offer "escalate" const action_choices = available_actions ? available_actions : ["escalate"]; + // If we're in dissent, we'll ask for a "dissent" note + const inDissent = + selectedOption && + !!Object.keys(vote_counts).find( + (k: string) => + k !== selectedOption && (vote_counts[selectedOption] ?? 0) < vote_counts[k], + ); + return (

@@ -217,7 +224,7 @@ export function ModerationActionSelector({ ))} {selectedOption === "escalate" && (