Activate the new Repository creation workflow

Summary:
Ref T2231. This:

  - Activates the new multi-step workflow, and exposes it in the UI.
  - Adds "can create", "default view" and "default edit" capabilities.
  - Provides a default value for `repository.default-local-path` and forces repositories into it by default. It's still editable, but Phabricator gets it correct (for some definition of correct) by default now.

Test Plan: Created some new repositories with the new workflow.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1286, T2231

Differential Revision: https://secure.phabricator.com/D7413
This commit is contained in:
epriestley
2013-10-25 17:46:08 -07:00
parent c585f97e90
commit 5f6ea9f662
13 changed files with 261 additions and 17 deletions

View File

@@ -32,6 +32,9 @@ final class DiffusionRepositoryCreateController
$cancel_uri = $this->getRepositoryControllerURI($repository, 'edit/');
} else {
$this->requireApplicationCapability(
DiffusionCapabilityCreateRepositories::CAPABILITY);
$cancel_uri = $this->getApplicationURI();
}
@@ -60,15 +63,19 @@ final class DiffusionRepositoryCreateController
if ($request->isFormPost()) {
$form->readFromRequest($request);
if ($form->isComplete()) {
$is_create = ($this->edit === null);
if ($this->edit != 'remote') {
// TODO: This exception is heartwarming but should probably take more
// substantive actions.
throw new Exception("GOOD JOB AT FORM");
if ($is_create) {
$repository = PhabricatorRepository::initializeNewRepository(
$viewer);
}
$template = id(new PhabricatorRepositoryTransaction());
$type_name = PhabricatorRepositoryTransaction::TYPE_NAME;
$type_vcs = PhabricatorRepositoryTransaction::TYPE_VCS;
$type_activate = PhabricatorRepositoryTransaction::TYPE_ACTIVATE;
$type_local_path = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
$type_remote_uri = PhabricatorRepositoryTransaction::TYPE_REMOTE_URI;
$type_ssh_login = PhabricatorRepositoryTransaction::TYPE_SSH_LOGIN;
$type_ssh_key = PhabricatorRepositoryTransaction::TYPE_SSH_KEY;
@@ -78,6 +85,44 @@ final class DiffusionRepositoryCreateController
$xactions = array();
// If we're creating a new repository, set all this core stuff.
if ($is_create) {
$callsign = $form->getPage('name')
->getControl('callsign')->getValue();
// We must set this to a unique value to save the repository
// initially, and it's immutable, so we don't bother using
// transactions to apply this change.
$repository->setCallsign($callsign);
$xactions[] = id(clone $template)
->setTransactionType($type_name)
->setNewValue(
$form->getPage('name')->getControl('name')->getValue());
$xactions[] = id(clone $template)
->setTransactionType($type_vcs)
->setNewValue(
$form->getPage('vcs')->getControl('vcs')->getValue());
$activate = $form->getPage('done')
->getControl('activate')->getValue();
$xactions[] = id(clone $template)
->setTransactionType($type_activate)
->setNewValue(
($activate == 'start'));
$default_local_path = PhabricatorEnv::getEnvConfig(
'repository.default-local-path');
$default_local_path = rtrim($default_local_path, '/');
$default_local_path = $default_local_path.'/'.$callsign.'/';
$xactions[] = id(clone $template)
->setTransactionType($type_local_path)
->setNewValue($default_local_path);
}
$xactions[] = id(clone $template)
->setTransactionType($type_remote_uri)
->setNewValue(
@@ -619,7 +664,7 @@ final class DiffusionRepositoryCreateController
pht('Configure More Options First'),
pht(
'Configure more options before beginning the repository '.
'import. This will let you fine-tune settings.. You can '.
'import. This will let you fine-tune settings. You can '.
'start the import whenever you are ready.')));
}