Skip to content

Commit

Permalink
ui: move changelist to shared
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed May 28, 2024
1 parent 8c9177d commit 73ba073
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
12 changes: 12 additions & 0 deletions i18n/shared/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
"deputy.moreInfo": "More information",
"deputy.dismiss": "Dismiss",

"deputy.revision.cur": "cur",
"deputy.revision.prev": "prev",
"deputy.revision.cur.tooltip": "Difference with latest revision",
"deputy.revision.prev.tooltip": "Difference with preceding revision",
"deputy.revision.talk": "talk",
"deputy.revision.contribs": "contribs",
"deputy.revision.bytes": "{{FORMATNUM:$1}} bytes",
"deputy.revision.byteChange": "{{FORMATNUM:$1}} bytes after change of this size",
"deputy.revision.tags": "{{PLURAL:$1|Tag|Tags}}:",
"deputy.revision.new": "N",
"deputy.revision.new.tooltip": "This edit created a new page.",

"deputy.comma-separator": ", ",

"deputy.diff": "Review your changes",
Expand Down
2 changes: 1 addition & 1 deletion src/ui/root/DeputyContributionSurveyRevision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ChangesListTags, ChangesListTime,
ChangesListUser,
NewPageIndicator
} from './DeputyChangesListElements';
} from '../shared/ChangesList';
import unwrapElement from '../../util/unwrapElement';
import DeputyLoadingDots from './DeputyLoadingDots';
import MwApi from '../../MwApi';
Expand Down
4 changes: 2 additions & 2 deletions src/ui/root/DeputyFinishedContributionSurveyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ export default class DeputyFinishedContributionSurveyRow {
target="_blank"
rel="noopener" href={ mw.util.getUrl( talkPage.getPrefixedDb() ) }
title={ talkPage.getPrefixedText() }
>{ mw.msg( 'deputy.session.revision.talk' ) }</a></span>
>{ mw.msg( 'deputy.revision.talk' ) }</a></span>
<span><a
class="mw-usertoollinks-contribs"
target="_blank"
rel="noopener" href={ mw.util.getUrl( contribsPage.getPrefixedDb() ) }
title={ contribsPage.getPrefixedText() }
>{ mw.msg( 'deputy.session.revision.contribs' ) }</a></span>
>{ mw.msg( 'deputy.revision.contribs' ) }</a></span>
</span>
</span> ).outerHTML
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import '../../types';
import { h } from 'tsx-dom';
import { ContributionSurveyRevision } from '../../models/ContributionSurveyRevision';
import getRevisionURL from '../../wiki/util/getRevisionURL';
import getRevisionDiffURL from '../../wiki/util/getRevisionDiffURL';
import nsId from '../../wiki/util/nsId';
import type { ExpandedRevisionData } from '../../api/ExpandedRevisionData';
import { ContributionSurveyRevision } from '../../models/ContributionSurveyRevision';

/**
* @param root0
Expand Down Expand Up @@ -45,7 +46,7 @@ export function ChangesListLinks(
href={ cur }
title={ mw.msg( 'deputy.session.revision.cur.tooltip' ) }
target="_blank"
>{ mw.msg( 'deputy.session.revision.cur' ) }</a></span>
>{ mw.msg( 'deputy.revision.cur' ) }</a></span>
<span>{
( !_parentid && !missing ) ?
mw.msg( 'deputy.session.revision.prev' ) :
Expand All @@ -54,7 +55,7 @@ export function ChangesListLinks(
href={ prev }
title={ mw.msg( 'deputy.session.revision.prev.tooltip' ) }
target="_blank"
>{ mw.msg( 'deputy.session.revision.prev' ) }</a>
>{ mw.msg( 'deputy.revision.prev' ) }</a>
}</span>
{
!!window.deputy.config.cci.showCvLink &&
Expand All @@ -77,8 +78,8 @@ export function ChangesListLinks(
export function NewPageIndicator(): JSX.Element {
return <abbr
class="newpage"
title={ mw.msg( 'deputy.session.revision.new.tooltip' ) }
>{ mw.msg( 'deputy.session.revision.new' ) }</abbr>;
title={ mw.msg( 'deputy.revision.new.tooltip' ) }
>{ mw.msg( 'deputy.revision.new' ) }</abbr>;
}
/**
* @param root0
Expand All @@ -100,10 +101,12 @@ export function ChangesListTime(
/**
* @param root0
* @param root0.revision
* @param root0.link
* @return HTML element
*/
export function ChangesListDate(
{ revision }: { revision: ContributionSurveyRevision }
{ revision, link }: { revision: ExpandedRevisionData, link?: boolean } |
{ revision: { timestamp: string }, link: false }
): JSX.Element {
const time = new Date( revision.timestamp );
let now = window.moment( time );
Expand All @@ -125,9 +128,11 @@ export function ChangesListDate(

const comma = mw.msg( 'comma-separator' );

return <a class="mw-changeslist-date" href={
getRevisionURL( revision.revid, revision.page.title )
}>{ formattedTime }{ comma }{ formattedDate }</a>;
return link !== false ?
<a class="mw-changeslist-date" href={
getRevisionURL( revision.revid, revision.page.title )
}>{ formattedTime }{ comma }{ formattedDate }</a> :
<span>{ formattedTime }{ comma }{ formattedDate }</span>;
}

/**
Expand Down Expand Up @@ -161,7 +166,7 @@ export function ChangesListUser( { user }: { user: string } ) {
userTalkPage.getPrefixedDb()
)}
title={ userTalkPage.getPrefixedText() }
>{ mw.msg( 'deputy.session.revision.talk' ) }</a></span> <span><a
>{ mw.msg( 'deputy.revision.talk' ) }</a></span> <span><a
class="mw-usertoollinks-contribs"
target="_blank"
rel="noopener"
Expand All @@ -170,7 +175,7 @@ export function ChangesListUser( { user }: { user: string } ) {
userContribsPage.getPrefixedDb()
)}
title={ userContribsPage.getPrefixedText() }
>{ mw.msg( 'deputy.session.revision.contribs' ) }</a></span>
>{ mw.msg( 'deputy.revision.contribs' ) }</a></span>
</span>
</span>;
}
Expand All @@ -184,7 +189,7 @@ export function ChangesListBytes( { size }: { size: number } ): JSX.Element {
return <span
class="history-size mw-diff-bytes"
data-mw-bytes={ size }
>{ mw.message( 'deputy.session.revision.bytes', size.toString() ).text() }</span>;
>{ mw.message( 'deputy.revision.bytes', size.toString() ).text() }</span>;
}

/**
Expand All @@ -209,7 +214,7 @@ export function ChangesListDiff(
diffsize == null ?
mw.msg( 'deputy.brokenDiff.explain' ) :
mw.message(
'deputy.session.revision.byteChange',
'deputy.revision.byteChange',
size.toString()
).text()
}>
Expand Down Expand Up @@ -249,7 +254,7 @@ export function ChangesListTags( { tags }: { tags: [string, string][] } ): JSX.E
title="Special:Tags"
target="_blank"
>{ mw.message(
'deputy.session.revision.tags',
'deputy.revision.tags',
tags.length.toString()
).text() }</a>{
tags.map( ( v ) => <span
Expand Down

0 comments on commit 73ba073

Please sign in to comment.