1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 13:00: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/'.$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())
->setHeader($book->getTitle())
->setUser($viewer)
->setPolicyObject($book)
->setEpoch($book->getDateModified())
->addActionLink($action_button);
->setActionList($actions);
// TODO: This could probably look better.
if ($book->getRepositoryPHID()) {

View file

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

View file

@ -24,17 +24,8 @@ final class PhamePostViewController
if (!$is_external) {
$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->addActionLink($action_button);
$header->setActionList($actions);
}
$document = id(new PHUIDocumentViewPro())

View file

@ -203,19 +203,11 @@ final class PhrictionDocumentController
$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())
->setUser($viewer)
->setPolicyObject($document)
->setHeader($page_title)
->addActionLink($action_button);
->setActionList($actions);
if ($content) {
$header->setEpoch($content->getDateCreated());

View file

@ -23,6 +23,7 @@ final class PHUIHeaderView extends AphrontTagView {
private $actionIcons = array();
private $badges = array();
private $href;
private $actionList;
public function setHeader($header) {
$this->header = $header;
@ -84,6 +85,11 @@ final class PHUIHeaderView extends AphrontTagView {
return $this;
}
public function setActionList(PhabricatorActionListView $list) {
$this->actionList = $list;
return $this;
}
public function setPolicyObject(PhabricatorPolicyInterface $object) {
$this->policyObject = $object;
return $this;
@ -191,6 +197,17 @@ final class PHUIHeaderView extends AphrontTagView {
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;
if ($this->image) {
$image_href = null;