Skip to content

Commit

Permalink
cci: add option for presumptive removal
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Oct 2, 2022
1 parent fbe5826 commit 14c1b81
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions i18n/core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"deputy.session.row.status.withViolations": "Violations found",
"deputy.session.row.status.withoutViolations": "No violations found",
"deputy.session.row.status.missing": "Missing",
"deputy.session.row.status.presumptiveRemoval": "Presumptively removed",

"deputy.session.row.details.new": "created",
"deputy.session.row.details.edits": "{{PLURAL:$1|$1 edit|{{FORMATNUM:$1}} edits}}",
Expand Down
7 changes: 5 additions & 2 deletions src/models/ContributionSurveyRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export enum ContributionSurveyRowStatus {
// The row has been processed and violations were not found ({{n}})
WithoutViolations = 3,
// The row has been found but the added text is no longer in the existing revision
Missing = 4
Missing = 4,
// The row has been processed and text was presumptively removed ({{x}}),
PresumptiveRemoval = 5
}

/**
Expand Down Expand Up @@ -45,7 +47,8 @@ export default class ContributionSurveyRow {
// TODO: Wiki localization
[ ContributionSurveyRowStatus.WithViolations ]: /\{\{(aye|y)}}/gi,
[ ContributionSurveyRowStatus.WithoutViolations ]: /\{\{n(ay)?}}/gi,
[ ContributionSurveyRowStatus.Missing ]: /\{\{\?}}/gi
[ ContributionSurveyRowStatus.Missing ]: /\{\{\?}}/gi,
[ ContributionSurveyRowStatus.PresumptiveRemoval ]: /\{\{x}}/gi
};

/**
Expand Down
8 changes: 7 additions & 1 deletion src/ui/root/DeputyContributionSurveyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default class DeputyContributionSurveyRow implements DeputyUIElement {
[ ContributionSurveyRowStatus.Unknown ]: 'alert',
[ ContributionSurveyRowStatus.WithViolations ]: 'check',
[ ContributionSurveyRowStatus.WithoutViolations ]: 'close',
[ ContributionSurveyRowStatus.Missing ]: 'help'
[ ContributionSurveyRowStatus.Missing ]: 'help',
[ ContributionSurveyRowStatus.PresumptiveRemoval ]: 'trash'
};

disabled: boolean;
Expand Down Expand Up @@ -258,6 +259,7 @@ export default class DeputyContributionSurveyRow implements DeputyUIElement {
const useUserData = () => {
let addComments = false;
switch ( this.status ) {
// TODO: l10n
case ContributionSurveyRowStatus.Unfinished:
// This state should not exist. Just add signature (done outside of switch).
break;
Expand All @@ -279,6 +281,10 @@ export default class DeputyContributionSurveyRow implements DeputyUIElement {
result += '{{?}}';
addComments = true;
break;
case ContributionSurveyRowStatus.PresumptiveRemoval:
result += '{{x}}';
addComments = true;
break;
}

const userComments = this.comments
Expand Down
4 changes: 3 additions & 1 deletion src/ui/shared/DeputyCCIStatusDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default class DeputyCCIStatusDropdown extends EventTarget {
[ ContributionSurveyRowStatus.Unknown ]: 'alert',
[ ContributionSurveyRowStatus.WithViolations ]: 'check',
[ ContributionSurveyRowStatus.WithoutViolations ]: 'close',
[ ContributionSurveyRowStatus.Missing ]: 'help'
[ ContributionSurveyRowStatus.Missing ]: 'help',
[ ContributionSurveyRowStatus.PresumptiveRemoval ]: 'trash'
};

/**
Expand Down Expand Up @@ -377,6 +378,7 @@ export default class DeputyCCIStatusDropdown extends EventTarget {
* - WithViolations: _usually not disabled, kept as is_
* - WithoutViolations: _usually not disabled, kept as is_
* - Missing: _usually not disabled, kept as is_
* - PresumptiveRemoval: _usually not disabled, kept as is_
*
* @param status The status that was <b>changed into</b>
*/
Expand Down
3 changes: 2 additions & 1 deletion src/wiki/DeputyCasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class DeputyCasePage extends DeputyCase {
*/
isContributionSurveyHeading( el: HTMLElement ): el is ContributionSurveyHeading {
// All headings (h1, h2, h3, h4, h5, h6)
// TODO: l10n
const headlineElement = this.parsoid ? el : el.querySelector<HTMLElement>( '.mw-headline' );
return /^H\d$/.test( el.tagName ) &&
headlineElement != null &&
Expand Down Expand Up @@ -157,7 +158,7 @@ export default class DeputyCasePage extends DeputyCase {
throw new Error( 'Current page is not a case page.' );
} else {
return ( Array.from( this.document.querySelectorAll(
// All headings (h1, h2, h3, h4, h5, h6)
// All headings (`h1, h2, h3, h4, h5, h6`)
[ 1, 2, 3, 4, 5, 6 ]
.map( ( i ) => `.mw-parser-output h${i}` )
.join( ',' )
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/ContributionSurveyRowUnitTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ describe( 'ContributionSurveyRow static unit tests', () => {
);
} )
).resolves.toBe( ContributionSurveyRowStatus.Missing ),
expect(
page.evaluate( () => {
return window.deputy.models.ContributionSurveyRow.identifyCommentStatus(
'{{x}}'
);
} )
).resolves.toBe( ContributionSurveyRowStatus.PresumptiveRemoval ),
expect(
page.evaluate( () => {
return window.deputy.models.ContributionSurveyRow.identifyCommentStatus(
'BOOM {{x}}'
);
} )
).resolves.toBe( ContributionSurveyRowStatus.PresumptiveRemoval ),
expect(
page.evaluate( () => {
return window.deputy.models.ContributionSurveyRow.identifyCommentStatus(
'{{x}} explosion!'
);
} )
).resolves.toBe( ContributionSurveyRowStatus.PresumptiveRemoval ),
expect(
page.evaluate( () => {
return window.deputy.models.ContributionSurveyRow.identifyCommentStatus(
Expand Down

0 comments on commit 14c1b81

Please sign in to comment.