Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/233978
Change subject: Ask the user to log in if the session is lost.
......................................................................
Ask the user to log in if the session is lost.
Bug: T105968
Change-Id: If9701e29b211b925670366cb329dcd7de3cf31be
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/draft/ext.cx.draft.js
M modules/publish/ext.cx.publish.js
5 files changed, 39 insertions(+), 22 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/78/233978/1
diff --git a/extension.json b/extension.json
index f12c192..eb2be52 100644
--- a/extension.json
+++ b/extension.json
@@ -614,9 +614,10 @@
"jquery.throttle-debounce"
],
"messages": [
- "cx-save-draft-saving",
- "cx-save-draft-save-success",
+ "cx-lost-session-draft",
"cx-save-draft-error",
+ "cx-save-draft-save-success",
+ "cx-save-draft-saving",
"cx-save-draft-tooltip"
]
},
@@ -636,10 +637,11 @@
"mediawiki.api.edit"
],
"messages": [
- "cx-publish-page-success",
- "cx-publish-page-error",
+ "cx-lost-session-publish",
"cx-publish-button-publishing",
"cx-publish-captcha-title",
+ "cx-publish-page-error",
+ "cx-publish-page-success",
"unknown-error"
]
},
diff --git a/i18n/en.json b/i18n/en.json
index 7437783..d416f80 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -181,5 +181,7 @@
"cx-tools-link-external-link-placeholder": "Add external link",
"cx-tools-link-to-another-page": "Link to another page",
"cx-tools-link-apply": "Done",
- "mw-pageselector-missing": "Page does not exist"
+ "mw-pageselector-missing": "Page does not exist",
+ "cx-lost-session-draft": "Your session has expired. Your progress
cannot be saved unless you log in again in another window.",
+ "cx-lost-session-publish": "Your session has expired. You cannot
publish until you log in again in another window"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 7bcc492..b0c2870 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -186,5 +186,7 @@
"cx-tools-link-external-link-placeholder": "Placeholder text for the
input field to enter an external link",
"cx-tools-link-to-another-page": "Opens a tool that allows linking to
any internal or external page.",
"cx-tools-link-apply": "Button label to apply the link selection from
link tool card\n{{Identical|Done}}",
- "mw-pageselector-missing": "Message shown in page selector when the
search did not fetch any result"
+ "mw-pageselector-missing": "Message shown in page selector when the
search did not fetch any result",
+ "cx-lost-session-draft": "Error message to display.",
+ "cx-lost-session-publish": "Error message to display."
}
diff --git a/modules/draft/ext.cx.draft.js b/modules/draft/ext.cx.draft.js
index 3f4ea05..d4d1032 100644
--- a/modules/draft/ext.cx.draft.js
+++ b/modules/draft/ext.cx.draft.js
@@ -127,6 +127,7 @@
deferred.resolve( null );
}
} );
+
return deferred.promise();
};
@@ -333,6 +334,7 @@
return;
}
apiParams = $.extend( {}, params, {
+ assert: 'user',
action: 'cxpublish'
} );
api.postWithToken( 'edit', apiParams, {
@@ -347,8 +349,12 @@
timer = setInterval( function () {
checkAndsave();
}, 5 * 60 * 1000 );
- } ).fail( function () {
- mw.hook( 'mw.cx.error' ).fire( mw.msg(
'cx-save-draft-error' ) );
+ } ).fail( function ( errorCode ) {
+ if ( errorCode === 'assertuserfailed' ) {
+ mw.hook( 'mw.cx.error' ).fire( mw.msg(
'cx-lost-session-draft' ) );
+ } else {
+ mw.hook( 'mw.cx.error' ).fire( mw.msg(
'cx-save-draft-error' ) );
+ }
} );
};
diff --git a/modules/publish/ext.cx.publish.js
b/modules/publish/ext.cx.publish.js
index 6d2411a..c13200e 100644
--- a/modules/publish/ext.cx.publish.js
+++ b/modules/publish/ext.cx.publish.js
@@ -31,6 +31,7 @@
$( '.cx-column--translation > h2' ).text();
apiParams = $.extend( {}, params, {
+ assert: 'user',
action: 'cxpublish',
from: mw.cx.sourceLanguage,
to: mw.cx.targetLanguage,
@@ -315,21 +316,25 @@
JSON.stringify( details )
);
- // Try providing useful error information. "Unknown" by default.
- error = mw.msg( 'unknown-error' );
- if ( details.error && details.error.info ) {
- //
{"servedby":"mw####","error":{"code":"blocked","info":"You have been blocked
from editing",
- // "*":"See ...
- error = details.error.info;
- } else if ( details.edit ) {
- //
{"result":"error","edit":{"spamblacklist":"facebook.com","result":"Failure"}}
- error = JSON.stringify( details.edit );
- } else if ( details.textStatus ) {
- //
{"xhr":{"readyState":0,"status":0,"statusText":"timeout"},"textStatus":"timeout",...
- error = details.textStatus;
+ if ( code === 'assertuserfailed' ) {
+ mw.hook( 'mw.cx.error' ).fire( mw.msg(
'cx-lost-session-publish' ) );
+ } else {
+ // Try providing useful error information. "Unknown" by
default.
+ error = mw.msg( 'unknown-error' );
+ if ( details.error && details.error.info ) {
+ //
{"servedby":"mw####","error":{"code":"blocked","info":"You have been blocked
from editing",
+ // "*":"See ...
+ error = details.error.info;
+ } else if ( details.edit ) {
+ //
{"result":"error","edit":{"spamblacklist":"facebook.com","result":"Failure"}}
+ error = JSON.stringify( details.edit );
+ } else if ( details.textStatus ) {
+ //
{"xhr":{"readyState":0,"status":0,"statusText":"timeout"},"textStatus":"timeout",...
+ error = details.textStatus;
+ }
+ mw.hook( 'mw.cx.error' ).fire( mw.msg(
'cx-publish-page-error', error ) );
+ mw.log( '[CX] Error while publishing:', code, trace );
}
- mw.hook( 'mw.cx.error' ).fire( mw.msg( 'cx-publish-page-error',
error ) );
- mw.log( '[CX] Error while publishing:', code, trace );
// Enable the Publish button to allow retrying,
// and set the label back to "Publish"
--
To view, visit https://gerrit.wikimedia.org/r/233978
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9701e29b211b925670366cb329dcd7de3cf31be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits