mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 14:51:06 +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:
parent
2348b3b450
commit
9b15aa195e
5 changed files with 38 additions and 124 deletions
|
@ -20,138 +20,36 @@
|
|||
* @group phame
|
||||
*/
|
||||
abstract class PhameController extends PhabricatorController {
|
||||
private $showSideNav;
|
||||
private $showChrome = true;
|
||||
private $deviceReady = false;
|
||||
|
||||
protected function setShowSideNav($value) {
|
||||
$this->showSideNav = (bool) $value;
|
||||
return $this;
|
||||
}
|
||||
private function showSideNav() {
|
||||
return $this->showSideNav;
|
||||
}
|
||||
protected function renderSideNavFilterView() {
|
||||
|
||||
protected function setShowChrome($show_chrome) {
|
||||
$this->showChrome = $show_chrome;
|
||||
return $this;
|
||||
}
|
||||
private function getShowChrome() {
|
||||
return $this->showChrome;
|
||||
}
|
||||
$base_uri = new PhutilURI($this->getApplicationURI());
|
||||
|
||||
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->setBaseURI($base_uri);
|
||||
|
||||
$nav->addLabel('Create');
|
||||
$nav->addFilter('post/new', 'New Post');
|
||||
$nav->addFilter('blog/new', 'New Blog');
|
||||
|
||||
$nav->addSpacer();
|
||||
|
||||
$nav->addLabel('Posts');
|
||||
$nav->addFilter('post/draft',
|
||||
'My Drafts');
|
||||
foreach ($this->getSideNavExtraDraftFilters() as $draft_filter) {
|
||||
$nav->addFilter($draft_filter['key'],
|
||||
$draft_filter['name'],
|
||||
idx($draft_filter, 'uri'));
|
||||
}
|
||||
$nav->addFilter('post/', 'My Posts');
|
||||
$nav->addFilter('post/draft', 'My Drafts');
|
||||
$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->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;
|
||||
}
|
||||
|
||||
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(
|
||||
array $posts,
|
||||
PhabricatorUser $user,
|
||||
|
|
|
@ -187,9 +187,14 @@ final class PhameBlogEditController
|
|||
$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(
|
||||
array(
|
||||
$header,
|
||||
$error_view,
|
||||
$form,
|
||||
));
|
||||
|
|
|
@ -39,12 +39,12 @@ final class PhameBlogListController extends PhameController {
|
|||
|
||||
switch ($filter) {
|
||||
case 'blog/all':
|
||||
$title = 'All Blogs';
|
||||
$nodata = 'No blogs have been created.';
|
||||
$title = pht('All Blogs');
|
||||
$nodata = pht('No blogs have been created.');
|
||||
break;
|
||||
case 'blog/user':
|
||||
$title = 'My Blogs';
|
||||
$nodata = 'There are no blogs you can contribute to.';
|
||||
$title = pht('Joinable Blogs');
|
||||
$nodata = pht('There are no blogs you can contribute to.');
|
||||
$query->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_JOIN,
|
||||
|
@ -93,7 +93,7 @@ final class PhameBlogListController extends PhameController {
|
|||
->setHeader($blog->getName())
|
||||
->setHref($this->getApplicationURI('blog/view/'.$blog->getID().'/'))
|
||||
->addDetail(
|
||||
'Custom Domain',
|
||||
pht('Custom Domain'),
|
||||
phutil_escape_html($blog->getDomain()));
|
||||
|
||||
$view->addItem($item);
|
||||
|
|
|
@ -36,12 +36,15 @@ final class PhamePostListController extends PhameController {
|
|||
$query = id(new PhamePostQuery())
|
||||
->setViewer($user);
|
||||
|
||||
$nav = $this->renderSideNavFilterView();
|
||||
|
||||
switch ($this->filter) {
|
||||
case 'draft':
|
||||
$query->withBloggerPHIDs(array($user->getPHID()));
|
||||
$query->withVisibility(PhamePost::VISIBILITY_DRAFT);
|
||||
$nodata = pht('You have no unpublished drafts.');
|
||||
$title = pht('Unpublished Drafts');
|
||||
$nav->selectFilter('post/draft');
|
||||
break;
|
||||
case 'blogger':
|
||||
if ($this->bloggername) {
|
||||
|
@ -57,6 +60,7 @@ final class PhamePostListController extends PhameController {
|
|||
|
||||
$query->withBloggerPHIDs(array($blogger->getPHID()));
|
||||
if ($blogger->getPHID() == $user->getPHID()) {
|
||||
$nav->selectFilter('post');
|
||||
$nodata = pht('You have not written any posts.');
|
||||
} else {
|
||||
$nodata = pht('%s has not written any posts.', $blogger);
|
||||
|
@ -66,6 +70,7 @@ final class PhamePostListController extends PhameController {
|
|||
case 'all':
|
||||
$nodata = pht('There are no visible posts.');
|
||||
$title = pht('Posts');
|
||||
$nav->selectFilter('post/all');
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown filter '{$this->filter}'!");
|
||||
|
@ -86,7 +91,6 @@ final class PhamePostListController extends PhameController {
|
|||
->setHeader($title);
|
||||
$post_list = $this->renderPostList($posts, $user, $nodata);
|
||||
|
||||
$nav = $this->renderSideNavFilterView(null);
|
||||
$nav->appendChild(
|
||||
array(
|
||||
$header,
|
||||
|
|
|
@ -33,13 +33,20 @@ final class PhamePostNewController extends PhameController {
|
|||
))
|
||||
->execute();
|
||||
|
||||
$nav = $this->renderSideNavFilterView(null);
|
||||
$nav = $this->renderSideNavFilterView();
|
||||
$nav->selectFilter('post/new');
|
||||
$nav->appendChild(
|
||||
id(new PhabricatorHeaderView())->setHeader(
|
||||
pht('Create Post')));
|
||||
|
||||
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 {
|
||||
$options = mpull($blogs, 'getName', 'getID');
|
||||
|
||||
|
|
Loading…
Reference in a new issue