mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Allow dashboard panel policies to be edited
Summary: Fixes T4982, expose dashboard panel policy editing to UI Test Plan: Create panel, verify that user can edit who can see and who can edit panel Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T4982 Differential Revision: https://secure.phabricator.com/D9238
This commit is contained in:
parent
5e905edafa
commit
953f95054f
2 changed files with 38 additions and 2 deletions
|
@ -66,16 +66,30 @@ final class PhabricatorDashboardPanelEditController
|
||||||
->readFieldsFromStorage($panel);
|
->readFieldsFromStorage($panel);
|
||||||
|
|
||||||
$validation_exception = null;
|
$validation_exception = null;
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$v_name = $request->getStr('name');
|
$v_name = $request->getStr('name');
|
||||||
|
$v_view_policy = $request->getStr('viewPolicy');
|
||||||
|
$v_edit_policy = $request->getStr('editPolicy');
|
||||||
|
|
||||||
|
$type_name = PhabricatorDashboardPanelTransaction::TYPE_NAME;
|
||||||
|
$type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
|
$type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
|
||||||
$type_name = PhabricatorDashboardPanelTransaction::TYPE_NAME;
|
|
||||||
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
|
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
|
||||||
->setTransactionType($type_name)
|
->setTransactionType($type_name)
|
||||||
->setNewValue($v_name);
|
->setNewValue($v_name);
|
||||||
|
|
||||||
|
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
|
||||||
|
->setTransactionType($type_view_policy)
|
||||||
|
->setNewValue($v_view_policy);
|
||||||
|
|
||||||
|
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
|
||||||
|
->setTransactionType($type_edit_policy)
|
||||||
|
->setNewValue($v_edit_policy);
|
||||||
|
|
||||||
$field_xactions = $field_list->buildFieldTransactionsFromRequest(
|
$field_xactions = $field_list->buildFieldTransactionsFromRequest(
|
||||||
new PhabricatorDashboardPanelTransaction(),
|
new PhabricatorDashboardPanelTransaction(),
|
||||||
$request);
|
$request);
|
||||||
|
@ -94,9 +108,17 @@ final class PhabricatorDashboardPanelEditController
|
||||||
$validation_exception = $ex;
|
$validation_exception = $ex;
|
||||||
|
|
||||||
$e_name = $validation_exception->getShortMessage($type_name);
|
$e_name = $validation_exception->getShortMessage($type_name);
|
||||||
|
|
||||||
|
$panel->setViewPolicy($v_view_policy);
|
||||||
|
$panel->setEditPolicy($v_edit_policy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$policies = id(new PhabricatorPolicyQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->setObject($panel)
|
||||||
|
->execute();
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
@ -104,7 +126,19 @@ final class PhabricatorDashboardPanelEditController
|
||||||
->setLabel(pht('Name'))
|
->setLabel(pht('Name'))
|
||||||
->setName('name')
|
->setName('name')
|
||||||
->setValue($v_name)
|
->setValue($v_name)
|
||||||
->setError($e_name));
|
->setError($e_name))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormPolicyControl())
|
||||||
|
->setName('viewPolicy')
|
||||||
|
->setPolicyObject($panel)
|
||||||
|
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
||||||
|
->setPolicies($policies))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormPolicyControl())
|
||||||
|
->setName('editPolicy')
|
||||||
|
->setPolicyObject($panel)
|
||||||
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||||
|
->setPolicies($policies));
|
||||||
|
|
||||||
$field_list->appendFieldsToForm($form);
|
$field_list->appendFieldsToForm($form);
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ final class PhabricatorDashboardPanelTransactionEditor
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorDashboardPanelTransaction::TYPE_NAME:
|
case PhabricatorDashboardPanelTransaction::TYPE_NAME:
|
||||||
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue