Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / management / DiffusionRepositoryManagementPanel.php
blob1a58ef6a49cf3ed12f6b303201df9ec73e085e8c
1 <?php
3 abstract class DiffusionRepositoryManagementPanel
4 extends Phobject {
6 private $viewer;
7 private $repository;
8 private $controller;
10 final public function setViewer(PhabricatorUser $viewer) {
11 $this->viewer = $viewer;
12 return $this;
15 final public function getViewer() {
16 return $this->viewer;
19 final public function setRepository(PhabricatorRepository $repository) {
20 $this->repository = $repository;
21 return $this;
24 final public function getRepository() {
25 return $this->repository;
28 final public function getRequest() {
29 return $this->controller->getRequest();
32 final public function setController(PhabricatorController $controller) {
33 $this->controller = $controller;
34 return $this;
37 final public function getManagementPanelKey() {
38 return $this->getPhobjectClassConstant('PANELKEY');
41 abstract public function getManagementPanelLabel();
42 abstract public function getManagementPanelOrder();
43 abstract public function buildManagementPanelContent();
44 public function buildManagementPanelCurtain() { return null; }
46 public function getManagementPanelIcon() {
47 return 'fa-pencil';
50 public function getManagementPanelGroupKey() {
51 return DiffusionRepositoryManagementMainPanelGroup::PANELGROUPKEY;
54 public function shouldEnableForRepository(
55 PhabricatorRepository $repository) {
56 return true;
59 public static function getAllPanels() {
60 return id(new PhutilClassMapQuery())
61 ->setAncestorClass(__CLASS__)
62 ->setUniqueMethod('getManagementPanelKey')
63 ->setSortMethod('getManagementPanelOrder')
64 ->execute();
67 final protected function newTimeline() {
68 return $this->controller->newTimeline($this->getRepository());
71 final public function getPanelURI() {
72 $repository = $this->getRepository();
73 $key = $this->getManagementPanelKey();
74 return $repository->getPathURI("manage/{$key}/");
77 final public function newEditEnginePage() {
78 $field_keys = $this->getEditEngineFieldKeys();
79 if (!$field_keys) {
80 return null;
83 $key = $this->getManagementPanelKey();
84 $label = $this->getManagementPanelLabel();
85 $panel_uri = $this->getPanelURI();
87 return id(new PhabricatorEditPage())
88 ->setKey($key)
89 ->setLabel($label)
90 ->setViewURI($panel_uri)
91 ->setFieldKeys($field_keys);
94 protected function getEditEngineFieldKeys() {
95 return array();
98 protected function getEditPageURI($page = null) {
99 if ($page === null) {
100 $page = $this->getManagementPanelKey();
103 $repository = $this->getRepository();
104 $id = $repository->getID();
105 return "/diffusion/edit/{$id}/page/{$page}/";
108 public function getPanelNavigationURI() {
109 return $this->getPanelURI();
112 final protected function newActionList() {
113 $viewer = $this->getViewer();
114 $action_id = celerity_generate_unique_node_id();
116 return id(new PhabricatorActionListView())
117 ->setViewer($viewer)
118 ->setID($action_id);
121 final protected function newCurtainView() {
122 $viewer = $this->getViewer();
124 return id(new PHUICurtainView())
125 ->setViewer($viewer);
128 final protected function newBox($header_text, $body) {
129 $viewer = $this->getViewer();
131 $header = id(new PHUIHeaderView())
132 ->setViewer($viewer)
133 ->setHeader($header_text);
135 $view = id(new PHUIObjectBoxView())
136 ->setViewer($viewer)
137 ->setHeader($header)
138 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
139 ->appendChild($body);
141 return $view;