Skip to content

Commit c8c794b

Browse files
add danger mode
1 parent f314105 commit c8c794b

18 files changed

Lines changed: 194 additions & 30 deletions

i18n/core/en.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,24 @@
2626
"deputy.session.section.closeComments": "Archiving comments",
2727
"deputy.session.section.closeCommentsSign": "Include my signature",
2828
"deputy.session.section.closeError": "Some revisions remain unassessed. You must mark these revisions as assessed before archiving this section.",
29+
"deputy.session.section.closeError.danger": "Some revisions remain unassessed, but Deputy will allow archiving while danger mode is enabled.",
2930
"deputy.session.section.closeWarn": "You have unsaved changes. Close the section without saving?",
3031
"deputy.session.section.closed": "This section has been archived. You can edit its contents, but you cannot un-archive it.",
3132

3233
"deputy.session.section.stop": "Stop session",
34+
"deputy.session.section.stop.title": "Stop then current session, closing all sections and saving changes for later.",
3335
"deputy.session.section.saved": "Section saved",
3436
"deputy.session.section.failed": "Failed to save section",
3537
"deputy.session.section.missingSection": "The target section is missing from the case page.",
3638
"deputy.session.section.sectionIncomplete": "The target section still has unreviewed rows.",
3739
"deputy.session.section.conflict.title": "Edit conflict",
3840
"deputy.session.section.conflict.help": "Someone else edited the page before you. Deputy will restart to load the new case content. Your changes will be preserved.",
3941

42+
"deputy.session.section.danger": "Danger mode",
43+
"deputy.session.section.markAllFinished": "Mark all revisions in all sections as finished",
44+
"deputy.session.section.instantArchive": "Archive",
45+
"deputy.session.section.instantArchive.title": "Archive and save this section immediately. Revisions will not be marked as finished.",
46+
4047
"deputy.session.row.status": "Current page status",
4148
"deputy.session.row.status.unfinished": "Unfinished",
4249
"deputy.session.row.status.unknown": "Unknown",

i18n/settings/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
"deputy.setting.user.core.portletNames.full": "Full names (e.g. Attribution Notice Template Editor)",
4545
"deputy.setting.user.core.portletNames.short": "Shortened names (e.g. Attrib. Template Editor)",
4646
"deputy.setting.user.core.portletNames.acronym": "Acronyms (e.g. ANTE)",
47+
"deputy.setting.user.core.dangerMode.name": "Danger mode",
48+
"deputy.setting.user.core.dangerMode.description": "Live on the edge. This disables most confirmations and warnings given by Deputy, only leaving potentially catastrophic actions, such as page edits which break templates. It also adds extra buttons meant for rapid case processing. Intended for clerk use; use with extreme caution.",
4749

4850
"deputy.setting.user.cci": "CCI",
4951

i18n/shared/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
"deputy.cancel": "Cancel",
1414
"deputy.review": "Review",
15+
"deputy.review.title": "Review a diff of the changes to be made to the page",
1516
"deputy.save": "Save",
1617
"deputy.close": "Close",
1718
"deputy.positiveDiff": "+{{FORMATNUM:$1}}",

