From 5c8025c41dad1e522e92f1dc46d87cebfe75d3ed Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 21 Dec 2015 14:12:36 -0800 Subject: [PATCH] Add some more consistant NUX to Phame Summary: Adds a no visible blogs and no posts nux state using new UI. Ref T10032 Test Plan: Archived all my blogs, got no posts fallback. Test a New Blog, got create a post, logged out, saw no create button. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T10032 Differential Revision: https://secure.phabricator.com/D14848 --- .../phame/controller/PhameHomeController.php | 43 +++++++++++++------ .../blog/PhameBlogViewController.php | 35 ++++++++++++--- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php index 6383a65894..c547071e67 100644 --- a/src/applications/phame/controller/PhameHomeController.php +++ b/src/applications/phame/controller/PhameHomeController.php @@ -15,16 +15,37 @@ final class PhameHomeController extends PhamePostController { ->needProfileImage(true) ->execute(); - $blog_phids = mpull($blogs, 'getPHID'); + $post_list = null; + if ($blogs) { + $blog_phids = mpull($blogs, 'getPHID'); - $pager = id(new AphrontCursorPagerView()) - ->readFromRequest($request); + $pager = id(new AphrontCursorPagerView()) + ->readFromRequest($request); - $posts = id(new PhamePostQuery()) - ->setViewer($viewer) - ->withBlogPHIDs($blog_phids) - ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED) - ->executeWithCursorPager($pager); + $posts = id(new PhamePostQuery()) + ->setViewer($viewer) + ->withBlogPHIDs($blog_phids) + ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED) + ->executeWithCursorPager($pager); + + $post_list = id(new PhamePostListView()) + ->setPosts($posts) + ->setViewer($viewer) + ->showBlog(true); + } else { + $create_button = id(new PHUIButtonView()) + ->setTag('a') + ->setText(pht('Create a Blog')) + ->setHref('/phame/blog/new/') + ->setColor(PHUIButtonView::GREEN); + + $post_list = id(new PHUIBigInfoView()) + ->setIcon('fa-star') + ->setTitle('Welcome to Phame') + ->setDescription( + pht('There aren\'t any visible Blog Posts.')) + ->addAction($create_button); + } $actions = $this->renderActions($viewer); $action_button = id(new PHUIButtonView()) @@ -41,12 +62,6 @@ final class PhameHomeController extends PhamePostController { ->setHeader($title) ->addActionLink($action_button); - $post_list = id(new PhamePostListView()) - ->setPosts($posts) - ->setViewer($viewer) - ->showBlog(true) - ->setNodata(pht('No Recent Visible Posts.')); - $crumbs = $this->buildApplicationCrumbs(); $crumbs->setBorder(true); $crumbs->addTextCrumb( diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php index dd963a327b..c387152019 100644 --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -57,12 +57,35 @@ final class PhameBlogViewController extends PhameLiveController { $header->setPolicyObject($blog); } - $post_list = id(new PhamePostListView()) - ->setPosts($posts) - ->setViewer($viewer) - ->setIsExternal($is_external) - ->setIsLive($is_live) - ->setNodata(pht('This blog has no visible posts.')); + if ($posts) { + $post_list = id(new PhamePostListView()) + ->setPosts($posts) + ->setViewer($viewer) + ->setIsExternal($is_external) + ->setIsLive($is_live) + ->setNodata(pht('This blog has no visible posts.')); + } else { + $create_button = id(new PHUIButtonView()) + ->setTag('a') + ->setText(pht('Write a Post')) + ->setHref($this->getApplicationURI('post/edit/?blog='.$blog->getID())) + ->setColor(PHUIButtonView::GREEN); + + $post_list = id(new PHUIBigInfoView()) + ->setIcon('fa-star') + ->setTitle($blog->getName()) + ->setDescription( + pht('No one has written any blog posts yet.')); + + $can_edit = PhabricatorPolicyFilter::hasCapability( + $viewer, + $blog, + PhabricatorPolicyCapability::CAN_EDIT); + + if ($can_edit) { + $post_list->addAction($create_button); + } + } $page = id(new PHUIDocumentViewPro()) ->setHeader($header)