jenkins-bot has submitted this change and it was merged.

Change subject: Article reader sees guidance about creating a collection
......................................................................


Article reader sees guidance about creating a collection

* Shows collection tutorial overlay under watchstar
** Only shows user has not added a collection and if enabled
** Set $wgGatherShouldShowTutorial = true; to test
*  Does not show again after dismissed or when disabled
* On Deployment set $wgGatherShouldShowTutorial
to be false two weeks after deployment date.

Note: positioning issues captured in T91047, in meantime
we work around this issue using a timeout (see FIXME)

bug: T91015

dependency: I9c5dbab0b7583fe7668b8a9873eddf566cfd92e2
Change-Id: Ie1fb074ddac82aefebecb077d4422d263c9c0bc1
---
M Gather.php
M i18n/en.json
M i18n/qqq.json
M includes/Gather.hooks.php
M resources/Resources.php
M resources/ext.gather.watchstar/init.js
6 files changed, 102 insertions(+), 9 deletions(-)

Approvals:
  Robmoen: Looks good to me, but someone else must approve
  Jhernandez: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Gather.php b/Gather.php
index 50556d2..8d7f415 100644
--- a/Gather.php
+++ b/Gather.php
@@ -84,5 +84,8 @@
 $wgAPIListModules['lists'] = 'Gather\api\ApiQueryLists';
 $wgAPIListModules['listpages'] = 'Gather\api\ApiQueryListPages';
 
+// Configuration
+$wgGatherShouldShowTutorial = true;
+
 // ResourceLoader modules
 require_once __DIR__ . "/resources/Resources.php";
diff --git a/i18n/en.json b/i18n/en.json
index 86f8582..36cbeb7 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -25,6 +25,9 @@
        "gather-add-toast": "The page has been added to your \"$1\" 
collection.",
        "gather-new-collection-failed-toast": "There was a problem creating 
your \"$1\" collection.",
        "gather-add-failed-toast": "There was a problem adding the item to your 
\"$1\" collection.",
+       "gather-add-to-collection-summary": "Would you like to add $1 to a 
collection?",
+       "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-desc": "Component of Mobile Frontend allowing users to curate 
lists.",
        "gather-no-public-lists-title": "No public collections",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 14694e1..09712a1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -26,6 +26,9 @@
        "gather-add-to-new": "Heading that shows in the watchstar content 
overlay above a form to create a new collection.",
        "gather-add-to-existing": "Heading that shows in the watchstar content 
overlay above a list of your existing collections.",
        "gather-add-toast": "Message displayed when you add an item to a 
collection. Parameters:\n* $1 - Name of collection.",
+       "gather-add-to-collection-summary": "Text for a tutorial overlay 
presented to a user the first time they see the collections watchstar asking 
them if they would like to add the current page to a 
collection.\n\nParameters:\n* $1 - page title\n",
+       "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-new-collection-failed-toast": "Message displayed when creating 
a new collection fails. Parameters:\n* $1 - Name of collection.",
        "gather-add-failed-toast": "Message displayed when adding an item to a 
collection fails. Parameters:\n* $1 - Name of collection.",
        "gather-remove-toast": "Message displayed when you remove an item from 
a collection. Parameters:\n* $1 - Name of collection.",
diff --git a/includes/Gather.hooks.php b/includes/Gather.hooks.php
index 65fe717..3f8201f 100644
--- a/includes/Gather.hooks.php
+++ b/includes/Gather.hooks.php
@@ -106,6 +106,7 @@
         * Load user collections
         */
        public static function onMakeGlobalVariablesScript( &$vars, $out ) {
+               global $wgGatherShouldShowTutorial;
                $user = $out->getUser();
                $title = $out->getTitle();
                if ( !$user->isAnon() ) {
@@ -136,6 +137,7 @@
                        }
                        $vars['wgGatherCollections'] = $gatherCollections;
                }
