Move "Remote URI" to modern repository editor thing

Summary:
Ref T2231. Allows you to edit the remote URI and credentials.

This is a little bit funky because I'm reusing some of the pages on the new (not-yet-hooked-up) create form. Specifically, it had pages like this:

  - Repo Type
  - Name/Callsign/Remote
  - Auth
  - Done

I split "Name/Callsign/Remote" into "Name/Callsign" and "Remote", then when editing the remote I just take you through "Remote" and "Auth" and then back. This lets us reuse the giant pile of protocol/URI sanity checking logic and ends up being pretty clean, although it's a little weird that the "Create" controller does both full-create and edit-remote.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: chad, aran

Maniphest Tasks: T2231

Differential Revision: https://secure.phabricator.com/D7405
This commit is contained in:
epriestley
2013-10-25 13:59:02 -07:00
parent 52d4e66883
commit b57b72368c
11 changed files with 432 additions and 113 deletions

View File

@@ -50,6 +50,10 @@ final class DiffusionRepositoryEditController extends DiffusionController {
$policy_properties =
$this->buildPolicyProperties($repository, $policy_actions);
$remote_properties = $this->buildRemoteProperties(
$repository,
$this->buildRemoteActions($repository));
$encoding_actions = $this->buildEncodingActions($repository);
$encoding_properties =
$this->buildEncodingProperties($repository, $encoding_actions);
@@ -98,6 +102,7 @@ final class DiffusionRepositoryEditController extends DiffusionController {
->setHeader($header)
->addPropertyList($basic_properties)
->addPropertyList($policy_properties)
->addPropertyList($remote_properties)
->addPropertyList($encoding_properties);
if ($branches_properties) {
@@ -445,4 +450,46 @@ final class DiffusionRepositoryEditController extends DiffusionController {
return $view;
}
private function buildRemoteActions(PhabricatorRepository $repository) {
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$repository,
PhabricatorPolicyCapability::CAN_EDIT);
$edit = id(new PhabricatorActionView())
->setIcon('edit')
->setName(pht('Edit Remote'))
->setHref(
$this->getRepositoryControllerURI($repository, 'edit/remote/'))
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit);
$view->addAction($edit);
return $view;
}
private function buildRemoteProperties(
PhabricatorRepository $repository,
PhabricatorActionListView $actions) {
$viewer = $this->getRequest()->getUser();
$view = id(new PHUIPropertyListView())
->setUser($viewer)
->setActionList($actions)
->addSectionHeader(pht('Remote'));
$view->addProperty(
pht('Remote URI'),
$repository->getDetail('remote-uri'));
return $view;
}
}