1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 03:12:41 +01:00
phorge-phorge/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
epriestley c0d42a8943 Split Repository EditEngine form into smaller pages
Summary:
Ref T10748. This allows an EditEngine form to be broken up into pages.

This is less powerful than `PHUIPagedFormView`, because the pages are not sequential / stateful. Each form saves immediately once it's submitted, and can not take you to a new form or back/forward in a series of forms.

For example, you can't create a workflow where the user fills out 5 pages of information before we create an object, like the current repository workflow does.

However, the only place we've ever wanted to do this is repositories and it's fairly bad there, so I feel reasonably confident we aren't going to miss this in the future.

(We do "choose a type of service/repository/rule -> fill out one page of info" fairly often, but can do this without the full-power paging stuff.)

Test Plan:
  - Created a repository usin the new Manage UI, filling out only a handful of fields.
  - Edited a repository using the new Manage UI.
  - All forms are now EditEngine forms offering paged views of the big huge underlying form:

{F1254371}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10748

Differential Revision: https://secure.phabricator.com/D15832
2016-05-02 08:28:38 -07:00

80 lines
2.8 KiB
PHP

<?php
final class DiffusionRepositoryEditDangerousController
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 (!$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($edit_uri);
} else {
return $this->newDialog()
->setTitle(pht('Unprotectable Repository'))
->appendParagraph(
pht(
'This repository can not be protected from dangerous changes '.
'because Phabricator does not control what users are allowed '.
'to push to it.'))
->addCancelButton($edit_uri);
}
}
if ($request->isFormPost()) {
$xaction = id(new PhabricatorRepositoryTransaction())
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_DANGEROUS)
->setNewValue(!$repository->shouldAllowDangerousChanges());
$editor = id(new PhabricatorRepositoryEditor())
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
->setActor($viewer)
->applyTransactions($repository, array($xaction));
return id(new AphrontReloadResponse())->setURI($edit_uri);
}
$force = phutil_tag('tt', array(), '--force');
if ($repository->shouldAllowDangerousChanges()) {
return $this->newDialog()
->setTitle(pht('Prevent Dangerous changes?'))
->appendChild(
pht(
'It will no longer be possible to delete branches from this '.
'repository, or %s push to this repository.',
$force))
->addSubmitButton(pht('Prevent Dangerous Changes'))
->addCancelButton($edit_uri);
} else {
return $this->newDialog()
->setTitle(pht('Allow Dangerous Changes?'))
->appendChild(
pht(
'If you allow dangerous changes, it will be possible to delete '.
'branches and %s push this repository. These operations can '.
'alter a repository in a way that is difficult to recover from.',
$force))
->addSubmitButton(pht('Allow Dangerous Changes'))
->addCancelButton($edit_uri);
}
}
}