Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / diffusion / management / DiffusionRepositoryLimitsManagementPanel.php
blobb57ed5cf56890b266b5b7755021615bba94c8305
1 <?php
3 final class DiffusionRepositoryLimitsManagementPanel
4 extends DiffusionRepositoryManagementPanel {
6 const PANELKEY = 'limits';
8 public function getManagementPanelLabel() {
9 return pht('Limits');
12 public function getManagementPanelOrder() {
13 return 700;
16 public function shouldEnableForRepository(
17 PhabricatorRepository $repository) {
18 return $repository->isGit();
21 public function getManagementPanelIcon() {
22 $repository = $this->getRepository();
24 $any_limit = false;
26 if ($repository->getFilesizeLimit()) {
27 $any_limit = true;
30 if ($any_limit) {
31 return 'fa-signal';
32 } else {
33 return 'fa-signal grey';
37 protected function getEditEngineFieldKeys() {
38 return array(
39 'filesizeLimit',
40 'copyTimeLimit',
41 'touchLimit',
45 public function buildManagementPanelCurtain() {
46 $repository = $this->getRepository();
47 $viewer = $this->getViewer();
48 $action_list = $this->newActionList();
50 $can_edit = PhabricatorPolicyFilter::hasCapability(
51 $viewer,
52 $repository,
53 PhabricatorPolicyCapability::CAN_EDIT);
55 $limits_uri = $this->getEditPageURI();
57 $action_list->addAction(
58 id(new PhabricatorActionView())
59 ->setIcon('fa-pencil')
60 ->setName(pht('Edit Limits'))
61 ->setHref($limits_uri)
62 ->setDisabled(!$can_edit)
63 ->setWorkflow(!$can_edit));
65 return $this->newCurtainView()
66 ->setActionList($action_list);
69 public function buildManagementPanelContent() {
70 $repository = $this->getRepository();
71 $viewer = $this->getViewer();
73 $view = id(new PHUIPropertyListView())
74 ->setViewer($viewer);
76 $byte_limit = $repository->getFilesizeLimit();
77 if ($byte_limit) {
78 $filesize_display = pht('%s Bytes', new PhutilNumber($byte_limit));
79 } else {
80 $filesize_display = pht('Unlimited');
81 $filesize_display = phutil_tag('em', array(), $filesize_display);
84 $view->addProperty(pht('Filesize Limit'), $filesize_display);
86 $copy_limit = $repository->getCopyTimeLimit();
87 if ($copy_limit) {
88 $copy_display = pht('%s Seconds', new PhutilNumber($copy_limit));
89 } else {
90 $copy_default = $repository->getDefaultCopyTimeLimit();
91 $copy_display = pht(
92 'Default (%s Seconds)',
93 new PhutilNumber($copy_default));
94 $copy_display = phutil_tag('em', array(), $copy_display);
97 $view->addProperty(pht('Clone/Fetch Timeout'), $copy_display);
99 $touch_limit = $repository->getTouchLimit();
100 if ($touch_limit) {
101 $touch_display = pht('%s Paths', new PhutilNumber($touch_limit));
102 } else {
103 $touch_display = pht('Unlimited');
104 $touch_display = phutil_tag('em', array(), $touch_display);
107 $view->addProperty(pht('Touched Paths Limit'), $touch_display);
109 return $this->newBox(pht('Limits'), $view);