diff --git a/resources/sql/autopatches/20150624.spaces.1.repo.sql b/resources/sql/autopatches/20150624.spaces.1.repo.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20150624.spaces.1.repo.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_repository.repository + ADD spacePHID VARBINARY(64); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -6185,6 +6185,7 @@ 'PhabricatorMarkupInterface', 'PhabricatorDestructibleInterface', 'PhabricatorProjectInterface', + 'PhabricatorSpacesInterface', ), 'PhabricatorRepositoryArcanistProject' => array( 'PhabricatorRepositoryDAO', diff --git a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php --- a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php @@ -137,6 +137,7 @@ $type_credential = PhabricatorRepositoryTransaction::TYPE_CREDENTIAL; $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; + $type_space = PhabricatorTransactions::TYPE_SPACE; $type_push = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY; $type_service = PhabricatorRepositoryTransaction::TYPE_SERVICE; @@ -225,22 +226,26 @@ } if ($is_policy) { + $policy_page = $form->getPage('policy'); + $xactions[] = id(clone $template) ->setTransactionType($type_view) - ->setNewValue( - $form->getPage('policy')->getControl('viewPolicy')->getValue()); + ->setNewValue($policy_page->getControl('viewPolicy')->getValue()); $xactions[] = id(clone $template) ->setTransactionType($type_edit) - ->setNewValue( - $form->getPage('policy')->getControl('editPolicy')->getValue()); + ->setNewValue($policy_page->getControl('editPolicy')->getValue()); if ($is_init || $repository->isHosted()) { $xactions[] = id(clone $template) ->setTransactionType($type_push) - ->setNewValue( - $form->getPage('policy')->getControl('pushPolicy')->getValue()); + ->setNewValue($policy_page->getControl('pushPolicy')->getValue()); } + + $xactions[] = id(clone $template) + ->setTransactionType($type_space) + ->setNewValue( + $policy_page->getControl('viewPolicy')->getSpacePHID()); } id(new PhabricatorRepositoryEditor()) @@ -261,6 +266,7 @@ 'viewPolicy' => $repository->getViewPolicy(), 'editPolicy' => $repository->getEditPolicy(), 'pushPolicy' => $repository->getPushPolicy(), + 'spacePHID' => $repository->getSpacePHID(), ); } $form->readFromObject($dict); @@ -729,15 +735,15 @@ ->setName('pushPolicy'); return id(new PHUIFormPageView()) - ->setPageName(pht('Policies')) - ->setValidateFormPageCallback(array($this, 'validatePolicyPage')) - ->setAdjustFormPageCallback(array($this, 'adjustPolicyPage')) - ->setUser($viewer) - ->addRemarkupInstructions( - pht('Select access policies for this repository.')) - ->addControl($view_policy) - ->addControl($edit_policy) - ->addControl($push_policy); + ->setPageName(pht('Policies')) + ->setValidateFormPageCallback(array($this, 'validatePolicyPage')) + ->setAdjustFormPageCallback(array($this, 'adjustPolicyPage')) + ->setUser($viewer) + ->addRemarkupInstructions( + pht('Select access policies for this repository.')) + ->addControl($view_policy) + ->addControl($edit_policy) + ->addControl($push_policy); } public function adjustPolicyPage(PHUIFormPageView $page) { diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php --- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php @@ -386,9 +386,17 @@ $viewer, $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( pht('Visible To'), - $descriptions[PhabricatorPolicyCapability::CAN_VIEW]); + phutil_implode_html(" \xC2\xB7 ", $view_parts)); $view->addProperty( pht('Editable By'), diff --git a/src/applications/repository/query/PhabricatorRepositorySearchEngine.php b/src/applications/repository/query/PhabricatorRepositorySearchEngine.php --- a/src/applications/repository/query/PhabricatorRepositorySearchEngine.php +++ b/src/applications/repository/query/PhabricatorRepositorySearchEngine.php @@ -153,6 +153,7 @@ $item = id(new PHUIObjectItemView()) ->setUser($viewer) + ->setObject($repository) ->setHeader($repository->getName()) ->setObjectName('r'.$repository->getCallsign()) ->setHref($this->getApplicationURI($repository->getCallsign().'/')); diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -11,7 +11,8 @@ PhabricatorFlaggableInterface, PhabricatorMarkupInterface, PhabricatorDestructibleInterface, - PhabricatorProjectInterface { + PhabricatorProjectInterface, + PhabricatorSpacesInterface { /** * Shortest hash we'll recognize in raw "a829f32" form. @@ -54,6 +55,7 @@ protected $details = array(); protected $credentialPHID; protected $almanacServicePHID; + protected $spacePHID; private $commitCount = self::ATTACHABLE; private $mostRecentCommit = self::ATTACHABLE; @@ -72,7 +74,8 @@ $repository = id(new PhabricatorRepository()) ->setViewPolicy($view_policy) ->setEditPolicy($edit_policy) - ->setPushPolicy($push_policy); + ->setPushPolicy($push_policy) + ->setSpacePHID($actor->getDefaultSpacePHID()); // Put the repository in "Importing" mode until we finish // parsing it. @@ -1909,6 +1912,7 @@ /* -( PhabricatorDestructibleInterface )----------------------------------- */ + public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { @@ -1935,4 +1939,12 @@ $this->saveTransaction(); } + +/* -( PhabricatorSpacesInterface )----------------------------------------- */ + + + public function getSpacePHID() { + return $this->spacePHID; + } + } diff --git a/src/view/form/control/AphrontFormPolicyControl.php b/src/view/form/control/AphrontFormPolicyControl.php --- a/src/view/form/control/AphrontFormPolicyControl.php +++ b/src/view/form/control/AphrontFormPolicyControl.php @@ -39,6 +39,22 @@ 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) { $this->capability = $capability;