Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/199659
Change subject: Fix actions on Special:Gather
......................................................................
Fix actions on Special:Gather
* id of a collection can be a string, convert it to be a number (ugly
workaround,
because we can't use double equals?)
* Don't return null/false or something like that in OverlayManagers factory
function,
always return everything suitable. For non-existent actions or if the action
seems to
be done on the false collection, show an error toast and return a Deferred and
just
don't resolve it.
Change-Id: Ib7db1d7ffbf276ceaa3baa869b357a96c12e61fb
---
M i18n/en.json
M i18n/qqq.json
M resources/Resources.php
M resources/ext.gather.special/init.js
4 files changed, 15 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather
refs/changes/59/199659/1
diff --git a/i18n/en.json b/i18n/en.json
index ca3ac0a..b3a14eb 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -49,6 +49,8 @@
"gather-add-to-collection-confirm": "Add to collection",
"gather-add-to-collection-cancel": "No thanks",
"gather-remove-toast": "The page has been removed from your \"$1\"
collection.",
+ "gather-no-such-action": "Sorry, the requested action doesn't exist.",
+ "gather-unknown-error": "Sorry, there was an unknown error while
processing your request.",
"gather-desc": "Component of Mobile Frontend allowing users to curate
lists.",
"gather-no-public-lists-title": "No public collections",
"gather-no-public-lists-description": "There are no public collections
for this user.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 6dfdc6e..d5fcea6 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -53,6 +53,8 @@
"gather-add-to-collection-confirm": "Label for button that user can
click if they would like to add the current page to a collection",
"gather-add-to-collection-cancel": "Label for button that user can
click if they do not want to add to a collection.\n{{Identical|No thanks}}",
"gather-remove-toast": "Message displayed when you remove an item from
a collection. Parameters:\n* $1 - Name of collection.",
+ "gather-no-such-action": "Message used, if thse user tried to request a
non-existent action on a collection.",
+ "gather-unknown-error": "Used as an error message, if there was an
unknown error.",
"gather-desc":
"{{desc|name=Gather|url=https://www.mediawiki.org/wiki/Extension:Gather}}",
"gather-no-public-lists-title": "The title of the view shown when there
are no public collections for a user.",
"gather-no-public-lists-description": "The descriptive text explaining
that there are no public collections for a user.",
diff --git a/resources/Resources.php b/resources/Resources.php
index f0f15e4..dd101b9 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -216,6 +216,9 @@
'scripts' => array(
'ext.gather.special/init.js',
),
+ 'messages' => array(
+ 'gather-no-such-action',
+ ),
),
'ext.gather.lists' => $wgGatherMobileSpecialPageResourceBoilerplate +
array(
diff --git a/resources/ext.gather.special/init.js
b/resources/ext.gather.special/init.js
index 698b699..6c1ea20 100644
--- a/resources/ext.gather.special/init.js
+++ b/resources/ext.gather.special/init.js
@@ -2,6 +2,7 @@
var CollectionEditOverlay = M.require(
'ext.gather.edit/CollectionEditOverlay' ),
CollectionDeleteOverlay = M.require(
'ext.gather.delete/CollectionDeleteOverlay' ),
+ toast = M.require( 'toast' ),
overlayManager = M.require( 'overlayManager' );
/** Add routes for editing and deleting to the overlay manager */
@@ -10,10 +11,11 @@
id = parseInt( id, 10 );
var collection;
$.each( mw.config.get( 'wgGatherCollections' ),
function () {
- if ( this.id === id && this.isWatchlist ===
false ) {
+ if ( parseFloat( this.id ) === id &&
this.isWatchlist === false ) {
collection = this;
}
} );
+
if ( collection ) {
if ( action === 'edit' ) {
return new CollectionEditOverlay( {
@@ -23,9 +25,13 @@
return new CollectionDeleteOverlay( {
collection: collection
} );
+ } else {
+ toast.show( mw.msg(
'gather-no-such-action' ), 'error' );
+ return $.Deferred();
}
} else {
- return null;
+ toast.show( mw.msg( 'gather-unknown-error' ),
'error' );
+ return $.Deferred();
}
} );
}
--
To view, visit https://gerrit.wikimedia.org/r/199659
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7db1d7ffbf276ceaa3baa869b357a96c12e61fb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits