From 73ba0735b13b079ffec5580f9f64c958e86ec9d6 Mon Sep 17 00:00:00 2001 From: Chlod Alejandro Date: Thu, 16 Mar 2023 11:27:01 +0800 Subject: [PATCH] ui: move changelist to shared --- i18n/shared/en.json | 12 +++++++ .../root/DeputyContributionSurveyRevision.tsx | 2 +- .../DeputyFinishedContributionSurveyRow.tsx | 4 +-- .../ChangesList.tsx} | 33 +++++++++++-------- 4 files changed, 34 insertions(+), 17 deletions(-) rename src/ui/{root/DeputyChangesListElements.tsx => shared/ChangesList.tsx} (87%) diff --git a/i18n/shared/en.json b/i18n/shared/en.json index 29f424b0..948dfc00 100644 --- a/i18n/shared/en.json +++ b/i18n/shared/en.json @@ -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", diff --git a/src/ui/root/DeputyContributionSurveyRevision.tsx b/src/ui/root/DeputyContributionSurveyRevision.tsx index be57b3dd..da8d43bf 100644 --- a/src/ui/root/DeputyContributionSurveyRevision.tsx +++ b/src/ui/root/DeputyContributionSurveyRevision.tsx @@ -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'; diff --git a/src/ui/root/DeputyFinishedContributionSurveyRow.tsx b/src/ui/root/DeputyFinishedContributionSurveyRow.tsx index f699c4e7..6f691d25 100644 --- a/src/ui/root/DeputyFinishedContributionSurveyRow.tsx +++ b/src/ui/root/DeputyFinishedContributionSurveyRow.tsx @@ -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' ) } + >{ mw.msg( 'deputy.revision.talk' ) } { mw.msg( 'deputy.session.revision.contribs' ) } + >{ mw.msg( 'deputy.revision.contribs' ) } ).outerHTML ]; diff --git a/src/ui/root/DeputyChangesListElements.tsx b/src/ui/shared/ChangesList.tsx similarity index 87% rename from src/ui/root/DeputyChangesListElements.tsx rename to src/ui/shared/ChangesList.tsx index a50c167d..ca08ca8b 100644 --- a/src/ui/root/DeputyChangesListElements.tsx +++ b/src/ui/shared/ChangesList.tsx @@ -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 @@ -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' ) } + >{ mw.msg( 'deputy.revision.cur' ) } { ( !_parentid && !missing ) ? mw.msg( 'deputy.session.revision.prev' ) : @@ -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' ) } + >{ mw.msg( 'deputy.revision.prev' ) } } { !!window.deputy.config.cci.showCvLink && @@ -77,8 +78,8 @@ export function ChangesListLinks( export function NewPageIndicator(): JSX.Element { return { mw.msg( 'deputy.session.revision.new' ) }; + title={ mw.msg( 'deputy.revision.new.tooltip' ) } + >{ mw.msg( 'deputy.revision.new' ) }; } /** * @param root0 @@ -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 ); @@ -125,9 +128,11 @@ export function ChangesListDate( const comma = mw.msg( 'comma-separator' ); - return { formattedTime }{ comma }{ formattedDate }; + return link !== false ? + { formattedTime }{ comma }{ formattedDate } : + { formattedTime }{ comma }{ formattedDate }; } /** @@ -161,7 +166,7 @@ export function ChangesListUser( { user }: { user: string } ) { userTalkPage.getPrefixedDb() )} title={ userTalkPage.getPrefixedText() } - >{ mw.msg( 'deputy.session.revision.talk' ) } { mw.msg( 'deputy.revision.talk' ) } { mw.msg( 'deputy.session.revision.contribs' ) } + >{ mw.msg( 'deputy.revision.contribs' ) } ; } @@ -184,7 +189,7 @@ export function ChangesListBytes( { size }: { size: number } ): JSX.Element { return { mw.message( 'deputy.session.revision.bytes', size.toString() ).text() }; + >{ mw.message( 'deputy.revision.bytes', size.toString() ).text() }; } /** @@ -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() }> @@ -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() }{ tags.map( ( v ) =>