+               $vars['wgGatherShouldShowTutorial'] = 
$wgGatherShouldShowTutorial;
                // Expose page image.
                // FIXME: Should probably be in PageImages extension
                if ( defined( 'PAGE_IMAGES_INSTALLED' ) && 
$title->getNamespace() === NS_MAIN ) {
diff --git a/resources/Resources.php b/resources/Resources.php
index 2f25098..1c01506 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -122,6 +122,9 @@
                        'gather-add-to-new',
                        'gather-collection-non-member',
                        'gather-add-new-placeholder',
+                       'gather-add-to-collection-summary',
+                       'gather-add-to-collection-confirm',
+                       'gather-add-to-collection-cancel',
                ),
                'templates' => array(
                        'content.hogan' => 'ext.gather.watchstar/content.hogan',
diff --git a/resources/ext.gather.watchstar/init.js 
b/resources/ext.gather.watchstar/init.js
index b10e235..30cb04c 100644
--- a/resources/ext.gather.watchstar/init.js
+++ b/resources/ext.gather.watchstar/init.js
@@ -1,9 +1,81 @@
 // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
 ( function ( M, $ ) {
 
-       var CollectionsWatchstar = M.require( 
'ext.gather.watchstar/CollectionsWatchstar' ),
+       var actionOverlay,
+               $target = $( '#ca-watch' ),
+               CollectionsWatchstar = M.require( 
'ext.gather.watchstar/CollectionsWatchstar' ),
+               PageActionOverlay = M.require( 
'modules/tutorials/PageActionOverlay' ),
+               settings = M.require( 'settings' ),
+               settingName = 'gather-has-dismissed-tutorial',
                util = M.require( 'util' ),
                user = M.require( 'user' );
+
+       /**
+        * Determines if collection tutorial should be shown
+        *
+        * @method
+        * @ignore
+        * @returns {Boolean}
+        */
+       function shouldShowCollectionTutorial() {
+               var collections = mw.config.get( 'wgGatherCollections' ),
+                       // Show to anonymous or a user with only watchstar as a 
collection
+                       // note ES5 method usage
+                       showToUser = user.isAnon() || Object.keys( collections 
).length === 1;
+
+               if (
+                       // User only has a watchlist, meaning they have not 
created a collection
+                       showToUser &&
+                       // Tutorial has never been dismissed
+                       !settings.get( settingName ) &&
+                       // Feature flag is enabled
+                       mw.config.get( 'wgGatherShouldShowTutorial' )
+               ) {
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Disable and hide the tutorial
+        * @method
+        * @ignore
+        */
+       function dismissTutorial() {
+               actionOverlay.hide();
+               settings.save( settingName, true );
+       }
+
+       /**
+        * Show a pointer that points to the collection feature.
+        * @method
+        * @param {Watchstar} watchstar
+        * @ignore
+        */
+       function showPointer( watchstar ) {
+               // FIXME: Should be it's own View (WatchstarPageActionOverlay)
+               actionOverlay = new PageActionOverlay( {
+                       target: $target,
+                       className: 'slide active editing',
+                       summary: mw.msg( 'gather-add-to-collection-summary', 
mw.config.get( 'wgTitle' ) ),
+                       confirmMsg: mw.msg( 'gather-add-to-collection-confirm' 
),
+                       cancelMsg: mw.msg( 'gather-add-to-collection-cancel' )
+               } );
+               actionOverlay.show();
+               // Refresh pointer otherwise it is not positioned
+               // FIXME: Remove when ContentOverlay is fixed
+               actionOverlay.refreshPointerArrow( $target );
+               // Dismiss when watchstar is clicked
+               $target.on( 'click', dismissTutorial );
+               // Dismiss when 'No thanks' button is clicked
+               actionOverlay.$( '.cancel' ).on( 'click', dismissTutorial );
+               // Toggle WatstarOverlay and dismiss
+               actionOverlay.$( '.actionable' ).on( 'click', function ( ev ) {
+                       // Hide the tutorial
+                       watchstar.onStatusToggle.call( watchstar, ev );
+                       dismissTutorial();
+               } );
+       }
 
        /**
         * Toggle the watch status of a known page
@@ -12,17 +84,24 @@
         * @ignore
         */
        function init( page ) {
-               var $container = $( '#ca-watch' );
+               var watchstar = new CollectionsWatchstar( {
+                       el: $target,
+                       page: page,
+                       isAnon: user.isAnon(),
+                       collections: mw.config.get( 'wgGatherCollections' ),
+                       isNewlyAuthenticatedUser: util.query.article_action === 
'add_to_collection'
+               } );
                if ( !page.inNamespace( 'special' ) ) {
-                       new CollectionsWatchstar( {
-                               el: $container,
-                               page: page,
-                               isAnon: user.isAnon(),
-                               collections: mw.config.get( 
'wgGatherCollections' ),
-                               isNewlyAuthenticatedUser: 
util.query.article_action === 'add_to_collection'
-                       } );
+                       // Determine if we should show the collection tutorial
+                       if ( $target.length > 0 && 
shouldShowCollectionTutorial() ) {
+                               // FIXME: Timeout shouldn't be necessary but 
T91047 exists.
+                               setTimeout( function () {
+                                       showPointer( watchstar );
+                               }, 2000 );
+                       }
                }
        }
+
        init( M.getCurrentPage() );
 
 }( mw.mobileFrontend, jQuery ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie1fb074ddac82aefebecb077d4422d263c9c0bc1
Gerrit-PatchSet: 15
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Robmoen <rm...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Robmoen <rm...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to