3 final class DiffusionRepositoryPoliciesManagementPanel
4 extends DiffusionRepositoryManagementPanel
{
6 const PANELKEY
= 'policies';
8 public function getManagementPanelLabel() {
9 return pht('Policies');
12 public function getManagementPanelOrder() {
16 public function getManagementPanelIcon() {
17 $viewer = $this->getViewer();
18 $repository = $this->getRepository();
20 $can_view = PhabricatorPolicyCapability
::CAN_VIEW
;
21 $can_edit = PhabricatorPolicyCapability
::CAN_EDIT
;
22 $can_push = DiffusionPushCapability
::CAPABILITY
;
24 $actual_values = array(
25 'spacePHID' => $repository->getSpacePHID(),
26 'view' => $repository->getPolicy($can_view),
27 'edit' => $repository->getPolicy($can_edit),
28 'push' => $repository->getPolicy($can_push),
31 $default = PhabricatorRepository
::initializeNewRepository(
34 $default_values = array(
35 'spacePHID' => $default->getSpacePHID(),
36 'view' => $default->getPolicy($can_view),
37 'edit' => $default->getPolicy($can_edit),
38 'push' => $default->getPolicy($can_push),
41 if ($actual_values === $default_values) {
42 return 'fa-lock grey';
48 protected function getEditEngineFieldKeys() {
57 public function buildManagementPanelCurtain() {
58 $repository = $this->getRepository();
59 $viewer = $this->getViewer();
60 $action_list = $this->newActionList();
62 $can_edit = PhabricatorPolicyFilter
::hasCapability(
65 PhabricatorPolicyCapability
::CAN_EDIT
);
67 $edit_uri = $this->getEditPageURI();
69 $action_list->addAction(
70 id(new PhabricatorActionView())
71 ->setName(pht('Edit Policies'))
73 ->setIcon('fa-pencil')
74 ->setDisabled(!$can_edit)
75 ->setWorkflow(!$can_edit));
77 return $this->newCurtainView()
78 ->setActionList($action_list);
82 public function buildManagementPanelContent() {
83 $repository = $this->getRepository();
84 $viewer = $this->getViewer();
86 $view = id(new PHUIPropertyListView())
89 $descriptions = PhabricatorPolicyQuery
::renderPolicyDescriptions(
93 $view_parts = array();
94 if (PhabricatorSpacesNamespaceQuery
::getViewerSpacesExist($viewer)) {
95 $space_phid = PhabricatorSpacesNamespaceQuery
::getObjectSpacePHID(
97 $view_parts[] = $viewer->renderHandle($space_phid);
99 $view_parts[] = $descriptions[PhabricatorPolicyCapability
::CAN_VIEW
];
103 phutil_implode_html(" \xC2\xB7 ", $view_parts));
107 $descriptions[PhabricatorPolicyCapability
::CAN_EDIT
]);
109 $pushable = $repository->isHosted()
110 ?
$descriptions[DiffusionPushCapability
::CAPABILITY
]
111 : phutil_tag('em', array(), pht('Not a Hosted Repository'));
112 $view->addProperty(pht('Pushable By'), $pushable);
114 return $this->newBox(pht('Policies'), $view);