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

Change subject: Render tabs to my collections and active collections
......................................................................


Render tabs to my collections and active collections

When anon and click my collections take the user to the login page.
Only show tabs for your own collection and public collections (we may
want to revisit this later)

Changes:
Views no longer need to define getTitle

Bug: T102188
Change-Id: I1dbe05177dfcc40857cfd0ff6a7ba3f821a89b49
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/specials/SpecialGather.php
A includes/views/Tabs.php
M includes/views/View.php
M templates/CollectionsList.mustache
A templates/tabs.mustache
8 files changed, 81 insertions(+), 3 deletions(-)

Approvals:
  Jhernandez: Looks good to me, approved
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 21759b6..75dcafc 100644
--- a/extension.json
+++ b/extension.json
@@ -79,6 +79,7 @@
                "Gather\\views\\Pagination": "includes/views/Pagination.php",
                "Gather\\views\\ReportTableRow": 
"includes/views/ReportTableRow.php",
                "Gather\\views\\ReportTable": "includes/views/ReportTable.php",
+               "Gather\\views\\Tabs": "includes/views/Tabs.php",
                "Gather\\views\\helpers\\CSS": "includes/views/helpers/CSS.php",
                "Gather\\views\\helpers\\Template": 
"includes/views/helpers/Template.php",
                "Gather\\SpecialGather": "includes/specials/SpecialGather.php",
diff --git a/i18n/en.json b/i18n/en.json
index 8dd9851..052abf7 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -32,6 +32,8 @@
        "gather-lists-show-success-toast": "List \"$1\" was made public again 
successfully.",
        "gather-lists-show-failure-toast": "Failed to show list \"$1\".",
        "gather-lists-hide-protocol": "",
+       "gather-my-collections": "My collections",
+       "gather-all-collections": "Active",
        "gather-collection-random-title": "Random pages",
        "gather-collection-random-description": "A collection of random pages 
from across {{SITENAME}}",
        "gather-editfeed-show": "Show",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 60428d8..a5e66e1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -35,6 +35,9 @@
        "gather-lists-show-failure-toast": "Label for toast diaplaying that 
showing specified list failed. Only shown to admins. Parameters:\n* $1 - Title 
of the collection.",
        "gather-lists-hide-protocol": "Text shown to administrator to a 
moderation policy which outlines moderation expectations on 
[[Special:GatherLists]] (optional)",
        "gather-collection-random-title": "Title of a collection which contains 
random items.\n{{Identical|Random page}}",
+       "gather-my-collections": "Label for tab pointing to the current user's 
collections.",
+       "gather-all-collections": "Label for tab pointing to all public 
collections.",
+       "gather-collection-random-title": "Title of a collection which contains 
random items.",
        "gather-collection-random-description": "Description of a collection 
which contains random items.",
        "gather-editfeed-show": "Label for a button to switch to a list of 
pages from the list of updates to said pages.\n\n{{Identical|Show}}",
        "gather-editfeed-title": "Title for page that allows you to view edits 
