Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / management / DiffusionRepositoryPoliciesManagementPanel.php
blob7cada92fed7e9a55ec2047f9754c00e0961b5f9e
1 <?php
3 final class DiffusionRepositoryPoliciesManagementPanel
4 extends DiffusionRepositoryManagementPanel {
6 const PANELKEY = 'policies';
8 public function getManagementPanelLabel() {
9 return pht('Policies');
12 public function getManagementPanelOrder() {
13 return 300;
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(
32 $viewer);
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';
43 } else {
44 return 'fa-lock';
48 protected function getEditEngineFieldKeys() {
49 return array(
50 'policy.view',
51 'policy.edit',
52 'spacePHID',
53 'policy.push',
57 public function buildManagementPanelCurtain() {
58 $repository = $this->getRepository();
59 $viewer = $this->getViewer();
60 $action_list = $this->newActionList();
62 $can_edit = PhabricatorPolicyFilter::hasCapability(
63 $viewer,
64 $repository,
65 PhabricatorPolicyCapability::CAN_EDIT);
67 $edit_uri = $this->getEditPageURI();
69 $action_list->addAction(
70 id(new PhabricatorActionView())
71 ->setName(pht('Edit Policies'))
72 ->setHref($edit_uri)
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())
87 ->setViewer($viewer);
89 $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
90 $viewer,
91 $repository);
93 $view_parts = array();
94 if (PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
95 $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID(
96 $repository);
97 $view_parts[] = $viewer->renderHandle($space_phid);
99 $view_parts[] = $descriptions[PhabricatorPolicyCapability::CAN_VIEW];
101 $view->addProperty(
102 pht('Visible To'),
103 phutil_implode_html(" \xC2\xB7 ", $view_parts));
105 $view->addProperty(
106 pht('Editable By'),
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);