mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-25 02:31:20 +01:00
Move editing "Local Path" to modern UI/controller/etc
Summary: Fixes T1286. Ref T2231. See previous diffs; same as the others but does "Local Path". Test Plan: See screenshots. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1286, T2231 Differential Revision: https://secure.phabricator.com/D7409
This commit is contained in:
parent
e1683f353e
commit
c4cdb5c5f0
6 changed files with 181 additions and 3 deletions
|
@ -510,6 +510,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryEditBranchesController' => 'applications/diffusion/controller/DiffusionRepositoryEditBranchesController.php',
|
||||
'DiffusionRepositoryEditController' => 'applications/diffusion/controller/DiffusionRepositoryEditController.php',
|
||||
'DiffusionRepositoryEditEncodingController' => 'applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php',
|
||||
'DiffusionRepositoryEditLocalController' => 'applications/diffusion/controller/DiffusionRepositoryEditLocalController.php',
|
||||
'DiffusionRepositoryEditMainController' => 'applications/diffusion/controller/DiffusionRepositoryEditMainController.php',
|
||||
'DiffusionRepositoryEditPolicyController' => 'applications/diffusion/controller/DiffusionRepositoryEditPolicyController.php',
|
||||
'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php',
|
||||
|
@ -2686,6 +2687,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryEditBranchesController' => 'DiffusionRepositoryEditController',
|
||||
'DiffusionRepositoryEditController' => 'DiffusionController',
|
||||
'DiffusionRepositoryEditEncodingController' => 'DiffusionRepositoryEditController',
|
||||
'DiffusionRepositoryEditLocalController' => 'DiffusionRepositoryEditController',
|
||||
'DiffusionRepositoryEditMainController' => 'DiffusionRepositoryEditController',
|
||||
'DiffusionRepositoryEditPolicyController' => 'DiffusionRepositoryEditController',
|
||||
'DiffusionRepositoryEditSubversionController' => 'DiffusionRepositoryEditController',
|
||||
|
|
|
@ -73,6 +73,7 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication {
|
|||
'subversion/' => 'DiffusionRepositoryEditSubversionController',
|
||||
'actions/' => 'DiffusionRepositoryEditActionsController',
|
||||
'(?P<edit>remote)/' => 'DiffusionRepositoryCreateController',
|
||||
'local/' => 'DiffusionRepositoryEditLocalController',
|
||||
),
|
||||
),
|
||||
'inline/' => array(
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionRepositoryEditLocalController
|
||||
extends DiffusionRepositoryEditController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$drequest = $this->diffusionRequest;
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$repository = id(new PhabricatorRepositoryQuery())
|
||||
->setViewer($user)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->withIDs(array($repository->getID()))
|
||||
->executeOne();
|
||||
|
||||
if (!$repository) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
|
||||
|
||||
$v_local = $repository->getHumanReadableDetail('local-path');
|
||||
$e_local = true;
|
||||
$errors = array();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$v_local = $request->getStr('local');
|
||||
|
||||
if (!strlen($v_local)) {
|
||||
$e_local = pht('Required');
|
||||
$errors[] = pht('You must specify a local path.');
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$xactions = array();
|
||||
$template = id(new PhabricatorRepositoryTransaction());
|
||||
|
||||
$type_local = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
|
||||
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType($type_local)
|
||||
->setNewValue($v_local);
|
||||
|
||||
try {
|
||||
id(new PhabricatorRepositoryEditor())
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setActor($user)
|
||||
->applyTransactions($repository, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($edit_uri);
|
||||
} catch (Exception $ex) {
|
||||
$errors[] = $ex->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Edit Local')));
|
||||
|
||||
$title = pht('Edit %s', $repository->getName());
|
||||
|
||||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = id(new AphrontErrorView())
|
||||
->setTitle(pht('Form Errors'))
|
||||
->setErrors($errors);
|
||||
}
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->appendRemarkupInstructions(
|
||||
pht(
|
||||
'You can adjust the local path for this repository here. This is '.
|
||||
'an advanced setting and you usually should not change it.'))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('local')
|
||||
->setLabel(pht('Local Path'))
|
||||
->setValue($v_local)
|
||||
->setError($e_local))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue(pht('Save Local'))
|
||||
->addCancelButton($edit_uri));
|
||||
|
||||
$object_box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($title)
|
||||
->setForm($form)
|
||||
->setFormError($error_view);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$object_box,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -19,12 +19,16 @@ final class DiffusionRepositoryEditMainController
|
|||
$is_hg = false;
|
||||
switch ($repository->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||
$has_local = true;
|
||||
$is_git = true;
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
// TOOD: This will be true for hosted SVN repositories.
|
||||
$has_local = false;
|
||||
$is_svn = true;
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
||||
$has_local = true;
|
||||
$is_hg = true;
|
||||
break;
|
||||
}
|
||||
|
@ -75,6 +79,13 @@ final class DiffusionRepositoryEditMainController
|
|||
$this->buildSubversionActions($repository));
|
||||
}
|
||||
|
||||
$local_properties = null;
|
||||
if ($has_local) {
|
||||
$local_properties = $this->buildLocalProperties(
|
||||
$repository,
|
||||
$this->buildLocalActions($repository));
|
||||
}
|
||||
|
||||
$actions_properties = $this->buildActionsProperties(
|
||||
$repository,
|
||||
$this->buildActionsActions($repository));
|
||||
|
@ -105,8 +116,13 @@ final class DiffusionRepositoryEditMainController
|
|||
->setHeader($header)
|
||||
->addPropertyList($basic_properties)
|
||||
->addPropertyList($policy_properties)
|
||||
->addPropertyList($remote_properties)
|
||||
->addPropertyList($encoding_properties);
|
||||
->addPropertyList($remote_properties);
|
||||
|
||||
if ($local_properties) {
|
||||
$obj_box->addPropertyList($local_properties);
|
||||
}
|
||||
|
||||
$obj_box->addPropertyList($encoding_properties);
|
||||
|
||||
if ($branches_properties) {
|
||||
$obj_box->addPropertyList($branches_properties);
|
||||
|
@ -440,9 +456,43 @@ final class DiffusionRepositoryEditMainController
|
|||
|
||||
$view->addProperty(
|
||||
pht('Remote URI'),
|
||||
$repository->getDetail('remote-uri'));
|
||||
$repository->getHumanReadableDetail('remote-uri'));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function buildLocalActions(PhabricatorRepository $repository) {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$view = id(new PhabricatorActionListView())
|
||||
->setObjectURI($this->getRequest()->getRequestURI())
|
||||
->setUser($viewer);
|
||||
|
||||
$edit = id(new PhabricatorActionView())
|
||||
->setIcon('edit')
|
||||
->setName(pht('Edit Local'))
|
||||
->setHref(
|
||||
$this->getRepositoryControllerURI($repository, 'edit/local/'));
|
||||
$view->addAction($edit);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function buildLocalProperties(
|
||||
PhabricatorRepository $repository,
|
||||
PhabricatorActionListView $actions) {
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$view = id(new PHUIPropertyListView())
|
||||
->setUser($viewer)
|
||||
->setActionList($actions)
|
||||
->addSectionHeader(pht('Local'));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Local Path'),
|
||||
$repository->getHumanReadableDetail('local-path'));
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ final class PhabricatorRepositoryEditor
|
|||
$types[] = PhabricatorRepositoryTransaction::TYPE_SSH_KEYFILE;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_HTTP_LOGIN;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_HTTP_PASS;
|
||||
$types[] = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
|
||||
|
||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
|
@ -69,6 +70,8 @@ final class PhabricatorRepositoryEditor
|
|||
return $object->getDetail('http-login');
|
||||
case PhabricatorRepositoryTransaction::TYPE_HTTP_PASS:
|
||||
return $object->getDetail('http-pass');
|
||||
case PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH:
|
||||
return $object->getDetail('local-path');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,6 +95,7 @@ final class PhabricatorRepositoryEditor
|
|||
case PhabricatorRepositoryTransaction::TYPE_SSH_KEYFILE:
|
||||
case PhabricatorRepositoryTransaction::TYPE_HTTP_LOGIN:
|
||||
case PhabricatorRepositoryTransaction::TYPE_HTTP_PASS:
|
||||
case PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH:
|
||||
return $xaction->getNewValue();
|
||||
case PhabricatorRepositoryTransaction::TYPE_NOTIFY:
|
||||
case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE:
|
||||
|
@ -156,6 +160,9 @@ final class PhabricatorRepositoryEditor
|
|||
case PhabricatorRepositoryTransaction::TYPE_HTTP_PASS:
|
||||
$object->setDetail('http-pass', $xaction->getNewValue());
|
||||
break;
|
||||
case PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH:
|
||||
$object->setDetail('local-path', $xaction->getNewValue());
|
||||
break;
|
||||
case PhabricatorRepositoryTransaction::TYPE_ENCODING:
|
||||
// Make sure the encoding is valid by converting to UTF-8. This tests
|
||||
// that the user has mbstring installed, and also that they didn't type
|
||||
|
|
|
@ -20,6 +20,7 @@ final class PhabricatorRepositoryTransaction
|
|||
const TYPE_SSH_KEYFILE = 'repo:ssh-keyfile';
|
||||
const TYPE_HTTP_LOGIN = 'repo:http-login';
|
||||
const TYPE_HTTP_PASS = 'repo:http-pass';
|
||||
const TYPE_LOCAL_PATH = 'repo:local-path';
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'repository';
|
||||
|
@ -231,6 +232,12 @@ final class PhabricatorRepositoryTransaction
|
|||
return pht(
|
||||
'%s updated the HTTP password for this repository.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
case self::TYPE_LOCAL_PATH:
|
||||
return pht(
|
||||
'%s changed the local path from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old,
|
||||
$new);
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
|
|
Loading…
Add table
Reference in a new issue