inside a collection.",
diff --git a/includes/specials/SpecialGather.php 
b/includes/specials/SpecialGather.php
index ad68959..f7ef79b 100644
--- a/includes/specials/SpecialGather.php
+++ b/includes/specials/SpecialGather.php
@@ -63,6 +63,8 @@
                        'ext.gather.moderation',
                ) );
                $out->addModuleStyles( array(
+                       // FIXME: This is needed only for the tabs at the top 
of the page.
+                       'mobile.special.pagefeed.styles',
                        'mediawiki.ui.anchor',
                        'mediawiki.ui.icon',
                        'ext.gather.icons',
@@ -196,6 +198,7 @@
                        if ( $displayAsTable ) {
                                $this->renderRows( $cList, $mode === 'hidden' ? 
'show' : 'hide' );
                        } else {
+                               $this->renderTabs( 0 );
                                $this->renderCollectionsList( $cList );
                        }
                } else {
@@ -203,6 +206,43 @@
                        $this->renderError( new views\NotFound() );
                }
 
+       }
+
+       /**
+        * Render tabs to my collections and public collections
+        *
+        * @param integer [$activeTab] - the tab that is currently selected.
+        */
+       protected function renderTabs( $activeTab = 0 ) {
+               $currentUser = $this->getUser();
+               if ( $currentUser->isAnon() ) {
+                       $myUrl = SpecialPage::getTitleFor( 'Userlogin' )
+                               ->getLocalUrl(
+                                       array(
+                                               'returnto' => 'Special:Gather',
+                                               'warning' => 
'gather-anon-view-lists',
+                                       )
+                               );
+               } else {
+                       $myUrl = SpecialPage::getTitleFor( 'Gather' 
)->getSubPage( 'by' )
+                               ->getSubPage( $this->getUser()->getName() )
+                               ->getLocalUrl();
+               }
+               $data = array(
+                       'tabs' =>array(
+                               array(
+                                       'label' => wfMessage( 
'gather-all-collections' )->text(),
+                                       'href' => SpecialPage::getTitleFor( 
'Gather' )->getSubPage( 'all/active' )
+                                               ->getLocalUrl(),
+                               ),
+                               array(
+                                       'label' => wfMessage( 
'gather-my-collections' )->text(),
+                                       'href' => $myUrl,
+                               ),
+                       ),
+               );
+               $data['tabs'][$activeTab]["isCurrentTab"] = true;
+               $this->render( new views\Tabs(), $data );
        }
 
        /**
@@ -334,6 +374,7 @@
         * @param User $user owner of collections
         */
        public function renderUserCollectionsList( User $user ) {
+               $currentUser = $this->getUser();
                $collectionsList = models\CollectionsList::newFromApi(
                        $user, $this->getUser()->equals( $user ), false,
                        $this->getRequest()->getValues()
@@ -343,7 +384,10 @@
                                wfMessage( 'gather-meta-description', 
$user->getName() ),
                                models\Image::getThumbnail( 
$collectionsList->getFile() )
                        );
-                       $this->render( new views\CollectionsList( 
$this->getUser(), $collectionsList ) );
+                       if ( $collectionsList->isOwner( $currentUser ) ) {
+                               $this->renderTabs( 1 );
+                       }
+                       $this->render( new views\CollectionsList( $currentUser, 
$collectionsList ) );
                } else {
                        $this->renderError( new views\NoPublic( $user ) );
                }
diff --git a/includes/views/Tabs.php b/includes/views/Tabs.php
new file mode 100644
index 0000000..35dd258
--- /dev/null
+++ b/includes/views/Tabs.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * CollectionsList.php
+ */
+
+namespace Gather\views;
+
+use Gather\models;
+use Gather\views\helpers\Template;
+
+/**
+ * Renders a mobile collection card list
+ */
+class Tabs extends View {
+       /**
+        * @inheritdoc
+        */
+       public function getHtml( $data = array() ) {
+               return Template::render( 'tabs', $data );
+       }
+}
diff --git a/includes/views/View.php b/includes/views/View.php
index 0931721..130f8de 100644
--- a/includes/views/View.php
+++ b/includes/views/View.php
@@ -25,7 +25,9 @@
         * @private
         * @return string Html
         */
-       abstract public function getTitle();
+       public function getTitle() {
+               return '';
+       }
 
        /**
         * Returns the title for the HTML tag title
diff --git a/templates/CollectionsList.mustache 
b/templates/CollectionsList.mustache
index b9465e2..f0f58c5 100644
--- a/templates/CollectionsList.mustache
+++ b/templates/CollectionsList.mustache
@@ -1,4 +1,3 @@
-
 <div class='collections-list content view-border-box' data-owner="{{owner}}" 
data-is-owner='{{{isOwner}}}'>
   <div class='collection-cards'>
     {{{items}}}
diff --git a/templates/tabs.mustache b/templates/tabs.mustache
new file mode 100644
index 0000000..66c6d8e
--- /dev/null
+++ b/templates/tabs.mustache
@@ -0,0 +1,6 @@
+<div class="content-header">
+       <ul class="button-bar mw-ui-button-group">
+               {{#tabs}}<li class="mw-ui-button 
{{#isCurrentTab}}mw-ui-progressive{{/isCurrentTab}}">
+                       <a href="{{href}}">{{label}}</a></li>{{/tabs}}
+       </ul>
+</div>
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1dbe05177dfcc40857cfd0ff6a7ba3f821a89b49
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
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