jenkins-bot has submitted this change and it was merged.
Change subject: Create no public lists view and render when user has no public
lists
......................................................................
Create no public lists view and render when user has no public lists
bug: T91777
Change-Id: I9f11e58d1ec12126640dd49afde91004182025b6
---
M Gather.php
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/models/CollectionsList.php
M includes/specials/SpecialGather.php
A includes/views/NoPublic.php
M includes/views/NotFound.php
M resources/ext.gather.styles/collections.less
9 files changed, 62 insertions(+), 9 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Gather.php b/Gather.php
index 1b07e07..3f87930 100644
--- a/Gather.php
+++ b/Gather.php
@@ -53,6 +53,7 @@
'Gather\views\View' => 'views/View',
'Gather\views\NotFound' => 'views/NotFound',
+ 'Gather\views\NoPublic' => 'views/NoPublic',
'Gather\views\Collection' => 'views/Collection',
'Gather\views\CollectionItemCard' => 'views/CollectionItemCard',
'Gather\views\Image' => 'views/Image',
diff --git a/extension.json b/extension.json
index 228bc49..67fa96a 100644
--- a/extension.json
+++ b/extension.json
@@ -46,6 +46,7 @@
"Gather\\stores\\ItemImages": "includes/stores/ItemImages.php",
"Gather\\views\\View": "includes/views/View.php",
"Gather\\views\\NotFound": "includes/views/NotFound.php",
+ "Gather\\views\\NoPublic": "includes/views/NoPublic.php",
"Gather\\views\\Collection": "includes/views/Collection.php",
"Gather\\views\\CollectionItemCard":
"includes/views/CollectionItemCard.php",
"Gather\\views\\Image": "includes/views/Image.php",
diff --git a/i18n/en.json b/i18n/en.json
index 5b39040..d18f52d 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -20,6 +20,8 @@
"gather-add-failed-toast": "There was a problem adding the item to your
\"$1\" collection.",
"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",
+ "gather-no-public-lists-description": "There are no public collections
for this user.",
"gather-anon-view-lists": "You need to be logged in to see your
Collections.",
"gather-watchlist-title": "Watchlist",
"gather-watchlist-description": "A list of pages that I am interested
in.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 151abbf..97cc048 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -23,6 +23,8 @@
"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.",
"gather-desc":
"{{desc|name=Gather|url=https://www.mediawiki.org/wiki/Extension:Gather}}",
+ "gather-no-public-lists-title": "Note: Experimental feature. Messages
and UI may change radically at any time. Translate at your own risk.\n The
title of the view shown when there are no public collections for a user",
+ "gather-no-public-lists-description": "Note: Experimental feature.
Messages and UI may change radically at any time. Translate at your own risk.\n
The descriptive text explaining that there are no public collections for a
user.",
"gather-anon-view-lists": "Note: Experimental feature. Messages and UI
may change radically at any time. Translate at your own risk.\n Text shown when
trying to see your own collections on [[Special:Gather]] but the user is not
logged in.",
"gather-watchlist-title": "Note: Experimental feature. Messages and UI
may change radically at any time. Translate at your own risk.\n Title used for
special casing the Watchlist collection on the [[Special:Gather]]
page.\n{{Identical|Watchlist}}",
"gather-watchlist-description": "Note: Experimental feature. Messages
and UI may change radically at any time. Translate at your own risk.\n Default
description for special casing the Watchlist collection on the
[[Special:Gather]] page.",
diff --git a/includes/models/CollectionsList.php
b/includes/models/CollectionsList.php
index dc1f07e..38dbe20 100644
--- a/includes/models/CollectionsList.php
+++ b/includes/models/CollectionsList.php
@@ -58,6 +58,14 @@
return new ArrayIterator( $this->collections );
}
+ /**
+ * Gets the amount of collections in list
+ * @returns int
+ */
+ public function getCount() {
+ return count( $this->collections );
+ }
+
/** @inheritdoc */
public function toArray() {
$arr = array();
diff --git a/includes/specials/SpecialGather.php
b/includes/specials/SpecialGather.php
index b98e7fe..ccd7178 100644
--- a/includes/specials/SpecialGather.php
+++ b/includes/specials/SpecialGather.php
@@ -53,7 +53,7 @@
if ( !( $user && $user->getId() ) ) {
// Invalid user
- $this->renderNotFoundError();
+ $this->renderError( new views\NotFound() );
} else {
if ( isset( $args ) && isset( $args[1] ) ) {
$id = intval( $args[1] );
@@ -65,10 +65,12 @@
}
/**
- * Render an error when the user was not found
+ * Render an error to the special page
+ *
+ * @param View $view View of error to render
*/
- public function renderNotFoundError() {
- $this->render( new views\NotFound() );
+ public function renderError( $view ) {
+ $this->render( $view );
}
/**
@@ -82,7 +84,7 @@
if ( $collection === null ||
( !$collection->isPublic() && !$this->isOwner( $user )
) ) {
// FIXME: No permissions to visit this. Showing not
found ATM.
- $this->renderNotFoundError();
+ $this->renderError( new views\NotFound() );
} else {
$this->modules[] = 'ext.gather.edit';
$this->render( new views\Collection( $this->getUser(),
$collection ) );
@@ -96,7 +98,11 @@
*/
public function renderUserCollectionsList( User $user ) {
$collectionsList = stores\UserPageCollectionsList::newFromUser(
$user, $this->isOwner( $user ) );
- $this->render( new views\CollectionsList( $collectionsList ) );
+ if ( $collectionsList->getCount() > 0 ) {
+ $this->render( new views\CollectionsList(
$collectionsList ) );
+ } else {
+ $this->renderError( new views\NoPublic() );
+ }
}
/**
diff --git a/includes/views/NoPublic.php b/includes/views/NoPublic.php
new file mode 100644
index 0000000..5047d1f
--- /dev/null
+++ b/includes/views/NoPublic.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * NotFound.php
+ */
+
+namespace Gather\views;
+
+use \Html;
+
+/**
+ * Renders an error when there are no public lists for a user
+ */
+class NoPublic extends View {
+
+ /**
+ * @inheritdoc
+ */
+ public function getTitle() {
+ return wfMessage( 'gather-no-public-lists-title' )->text();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getHtml() {
+ $html = Html::openElement( 'div', array( 'class' => 'collection
not-found' ) );
+ $html .= Html::element( 'span', array( 'class' => 'mw-ui-anchor
mw-ui-destructive' ),
+ wfMessage( 'gather-no-public-lists-description'
)->text() );
+ $html .= Html::closeElement( 'div' );
+ return $html;
+ }
+
+}
diff --git a/includes/views/NotFound.php b/includes/views/NotFound.php
index 6c5819b..bab6e53 100644
--- a/includes/views/NotFound.php
+++ b/includes/views/NotFound.php
@@ -24,7 +24,7 @@
*/
public function getHtml() {
// FIXME: Showing generic not found error right now. Show user
not found instead
- $html = Html::openElement( 'div', array( 'class' => 'collection
user-not-found' ) );
+ $html = Html::openElement( 'div', array( 'class' => 'collection
not-found' ) );
$html .= Html::element( 'span', array( 'class' => 'mw-ui-anchor
mw-ui-destructive' ),
wfMessage( 'mobile-frontend-generic-404-desc' )->text()
);
$html .= Html::closeElement( 'div' );
diff --git a/resources/ext.gather.styles/collections.less
b/resources/ext.gather.styles/collections.less
index 8355c30..48bf010 100644
--- a/resources/ext.gather.styles/collections.less
+++ b/resources/ext.gather.styles/collections.less
@@ -183,8 +183,8 @@
.reset-link-styles();
}
- // User not found page
- &.user-not-found {
+ // User or collections not found
+ &.not-found {
text-align: center;
}
--
To view, visit https://gerrit.wikimedia.org/r/195322
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9f11e58d1ec12126640dd49afde91004182025b6
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Robmoen <[email protected]>
Gerrit-Reviewer: Jdlrobson <[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