Differential D14945 Diff 36121 src/applications/diffusion/controller/DiffusionRepositoryEditStorageController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryEditStorageController.php
<?php | <?php | ||||
final class DiffusionRepositoryEditStorageController | final class DiffusionRepositoryEditStorageController | ||||
extends DiffusionRepositoryEditController { | extends DiffusionRepositoryEditController { | ||||
protected function processDiffusionRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$user = $request->getUser(); | $response = $this->loadDiffusionContextForEdit(); | ||||
$drequest = $this->diffusionRequest; | if ($response) { | ||||
$repository = $drequest->getRepository(); | return $response; | ||||
$repository = id(new PhabricatorRepositoryQuery()) | |||||
->setViewer($user) | |||||
->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/'); | ||||
$v_local = $repository->getHumanReadableDetail('local-path'); | $v_local = $repository->getHumanReadableDetail('local-path'); | ||||
$errors = array(); | $errors = array(); | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb(pht('Edit Storage')); | $crumbs->addTextCrumb(pht('Edit Storage')); | ||||
$title = pht('Edit %s', $repository->getName()); | $title = pht('Edit %s', $repository->getName()); | ||||
$service_phid = $repository->getAlmanacServicePHID(); | $service_phid = $repository->getAlmanacServicePHID(); | ||||
if ($service_phid) { | if ($service_phid) { | ||||
$handles = $this->loadViewerHandles(array($service_phid)); | $handles = $this->loadViewerHandles(array($service_phid)); | ||||
$v_service = $handles[$service_phid]->renderLink(); | $v_service = $handles[$service_phid]->renderLink(); | ||||
} else { | } else { | ||||
$v_service = phutil_tag( | $v_service = phutil_tag( | ||||
'em', | 'em', | ||||
array(), | array(), | ||||
pht('Local')); | pht('Local')); | ||||
} | } | ||||
$form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
->setUser($user) | ->setUser($viewer) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormMarkupControl()) | id(new AphrontFormMarkupControl()) | ||||
->setLabel(pht('Storage Service')) | ->setLabel(pht('Storage Service')) | ||||
->setValue($v_service)) | ->setValue($v_service)) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormMarkupControl()) | id(new AphrontFormMarkupControl()) | ||||
->setName('local') | ->setName('local') | ||||
->setLabel(pht('Storage Path')) | ->setLabel(pht('Storage Path')) | ||||
->setValue($v_local)) | ->setValue($v_local)) | ||||
->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
pht( | pht( | ||||
"You can not adjust the local path for this repository from the ". | "You can not adjust the local path for this repository from the ". | ||||
"web interface. To edit it, run this command:\n\n %s", | "web interface. To edit it, run this command:\n\n %s", | ||||
sprintf( | sprintf( | ||||
'phabricator/ $ ./bin/repository edit %s --as %s --local-path ...', | 'phabricator/ $ ./bin/repository edit %s --as %s --local-path ...', | ||||
$repository->getMonogram(), | $repository->getMonogram(), | ||||
$user->getUsername()))) | $viewer->getUsername()))) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
->addCancelButton($edit_uri, pht('Done'))); | ->addCancelButton($edit_uri, pht('Done'))); | ||||
$object_box = id(new PHUIObjectBoxView()) | $object_box = id(new PHUIObjectBoxView()) | ||||
->setHeaderText($title) | ->setHeaderText($title) | ||||
->setForm($form) | ->setForm($form) | ||||
->setFormErrors($errors); | ->setFormErrors($errors); | ||||
return $this->buildApplicationPage( | return $this->newPage() | ||||
array( | ->setTitle($title) | ||||
$crumbs, | ->setCrumbs($crumbs) | ||||
$object_box, | ->appendChild($object_box); | ||||
), | |||||
array( | |||||
'title' => $title, | |||||
)); | |||||
} | } | ||||
} | } |