Skip to content

Commit ec1bd49

Browse files
cci(changelist): adjust layout, fix links
1 parent a5c6abf commit ec1bd49

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/ui/root/DeputyChangesListElements.tsx

+7-12
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,24 @@ export function ChangesListLinks(
1616
{ revid: _revid, parentid: _parentid, missing }:
1717
{ revid: number, parentid: number, missing?: boolean }
1818
): JSX.Element {
19-
let diff: number | 'prev' = _revid;
20-
let oldid = _parentid;
21-
if ( missing ) {
22-
oldid = _revid;
23-
diff = 'prev';
24-
}
19+
const cur = getRevisionDiffURL( _revid, 'cur' );
20+
const prev = missing ?
21+
getRevisionDiffURL( _revid, 'prev' ) :
22+
getRevisionDiffURL( _parentid, _revid );
2523

2624
return <span class="mw-changeslist-links">
2725
<span><a
2826
rel="noopener"
29-
href={ getRevisionDiffURL( diff, 'cur' ) }
27+
href={ cur }
3028
title={ mw.msg( 'deputy.session.revision.cur.tooltip' ) }
3129
target="_blank"
3230
>{ mw.msg( 'deputy.session.revision.cur' ) }</a></span>
3331
<span>{
34-
!oldid ?
32+
( !_parentid && !missing ) ?
3533
mw.msg( 'deputy.session.revision.prev' ) :
3634
<a
3735
rel="noopener"
38-
href={ !oldid ?
39-
null :
40-
getRevisionDiffURL( oldid, diff )
41-
}
36+
href={ prev }
4237
title={ mw.msg( 'deputy.session.revision.prev.tooltip' ) }
4338
target="_blank"
4439
>{ mw.msg( 'deputy.session.revision.prev' ) }</a>

src/ui/root/DeputyContributionSurveyRevision.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ export default class DeputyContributionSurveyRevision
189189
return <span>
190190
{
191191
!this.revision.parentid && <NewPageIndicator />
192-
}<ChangesListTime
192+
} <ChangesListTime
193193
timestamp={ this.revision.timestamp }
194194
/><ChangesListDate
195195
revision={ this.revision }
196-
/> <ChangesListUser
196+
/> <ChangesListUser
197197
user={ this.revision.user }
198198
/> <span
199199
class="mw-changeslist-separator"
@@ -216,7 +216,7 @@ export default class DeputyContributionSurveyRevision
216216
*/
217217
renderMissingRevisionInfo(): HTMLElement {
218218
return <span>
219-
<i dangerouslySetInnerHTML={mw.message(
219+
{' '}<i dangerouslySetInnerHTML={mw.message(
220220
'deputy.session.revision.missing',
221221
this.revision.revid
222222
).parse()}/>
@@ -241,7 +241,7 @@ export default class DeputyContributionSurveyRevision
241241
revid={ this.revision.revid }
242242
parentid={ this.revision.parentid }
243243
missing={ ( this.revision as any ).missing }
244-
/> {unwrapElement(
244+
/>{unwrapElement(
245245
( this.revision as any ).missing ?
246246
this.renderMissingRevisionInfo() :
247247
this.renderRevisionInfo()

src/util/unwrapElement.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* @param el The element to unwrap.
66
* @return The unwrapped element.
77
*/
8-
export default function ( el: HTMLElement ): HTMLElement[] {
9-
return Array.from( el.children ) as HTMLElement[];
8+
export default function ( el: HTMLElement ): ( HTMLElement | string )[] {
9+
return Array.from( el.childNodes ).map( v =>
10+
v instanceof HTMLElement ? v :
11+
( v instanceof Text ? v.textContent : undefined )
12+
).filter( v => v !== undefined );
1013
}

0 commit comments

Comments
 (0)