From 29edb68446b5b6faa4b5038698f042ef25e4425d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 22 Oct 2015 21:25:32 +0200 Subject: [PATCH] mediawiki.Upload.BookletLayout: If the user can't upload, don't show them the form To improve in the future: * Check the rights on the target wiki rather than current, they might not be the same * Use a better error message when not all logged-in users can upload Bug: T115866 Change-Id: I6f68122b5399f4b8766825c752e964478ae7563d --- resources/Resources.php | 1 + .../src/mediawiki/mediawiki.Upload.BookletLayout.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/resources/Resources.php b/resources/Resources.php index 59ce155497..3a6a3b56bc 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1171,6 +1171,7 @@ return array( ), 'dependencies' => array( 'oojs-ui', + 'mediawiki.user', 'mediawiki.Upload', 'mediawiki.jqueryMsg', ), diff --git a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js index dd199ceff7..0a1121b651 100644 --- a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js +++ b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js @@ -88,6 +88,17 @@ content: [ this.insertForm ] } ) ] ); + + // If the user can't upload anything, don't give them the option to + // TODO Check the rights on the target wiki rather than current, they might not be the same + mw.user.getRights().done( function ( rights ) { + if ( rights.indexOf( 'upload' ) === -1 ) { + this.getPage( 'upload' ).$element + .empty() + // TODO Use a better error message when not all logged-in users can upload + .msg( 'api-error-mustbeloggedin' ); + } + }.bind( this ) ); }; /* Setup */ -- 2.20.1