mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-10 03:18:41 +02:00
Summary: Ref T10748. This supports more transaction types in the modern editor and improves validation so Conduit benefits. You can technically create repositories via `diffusion.repository.edit` now, although they aren't very useful. Test Plan: - Used `diffusion.repository.edit` to create and edit repositories. - Used `/editpro/` to edit repositories. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15740
56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class DiffusionRepositoryEditActivateController
|
|
extends DiffusionRepositoryEditController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContextForEdit();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$viewer = $this->getViewer();
|
|
$drequest = $this->getDiffusionRequest();
|
|
$repository = $drequest->getRepository();
|
|
|
|
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
|
|
|
|
if ($request->isFormPost()) {
|
|
if (!$repository->isTracked()) {
|
|
$new_status = PhabricatorRepository::STATUS_ACTIVE;
|
|
} else {
|
|
$new_status = PhabricatorRepository::STATUS_INACTIVE;
|
|
}
|
|
|
|
$xaction = id(new PhabricatorRepositoryTransaction())
|
|
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_ACTIVATE)
|
|
->setNewValue($new_status);
|
|
|
|
$editor = id(new PhabricatorRepositoryEditor())
|
|
->setContinueOnNoEffect(true)
|
|
->setContinueOnMissingFields(true)
|
|
->setContentSourceFromRequest($request)
|
|
->setActor($viewer)
|
|
->applyTransactions($repository, array($xaction));
|
|
|
|
return id(new AphrontReloadResponse())->setURI($edit_uri);
|
|
}
|
|
|
|
if ($repository->isTracked()) {
|
|
return $this->newDialog()
|
|
->setTitle(pht('Deactivate Repository?'))
|
|
->appendChild(
|
|
pht('Deactivate this repository?'))
|
|
->addSubmitButton(pht('Deactivate Repository'))
|
|
->addCancelButton($edit_uri);
|
|
} else {
|
|
return $this->newDialog()
|
|
->setTitle(pht('Activate Repository?'))
|
|
->appendChild(
|
|
pht('Activate this repository?'))
|
|
->addSubmitButton(pht('Activate Repository'))
|
|
->addCancelButton($edit_uri);
|
|
}
|
|
}
|
|
|
|
}
|