Allow repositories to be associated with projects

Summary: Ref T4264. Ref T2628. Ref T3102. Allows you to associate repositories with projects. In the future, you'll be able to write Herald object rules against projects, use Herald fields like "Repository's projects", and search by project.

Test Plan: See screenshots.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3102, T4264, T2628

Differential Revision: https://secure.phabricator.com/D7881
This commit is contained in:
epriestley
2014-01-03 12:24:09 -08:00
parent f981d50f5d
commit 637e3f38f3
9 changed files with 110 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ final class DiffusionRepositoryEditBasicController
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->needProjectPHIDs(true)
->withIDs(array($repository->getID()))
->executeOne();
@@ -33,6 +34,7 @@ final class DiffusionRepositoryEditBasicController
if ($request->isFormPost()) {
$v_name = $request->getStr('name');
$v_desc = $request->getStr('description');
$v_projects = $request->getArr('projectPHIDs');
if (!strlen($v_name)) {
$e_name = pht('Required');
@@ -47,6 +49,7 @@ final class DiffusionRepositoryEditBasicController
$type_name = PhabricatorRepositoryTransaction::TYPE_NAME;
$type_desc = PhabricatorRepositoryTransaction::TYPE_DESCRIPTION;
$type_edge = PhabricatorTransactions::TYPE_EDGE;
$xactions[] = id(clone $template)
->setTransactionType($type_name)
@@ -56,6 +59,16 @@ final class DiffusionRepositoryEditBasicController
->setTransactionType($type_desc)
->setNewValue($v_desc);
$xactions[] = id(clone $template)
->setTransactionType($type_edge)
->setMetadataValue(
'edge:type',
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT)
->setNewValue(
array(
'=' => array_fuse($v_projects),
));
id(new PhabricatorRepositoryEditor())
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
@@ -78,6 +91,8 @@ final class DiffusionRepositoryEditBasicController
->setErrors($errors);
}
$project_handles = $this->loadViewerHandles($repository->getProjectPHIDs());
$form = id(new AphrontFormView())
->setUser($user)
->appendChild(
@@ -91,6 +106,12 @@ final class DiffusionRepositoryEditBasicController
->setName('description')
->setLabel(pht('Description'))
->setValue($v_desc))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/projects/')
->setName('projectPHIDs')
->setLabel(pht('Projects'))
->setValue($project_handles))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save'))