Differential D16174 Diff 38912 src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
| Show All 12 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
| $repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
| $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel()) | $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel()) | ||||
| ->setRepository($repository) | ->setRepository($repository) | ||||
| ->getPanelURI(); | ->getPanelURI(); | ||||
| if (!$repository->canAllowDangerousChanges()) { | if (!$repository->canAllowDangerousChanges()) { | ||||
| if ($repository->isSVN()) { | |||||
| return $this->newDialog() | |||||
| ->setTitle(pht('Not in Danger')) | |||||
| ->appendParagraph( | |||||
| pht( | |||||
| 'It is not possible for users to push any dangerous changes '. | |||||
| 'to a Subversion repository. Pushes to a Subversion repository '. | |||||
| 'can always be reverted and never destroy data.')) | |||||
| ->addCancelButton($panel_uri); | |||||
| } else { | |||||
| return $this->newDialog() | return $this->newDialog() | ||||
| ->setTitle(pht('Unprotectable Repository')) | ->setTitle(pht('Unprotectable Repository')) | ||||
| ->appendParagraph( | ->appendParagraph( | ||||
| pht( | pht( | ||||
| 'This repository can not be protected from dangerous changes '. | 'This repository can not be protected from dangerous changes '. | ||||
| 'because Phabricator does not control what users are allowed '. | 'because Phabricator does not control what users are allowed '. | ||||
| 'to push to it.')) | 'to push to it.')) | ||||
| ->addCancelButton($panel_uri); | ->addCancelButton($panel_uri); | ||||
| } | } | ||||
| } | |||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $xaction = id(new PhabricatorRepositoryTransaction()) | $xaction = id(new PhabricatorRepositoryTransaction()) | ||||
| ->setTransactionType(PhabricatorRepositoryTransaction::TYPE_DANGEROUS) | ->setTransactionType(PhabricatorRepositoryTransaction::TYPE_DANGEROUS) | ||||
| ->setNewValue(!$repository->shouldAllowDangerousChanges()); | ->setNewValue(!$repository->shouldAllowDangerousChanges()); | ||||
| $editor = id(new PhabricatorRepositoryEditor()) | $editor = id(new PhabricatorRepositoryEditor()) | ||||
| ->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
| ->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
| ->setActor($viewer) | ->setActor($viewer) | ||||
| ->applyTransactions($repository, array($xaction)); | ->applyTransactions($repository, array($xaction)); | ||||
| return id(new AphrontReloadResponse())->setURI($panel_uri); | return id(new AphrontReloadResponse())->setURI($panel_uri); | ||||
| } | } | ||||
| $force = phutil_tag('tt', array(), '--force'); | $force = phutil_tag('tt', array(), '--force'); | ||||
| if ($repository->shouldAllowDangerousChanges()) { | if ($repository->shouldAllowDangerousChanges()) { | ||||
| $title = pht('Prevent Dangerous Changes'); | $title = pht('Prevent Dangerous Changes'); | ||||
| if ($repository->isSVN()) { | |||||
| $body = pht( | |||||
| 'It will no longer be possible to edit revprops in this '. | |||||
| 'repository.'); | |||||
| } else { | |||||
| $body = pht( | $body = pht( | ||||
| 'It will no longer be possible to delete branches from this '. | 'It will no longer be possible to delete branches from this '. | ||||
| 'repository, or %s push to this repository.', | 'repository, or %s push to this repository.', | ||||
| $force); | $force); | ||||
| } | |||||
| $submit = pht('Prevent Dangerous Changes'); | $submit = pht('Prevent Dangerous Changes'); | ||||
| } else { | } else { | ||||
| $title = pht('Allow Dangerous Changes'); | $title = pht('Allow Dangerous Changes'); | ||||
| if ($repository->isSVN()) { | |||||
| $body = pht( | |||||
| 'If you allow dangerous changes, it will be possible to edit '. | |||||
| 'reprops in this repository, including arbitrarily rewriting '. | |||||
| 'commit messages. These operations can alter a repository in a '. | |||||
| 'way that is difficult to recover from.'); | |||||
| } else { | |||||
| $body = pht( | $body = pht( | ||||
| 'If you allow dangerous changes, it will be possible to delete '. | 'If you allow dangerous changes, it will be possible to delete '. | ||||
| 'branches and %s push this repository. These operations can '. | 'branches and %s push this repository. These operations can '. | ||||
| 'alter a repository in a way that is difficult to recover from.', | 'alter a repository in a way that is difficult to recover from.', | ||||
| $force); | $force); | ||||
| } | |||||
| $submit = pht('Allow Dangerous Changes'); | $submit = pht('Allow Dangerous Changes'); | ||||
| } | } | ||||
| return $this->newDialog() | return $this->newDialog() | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->appendParagraph($body) | ->appendParagraph($body) | ||||
| ->addSubmitButton($submit) | ->addSubmitButton($submit) | ||||
| ->addCancelButton($panel_uri); | ->addCancelButton($panel_uri); | ||||
| } | } | ||||
| } | } | ||||