jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/353040 )
Change subject: CX2: Fix the js error in publishing and show success message
......................................................................
CX2: Fix the js error in publishing and show success message
Bug: T162768
Change-Id: Icc53ee5d63ef2724d6f158de25701507f174f681
---
M extension.json
M modules/mw.cx.TargetArticle.js
M modules/ui/mw.cx.ui.TranslationView.js
3 files changed, 29 insertions(+), 9 deletions(-)
Approvals:
jenkins-bot: Verified
Nikerabbit: Looks good to me, approved
diff --git a/extension.json b/extension.json
index 0febb5e..a451c91 100644
--- a/extension.json
+++ b/extension.json
@@ -1468,7 +1468,8 @@
],
"messages": [
"cx-publish-button",
- "cx-publish-button-publishing"
+ "cx-publish-button-publishing",
+ "cx-publish-page-success"
],
"dependencies": [
"ext.cx.model",
diff --git a/modules/mw.cx.TargetArticle.js b/modules/mw.cx.TargetArticle.js
index 2201c4f..8c0591d 100644
--- a/modules/mw.cx.TargetArticle.js
+++ b/modules/mw.cx.TargetArticle.js
@@ -47,13 +47,11 @@
this.checkTargetTitle( this.targetTitle ).then( function ( title ) {
apiParams.title = title;
// Post the content to publish.
- return mw.Api().postWithToken( 'csrf', apiParams, {
+ return new mw.Api().postWithToken( 'csrf', apiParams, {
// A bigger timeout since publishing after converting
html to wikitext
// parsoid is not a fast operation.
timeout: 100 * 1000 // in milliseconds
- } ).then( this.publishSuccess.bind( this ) )
- // Failure handler
- .fail( this.publishFail.bind( this ) );
+ } ).then( this.publishSuccess.bind( this ),
this.publishFail.bind( this ) );
}.bind( this ) );
return this.publishDeferred.promise();
@@ -85,8 +83,7 @@
*/
mw.cx.TargetArticle.prototype.publishComplete = function () {
this.publishDeferred.resolve( true );
- this.emit( 'publish' );
- // TODO: Event logging the publishing success
+ this.emit( 'publishSuccess' );
};
/**
diff --git a/modules/ui/mw.cx.ui.TranslationView.js
b/modules/ui/mw.cx.ui.TranslationView.js
index e5868bc..42a745b 100644
--- a/modules/ui/mw.cx.ui.TranslationView.js
+++ b/modules/ui/mw.cx.ui.TranslationView.js
@@ -189,8 +189,12 @@
mw.cx.ui.TranslationView.prototype.publish = function () {
// Disable the trigger button
this.publishButton.setDisabled( true ).setLabel( mw.msg(
'cx-publish-button-publishing' ) );
- this.targetArticle = this.targetArticle ||
- new mw.cx.TargetArticle( this.translation, this, this.config );
+ if ( !this.targetArticle ) {
+ this.targetArticle = new mw.cx.TargetArticle( this.translation,
this, this.config );
+ this.targetArticle.connect( this, {
+ publishSuccess: 'onPublishSuccess'
+ } );
+ }
this.targetArticle.publish().always( function () {
this.publishButton.setDisabled( true ).setLabel( mw.msg(
'cx-publish-button' ) );
}.bind( this ) );
@@ -211,6 +215,24 @@
this.onChange();
};
+mw.cx.ui.TranslationView.prototype.onPublishSuccess = function () {
+ this.showMessage(
+ 'success',
+ mw.message( 'cx-publish-page-success',
+ $( '<a>' ).attr( {
+ href: mw.util.getUrl( this.translation.targetTitle ),
+ target: '_blank'
+ } ).text( this.translation.targetTitle )[ 0 ].outerHTML
+ ) );
+ // Event logging
+ mw.hook( 'mw.cx.translation.published' ).fire(
+ this.translation.sourceLanguage,
+ this.translation.targetLanguage,
+ this.translation.sourceTitle,
+ this.translation.targetTitle
+ );
+};
+
/**
* Show a success/error message in the view
* @param {string} type Message class.
--
To view, visit https://gerrit.wikimedia.org/r/353040
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icc53ee5d63ef2724d6f158de25701507f174f681
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits