Skip to content

Commit d7d95d1

Browse files
util: + unwrapJQ
1 parent 404fb7a commit d7d95d1

12 files changed

+74
-67
lines changed

i18n/ia/en.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
"deputy.ia.listing.re.unverified": "Permission unverified as of this tagging; article will need to be deleted if that does not change.",
7676
"deputy.ia.listing.re.viable": "Viable rewrite proposed; rewrite on temp page can be merged into the article.",
7777

78-
"deputy.ia.report.intro": "You are reporting to <b>{{wikilink:$1}}</b>",
79-
"deputy.ia.report.page": "Currently reporting <b>{{wikilink:$1}}</b>",
78+
"deputy.ia.report.intro": "You are reporting to <b>[[$1]]</b>",
79+
"deputy.ia.report.page": "Currently reporting <b>[[$1]]</b>",
8080
"deputy.ia.report.lead": "Lead section",
8181
"deputy.ia.report.end": "End of page",
8282
"deputy.ia.report.section": "$1: $2",

i18n/settings/en.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"deputy.about.openSource": "Source",
66
"deputy.about.contact": "Contact",
77
"deputy.about.credit": "Deputy was made with the help of the English Wikipedia Copyright Cleanup WikiProject and the Wikimedia Foundation.",
8-
"deputy.about.license": "Deputy is licensed under the <a href=\"$1\">Apache License 2.0</a>. The source code for Deputy is available on <a href=\"$2\">GitHub</a>, and is free for everyone to view and suggest changes.",
9-
"deputy.about.thirdParty": "Deputy is bundled with third party libraries to make development easier. All libraries have been vetted for user security and license compatibility. For more information, see the <a href=\"$1\">\"Licensing\"</a> section on Deputy's README.",
8+
"deputy.about.license": "Deputy is licensed under the [$1 Apache License 2.0]. The source code for Deputy is available on [$2 GitHub], and is free for everyone to view and suggest changes.",
9+
"deputy.about.thirdParty": "Deputy is bundled with third party libraries to make development easier. All libraries have been vetted for user security and license compatibility. For more information, see the [$1 Licensing] section on Deputy's README.",
1010
"deputy.about.buildInfo": "Deputy v$1 ($2), committed $3.",
1111
"deputy.about.footer": "Made with love, coffee, and the tears of copyright editors.",
1212

@@ -15,7 +15,7 @@
1515

1616
"deputy.settings.wikiEditIntro.title": "This is a Deputy configuration page",
1717
"deputy.settings.wikiEditIntro.current": "Deputy's active configuration comes from this page. Changing this page will affect the settings of all Deputy users on this wiki. Edit responsibly, and avoid making significant changes without prior discussion.",
18-
"deputy.settings.wikiEditIntro.other": "This is a valid Deputy configuration page, but the configuration is currently being loaded from {{wikilink:$1}}. If this becomes the active configuration page, changing it will affect the settings of all Deputy users on this wiki. Edit responsibly, and avoid making significant changes without prior discussion.",
18+
"deputy.settings.wikiEditIntro.other": "This is a valid Deputy configuration page, but the configuration is currently being loaded from [[$1]]. If this becomes the active configuration page, changing it will affect the settings of all Deputy users on this wiki. Edit responsibly, and avoid making significant changes without prior discussion.",
1919
"deputy.settings.wikiEditIntro.edit.current": "Modify configuration",
2020
"deputy.settings.wikiEditIntro.edit.other": "Modify this configuration",
2121
"deputy.settings.wikiEditIntro.edit.otherCurrent": "Modify the active configuration",

src/modules/ia/ui/ListingActionLink.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { h } from 'tsx-dom';
22
import type CopyrightProblemsListing from '../models/CopyrightProblemsListing';
33
import type CopyrightProblemsSession from '../models/CopyrightProblemsSession';
44
import ListingResponsePanel from './ListingResponsePanel';
5-
import DeputyLanguage from '../../../DeputyLanguage';
65

