jenkins-bot has submitted this change and it was merged. Change subject: Misc link tool fixes ......................................................................
Misc link tool fixes While creating links in translation by clicking on source links, make sure the new link has title and target to target language than just copy of source link. Fixes T102118: link cards aren't shown when selecting text in the target that doesn't exist as a link neither in source nor in target Fixes T102115: "Mark the page as missing" must not appear in the source link card Bug: T102118 Bug: T102115 Change-Id: Ib20dd0c4f4ba016ae9c31a4e797ec1c254f47c89 --- M modules/tools/ext.cx.tools.link.js 1 file changed, 26 insertions(+), 17 deletions(-) Approvals: Amire80: Looks good to me, but someone else must approve Nikerabbit: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/tools/ext.cx.tools.link.js b/modules/tools/ext.cx.tools.link.js index cbd02a3..6d6e96c 100644 --- a/modules/tools/ext.cx.tools.link.js +++ b/modules/tools/ext.cx.tools.link.js @@ -269,6 +269,11 @@ return this.title; }; + CXLink.prototype.getTargetTitle = function () { + var targetTitle = cache.linkPairs[ this.getTitle() ] || this.getTitle(); + return mw.Title.newFromText( targetTitle ).getPrefixedText(); + }; + /** * Convert a current selection if present, if editable to a link */ @@ -280,10 +285,10 @@ selection = mw.cx.selection.get(); $link = $( '<a>' ) .addClass( 'cx-target-link' ) - .text( selection.toString() || cache.linkPairs[ this.title ] || this.title ) + .text( selection.toString() || this.getTargetTitle() ) .attr( { - title: this.title, - href: this.title, + title: this.getTargetTitle(), + href: this.getTargetTitle(), rel: 'mw:WikiLink' } ); @@ -297,6 +302,10 @@ return $link; }; + /** + * Fetch the details about a page. + * @return {jQuery.Promise} + */ CXLink.prototype.fetchLinkData = function () { var api, title, self = this, language = this.getLanguage(); @@ -395,12 +404,12 @@ // This link opens Special:CX with this missing page to help translate it $link = $( '<a>' ) .addClass( 'card__link-text new' ) - .text( this.getTitle() ) + .text( mw.Title.newFromText( this.getTitle() ).getPrefixedText() ) .prop( { target: '_blank', title: mw.msg( 'cx-tools-missing-link-tooltip' ), href: new mw.Uri().extend( { - page: this.getTitle() + targettitle: this.getTitle() } ).toString() } ); @@ -800,7 +809,7 @@ var title = text.trim(); title = mw.Title.newFromText( title ); - title = title && title.getPrefixedText(); + title = title && title.toString(); return title; } @@ -849,17 +858,17 @@ // Fetch the link data and show the card in correct order - Source card and then // target card. - $.when( this.sourceLink.fetchLinkData(), this.targetLink.fetchLinkData() ) - .then( function ( sourceLink, targetLink ) { - if ( !sourceLink && !targetLink ) { - // Missing link for both source and target. Dont show the card. - self.stop(); - return; - } - self.$card.append( self.sourceLink.getCard(), self.targetLink.getCard() ); - self.$card.show(); - self.onShow(); - } ); + this.sourceLink.fetchLinkData().done( function ( page ) { + if ( page ) { + self.$card.append( self.sourceLink.getCard() ); + } + } ); + + this.targetLink.fetchLinkData().done( function () { + self.$card.append( self.targetLink.getCard() ); + self.$card.show(); + self.onShow(); + } ); }; /** -- To view, visit https://gerrit.wikimedia.org/r/217840 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib20dd0c4f4ba016ae9c31a4e797ec1c254f47c89 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits