From 7c0f0807da2e0163166f62f83f48ed3953712de6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 5 Oct 2012 13:12:31 -0700 Subject: [PATCH] Use action list and property list elements in Ponder Summary: This is sort of silly as-is, but automatically exposes flagging and will give subscribe/unsubscribe and "Subscribers" a place to plug into shortly. For context, see D3637 and T1808. Test Plan: {F20550} Reviewers: pieter, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1808 Differential Revision: https://secure.phabricator.com/D3641 --- .../PonderQuestionViewController.php | 36 +++++++++++++++++++ .../ponder/view/PonderQuestionDetailView.php | 13 +------ src/view/layout/PhabricatorActionListView.php | 4 +++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php index 420d4b01c1..5b412e86b2 100644 --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -52,6 +52,7 @@ final class PonderQuestionViewController extends PonderController { } $handles = $this->loadViewerHandles($object_phids); + $this->loadHandles($object_phids); $detail_panel = new PonderQuestionDetailView(); $detail_panel @@ -72,9 +73,19 @@ final class PonderQuestionViewController extends PonderController { ->setUser($user) ->setActionURI("/ponder/answer/add/"); + $header = id(new PhabricatorHeaderView()) + ->setObjectName('Q'.$question->getID()) + ->setHeader($question->getTitle()); + + $actions = $this->buildActionListView($question); + $properties = $this->buildPropertyListView($question); + $nav = $this->buildSideNavView($question); $nav->appendChild( array( + $header, + $actions, + $properties, $detail_panel, $responses_panel, $answer_add_panel @@ -89,4 +100,29 @@ final class PonderQuestionViewController extends PonderController { 'title' => 'Q'.$question->getID().' '.$question->getTitle() )); } + + private function buildActionListView(PonderQuestion $question) { + $viewer = $this->getRequest()->getUser(); + $view = new PhabricatorActionListView(); + + $view->setUser($viewer); + $view->setObject($question); + + return $view; + } + + private function buildPropertyListView(PonderQuestion $question) { + $viewer = $this->getRequest()->getUser(); + $view = new PhabricatorPropertyListView(); + + $view->addProperty( + pht('Author'), + $this->getHandle($question->getAuthorPHID())->renderLink()); + + $view->addProperty( + pht('Created'), + phabricator_datetime($question->getDateCreated(), $viewer)); + + return $view; + } } diff --git a/src/applications/ponder/view/PonderQuestionDetailView.php b/src/applications/ponder/view/PonderQuestionDetailView.php index a9326e724a..9ff5c3dda3 100644 --- a/src/applications/ponder/view/PonderQuestionDetailView.php +++ b/src/applications/ponder/view/PonderQuestionDetailView.php @@ -45,10 +45,7 @@ final class PonderQuestionDetailView extends AphrontView { $user = $this->user; $panel = id(new AphrontPanelView()) - ->addClass("ponder-panel") - ->setHeader( - $this->renderObjectLink().' '. - phutil_escape_html($question->getTitle())); + ->addClass("ponder-panel"); $contentview = new PonderPostBodyView(); $contentview @@ -73,12 +70,4 @@ final class PonderQuestionDetailView extends AphrontView { return $panel->render(); } - private function renderObjectLink() { - return phutil_render_tag( - 'a', - array('href' => '/Q' . $this->question->getID()), - "Q". phutil_escape_html($this->question->getID()) - ); - } - } diff --git a/src/view/layout/PhabricatorActionListView.php b/src/view/layout/PhabricatorActionListView.php index b80ba779ef..e5fbd1e45f 100644 --- a/src/view/layout/PhabricatorActionListView.php +++ b/src/view/layout/PhabricatorActionListView.php @@ -53,6 +53,10 @@ final class PhabricatorActionListView extends AphrontView { $actions = $event->getValue('actions'); + if (!$actions) { + return null; + } + require_celerity_resource('phabricator-action-list-view-css'); return phutil_render_tag( 'ul',