forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiffusionRepositoryLimitsManagementPanel.php
112 lines (87 loc) · 2.85 KB
/
DiffusionRepositoryLimitsManagementPanel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
final class DiffusionRepositoryLimitsManagementPanel
extends DiffusionRepositoryManagementPanel {
const PANELKEY = 'limits';
public function getManagementPanelLabel() {
return pht('Limits');
}
public function getManagementPanelOrder() {
return 700;
}
public function shouldEnableForRepository(
PhabricatorRepository $repository) {
return $repository->isGit();
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
$any_limit = false;
if ($repository->getFilesizeLimit()) {
$any_limit = true;
}
if ($any_limit) {
return 'fa-signal';
} else {
return 'fa-signal grey';
}
}
protected function getEditEngineFieldKeys() {
return array(
'filesizeLimit',
'copyTimeLimit',
'touchLimit',
);
}
public function buildManagementPanelCurtain() {
$repository = $this->getRepository();
$viewer = $this->getViewer();
$action_list = $this->newActionList();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$repository,
PhabricatorPolicyCapability::CAN_EDIT);
$limits_uri = $this->getEditPageURI();
$action_list->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Limits'))
->setHref($limits_uri)
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
return $this->newCurtainView()
->setActionList($action_list);
}
public function buildManagementPanelContent() {
$repository = $this->getRepository();
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setViewer($viewer);
$byte_limit = $repository->getFilesizeLimit();
if ($byte_limit) {
$filesize_display = pht('%s Bytes', new PhutilNumber($byte_limit));
} else {
$filesize_display = pht('Unlimited');
$filesize_display = phutil_tag('em', array(), $filesize_display);
}
$view->addProperty(pht('Filesize Limit'), $filesize_display);
$copy_limit = $repository->getCopyTimeLimit();
if ($copy_limit) {
$copy_display = pht('%s Seconds', new PhutilNumber($copy_limit));
} else {
$copy_default = $repository->getDefaultCopyTimeLimit();
$copy_display = pht(
'Default (%s Seconds)',
new PhutilNumber($copy_default));
$copy_display = phutil_tag('em', array(), $copy_display);
}
$view->addProperty(pht('Clone/Fetch Timeout'), $copy_display);
$touch_limit = $repository->getTouchLimit();
if ($touch_limit) {
$touch_display = pht('%s Paths', new PhutilNumber($touch_limit));
} else {
$touch_display = pht('Unlimited');
$touch_display = phutil_tag('em', array(), $touch_display);
}
$view->addProperty(pht('Touched Paths Limit'), $touch_display);
return $this->newBox(pht('Limits'), $view);
}
}