jenkins-bot has submitted this change and it was merged.
Change subject: Override beta feature preference if Special:CX accessed with
valid token
......................................................................
Override beta feature preference if Special:CX accessed with valid token
Translations in CX involve two languages. When creating a new translation,
CX redirects the user to the target Wikipedia so that articles are created
locally.
This means that a user in the Spanish Wikipedia CX dashboard can start a
translation
from Spanish to Catalan, and as a result he will be redirected to Catalan
Wikipedia's CX translate editor. This redirect allows CX to present an
integrated
view of all translations (the user does not have to figure out to which site to
start a translation from), but avoid cross-wiki saving issues.
When CX is isolated as a beta feature, the redirect may be problematic since
the user needs to have the beta feature enabled for each of the languages
involved. If that is not the case, the user will get a page not found error
instead which will break the user experience badly.
To avoid this issue, we allow access CX even if the beta feature is disabled
only
in the case of being part of the described redirection. The rationale is that
the user has already enabled the beta feature on a site,
and is clearly expressing the intent to start a new translation
for which reaching CX will provide less surprise than getting an error message.
Bug: T78001
Change-Id: Ia54f8912ef5f9dad20af5d2ebaaa966df767de67
---
M modules/dashboard/ext.cx.dashboard.js
M modules/dashboard/ext.cx.translationlist.js
M modules/source/ext.cx.source.selector.js
M specials/SpecialContentTranslation.php
4 files changed, 22 insertions(+), 16 deletions(-)
Approvals:
Jsahleen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/dashboard/ext.cx.dashboard.js
b/modules/dashboard/ext.cx.dashboard.js
index 882ee74..44de4a9 100644
--- a/modules/dashboard/ext.cx.dashboard.js
+++ b/modules/dashboard/ext.cx.dashboard.js
@@ -61,7 +61,7 @@
var query,
sourceSelectorOptions = {};
- query =new mw.Uri().query;
+ query = new mw.Uri().query;
sourceSelectorOptions.sourceLanguage = query.from;
sourceSelectorOptions.targetLanguage = query.to;
sourceSelectorOptions.sourceTitle = query.page;
diff --git a/modules/dashboard/ext.cx.translationlist.js
b/modules/dashboard/ext.cx.translationlist.js
index 26af902..ff1fb8f 100644
--- a/modules/dashboard/ext.cx.translationlist.js
+++ b/modules/dashboard/ext.cx.translationlist.js
@@ -169,7 +169,7 @@
page: translation.sourceTitle,
targettitle:
translation.targetTitle,
draft: translation.status ===
'draft' ? translation.id : undefined
- } ).toString(),
+ } ).toString()
} ).text( translation.sourceTitle );
$sourceLanguage = $( '<div>' )
.addClass( 'source-language' )
@@ -201,9 +201,9 @@
for ( i = 0; i < languages.length; i++ ) {
$filter.append(
$( '<option>' )
- // Todo: use translated language name
- .text( $.uls.data.getAutonym(
languages[ i ] ) )
- .attr( 'value', languages[ i ] )
+ // Todo: use translated language name
+ .text( $.uls.data.getAutonym( languages[ i ] ) )
+ .attr( 'value', languages[ i ] )
);
}
};
@@ -213,8 +213,7 @@
.addClass( 'translation-filter' );
this.$statusFilter = createSelect(
- 'translation-status-filter',
- {
+ 'translation-status-filter', {
'': mw.msg(
'cx-translation-filter-all-translations' ),
published: mw.msg(
'cx-translation-filter-published-translations' ),
draft: mw.msg(
'cx-translation-filter-draft-translations' )
@@ -222,15 +221,13 @@
);
this.$sourceLanguageFilter = createSelect(
- 'translation-source-language-filter',
- {
+ 'translation-source-language-filter', {
'': mw.msg(
'cx-translation-filter-from-any-language' )
}
);
this.$targetLanguageFilter = createSelect(
- 'translation-target-language-filter',
- {
+ 'translation-target-language-filter', {
'': mw.msg(
'cx-translation-filter-to-any-language' )
}
);
diff --git a/modules/source/ext.cx.source.selector.js
b/modules/source/ext.cx.source.selector.js
index 79d4a31..150fef6 100644
--- a/modules/source/ext.cx.source.selector.js
+++ b/modules/source/ext.cx.source.selector.js
@@ -706,11 +706,12 @@
* @param {string} sourceTitle Source title
*/
function setCXToken( sourceLanguage, targetLanguage, sourceTitle ) {
- var date = new Date();
+ var slug, date = new Date();
// At this point, the translator saw the license agreement.
// Save that information in a domain cookie
+ slug = sourceTitle.replace( /\s/, '-' );
$.cookie(
- [ 'cx', sourceLanguage, targetLanguage, sourceTitle
].join( '_' ),
+ [ 'cx', sourceLanguage, targetLanguage, slug ].join(
'_' ),
true, {
prefix: '',
// Use Domain cookie. Example:
domain=.wikipedia.org
diff --git a/specials/SpecialContentTranslation.php
b/specials/SpecialContentTranslation.php
index e95fd76..afb2219 100644
--- a/specials/SpecialContentTranslation.php
+++ b/specials/SpecialContentTranslation.php
@@ -31,10 +31,18 @@
$request = $this->getRequest();
$token = implode( '_', array(
- 'cx', $request->getVal( 'from' ), $request->getVal(
'to' ), $request->getVal( 'page' )
- ) );
+ 'cx',
+ $request->getVal( 'from' ),
+ $request->getVal( 'to' ),
+ preg_replace( "/\s/", "-", urldecode( $request->getVal(
'page' ) ) )
+ ) );
+
// Direct access, isListed only affects Special:SpecialPages
- if ( !ContentTranslationHooks::isEnabledForUser(
$this->getUser() ) ) {
+ if ( !ContentTranslationHooks::isEnabledForUser(
$this->getUser() ) &&
+ // With a valid cx token or draft id, override beta
feature settings.
+ $request->getCookie( $token, '' ) === null &&
+ $request->getVal( 'draft' ) === null
+ ) {
$out->showErrorPage( 'nosuchspecialpage',
'nospecialpagetext' );
return;
}
--
To view, visit https://gerrit.wikimedia.org/r/179115
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia54f8912ef5f9dad20af5d2ebaaa966df767de67
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Jsahleen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits