jenkins-bot has submitted this change and it was merged.
Change subject: Render tabs to my collections and recent collections
......................................................................
Render tabs to my collections and recent collections
Restore the original patch now a workaround is in place.
Fix up to include i18n changes in I99e6d16b5aa87ead034e2219e55824baee84d482
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: I89f6dd5425cd559b070ee363a383bfe9f19657bd
See: 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 resources/ext.gather.styles/vector.less
M templates/CollectionsList.mustache
M templates/compiled/CollectionsList.mustache.php
A templates/compiled/tabs.mustache.php
A templates/tabs.mustache
M tests/browser/features/anonymous.feature
M tests/browser/features/step_definitions/anonymous_steps.rb
A tests/browser/features/support/pages/gather_recent_page.rb
14 files changed, 157 insertions(+), 9 deletions(-)
Approvals:
Jhernandez: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index c80570e..ec17381 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\\TemplateParser":
"includes/views/TemplateParser.php",
"Gather\\views\\helpers\\CSS": "includes/views/helpers/CSS.php",
"Gather\\views\\helpers\\Template":
"includes/views/helpers/Template.php",
diff --git a/i18n/en.json b/i18n/en.json
index 80a6f0a..c0da830 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": "Recent",
"gather-collection-random-title": "Random pages",
"gather-collection-random-description": "A collection of random pages
from across {{SITENAME}}",
"gather-collection-edited-title": "Recently edited",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 4c947cb..a80c5de 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-collection-edited-title": "Title of collection which contains
recently edited items.",
"gather-collection-edited-description": "Description of a collection
which contains the most recently edited pages from across {{SITENAME}}",
diff --git a/includes/specials/SpecialGather.php
b/includes/specials/SpecialGather.php
index fd7504d..7882586 100644
--- a/includes/specials/SpecialGather.php
+++ b/includes/specials/SpecialGather.php
@@ -73,6 +73,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',
@@ -88,7 +90,7 @@
->getSubPage( $user->getName()
);
} else {
$page = SpecialPage::getTitleFor( 'Gather'
)->getSubPage( 'all' )
- ->getSubPage( 'active' );
+ ->getSubPage( 'recent' );
}
$out->redirect( $page->getLocalUrl() );
} elseif ( $subpage === 'by' || $subpage === 'by/' ) {
@@ -157,7 +159,7 @@
// All collections. Public or hidden
// /all = /all/ = /all/public = /all/public/
// /all/hidden = /all/hidden/
- // /all/active = /all/active/
+ // /all/recent = /all/recent/
$apiParams = array();
$displayAsTable = true;
@@ -170,7 +172,7 @@
}
$originalMode = $mode;
- if ( $mode === 'active' ) {
+ if ( $mode === 'recent' ) {
// Fancy list of collections with a certain
amount of items.
$displayAsTable = false;
@@ -211,6 +213,7 @@
if ( $displayAsTable ) {
$this->renderRows( $cList, $mode === 'hidden' ?
'show' : 'hide' );
} else {
+ $this->renderTabs( 0 );
$this->renderCollectionsList( $cList );
}
} else {
@@ -218,6 +221,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/recent' )
+ ->getLocalUrl(),
+ ),
+ array(
+ 'label' => wfMessage(
'gather-my-collections' )->text(),
+ 'href' => $myUrl,
+ ),
+ ),
+ );
+ $data['tabs'][$activeTab]["isCurrentTab"] = true;
+ $this->render( new views\Tabs(), $data );
}
/**
@@ -349,6 +389,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()
@@ -358,7 +399,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/resources/ext.gather.styles/vector.less
b/resources/ext.gather.styles/vector.less
index 54e3258..374e310 100644
--- a/resources/ext.gather.styles/vector.less
+++ b/resources/ext.gather.styles/vector.less
@@ -2,6 +2,25 @@
@import "minerva.variables.less";
@import "minerva.mixins.less";
+.content-header {
+ padding: 0 16px 20px 0;
+}
+
+.mw-ui-button-group {
+ text-align: left;
+ margin: 0;
+
+ * {
+ // FIXME: !important needed to overrride rule in mw-ui-button
+ float: none !important;
+ }
+
+ // For talk and CTA drawer
+ .mw-ui-block {
+ width: auto;
+ }
+}
+
.view-border-box,
.collection {
* {
diff --git a/templates/CollectionsList.mustache
b/templates/CollectionsList.mustache
index 34a6c8a..7f99f71 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}}}' data-mode='{{mode}}'>
<div class='collection-cards'>
diff --git a/templates/compiled/CollectionsList.mustache.php
b/templates/compiled/CollectionsList.mustache.php
index 3bb75bf..974f20f 100644
--- a/templates/compiled/CollectionsList.mustache.php
+++ b/templates/compiled/CollectionsList.mustache.php
@@ -21,8 +21,7 @@
);
- return '
-<div class=\'collections-list content view-border-box\'
data-owner="'.htmlentities((string)LCRun3::v($cx, $in, array('owner')),
ENT_QUOTES, 'UTF-8').'"
+ return '<div class=\'collections-list content view-border-box\'
data-owner="'.htmlentities((string)LCRun3::v($cx, $in, array('owner')),
ENT_QUOTES, 'UTF-8').'"
data-is-owner=\''.LCRun3::v($cx, $in, array('isOwner')).'\'
data-mode=\''.htmlentities((string)LCRun3::v($cx, $in, array('mode')),
ENT_QUOTES, 'UTF-8').'\'>
<div class=\'collection-cards\'>
'.LCRun3::v($cx, $in, array('items')).'
diff --git a/templates/compiled/tabs.mustache.php
b/templates/compiled/tabs.mustache.php
new file mode 100644
index 0000000..ccd850f
--- /dev/null
+++ b/templates/compiled/tabs.mustache.php
@@ -0,0 +1,31 @@
+<?php return function ($in, $debugopt = 1) {
+ $cx = array(
+ 'flags' => array(
+ 'jstrue' => false,
+ 'jsobj' => false,
+ 'spvar' => false,
+ 'prop' => false,
+ 'method' => false,
+ 'mustlok' => true,
+ 'echo' => false,
+ 'debug' => $debugopt,
+ ),
+ 'constants' => array(),
+ 'helpers' => array(),
+ 'blockhelpers' => array(),
+ 'hbhelpers' => array(),
+ 'partials' => array(),
+ 'scopes' => array(),
+ 'sp_vars' => array('root' => $in),
+ 'lcrun' => 'LCRun3',
+
+ );
+
+ return '<div class="content-header">
+ <ul class="button-bar mw-ui-button-group">
+ '.LCRun3::sec($cx, LCRun3::v($cx, $in, array('tabs')), $in,
false, function($cx, $in) {return '<li class="mw-ui-button '.LCRun3::sec($cx,
LCRun3::v($cx, $in, array('isCurrentTab')), $in, false, function($cx, $in)
{return 'mw-ui-progressive';}).'">
+ <a href="'.htmlentities((string)LCRun3::v($cx, $in,
array('href')), ENT_QUOTES, 'UTF-8').'">'.htmlentities((string)LCRun3::v($cx,
$in, array('label')), ENT_QUOTES, 'UTF-8').'</a></li>';}).'
+ </ul>
+</div>';
+}
+?>
\ No newline at end of file
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
diff --git a/tests/browser/features/anonymous.feature
b/tests/browser/features/anonymous.feature
index ae5c11a..a5f1c30 100644
--- a/tests/browser/features/anonymous.feature
+++ b/tests/browser/features/anonymous.feature
@@ -5,8 +5,13 @@
Given I am not logged in
And I am using the mobile site
- Scenario: Gather redirects to login screen
+ Scenario: Gather shows public view
When I visit the Gather page
+ Then I see the recent collections page
+
+ Scenario: Clicking tab shows login page
+ When I visit the Gather page
+ And I click the my collections tab
Then I see the login page
Scenario: Anons not allowed to view private collections
diff --git a/tests/browser/features/step_definitions/anonymous_steps.rb
b/tests/browser/features/step_definitions/anonymous_steps.rb
index d80c08b..3439de2 100644
--- a/tests/browser/features/step_definitions/anonymous_steps.rb
+++ b/tests/browser/features/step_definitions/anonymous_steps.rb
@@ -9,6 +9,15 @@
visit(WatchlistCollectionPage)
end
+When(/^I click the my collections tab$/) do
+ on(GatherRecentPage).my_collections_button_element.click
+end
+
+
+Then(/^I see the recent collections page$/) do
+ expect(@browser.url).to match(/Special\:Gather\/all\/recent/)
+end
+
Then(/^I see the login page$/) do
expect(@browser.url).to match(/Special\:UserLogin/)
end
diff --git a/tests/browser/features/support/pages/gather_recent_page.rb
b/tests/browser/features/support/pages/gather_recent_page.rb
new file mode 100644
index 0000000..efc834a
--- /dev/null
+++ b/tests/browser/features/support/pages/gather_recent_page.rb
@@ -0,0 +1,7 @@
+class GatherRecentPage
+ include PageObject
+ include URL
+
+ page_url URL.url('Special:Gather/all/recent')
+ a(:my_collections_button, css: '.button-bar a', index: 1)
+end
--
To view, visit https://gerrit.wikimedia.org/r/218731
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I89f6dd5425cd559b070ee363a383bfe9f19657bd
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: BarryTheBrowserTestBot <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits