2013-09-22 01:23:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionRepositoryEditActivateController
|
2013-10-26 00:58:58 +02:00
|
|
|
extends DiffusionRepositoryEditController {
|
2013-09-22 01:23:35 +02:00
|
|
|
|
2016-01-05 17:49:10 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$response = $this->loadDiffusionContextForEdit();
|
|
|
|
if ($response) {
|
|
|
|
return $response;
|
2013-09-22 01:23:35 +02:00
|
|
|
}
|
|
|
|
|
2016-01-05 17:49:10 +01:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
2013-09-22 01:23:35 +02:00
|
|
|
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$xaction = id(new PhabricatorRepositoryTransaction())
|
|
|
|
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_ACTIVATE)
|
|
|
|
->setNewValue(!$repository->isTracked());
|
|
|
|
|
|
|
|
$editor = id(new PhabricatorRepositoryEditor())
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setActor($viewer)
|
|
|
|
->applyTransactions($repository, array($xaction));
|
|
|
|
|
|
|
|
return id(new AphrontReloadResponse())->setURI($edit_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($repository->isTracked()) {
|
2016-01-05 17:49:10 +01:00
|
|
|
return $this->newDialog()
|
2013-09-22 01:23:35 +02:00
|
|
|
->setTitle(pht('Deactivate Repository?'))
|
|
|
|
->appendChild(
|
|
|
|
pht('Deactivate this repository?'))
|
|
|
|
->addSubmitButton(pht('Deactivate Repository'))
|
|
|
|
->addCancelButton($edit_uri);
|
|
|
|
} else {
|
2016-01-05 17:49:10 +01:00
|
|
|
return $this->newDialog()
|
2013-09-22 01:23:35 +02:00
|
|
|
->setTitle(pht('Activate Repository?'))
|
|
|
|
->appendChild(
|
|
|
|
pht('Activate this repository?'))
|
|
|
|
->addSubmitButton(pht('Activate Repository'))
|
|
|
|
->addCancelButton($edit_uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|