Remove PhabricatorProjectEditor

Summary:
Ref T4379. Perform all editing with modern transaction infrastructure. A few practical changes here:

  - Message for "project name required" should be a little nicer. I'll deal with this once more stuff gets straightened out. You get a reasonable message now, it's just not nicely handled as part of the form.
  - Message for "project name is not unique" should be a little nicer. Same as above.
  - Previously, we would automatically archive a project when the last member left or was removed. I'll probably restore this in a bit but am omitting it for the moment for simplicity.
  - Previously, we would create projects with goofy nonsensical permissions. Now we create them with reasonable permissions.

Test Plan:
  - Created project.
  - Edited project.
  - Ran unit tests.
  - Viewed project edit history.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4379

Differential Revision: https://secure.phabricator.com/D8168
This commit is contained in:
epriestley
2014-02-10 14:30:17 -08:00
parent 8544d0d00f
commit a035d3d528
9 changed files with 155 additions and 319 deletions

View File

@@ -35,45 +35,33 @@ final class PhabricatorProjectProfileEditController
$errors = array();
if ($request->isFormPost()) {
try {
$xactions = array();
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransaction::TYPE_NAME);
$xaction->setNewValue($request->getStr('name'));
$xactions[] = $xaction;
$xactions = array();
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransaction::TYPE_STATUS);
$xaction->setNewValue($request->getStr('status'));
$xactions[] = $xaction;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME)
->setNewValue($request->getStr('name'));
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorTransactions::TYPE_VIEW_POLICY);
$xaction->setNewValue($request->getStr('can_view'));
$xactions[] = $xaction;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
->setNewValue($request->getStr('status'));
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorTransactions::TYPE_EDIT_POLICY);
$xaction->setNewValue($request->getStr('can_edit'));
$xactions[] = $xaction;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
->setNewValue($request->getStr('can_view'));
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorTransactions::TYPE_JOIN_POLICY);
$xaction->setNewValue($request->getStr('can_join'));
$xactions[] = $xaction;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($request->getStr('can_edit'));
$editor = new PhabricatorProjectEditor($project);
$editor->setActor($user);
$editor->applyTransactions($xactions);
} catch (PhabricatorProjectNameCollisionException $ex) {
$e_name = pht('Not Unique');
$errors[] = $ex->getMessage();
}
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
->setNewValue($request->getStr('can_join'));
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($user)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->applyTransactions($project, $xactions);
$profile->setBlurb($request->getStr('blurb'));