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:
@@ -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) {
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user