76
/**
87
*

src/modules/ia/ui/SinglePageWorkflowDialog.tsx

+9-18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import equalTitle from '../../../util/equalTitle';
1212
import msgEval from '../../../wiki/util/msgEval';
1313
import CCICaseInputWidget from './CCICaseInputWidget';
1414
import changeTag from '../../../config/changeTag';
15+
import unwrapJQ from '../../../util/unwrapJQ';
1516

1617
export interface SinglePageWorkflowDialogData {
1718
page: TitleLike;
@@ -148,26 +149,16 @@ function initSinglePageWorkflowDialog() {
148149
initialize() {
149150
super.initialize();
150151

151-
const intro = <div
152-
class="ia-report-intro"
153-
dangerouslySetInnerHTML={
154-
mw.message(
155-
'deputy.ia.report.intro',
156-
CopyrightProblemsPage.getCurrentListingPage().getPrefixedText()
157-
).parse()
158-
}
159-
/>;
152+
const intro = unwrapJQ( <div class="ia-report-intro" />, mw.message(
153+
'deputy.ia.report.intro',
154+
CopyrightProblemsPage.getCurrentListingPage().getPrefixedText()
155+
).parseDom() );
160156
intro.querySelector( 'a' ).setAttribute( 'target', '_blank' );
161157

162-
const page = <div
163-
class="ia-report-intro"
164-
dangerouslySetInnerHTML={
165-
mw.message(
166-
'deputy.ia.report.page',
167-
this.page.getPrefixedText()
168-
).parse()
169-
}
170-
/>;
158+
const page = unwrapJQ( <div class="ia-report-intro" />, mw.message(
159+
'deputy.ia.report.page',
160+
this.page.getPrefixedText()
161+
).parseDom() );
171162
page.querySelector( 'a' ).setAttribute( 'target', '_blank' );
172163

173164
this.fieldsetLayout = new OO.ui.FieldsetLayout( {

src/ui/config/ConfigurationAboutTabPanel.tsx

+15-18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import deputyVersion, {
88
gitVersion
99
} from '../../DeputyVersion';
1010
import type WikiConfiguration from '../../config/WikiConfiguration';
11+
import unwrapJQ from '../../util/unwrapJQ';
1112

1213
interface ConfigurationGroupTabPanelOptions extends OO.ui.TabPanelLayout.ConfigOptions {
1314

@@ -81,27 +82,23 @@ function initConfigurationGroupTabPanel() {
8182
} ) )
8283
}</a>
8384
</div>
84-
<p dangerouslySetInnerHTML={ mw.msg( 'deputy.about.credit' ) }/>
85-
<p dangerouslySetInnerHTML={ mw.msg( 'deputy.about.license',
85+
{unwrapJQ( <p/>, mw.message( 'deputy.about.credit' ).parseDom() )}
86+
{unwrapJQ( <p/>, mw.message( 'deputy.about.license',
8687
'https://www.apache.org/licenses/LICENSE-2.0',
8788
'https://github.com/ChlodAlejandro/deputy'
88-
) }/>
89-
<p dangerouslySetInnerHTML={ mw.msg( 'deputy.about.thirdParty',
89+
).parseDom() ) }
90+
{unwrapJQ( <p/>, mw.message( 'deputy.about.thirdParty',
9091
'https://github.com/ChlodAlejandro/deputy#licensing'
91-
) }/>
92-
<p
93-
style={{ fontSize: '0.9em', color: 'darkgray' }}
94-
dangerouslySetInnerHTML={ mw.msg(
95-
'deputy.about.buildInfo',
96-
gitVersion as string,
97-
gitBranch as string,
98-
new Date( gitDate as string ).toLocaleString()
99-
) }
100-
/>
101-
<p
102-
style={{ fontSize: '0.9em', color: 'darkgray' }}
103-
dangerouslySetInnerHTML={ mw.msg( 'deputy.about.footer' ) }
104-
/>
92+
).parseDom() )}
93+
{unwrapJQ( <p style={{ fontSize: '0.9em', color: 'darkgray' }} />, mw.message(
94+
'deputy.about.buildInfo',
95+
gitVersion as string,
96+
gitBranch as string,
97+
new Date( gitDate as string ).toLocaleString()
98+
).parseDom() )}
99+
{ unwrapJQ( <p style={{ fontSize: '0.9em', color: 'darkgray' }} />, mw.message(
100+
'deputy.about.footer'
101+
).parseDom() ) }
105102
</div> );
106103
}
107104

src/ui/config/ConfigurationReloadBanner.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { h } from 'tsx-dom';
21
import '../../types';
32
import unwrapWidget from '../../util/unwrapWidget';
43
import DeputyMessageWidget from '../shared/DeputyMessageWidget';

src/ui/config/WikiConfigurationEditIntro.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import WikiConfiguration from '../../config/WikiConfiguration';
44
import { spawnConfigurationDialog } from './ConfigurationDialog';
55
import normalizeTitle from '../../wiki/util/normalizeTitle';
66
import DeputyMessageWidget from '../shared/DeputyMessageWidget';
7+
import unwrapJQ from '../../util/unwrapJQ';
78

89
/**
910
* @param config The current configuration (actively loaded, not the one being viewed)
@@ -57,12 +58,10 @@ export default function WikiConfigurationEditIntro( config: WikiConfiguration ):
5758
title: mw.msg( 'deputy.settings.wikiEditIntro.title' ),
5859
message: current ?
5960
mw.msg( 'deputy.settings.wikiEditIntro.current' ) :
60-
<span dangerouslySetInnerHTML={
61-
mw.message(
62-
'deputy.settings.wikiEditIntro.other',
63-
config.sourcePage.getPrefixedText()
64-
).parse()
65-
} />,
61+
unwrapJQ( <span/>, mw.message(
62+
'deputy.settings.wikiEditIntro.other',
63+
config.sourcePage.getPrefixedText()
64+
).parseDom() ),
6665
actions: buttons
6766
} );
6867

src/ui/root/DeputyFinishedContributionSurveyRow.tsx

+9-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import nsId from '../../wiki/util/nsId';
66
import type { Moment } from 'moment';
77
import { guessTrace } from '../../models/DeputyTrace';
88
import warn from '../../util/warn';
9+
import unwrapJQ from '../../util/unwrapJQ';
910

1011
/**
1112
* Displayed when a ContributionSurveyRow has no remaining diffs. Deputy is not able
@@ -88,7 +89,7 @@ export default class DeputyFinishedContributionSurveyRow {
8889
const talkPage = userPage.getTalkPage();
8990
const contribsPage = new mw.Title( 'Special:Contributions/' + this.author );
9091

91-
const params: string[] = [
92+
const params: ( string|JSX.Element )[] = [
9293
( <span>
9394
<a
9495
target="_blank"
@@ -108,7 +109,7 @@ export default class DeputyFinishedContributionSurveyRow {
108109
title={ contribsPage.getPrefixedText() }
109110
>{ mw.msg( 'deputy.revision.contribs' ) }</a></span>
110111
</span>
111-
</span> ).outerHTML
112+
</span> )
112113
];
113114

114115
if ( this.timestamp ) {
@@ -119,16 +120,12 @@ export default class DeputyFinishedContributionSurveyRow {
119120
);
120121
}
121122

122-
return <i
123-
dangerouslySetInnerHTML={
124-
mw.message(
125-
this.timestamp ?
126-
'deputy.session.row.checkedComplete' :
127-
'deputy.session.row.checked',
128-
...params
129-
).text()
130-
}
131-
/>;
123+
return unwrapJQ( <i/>, mw.message(
124+
this.timestamp ?
125+
'deputy.session.row.checkedComplete' :
126+
'deputy.session.row.checked',
127+
...params
128+
).parseDom() );
132129
} else {
133130
return null;
134131
}

src/ui/root/DeputyReviewDialog.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ function initDeputyReviewDialog() {
137137
</div>
138138
);
139139
} else {
140+
// noinspection JSXDomNesting
140141
this.element = swapElements(
141142
this.element,
142143
<table class="diff">

src/ui/shared/ChangesList.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import '../../types';
2-
import { h } from 'tsx-dom';
32
import getRevisionURL from '../../wiki/util/getRevisionURL';
43
import getRevisionDiffURL from '../../wiki/util/getRevisionDiffURL';
54
import nsId from '../../wiki/util/nsId';
65
import type { ExpandedRevisionData } from '../../api/ExpandedRevisionData';
7-
import { ContributionSurveyRevision } from '../../models/ContributionSurveyRevision';
6+
import { h } from 'tsx-dom';
7+
import unwrapJQ from '../../util/unwrapJQ';
88
import { USER_LOCALE } from '../../wiki/Locale';
99

1010
/**
@@ -262,10 +262,19 @@ export function ChangesListTags( { tags }: { tags: [string, string][] } ): JSX.E
262262
'deputy.revision.tags',
263263
tags.length.toString()
264264
).text() }</a>{
265-
tags.map( ( v ) => <span
266-
class={ `mw-tag-marker mw-tag-marker-${ v[ 0 ] }` }
267-
dangerouslySetInnerHTML={ v[ 1 ] }
268-
/> )
265+
tags.map( ( v ) => {
266+
// eslint-disable-next-line mediawiki/msg-doc
267+
const tagMessage = mw.message( `tag-${ v }` ).parseDom();
268+
return [
269+
' ',
270+
tagMessage.text() !== '-' && unwrapJQ(
271+
<span
272+
class={ `mw-tag-marker mw-tag-marker-${ v }` }
273+
/>,
274+
tagMessage
275+
)
276+
];
277+
} )
269278
}
270279
</span>;
271280
}

src/util/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Requester from './Requester';
2222
import sleep from './sleep';
2323
import swapElements from './swapElements';
2424
import unwrapElement from './unwrapElement';
25+
import unwrapJQ from './unwrapJQ';
2526
import unwrapWidget from './unwrapWidget';
2627
import warn from './warn';
2728
import yesNo from './yesNo';
@@ -50,6 +51,7 @@ export default {
5051
sleep: sleep,
5152
swapElements: swapElements,
5253
unwrapElement: unwrapElement,
54+
unwrapJQ: unwrapJQ,
5355
unwrapWidget: unwrapWidget,
5456
warn: warn,
5557
yesNo: yesNo

src/util/unwrapJQ.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { h } from 'tsx-dom';
2+
3+
/**
4+
* Get the nodes from a JQuery object and wraps it in an element.
5+
*
6+
* @param element The element to add the children into
7+
* @param $j The JQuery object
8+
* @return The original element, now with children
9+
*/
10+
export default function unwrapJQ( element = <span/>, $j: JQuery ): JSX.Element {
11+
$j.each( ( i, e ) => element.append( e ) );
12+
return element;
13+
}

0 commit comments

Comments
 (0)