mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-16 03:42:41 +01:00
a823654be0
Summary: Fixes T5646. Makes diffusion a much better user experience. Users now see a 404 exception page when they have a bad URI. Previously, they saw a developer-facing raw exception. Test Plan: played around in diffusion a bunch. most of these changes were fairly mechanical at the end of the day. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T5646 Differential Revision: https://secure.phabricator.com/D11299
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class DiffusionRepositoryEditActivateController
|
|
extends DiffusionRepositoryEditController {
|
|
|
|
protected function processDiffusionRequest(AphrontRequest $request) {
|
|
$viewer = $request->getUser();
|
|
$drequest = $this->diffusionRequest;
|
|
$repository = $drequest->getRepository();
|
|
|
|
$repository = id(new PhabricatorRepositoryQuery())
|
|
->setViewer($viewer)
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->withIDs(array($repository->getID()))
|
|
->executeOne();
|
|
|
|
if (!$repository) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$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);
|
|
}
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($viewer);
|
|
|
|
if ($repository->isTracked()) {
|
|
$dialog
|
|
->setTitle(pht('Deactivate Repository?'))
|
|
->appendChild(
|
|
pht('Deactivate this repository?'))
|
|
->addSubmitButton(pht('Deactivate Repository'))
|
|
->addCancelButton($edit_uri);
|
|
} else {
|
|
$dialog
|
|
->setTitle(pht('Activate Repository?'))
|
|
->appendChild(
|
|
pht('Activate this repository?'))
|
|
->addSubmitButton(pht('Activate Repository'))
|
|
->addCancelButton($edit_uri);
|
|
}
|
|
|
|
return id(new AphrontDialogResponse())
|
|
->setDialog($dialog);
|
|
}
|
|
|
|
|
|
}
|