diff --git a/resources/sql/autopatches/20150624.spaces.1.repo.sql b/resources/sql/autopatches/20150624.spaces.1.repo.sql new file mode 100644 index 0000000000..dbb1e23206 --- /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 index 72a99b56df..1a6a2cceed 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -6185,6 +6185,7 @@ phutil_register_library_map(array( 'PhabricatorMarkupInterface', 'PhabricatorDestructibleInterface', 'PhabricatorProjectInterface', + 'PhabricatorSpacesInterface', ), 'PhabricatorRepositoryArcanistProject' => array( 'PhabricatorRepositoryDAO', diff --git a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php index b450fd09d3..d67f43d66f 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php @@ -137,6 +137,7 @@ final class DiffusionRepositoryCreateController $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 @@ final class DiffusionRepositoryCreateController } 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 @@ final class DiffusionRepositoryCreateController 'viewPolicy' => $repository->getViewPolicy(), 'editPolicy' => $repository->getEditPolicy(), 'pushPolicy' => $repository->getPushPolicy(), + 'spacePHID' => $repository->getSpacePHID(), ); } $form->readFromObject($dict); @@ -729,15 +735,15 @@ final class DiffusionRepositoryCreateController ->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 index 824a7afe1d..90891deb1d 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php @@ -386,9 +386,17 @@ final class DiffusionRepositoryEditMainController $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 index 2070586498..ab6c66f847 100644 --- a/src/applications/repository/query/PhabricatorRepositorySearchEngine.php +++ b/src/applications/repository/query/PhabricatorRepositorySearchEngine.php @@ -153,6 +153,7 @@ final class PhabricatorRepositorySearchEngine $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 index 12865a0e59..96208747b0 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -11,7 +11,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO PhabricatorFlaggableInterface, PhabricatorMarkupInterface, PhabricatorDestructibleInterface, - PhabricatorProjectInterface { + PhabricatorProjectInterface, + PhabricatorSpacesInterface { /** * Shortest hash we'll recognize in raw "a829f32" form. @@ -54,6 +55,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO protected $details = array(); protected $credentialPHID; protected $almanacServicePHID; + protected $spacePHID; private $commitCount = self::ATTACHABLE; private $mostRecentCommit = self::ATTACHABLE; @@ -72,7 +74,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO $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 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO /* -( PhabricatorDestructibleInterface )----------------------------------- */ + public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { @@ -1935,4 +1939,12 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO $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 index f062bb1b5a..88ab482111 100644 --- a/src/view/form/control/AphrontFormPolicyControl.php +++ b/src/view/form/control/AphrontFormPolicyControl.php @@ -39,6 +39,22 @@ final class AphrontFormPolicyControl extends AphrontFormControl { 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;