Differential D14945 Diff 36121 src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php
<?php | <?php | ||||
final class DiffusionRepositoryEditDeleteController | final class DiffusionRepositoryEditDeleteController | ||||
extends DiffusionRepositoryEditController { | extends DiffusionRepositoryEditController { | ||||
protected function processDiffusionRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getUser(); | $response = $this->loadDiffusionContextForEdit(); | ||||
$drequest = $this->diffusionRequest; | if ($response) { | ||||
$repository = $drequest->getRepository(); | return $response; | ||||
$repository = id(new PhabricatorRepositoryQuery()) | |||||
->setViewer($viewer) | |||||
->requireCapabilities( | |||||
array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
)) | |||||
->withIDs(array($repository->getID())) | |||||
->executeOne(); | |||||
if (!$repository) { | |||||
return new Aphront404Response(); | |||||
} | } | ||||
$viewer = $this->getViewer(); | |||||
$drequest = $this->getDiffusionRequest(); | |||||
$repository = $drequest->getRepository(); | |||||
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); | $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); | ||||
$dialog = new AphrontDialogView(); | $dialog = new AphrontDialogView(); | ||||
$text_1 = pht( | $text_1 = pht( | ||||
'If you really want to delete the repository, run this command from '. | 'If you really want to delete the repository, run this command from '. | ||||
'the command line:'); | 'the command line:'); | ||||
$command = csprintf( | $command = csprintf( | ||||
'phabricator/ $ ./bin/remove destroy %R', | 'phabricator/ $ ./bin/remove destroy %R', | ||||
$repository->getMonogram()); | $repository->getMonogram()); | ||||
$text_2 = pht( | $text_2 = pht( | ||||
'Repositories touch many objects and as such deletes are '. | 'Repositories touch many objects and as such deletes are '. | ||||
'prohibitively expensive to run from the web UI.'); | 'prohibitively expensive to run from the web UI.'); | ||||
$body = phutil_tag( | $body = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phabricator-remarkup', | 'class' => 'phabricator-remarkup', | ||||
), | ), | ||||
array( | array( | ||||
phutil_tag('p', array(), $text_1), | phutil_tag('p', array(), $text_1), | ||||
phutil_tag('p', array(), | phutil_tag('p', array(), | ||||
phutil_tag('tt', array(), $command)), | phutil_tag('tt', array(), $command)), | ||||
phutil_tag('p', array(), $text_2), | phutil_tag('p', array(), $text_2), | ||||
)); | )); | ||||
$dialog = id(new AphrontDialogView()) | return $this->newDialog() | ||||
->setUser($request->getUser()) | |||||
->setTitle(pht('Really want to delete the repository?')) | ->setTitle(pht('Really want to delete the repository?')) | ||||
->appendChild($body) | ->appendChild($body) | ||||
->addCancelButton($edit_uri, pht('Okay')); | ->addCancelButton($edit_uri, pht('Okay')); | ||||
return id(new AphrontDialogResponse())->setDialog($dialog); | |||||
} | } | ||||
} | } |