1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-25 14:08:19 +01:00

Improve various Phame UI things

Summary:
  - Clean up the menu selection states.
  - Nuke some unused code.
  - Show some more contextual error messages.
  - Improve/pht() some strings.

Test Plan: Looked at post/blog list, empty state of "new post".

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1373

Differential Revision: https://secure.phabricator.com/D3706
This commit is contained in:
epriestley 2012-10-15 17:55:57 -07:00
parent 2348b3b450
commit 9b15aa195e
5 changed files with 38 additions and 124 deletions

View file

@ -20,138 +20,36 @@
* @group phame * @group phame
*/ */
abstract class PhameController extends PhabricatorController { abstract class PhameController extends PhabricatorController {
private $showSideNav;
private $showChrome = true;
private $deviceReady = false;
protected function setShowSideNav($value) { protected function renderSideNavFilterView() {
$this->showSideNav = (bool) $value;
return $this;
}
private function showSideNav() {
return $this->showSideNav;
}
protected function setShowChrome($show_chrome) { $base_uri = new PhutilURI($this->getApplicationURI());
$this->showChrome = $show_chrome;
return $this;
}
private function getShowChrome() {
return $this->showChrome;
}
public function setDeviceReady($device_ready) {
$this->deviceReady = $device_ready;
return $this;
}
public function getDeviceReady() {
return $this->deviceReady;
}
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
$page->setApplicationName('Phame');
$page->setBaseURI('/phame/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xe2\x9c\xa9");
$page->setShowChrome($this->getShowChrome());
$page->setDeviceReady($this->getDeviceReady());
if ($this->showSideNav()) {
$nav = $this->renderSideNavFilterView($this->getSideNavFilter());
$nav->appendChild($view);
$page->appendChild($nav);
} else {
$page->appendChild($view);
}
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
protected function renderSideNavFilterView($filter) {
$base_uri = new PhutilURI('/phame/');
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI($base_uri); $nav->setBaseURI($base_uri);
$nav->addLabel('Create'); $nav->addLabel('Create');
$nav->addFilter('post/new', 'New Post'); $nav->addFilter('post/new', 'New Post');
$nav->addFilter('blog/new', 'New Blog'); $nav->addFilter('blog/new', 'New Blog');
$nav->addSpacer(); $nav->addSpacer();
$nav->addLabel('Posts'); $nav->addLabel('Posts');
$nav->addFilter('post/draft', $nav->addFilter('post/draft', 'My Drafts');
'My Drafts'); $nav->addFilter('post', 'My Posts');
foreach ($this->getSideNavExtraDraftFilters() as $draft_filter) { $nav->addFilter('post/all', 'All Posts');
$nav->addFilter($draft_filter['key'],
$draft_filter['name'],
idx($draft_filter, 'uri'));
}
$nav->addFilter('post/', 'My Posts');
$nav->addFilter('post/all', 'All Posts');
foreach ($this->getSideNavExtraPostFilters() as $post_filter) {
$nav->addFilter($post_filter['key'],
$post_filter['name'],
idx($post_filter, 'uri'));
}
$nav->addSpacer(); $nav->addSpacer();
$nav->addLabel('Blogs');
foreach ($this->getSideNavBlogFilters() as $blog_filter) {
$nav->addFilter($blog_filter['key'],
$blog_filter['name'],
idx($blog_filter, 'uri'));
}
$nav->selectFilter($filter); $nav->addLabel('Blogs');
$nav->addFilter('blog/user', 'Joinable Blogs');
$nav->addFilter('blog/all', 'All Blogs');
$nav->selectFilter(null);
return $nav; return $nav;
} }
protected function getSideNavExtraDraftFilters() {
return array();
}
protected function getSideNavExtraPostFilters() {
return array();
}
protected function getSideNavBlogFilters() {
return array(
array(
'key' => 'blog/user',
'name' => 'My Blogs',
),
array(
'key' => 'blog/all',
'name' => 'All Blogs',
),
);
}
protected function getSideNavFilter() {
return 'post';
}
protected function getPager() {
$request = $this->getRequest();
$pager = new AphrontPagerView();
$page_size = 50;
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setPageSize($page_size);
$pager->setOffset($request->getInt('offset'));
return $pager;
}
protected function buildNoticeView() {
$notice_view = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setTitle('Meta thoughts and feelings');
return $notice_view;
}
protected function renderPostList( protected function renderPostList(
array $posts, array $posts,
PhabricatorUser $user, PhabricatorUser $user,

View file

@ -187,9 +187,14 @@ final class PhameBlogEditController
$error_view = null; $error_view = null;
} }
$nav = $this->renderSideNavFilterView(null); $header = id(new PhabricatorHeaderView())
->setHeader($page_title);
$nav = $this->renderSideNavFilterView();
$nav->selectFilter($this->id ? null : 'blog/new');
$nav->appendChild( $nav->appendChild(
array( array(
$header,
$error_view, $error_view,
$form, $form,
)); ));

View file

@ -39,12 +39,12 @@ final class PhameBlogListController extends PhameController {
switch ($filter) { switch ($filter) {
case 'blog/all': case 'blog/all':
$title = 'All Blogs'; $title = pht('All Blogs');
$nodata = 'No blogs have been created.'; $nodata = pht('No blogs have been created.');
break; break;
case 'blog/user': case 'blog/user':
$title = 'My Blogs'; $title = pht('Joinable Blogs');
$nodata = 'There are no blogs you can contribute to.'; $nodata = pht('There are no blogs you can contribute to.');
$query->requireCapabilities( $query->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_JOIN, PhabricatorPolicyCapability::CAN_JOIN,
@ -93,7 +93,7 @@ final class PhameBlogListController extends PhameController {
->setHeader($blog->getName()) ->setHeader($blog->getName())
->setHref($this->getApplicationURI('blog/view/'.$blog->getID().'/')) ->setHref($this->getApplicationURI('blog/view/'.$blog->getID().'/'))
->addDetail( ->addDetail(
'Custom Domain', pht('Custom Domain'),
phutil_escape_html($blog->getDomain())); phutil_escape_html($blog->getDomain()));
$view->addItem($item); $view->addItem($item);

View file

@ -36,12 +36,15 @@ final class PhamePostListController extends PhameController {
$query = id(new PhamePostQuery()) $query = id(new PhamePostQuery())
->setViewer($user); ->setViewer($user);
$nav = $this->renderSideNavFilterView();
switch ($this->filter) { switch ($this->filter) {
case 'draft': case 'draft':
$query->withBloggerPHIDs(array($user->getPHID())); $query->withBloggerPHIDs(array($user->getPHID()));
$query->withVisibility(PhamePost::VISIBILITY_DRAFT); $query->withVisibility(PhamePost::VISIBILITY_DRAFT);
$nodata = pht('You have no unpublished drafts.'); $nodata = pht('You have no unpublished drafts.');
$title = pht('Unpublished Drafts'); $title = pht('Unpublished Drafts');
$nav->selectFilter('post/draft');
break; break;
case 'blogger': case 'blogger':
if ($this->bloggername) { if ($this->bloggername) {
@ -57,6 +60,7 @@ final class PhamePostListController extends PhameController {
$query->withBloggerPHIDs(array($blogger->getPHID())); $query->withBloggerPHIDs(array($blogger->getPHID()));
if ($blogger->getPHID() == $user->getPHID()) { if ($blogger->getPHID() == $user->getPHID()) {
$nav->selectFilter('post');
$nodata = pht('You have not written any posts.'); $nodata = pht('You have not written any posts.');
} else { } else {
$nodata = pht('%s has not written any posts.', $blogger); $nodata = pht('%s has not written any posts.', $blogger);
@ -66,6 +70,7 @@ final class PhamePostListController extends PhameController {
case 'all': case 'all':
$nodata = pht('There are no visible posts.'); $nodata = pht('There are no visible posts.');
$title = pht('Posts'); $title = pht('Posts');
$nav->selectFilter('post/all');
break; break;
default: default:
throw new Exception("Unknown filter '{$this->filter}'!"); throw new Exception("Unknown filter '{$this->filter}'!");
@ -86,7 +91,6 @@ final class PhamePostListController extends PhameController {
->setHeader($title); ->setHeader($title);
$post_list = $this->renderPostList($posts, $user, $nodata); $post_list = $this->renderPostList($posts, $user, $nodata);
$nav = $this->renderSideNavFilterView(null);
$nav->appendChild( $nav->appendChild(
array( array(
$header, $header,

View file

@ -33,13 +33,20 @@ final class PhamePostNewController extends PhameController {
)) ))
->execute(); ->execute();
$nav = $this->renderSideNavFilterView(null); $nav = $this->renderSideNavFilterView();
$nav->selectFilter('post/new');
$nav->appendChild( $nav->appendChild(
id(new PhabricatorHeaderView())->setHeader( id(new PhabricatorHeaderView())->setHeader(
pht('Create Post'))); pht('Create Post')));
if (!$blogs) { if (!$blogs) {
$notification = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NODATA)
->appendChild(
pht('You do not have permission to join any blogs. Create a blog '.
'first, then you can post to it.'));
$nav->appendChild($notification);
} else { } else {
$options = mpull($blogs, 'getName', 'getID'); $options = mpull($blogs, 'getName', 'getID');