Allow workboards to be disabled, hiding "(Backlog)" column annotations

Summary:
Fixes T7410.

  - Adds a "Disable Workboard" action to the "Manage Backlog" menu.
  - We'll probably move this somewhere else if/when that column gets too messy.
  - Disabling a board hides it, prevents it from being recreated by non-editors, and hides the "Project (Backlog)" annotations.
  - Resotring a board puts it back in pristine condition.

Test Plan:
  - Disabled a board.
  - Verified "(Backlog)" annotations vanished.
  - Enabled a board.

Reviewers: chad

Reviewed By: chad

Subscribers: mbishopim3

Maniphest Tasks: T7410

Differential Revision: https://secure.phabricator.com/D15215
This commit is contained in:
epriestley
2016-02-08 11:24:32 -08:00
parent 9c95b387bd
commit 3682cc9bb2
7 changed files with 201 additions and 9 deletions

View File

@@ -121,18 +121,27 @@ final class PhabricatorProjectBoardViewController
->setViewer($viewer)
->setBoardPHIDs(array($board_phid))
->setObjectPHIDs(array_keys($tasks))
->setFetchAllBoards(true)
->executeLayout();
$columns = $layout_engine->getColumns($board_phid);
if (!$columns) {
if (!$columns || !$project->getHasWorkboard()) {
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$project,
PhabricatorPolicyCapability::CAN_EDIT);
if (!$can_edit) {
$content = $this->buildNoAccessContent($project);
if (!$columns) {
if (!$can_edit) {
$content = $this->buildNoAccessContent($project);
} else {
$content = $this->buildInitializeContent($project);
}
} else {
$content = $this->buildInitializeContent($project);
if (!$can_edit) {
$content = $this->buildDisabledContent($project);
} else {
$content = $this->buildEnableContent($project);
}
}
if ($content instanceof AphrontResponse) {
@@ -544,6 +553,12 @@ final class PhabricatorProjectBoardViewController
$request = $this->getRequest();
$viewer = $request->getUser();
$id = $project->getID();
$disable_uri = $this->getApplicationURI("board/{$id}/disable/");
$add_uri = $this->getApplicationURI("board/{$id}/edit/");
$reorder_uri = $this->getApplicationURI("board/{$id}/reorder/");
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$project,
@@ -554,14 +569,14 @@ final class PhabricatorProjectBoardViewController
$manage_items[] = id(new PhabricatorActionView())
->setIcon('fa-plus')
->setName(pht('Add Column'))
->setHref($this->getApplicationURI('board/'.$this->id.'/edit/'))
->setHref($add_uri)
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit);
$manage_items[] = id(new PhabricatorActionView())
->setIcon('fa-exchange')
->setName(pht('Reorder Columns'))
->setHref($this->getApplicationURI('board/'.$this->id.'/reorder/'))
->setHref($reorder_uri)
->setDisabled(!$can_edit)
->setWorkflow(true);
@@ -595,6 +610,13 @@ final class PhabricatorProjectBoardViewController
->setHref($batch_edit_uri)
->setDisabled(!$can_batch_edit);
$manage_items[] = id(new PhabricatorActionView())
->setIcon('fa-ban')
->setName(pht('Disable Workboard'))
->setHref($disable_uri)
->setWorkflow(true)
->setDisabled(!$can_edit);
$manage_menu = id(new PhabricatorActionListView())
->setUser($viewer);
foreach ($manage_items as $item) {
@@ -852,4 +874,59 @@ final class PhabricatorProjectBoardViewController
->addCancelButton($profile_uri);
}
private function buildEnableContent(PhabricatorProject $project) {
$request = $this->getRequest();
$viewer = $this->getViewer();
$id = $project->getID();
$profile_uri = $this->getApplicationURI("profile/{$id}/");
$board_uri = $this->getApplicationURI("board/{$id}/");
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorProjectTransaction::TYPE_HASWORKBOARD)
->setNewValue(1);
id(new PhabricatorProjectTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true)
->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())
->setURI($board_uri);
}
return $this->newDialog()
->setTitle(pht('Workboard Disabled'))
->addHiddenInput('initialize', 1)
->appendParagraph(
pht(
'This workboard has been disabled, but can be restored to its '.
'former glory.'))
->addCancelButton($profile_uri)
->addSubmitButton(pht('Enable Workboard'));
}
private function buildDisabledContent(PhabricatorProject $project) {
$viewer = $this->getViewer();
$id = $project->getID();
$profile_uri = $this->getApplicationURI("profile/{$id}/");
return $this->newDialog()
->setTitle(pht('Workboard Disabled'))
->appendParagraph(
pht(
'This workboard has been disabled, and you do not have permission '.
'to enable it. Only users who can edit this project can restore '.
'the workboard.'))
->addCancelButton($profile_uri);
}
}