1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-03 20:22:46 +01:00
phorge-phorge/src/applications/project/controller/PhabricatorProjectBoardManageController.php
Chad Little fdf001739c Normalize headers and actions in Project sub pages
Summary: Run through all the pages in projects and make sure they all feel similar. Adds back curtain on board manage page, even though it is sad for only having a single action.

Test Plan: Test all pages on a project for consistency in UI.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D17909
2017-05-16 09:58:33 -07:00

142 lines
3.8 KiB
PHP

<?php
final class PhabricatorProjectBoardManageController
extends PhabricatorProjectBoardController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$board_id = $request->getURIData('projectID');
$board = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($board_id))
->needImages(true)
->executeOne();
if (!$board) {
return new Aphront404Response();
}
$this->setProject($board);
// Perform layout of no tasks to load and populate the columns in the
// correct order.
$layout_engine = id(new PhabricatorBoardLayoutEngine())
->setViewer($viewer)
->setBoardPHIDs(array($board->getPHID()))
->setObjectPHIDs(array())
->setFetchAllBoards(true)
->executeLayout();
$columns = $layout_engine->getColumns($board->getPHID());
$board_id = $board->getID();
$header = $this->buildHeaderView($board);
$curtain = $this->buildCurtainView($board);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Workboard'), "/project/board/{$board_id}/");
$crumbs->addTextCrumb(pht('Manage'));
$crumbs->setBorder(true);
$nav = $this->getProfileMenu();
$columns_list = $this->buildColumnsList($board, $columns);
require_celerity_resource('project-view-css');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->addClass('project-view-home')
->addClass('project-view-people-home')
->setCurtain($curtain)
->setMainColumn($columns_list);
$title = array(
pht('Manage Workboard'),
$board->getDisplayName(),
);
return $this->newPage()
->setTitle($title)
->setNavigation($nav)
->setCrumbs($crumbs)
->appendChild($view);
}
private function buildHeaderView(PhabricatorProject $board) {
$viewer = $this->getViewer();
$header = id(new PHUIHeaderView())
->setHeader(pht('Workboard: %s', $board->getDisplayName()))
->setUser($viewer);
return $header;
}
private function buildCurtainView(PhabricatorProject $board) {
$viewer = $this->getViewer();
$id = $board->getID();
$curtain = $this->newCurtainView();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$board,
PhabricatorPolicyCapability::CAN_EDIT);
$disable_uri = $this->getApplicationURI("board/{$id}/disable/");
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-ban')
->setName(pht('Disable Workboard'))
->setHref($disable_uri)
->setDisabled(!$can_edit)
->setWorkflow(true));
return $curtain;
}
private function buildColumnsList(
PhabricatorProject $board,
array $columns) {
assert_instances_of($columns, 'PhabricatorProjectColumn');
$board_id = $board->getID();
$view = id(new PHUIObjectItemListView())
->setNoDataString(pht('This board has no columns.'));
foreach ($columns as $column) {
$column_id = $column->getID();
$proxy = $column->getProxy();
if ($proxy && !$proxy->isMilestone()) {
continue;
}
$detail_uri = "/project/board/{$board_id}/column/{$column_id}/";
$item = id(new PHUIObjectItemView())
->setHeader($column->getDisplayName())
->setHref($detail_uri);
if ($column->isHidden()) {
$item->setDisabled(true);
$item->addAttribute(pht('Hidden'));
$item->setImageIcon('fa-columns grey');
} else {
$item->addAttribute(pht('Visible'));
$item->setImageIcon('fa-columns');
}
$view->addItem($item);
}
return id(new PHUIObjectBoxView())
->setHeaderText(pht('Columns'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setObjectList($view);
}
}