1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 13:00:56 +01:00

Expose dashboard policy editing to UI

Summary: Fixes T4981, Allow Dashboard view and edit policies to be configured

Test Plan: Create dashboard, edit dashboard, make sure user can edit who can edit and who can see dashboard.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4981

Differential Revision: https://secure.phabricator.com/D9243
This commit is contained in:
lkassianik 2014-05-21 12:23:14 -07:00 committed by epriestley
parent 0bf18d5f27
commit fbbb43c472
2 changed files with 32 additions and 0 deletions

View file

@ -64,11 +64,15 @@ final class PhabricatorDashboardEditController
if ($request->isFormPost()) { if ($request->isFormPost()) {
$v_name = $request->getStr('name'); $v_name = $request->getStr('name');
$v_layout_mode = $request->getStr('layout_mode'); $v_layout_mode = $request->getStr('layout_mode');
$v_view_policy = $request->getStr('viewPolicy');
$v_edit_policy = $request->getStr('editPolicy');
$xactions = array(); $xactions = array();
$type_name = PhabricatorDashboardTransaction::TYPE_NAME; $type_name = PhabricatorDashboardTransaction::TYPE_NAME;
$type_layout_mode = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE; $type_layout_mode = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE;
$type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY;
$xactions[] = id(new PhabricatorDashboardTransaction()) $xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_name) ->setTransactionType($type_name)
@ -76,6 +80,12 @@ final class PhabricatorDashboardEditController
$xactions[] = id(new PhabricatorDashboardTransaction()) $xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_layout_mode) ->setTransactionType($type_layout_mode)
->setNewValue($v_layout_mode); ->setNewValue($v_layout_mode);
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_view_policy)
->setNewValue($v_view_policy);
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_edit_policy)
->setNewValue($v_edit_policy);
try { try {
$editor = id(new PhabricatorDashboardTransactionEditor()) $editor = id(new PhabricatorDashboardTransactionEditor())
@ -94,9 +104,17 @@ final class PhabricatorDashboardEditController
$validation_exception = $ex; $validation_exception = $ex;
$e_name = $validation_exception->getShortMessage($type_name); $e_name = $validation_exception->getShortMessage($type_name);
$dashboard->setViewPolicy($v_view_policy);
$dashboard->setEditPolicy($v_edit_policy);
} }
} }
$policies = id(new PhabricatorPolicyQuery())
->setViewer($viewer)
->setObject($dashboard)
->execute();
$layout_mode_options = $layout_mode_options =
PhabricatorDashboardLayoutConfig::getLayoutModeSelectOptions(); PhabricatorDashboardLayoutConfig::getLayoutModeSelectOptions();
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
@ -107,6 +125,18 @@ final class PhabricatorDashboardEditController
->setName('name') ->setName('name')
->setValue($v_name) ->setValue($v_name)
->setError($e_name)) ->setError($e_name))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('viewPolicy')
->setPolicyObject($dashboard)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicies($policies))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('editPolicy')
->setPolicyObject($dashboard)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setPolicies($policies))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel(pht('Layout Mode')) ->setLabel(pht('Layout Mode'))

View file

@ -89,6 +89,8 @@ final class PhabricatorDashboardTransactionEditor
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorDashboardTransaction::TYPE_NAME: case PhabricatorDashboardTransaction::TYPE_NAME:
case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE: case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
return; return;
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:
return; return;