mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-26 21:49:08 +01:00
Summary: Ref T9252. If you have a blueprint and you do not like that blueprint very much, you can disable it. Test Plan: Disabled / enabled some blueprints. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9252 Differential Revision: https://secure.phabricator.com/D14156
64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class DrydockBlueprintDisableController
|
|
extends DrydockBlueprintController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $request->getViewer();
|
|
$id = $request->getURIData('id');
|
|
|
|
$blueprint = id(new DrydockBlueprintQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($id))
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
if (!$blueprint) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$is_disable = ($request->getURIData('action') == 'disable');
|
|
$id = $blueprint->getID();
|
|
$cancel_uri = $this->getApplicationURI("blueprint/{$id}/");
|
|
|
|
if ($request->isFormPost()) {
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new DrydockBlueprintTransaction())
|
|
->setTransactionType(DrydockBlueprintTransaction::TYPE_DISABLED)
|
|
->setNewValue($is_disable ? 1 : 0);
|
|
|
|
$editor = id(new DrydockBlueprintEditor())
|
|
->setActor($viewer)
|
|
->setContentSourceFromRequest($request)
|
|
->setContinueOnNoEffect(true)
|
|
->setContinueOnMissingFields(true)
|
|
->applyTransactions($blueprint, $xactions);
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($cancel_uri);
|
|
}
|
|
|
|
if ($is_disable) {
|
|
$title = pht('Disable Blueprint');
|
|
$body = pht(
|
|
'If you disable this blueprint, Drydock will no longer use it to '.
|
|
'allocate new resources. Existing resources will not be affected.');
|
|
$button = pht('Disable Blueprint');
|
|
} else {
|
|
$title = pht('Enable Blueprint');
|
|
$body = pht(
|
|
'If you enable this blueprint, Drydock will start using it to '.
|
|
'allocate new resources.');
|
|
$button = pht('Enable Blueprint');
|
|
}
|
|
|
|
return $this->newDialog()
|
|
->setTitle($title)
|
|
->appendParagraph($body)
|
|
->addCancelButton($cancel_uri)
|
|
->addSubmitButton($button);
|
|
}
|
|
}
|