2016-02-16 15:24:15 +01:00
|
|
|
<?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);
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb(pht('Workboard'), "/project/board/{$board_id}/");
|
|
|
|
$crumbs->addTextCrumb(pht('Manage'));
|
2017-05-14 23:15:06 +02:00
|
|
|
$crumbs->setBorder(true);
|
2016-02-16 15:24:15 +01:00
|
|
|
|
|
|
|
$nav = $this->getProfileMenu();
|
2017-05-14 23:15:06 +02:00
|
|
|
$columns_list = $this->buildColumnsList($board, $columns);
|
|
|
|
|
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
->setHeader($header)
|
|
|
|
->setFooter($columns_list);
|
2016-02-16 15:24:15 +01:00
|
|
|
|
|
|
|
$title = array(
|
|
|
|
pht('Manage Workboard'),
|
|
|
|
$board->getDisplayName(),
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setNavigation($nav)
|
|
|
|
->setCrumbs($crumbs)
|
2017-05-14 23:15:06 +02:00
|
|
|
->appendChild($view);
|
2016-02-16 15:24:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildHeaderView(PhabricatorProject $board) {
|
2017-05-14 23:15:06 +02:00
|
|
|
$viewer = $this->getViewer();
|
2016-02-16 15:24:15 +01:00
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$board,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
2017-05-14 23:15:06 +02:00
|
|
|
$id = $board->getID();
|
2016-02-16 15:24:15 +01:00
|
|
|
$disable_uri = $this->getApplicationURI("board/{$id}/disable/");
|
|
|
|
|
2017-05-14 23:15:06 +02:00
|
|
|
$button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setIcon('fa-ban')
|
|
|
|
->setText(pht('Disable Board'))
|
|
|
|
->setHref($disable_uri)
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(true);
|
2016-02-16 15:24:15 +01:00
|
|
|
|
2017-05-14 23:15:06 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Workboard: %s', $board->getDisplayName()))
|
2016-02-16 15:24:15 +01:00
|
|
|
->setUser($viewer)
|
2017-05-14 23:15:06 +02:00
|
|
|
->setPolicyObject($board)
|
|
|
|
->setProfileHeader(true)
|
|
|
|
->addActionLink($button);
|
2016-02-16 15:52:32 +01:00
|
|
|
|
2017-05-14 23:15:06 +02:00
|
|
|
return $header;
|
2016-02-16 15:24:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2016-02-23 23:41:36 +01:00
|
|
|
$proxy = $column->getProxy();
|
|
|
|
if ($proxy && !$proxy->isMilestone()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-02-16 15:24:15 +01:00
|
|
|
$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);
|
2017-05-14 23:15:06 +02:00
|
|
|
$item->addAttribute(pht('Hidden'));
|
|
|
|
$item->setImageIcon('fa-columns grey');
|
|
|
|
} else {
|
|
|
|
$item->addAttribute(pht('Visible'));
|
|
|
|
$item->setImageIcon('fa-columns');
|
2016-02-16 15:24:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$view->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Columns'))
|
|
|
|
->setObjectList($view);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|