src/config/UserConfiguration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ export default class UserConfiguration extends ConfigurationBase {
7171
seenAnnouncements: new Setting<string[], string[]>( {
7272
defaultValue: [],
7373
displayOptions: { hidden: true }
74+
} ),
75+
dangerMode: new Setting<boolean, boolean>( {
76+
defaultValue: false,
77+
displayOptions: {
78+
type: 'checkbox'
79+
}
7480
} )
7581
};
7682
public readonly cci = <const>{

src/css/deputy.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ p.dp-messageWidget-message {
6262
margin-top: 0;
6363
}
6464

65+
.oo-ui-image-destructive.oo-ui-icon-checkAll, .oo-ui-image-destructive.mw-ui-icon-checkAll::before {
66+
background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2220%22 height=%2220%22 viewBox=%220 0 20 20%22%3E%3Ctitle%3E check all %3C/title%3E%3Cpath fill=%22%23d73333%22 d=%22m.29 12.71 1.42-1.42 2.22 2.22 8.3-10.14 1.54 1.26-9.7 11.86zM12 10h5v2h-5zm-3 4h5v2H9zm6-8h5v2h-5z%22/%3E%3C/svg%3E");
67+
}
68+
6569
/*
6670
===============================================================================
6771
@@ -159,6 +163,19 @@ p.dp-messageWidget-message {
159163
padding: 8px;
160164
}
161165

166+
.dp-cs-section-danger--separator {
167+
flex-basis: 100%;
168+
margin: 8px 0;
169+
border-bottom: 1px solid #d73333;
170+
color: #d73333;
171+
font-weight: bold;
172+
font-size: 0.7em;
173+
text-align: right;
174+
text-transform: uppercase;
175+
line-height: 0.7em;
176+
padding-bottom: 0.2em;
177+
}
178+
162179
.dp-cs-section-closing {
163180
margin: 1em 1.75em;
164181
}

src/modules/ante/ui/CopiedTemplateEditorDialog.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import normalizeTitle from '../../../wiki/util/normalizeTitle';
1919
import getPageContent from '../../../wiki/util/getPageContent';
2020
import openWindow from '../../../wiki/util/openWindow';
2121
import changeTag from '../../../config/changeTag';
22+
import dangerModeConfirm from '../../../util/dangerModeConfirm';
2223

2324
interface CopiedTemplateEditorDialogData {
2425
main: CopiedTemplateEditor;
@@ -243,7 +244,8 @@ function initCopiedTemplateEditorDialog() {
243244
.filter( v => v.length > 1 )
244245
.reduce( ( p, n ) => p + n.length, 0 );
245246
return noticeCount ?
246-
OO.ui.confirm(
247+
dangerModeConfirm(
248+
window.CopiedTemplateEditor.config,
247249
mw.message(
248250
'deputy.ante.mergeAll.confirm',
249251
`${noticeCount}`
@@ -268,7 +270,8 @@ function initCopiedTemplateEditorDialog() {
268270
title: mw.msg( 'deputy.ante.reset' )
269271
} );
270272
resetButton.on( 'click', () => {
271-
return OO.ui.confirm(
273+
dangerModeConfirm(
274+
window.CopiedTemplateEditor.config,
272275
mw.msg( 'deputy.ante.reset.confirm' )
273276
).done( ( confirmed: boolean ) => {
274277
if ( confirmed ) {
@@ -291,7 +294,8 @@ function initCopiedTemplateEditorDialog() {
291294
deleteButton.on( 'click', () => {
292295
// Original copied notice count.
293296
const notices = this.parsoid.findNotices();
294-
return OO.ui.confirm(
297+
dangerModeConfirm(
298+
window.CopiedTemplateEditor.config,
295299
mw.message(
296300
'deputy.ante.delete.confirm',
297301
`${notices.length}`
@@ -373,7 +377,8 @@ function initCopiedTemplateEditorDialog() {
373377

374378
if ( this.parsoid.getPage() !== talkPage ) {
375379
// Ask for user confirmation.
376-
await OO.ui.confirm(
380+
dangerModeConfirm(
381+
window.CopiedTemplateEditor.config,
377382
mw.message(
378383
'deputy.ante.loadRedirect.message',
379384
talkPage, this.parsoid.getPage()
@@ -493,7 +498,8 @@ function initCopiedTemplateEditorDialog() {
493498
this.parsoid.originalCount > 0 ?
494499
'deputy.ante.content.modify' :
495500
'deputy.ante.content.add'
496-
)
501+
),
502+
window.CopiedTemplateEditor.config
497503
)
498504
} ).catch( ( e, c ) => {
499505
throw errorToOO( e, c );

src/modules/ante/ui/RowPageShared.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { h } from 'tsx-dom';
88
import AttributionNotice from '../models/AttributionNotice';
99
import RowedAttributionNotice from '../models/RowedAttributionNotice';
10+
import dangerModeConfirm from '../../../util/dangerModeConfirm';
1011

1112
/**
1213
* Renders the panel used to merge multiple {{split article}} templates.
@@ -69,7 +70,8 @@ export function renderMergePanel<T extends SupportedAttributionNoticeType>(
6970
mergeAllButton.on( 'click', () => {
7071
const notices = parentTemplate.parsoid.findNoticeType( type );
7172
// Confirm before merging.
72-
OO.ui.confirm(
73+
dangerModeConfirm(
74+
window.CopiedTemplateEditor.config,
7375
mw.message(
7476
'deputy.ante.merge.all.confirm',
7577
`${notices.length - 1}`

src/modules/ante/ui/pages/BackwardsCopyTemplatePage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import swapElements from '../../../../util/swapElements';
1212
import DemoTemplateMessage from './messages/DemoTemplateMessage';
1313
import removeElement from '../../../../util/removeElement';
1414
import DeputyMessageWidget from '../../../../ui/shared/DeputyMessageWidget';
15+
import dangerModeConfirm from '../../../../util/dangerModeConfirm';
1516

1617
export interface BackwardsCopyTemplatePageData {
1718
/**
@@ -184,7 +185,8 @@ function initBackwardsCopyTemplatePage() {
184185
} );
185186
deleteButton.on( 'click', () => {
186187
if ( this.backwardsCopyTemplate.rows.length > 0 ) {
187-
OO.ui.confirm(
188+
dangerModeConfirm(
189+
window.CopiedTemplateEditor.config,
188190
mw.message(
189191
'deputy.ante.copied.remove.confirm',
190192
`${this.backwardsCopyTemplate.rows.length}`

src/modules/ante/ui/pages/CopiedTemplatePage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import CopiedTemplateEditorDialog from '../CopiedTemplateEditorDialog';
99
import { AttributionNoticePageLayout } from './AttributionNoticePageLayout';
1010
import { renderMergePanel, renderPreviewPanel } from '../RowPageShared';
1111
import yesNo from '../../../../util/yesNo';
12+
import dangerModeConfirm from '../../../../util/dangerModeConfirm';
1213

1314
export interface CopiedTemplatePageData {
1415
/**
@@ -183,7 +184,8 @@ function initCopiedTemplatePage() {
183184
} );
184185
deleteButton.on( 'click', () => {
185186
if ( this.copiedTemplate.rows.length > 0 ) {
186-
OO.ui.confirm(
187+
dangerModeConfirm(
188+
window.CopiedTemplateEditor.config,
187189
mw.message(
188190
'deputy.ante.copied.remove.confirm',
189191
`${this.copiedTemplate.rows.length}`

src/modules/ante/ui/pages/CopiedTemplateRowPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import equalTitle from '../../../../util/equalTitle';
1515
import RevisionDateGetButton from '../components/RevisionDateGetButton';
1616
import SmartTitleInputWidget from '../components/SmartTitleInputWidget';
1717
import PageLatestRevisionGetButton from '../components/PageLatestRevisionGetButton';
18+
import dangerModeConfirm from '../../../../util/dangerModeConfirm';
1819

1920
export interface CopiedTemplateRowPageData {
2021
/**
@@ -590,7 +591,8 @@ function initCopiedTemplateRowPage() {
590591
this.copiedTemplateRow[ rowName ] !== newValue
591592
) {
592593
confirmProcess.next( async () => {
593-
const confirmPromise = OO.ui.confirm(
594+
const confirmPromise = dangerModeConfirm(
595+
window.CopiedTemplateEditor.config,
594596
mw.message(
595597
'deputy.ante.copied.diffDeprecate.replace',
596598
rowName, this.copiedTemplateRow[ rowName ], newValue

0 commit comments

Comments
 (0)