@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 112 lines 2.9 kB view raw
1<?php 2 3final class DiffusionRepositoryLimitsManagementPanel 4 extends DiffusionRepositoryManagementPanel { 5 6 const PANELKEY = 'limits'; 7 8 public function getManagementPanelLabel() { 9 return pht('Limits'); 10 } 11 12 public function getManagementPanelOrder() { 13 return 700; 14 } 15 16 public function shouldEnableForRepository( 17 PhabricatorRepository $repository) { 18 return $repository->isGit(); 19 } 20 21 public function getManagementPanelIcon() { 22 $repository = $this->getRepository(); 23 24 $any_limit = false; 25 26 if ($repository->getFilesizeLimit()) { 27 $any_limit = true; 28 } 29 30 if ($any_limit) { 31 return 'fa-signal'; 32 } else { 33 return 'fa-signal grey'; 34 } 35 } 36 37 protected function getEditEngineFieldKeys() { 38 return array( 39 'filesizeLimit', 40 'copyTimeLimit', 41 'touchLimit', 42 ); 43 } 44 45 public function buildManagementPanelCurtain() { 46 $repository = $this->getRepository(); 47 $viewer = $this->getViewer(); 48 $action_list = $this->newActionList(); 49 50 $can_edit = PhabricatorPolicyFilter::hasCapability( 51 $viewer, 52 $repository, 53 PhabricatorPolicyCapability::CAN_EDIT); 54 55 $limits_uri = $this->getEditPageURI(); 56 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)); 64 65 return $this->newCurtainView() 66 ->setActionList($action_list); 67 } 68 69 public function buildManagementPanelContent() { 70 $repository = $this->getRepository(); 71 $viewer = $this->getViewer(); 72 73 $view = id(new PHUIPropertyListView()) 74 ->setViewer($viewer); 75 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); 82 } 83 84 $view->addProperty(pht('Filesize Limit'), $filesize_display); 85 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); 95 } 96 97 $view->addProperty(pht('Clone/Fetch Timeout'), $copy_display); 98 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); 105 } 106 107 $view->addProperty(pht('Touched Paths Limit'), $touch_display); 108 109 return $this->newBox(pht('Limits'), $view); 110 } 111 112}