1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Support Spaces in Diffusion

Summary:
Ref T8493. Diffusion is probably the strongest upstream use case we have for Spaces right now, so I want to get us on it to kick the tires a bit.

Small amount of hackiness around the multi-page form thing but it shouldn't create any problems.

Test Plan:
  - Created a new repo.
  - Edited a repo.
  - Tried invalid edits, saw value preserved.
  - Viewed edit full detail screen, saw space info.
  - Viewed repo detail view, saw space.
  - Viewed repo list view, saw space.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8493

Differential Revision: https://secure.phabricator.com/D13414
This commit is contained in:
epriestley 2015-06-24 10:56:46 -07:00
parent c1dca8238f
commit fcb35a55fd
7 changed files with 64 additions and 18 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_repository.repository
ADD spacePHID VARBINARY(64);

View file

@ -6185,6 +6185,7 @@ phutil_register_library_map(array(
'PhabricatorMarkupInterface', 'PhabricatorMarkupInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
'PhabricatorProjectInterface', 'PhabricatorProjectInterface',
'PhabricatorSpacesInterface',
), ),
'PhabricatorRepositoryArcanistProject' => array( 'PhabricatorRepositoryArcanistProject' => array(
'PhabricatorRepositoryDAO', 'PhabricatorRepositoryDAO',

View file

@ -137,6 +137,7 @@ final class DiffusionRepositoryCreateController
$type_credential = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL; $type_credential = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
$type_space = PhabricatorTransactions::TYPE_SPACE;
$type_push = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY; $type_push = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY;
$type_service = PhabricatorRepositoryTransaction::TYPE_SERVICE; $type_service = PhabricatorRepositoryTransaction::TYPE_SERVICE;
@ -225,22 +226,26 @@ final class DiffusionRepositoryCreateController
} }
if ($is_policy) { if ($is_policy) {
$policy_page = $form->getPage('policy');
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType($type_view) ->setTransactionType($type_view)
->setNewValue( ->setNewValue($policy_page->getControl('viewPolicy')->getValue());
$form->getPage('policy')->getControl('viewPolicy')->getValue());
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType($type_edit) ->setTransactionType($type_edit)
->setNewValue( ->setNewValue($policy_page->getControl('editPolicy')->getValue());
$form->getPage('policy')->getControl('editPolicy')->getValue());
if ($is_init || $repository->isHosted()) { if ($is_init || $repository->isHosted()) {
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType($type_push) ->setTransactionType($type_push)
->setNewValue( ->setNewValue($policy_page->getControl('pushPolicy')->getValue());
$form->getPage('policy')->getControl('pushPolicy')->getValue());
} }
$xactions[] = id(clone $template)
->setTransactionType($type_space)
->setNewValue(
$policy_page->getControl('viewPolicy')->getSpacePHID());
} }
id(new PhabricatorRepositoryEditor()) id(new PhabricatorRepositoryEditor())
@ -261,6 +266,7 @@ final class DiffusionRepositoryCreateController
'viewPolicy' => $repository->getViewPolicy(), 'viewPolicy' => $repository->getViewPolicy(),
'editPolicy' => $repository->getEditPolicy(), 'editPolicy' => $repository->getEditPolicy(),
'pushPolicy' => $repository->getPushPolicy(), 'pushPolicy' => $repository->getPushPolicy(),
'spacePHID' => $repository->getSpacePHID(),
); );
} }
$form->readFromObject($dict); $form->readFromObject($dict);

View file

@ -386,9 +386,17 @@ final class DiffusionRepositoryEditMainController
$viewer, $viewer,
$repository); $repository);
$view_parts = array();
if (PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
$space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID(
$repository);
$view_parts[] = $viewer->renderHandle($space_phid);
}
$view_parts[] = $descriptions[PhabricatorPolicyCapability::CAN_VIEW];
$view->addProperty( $view->addProperty(
pht('Visible To'), pht('Visible To'),
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]); phutil_implode_html(" \xC2\xB7 ", $view_parts));
$view->addProperty( $view->addProperty(
pht('Editable By'), pht('Editable By'),

View file

@ -153,6 +153,7 @@ final class PhabricatorRepositorySearchEngine
$item = id(new PHUIObjectItemView()) $item = id(new PHUIObjectItemView())
->setUser($viewer) ->setUser($viewer)
->setObject($repository)
->setHeader($repository->getName()) ->setHeader($repository->getName())
->setObjectName('r'.$repository->getCallsign()) ->setObjectName('r'.$repository->getCallsign())
->setHref($this->getApplicationURI($repository->getCallsign().'/')); ->setHref($this->getApplicationURI($repository->getCallsign().'/'));

View file

@ -11,7 +11,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
PhabricatorFlaggableInterface, PhabricatorFlaggableInterface,
PhabricatorMarkupInterface, PhabricatorMarkupInterface,
PhabricatorDestructibleInterface, PhabricatorDestructibleInterface,
PhabricatorProjectInterface { PhabricatorProjectInterface,
PhabricatorSpacesInterface {
/** /**
* Shortest hash we'll recognize in raw "a829f32" form. * Shortest hash we'll recognize in raw "a829f32" form.
@ -54,6 +55,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
protected $details = array(); protected $details = array();
protected $credentialPHID; protected $credentialPHID;
protected $almanacServicePHID; protected $almanacServicePHID;
protected $spacePHID;
private $commitCount = self::ATTACHABLE; private $commitCount = self::ATTACHABLE;
private $mostRecentCommit = self::ATTACHABLE; private $mostRecentCommit = self::ATTACHABLE;
@ -72,7 +74,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
$repository = id(new PhabricatorRepository()) $repository = id(new PhabricatorRepository())
->setViewPolicy($view_policy) ->setViewPolicy($view_policy)
->setEditPolicy($edit_policy) ->setEditPolicy($edit_policy)
->setPushPolicy($push_policy); ->setPushPolicy($push_policy)
->setSpacePHID($actor->getDefaultSpacePHID());
// Put the repository in "Importing" mode until we finish // Put the repository in "Importing" mode until we finish
// parsing it. // parsing it.
@ -1909,6 +1912,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
/* -( PhabricatorDestructibleInterface )----------------------------------- */ /* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently( public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) { PhabricatorDestructionEngine $engine) {
@ -1935,4 +1939,12 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
$this->saveTransaction(); $this->saveTransaction();
} }
/* -( PhabricatorSpacesInterface )----------------------------------------- */
public function getSpacePHID() {
return $this->spacePHID;
}
} }

View file

@ -39,6 +39,22 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
return $this; return $this;
} }
public function readValueFromDictionary(array $dictionary) {
// TODO: This is a little hacky but will only get us into trouble if we
// have multiple view policy controls in multiple paged form views on the
// same page, which seems unlikely.
$this->setSpacePHID(idx($dictionary, 'spacePHID'));
return parent::readValueFromDictionary($dictionary);
}
public function readValueFromRequest(AphrontRequest $request) {
// See note in readValueFromDictionary().
$this->setSpacePHID($request->getStr('spacePHID'));
return parent::readValueFromRequest($request);
}
public function setCapability($capability) { public function setCapability($capability) {
$this->capability = $capability; $this->capability = $capability;