3 final class DiffusionRepositoryEditDangerousController
4 extends DiffusionRepositoryManageController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $response = $this->loadDiffusionContextForEdit();
12 $viewer = $this->getViewer();
13 $drequest = $this->getDiffusionRequest();
14 $repository = $drequest->getRepository();
16 $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel())
17 ->setRepository($repository)
20 if (!$repository->canAllowDangerousChanges()) {
21 return $this->newDialog()
22 ->setTitle(pht('Unprotectable Repository'))
25 'This repository can not be protected from dangerous changes '.
26 'because Phabricator does not control what users are allowed '.
28 ->addCancelButton($panel_uri);
31 if ($request->isFormPost()) {
32 $xaction = id(new PhabricatorRepositoryTransaction())
34 PhabricatorRepositoryDangerousTransaction
::TRANSACTIONTYPE
)
35 ->setNewValue(!$repository->shouldAllowDangerousChanges());
37 $editor = id(new PhabricatorRepositoryEditor())
38 ->setContinueOnNoEffect(true)
39 ->setContentSourceFromRequest($request)
41 ->applyTransactions($repository, array($xaction));
43 return id(new AphrontReloadResponse())->setURI($panel_uri);
46 $force = phutil_tag('tt', array(), '--force');
48 if ($repository->shouldAllowDangerousChanges()) {
49 $title = pht('Prevent Dangerous Changes');
51 if ($repository->isSVN()) {
53 'It will no longer be possible to edit revprops in this '.
57 'It will no longer be possible to delete branches from this '.
58 'repository, or %s push to this repository.',
62 $submit = pht('Prevent Dangerous Changes');
64 $title = pht('Allow Dangerous Changes');
65 if ($repository->isSVN()) {
67 'If you allow dangerous changes, it will be possible to edit '.
68 'reprops in this repository, including arbitrarily rewriting '.
69 'commit messages. These operations can alter a repository in a '.
70 'way that is difficult to recover from.');
73 'If you allow dangerous changes, it will be possible to delete '.
74 'branches and %s push this repository. These operations can '.
75 'alter a repository in a way that is difficult to recover from.',
78 $submit = pht('Allow Dangerous Changes');
81 return $this->newDialog()
83 ->appendParagraph($body)
84 ->addSubmitButton($submit)
85 ->addCancelButton($panel_uri);