1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 21:10:56 +01:00

Add ability to setActionList to a PHUIHeaderView

Summary: We're using this a little more, so I'd prefer less copy-pasta and one place to manage the UI. Maybe add a caret?

Test Plan: grep for 'Actions', test Phriction, Diviner, ect, Action Menus.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15288
This commit is contained in:
Chad Little 2016-02-16 19:53:37 -08:00
parent 73bab57160
commit 8c3ca2a729
5 changed files with 21 additions and 38 deletions

View file

@ -29,20 +29,12 @@ final class DivinerBookController extends DivinerController {
$book->getShortTitle(), $book->getShortTitle(),
'/book/'.$book->getName().'/'); '/book/'.$book->getName().'/');
$action_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Actions'))
->setHref('#')
->setIcon('fa-bars')
->addClass('phui-mobile-menu')
->setDropdownMenu($actions);
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader($book->getTitle()) ->setHeader($book->getTitle())
->setUser($viewer) ->setUser($viewer)
->setPolicyObject($book) ->setPolicyObject($book)
->setEpoch($book->getDateModified()) ->setEpoch($book->getDateModified())
->addActionLink($action_button); ->setActionList($actions);
// TODO: This could probably look better. // TODO: This could probably look better.
if ($book->getRepositoryPHID()) { if ($book->getRepositoryPHID()) {

View file

@ -44,16 +44,7 @@ final class PhameBlogViewController extends PhameLiveController {
$header->setStatus($header_icon, $header_color, $header_name); $header->setStatus($header_icon, $header_color, $header_name);
$actions = $this->renderActions($blog); $actions = $this->renderActions($blog);
$action_button = id(new PHUIButtonView()) $header->setActionList($actions);
->setTag('a')
->setText(pht('Actions'))
->setHref('#')
->setIcon('fa-bars')
->addClass('phui-mobile-menu')
->setDropdownMenu($actions);
$header->addActionLink($action_button);
$header->setPolicyObject($blog); $header->setPolicyObject($blog);
} }

View file

@ -24,17 +24,8 @@ final class PhamePostViewController
if (!$is_external) { if (!$is_external) {
$actions = $this->renderActions($post); $actions = $this->renderActions($post);
$action_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Actions'))
->setHref('#')
->setIcon('fa-bars')
->addClass('phui-mobile-menu')
->setDropdownMenu($actions);
$header->setPolicyObject($post); $header->setPolicyObject($post);
$header->addActionLink($action_button); $header->setActionList($actions);
} }
$document = id(new PHUIDocumentViewPro()) $document = id(new PHUIDocumentViewPro())

View file

@ -203,19 +203,11 @@ final class PhrictionDocumentController
$crumbs->addCrumb($view); $crumbs->addCrumb($view);
} }
$action_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Actions'))
->setHref('#')
->setIcon('fa-bars')
->addClass('phui-mobile-menu')
->setDropdownMenu($actions);
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setUser($viewer) ->setUser($viewer)
->setPolicyObject($document) ->setPolicyObject($document)
->setHeader($page_title) ->setHeader($page_title)
->addActionLink($action_button); ->setActionList($actions);
if ($content) { if ($content) {
$header->setEpoch($content->getDateCreated()); $header->setEpoch($content->getDateCreated());

View file

@ -23,6 +23,7 @@ final class PHUIHeaderView extends AphrontTagView {
private $actionIcons = array(); private $actionIcons = array();
private $badges = array(); private $badges = array();
private $href; private $href;
private $actionList;
public function setHeader($header) { public function setHeader($header) {
$this->header = $header; $this->header = $header;
@ -84,6 +85,11 @@ final class PHUIHeaderView extends AphrontTagView {
return $this; return $this;
} }
public function setActionList(PhabricatorActionListView $list) {
$this->actionList = $list;
return $this;
}
public function setPolicyObject(PhabricatorPolicyInterface $object) { public function setPolicyObject(PhabricatorPolicyInterface $object) {
$this->policyObject = $object; $this->policyObject = $object;
return $this; return $this;
@ -191,6 +197,17 @@ final class PHUIHeaderView extends AphrontTagView {
protected function getTagContent() { protected function getTagContent() {
if ($this->actionList) {
$action_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Actions'))
->setHref('#')
->setIcon('fa-bars')
->addClass('phui-mobile-menu')
->setDropdownMenu($this->actionList);
$this->addActionLink($action_button);
}
$image = null; $image = null;
if ($this->image) { if ($this->image) {
$image_href = null; $image_href = null;