Add hosting, serving, and push policy options to repository edit
Summary: Basically straight from D7391. The differences are basically: - Policy stuff is all application-scope instead of global-scope. - Made a few strings a little nicer. - Deleted a bit of dead code. - Added a big "THIS DOESN'T WORK YET" warning. Test Plan: See screenshots. Reviewers: hach-que, btrahan Reviewed By: hach-que CC: aran Maniphest Tasks: T2230 Differential Revision: https://secure.phabricator.com/D7416
This commit is contained in:
@@ -27,16 +27,19 @@ final class DiffusionRepositoryEditPolicyController
|
||||
|
||||
$v_view = $repository->getViewPolicy();
|
||||
$v_edit = $repository->getEditPolicy();
|
||||
$v_push = $repository->getPushPolicy();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$v_view = $request->getStr('viewPolicy');
|
||||
$v_edit = $request->getStr('editPolicy');
|
||||
$v_push = $request->getStr('pushPolicy');
|
||||
|
||||
$xactions = array();
|
||||
$template = id(new PhabricatorRepositoryTransaction());
|
||||
|
||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$type_push = PhabricatorRepositoryTransaction::TYPE_PUSH_POLICY;
|
||||
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType($type_view)
|
||||
@@ -46,6 +49,12 @@ final class DiffusionRepositoryEditPolicyController
|
||||
->setTransactionType($type_edit)
|
||||
->setNewValue($v_edit);
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType($type_push)
|
||||
->setNewValue($v_push);
|
||||
}
|
||||
|
||||
id(new PhabricatorRepositoryEditor())
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSourceFromRequest($request)
|
||||
@@ -62,7 +71,7 @@ final class DiffusionRepositoryEditPolicyController
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Edit Policies')));
|
||||
|
||||
$title = pht('Edit %s', $repository->getName());
|
||||
$title = pht('Edit Policies (%s)', $repository->getName());
|
||||
|
||||
$policies = id(new PhabricatorPolicyQuery())
|
||||
->setViewer($viewer)
|
||||
@@ -84,7 +93,25 @@ final class DiffusionRepositoryEditPolicyController
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||
->setPolicyObject($repository)
|
||||
->setPolicies($policies)
|
||||
->setName('editPolicy'))
|
||||
->setName('editPolicy'));
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
$form->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($viewer)
|
||||
->setCapability(DiffusionCapabilityPush::CAPABILITY)
|
||||
->setPolicyObject($repository)
|
||||
->setPolicies($policies)
|
||||
->setName('pushPolicy'));
|
||||
} else {
|
||||
$form->appendChild(
|
||||
id(new AphrontFormMarkupControl())
|
||||
->setLabel(pht('Can Push'))
|
||||
->setValue(
|
||||
phutil_tag('em', array(), pht('Not a Hosted Repository'))));
|
||||
}
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue(pht('Save Policies'))
|
||||
|
||||
Reference in New Issue
Block a user