Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/75994


Change subject: A few UI cleanups
......................................................................

A few UI cleanups

* Added basic title tooltips from TODO comment
* Renamed the CSS module to use ext prefix

Change-Id: I1a5da44473ce4c1b809080285b41e82111be8fe3
---
M backend/MWOAuthUtils.php
M frontend/MWOAuthUI.setup.php
R frontend/modules/ext.MWOAuth.css
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
M frontend/specialpages/SpecialMWOAuthManageMyGrants.php
5 files changed, 36 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth 
refs/changes/94/75994/1

diff --git a/backend/MWOAuthUtils.php b/backend/MWOAuthUtils.php
index 59c7a72..99b14e9 100644
--- a/backend/MWOAuthUtils.php
+++ b/backend/MWOAuthUtils.php
@@ -131,6 +131,19 @@
        }
 
        /**
+        * @return array
+        */
+       public static function getRightsByGrant() {
+               global $wgMWOAuthGrantPermissions;
+
+               $res = array();
+               foreach ( $wgMWOAuthGrantPermissions as $grant => $rights ) {
+                       $res[$grant] = array_keys( array_filter( $rights ) );
+               }
+               return $res;
+       }
+
+       /**
         * @param string $grant
         * @return Message
         */
diff --git a/frontend/MWOAuthUI.setup.php b/frontend/MWOAuthUI.setup.php
index 5cc44ef..e0e1969 100644
--- a/frontend/MWOAuthUI.setup.php
+++ b/frontend/MWOAuthUI.setup.php
@@ -60,7 +60,7 @@
         */
        public static function defineResourceModules( array &$modules ) {
                $modules['ext.MWOAuth'] = array(
-                       'styles'        => 'MWOAuth.css',
+                       'styles'        => 'ext.MWOAuth.css',
                        'localBasePath' => dirname( __FILE__ ) . '/modules',
                        'remoteExtPath' => 'OAuth/frontend/modules',
                );
diff --git a/frontend/modules/MWOAuth.css b/frontend/modules/ext.MWOAuth.css
similarity index 100%
rename from frontend/modules/MWOAuth.css
rename to frontend/modules/ext.MWOAuth.css
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php 
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index 99a55f0..96e6e97 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -37,6 +37,7 @@
        public function execute( $par ) {
                $user = $this->getUser();
                $request = $this->getRequest();
+               $lang = $this->getLanguage();
 
                $block = $user->getBlock();
                if ( $block ) {
@@ -105,7 +106,16 @@
                                                        array_map( 
'MWOAuthUtils::grantName', MWOAuthUtils::getValidGrants() ),
                                                        
MWOAuthUtils::getValidGrants()
                                                ),
-                                               // @TODO: tooltips
+                                               'tooltips' => array_combine(
+                                                       array_map( 
'MWOAuthUtils::grantName', MWOAuthUtils::getValidGrants() ),
+                                                       array_map(
+                                                               function( 
$rights ) use ( $lang ) {
+                                                                       return 
$lang->semicolonList( array_map(
+                                                                               
'User::getRightDescription', $rights ) );
+                                                               },
+                                                               
MWOAuthUtils::getRightsByGrant()
+                                                       )
+                                               ),
                                        ),
                                        'restrictions' => array(
                                                'type' => 'textarea',
diff --git a/frontend/specialpages/SpecialMWOAuthManageMyGrants.php 
b/frontend/specialpages/SpecialMWOAuthManageMyGrants.php
index cbe8f18..ba29a57 100644
--- a/frontend/specialpages/SpecialMWOAuthManageMyGrants.php
+++ b/frontend/specialpages/SpecialMWOAuthManageMyGrants.php
@@ -100,6 +100,7 @@
         */
        protected function handleConsumerForm( $acceptanceId ) {
                $user = $this->getUser();
+               $lang = $this->getLanguage();
                $db = MWOAuthUtils::getCentralDB( DB_SLAVE );
 
                $cmra = MWOAuthDAOAccessControl::wrap(
@@ -157,8 +158,17 @@
                                        'default' => array_map(
                                                function( $g ) { return 
"grant-$g"; },
                                                $cmra->get( 'grants' )
+                                       ),
+                                       'tooltips' => array_combine(
+                                               array_map( 
'MWOAuthUtils::grantName', MWOAuthUtils::getValidGrants() ),
+                                               array_map(
+                                                       function( $rights ) use 
( $lang ) {
+                                                               return 
$lang->semicolonList( array_map(
+                                                                       
'User::getRightDescription', $rights ) );
+                                                       },
+                                                       
MWOAuthUtils::getRightsByGrant()
+                                               )
                                        )
-                                       // @TODO: tooltips
                                ),
                                'usedOnWiki' => array(
                                        'type' => 'info',

-- 
To view, visit https://gerrit.wikimedia.org/r/75994
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a5da44473ce4c1b809080285b41e82111be8fe3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to