Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php
13395 views
1
<?php
2
3
final class DiffusionRepositoryURIsManagementPanel
4
extends DiffusionRepositoryManagementPanel {
5
6
const PANELKEY = 'uris';
7
8
public function getManagementPanelLabel() {
9
return pht('URIs');
10
}
11
12
public function getManagementPanelIcon() {
13
return 'fa-globe';
14
}
15
16
public function getManagementPanelOrder() {
17
return 400;
18
}
19
20
public function buildManagementPanelCurtain() {
21
$repository = $this->getRepository();
22
$viewer = $this->getViewer();
23
$action_list = $this->newActionList();
24
25
$can_edit = PhabricatorPolicyFilter::hasCapability(
26
$viewer,
27
$repository,
28
PhabricatorPolicyCapability::CAN_EDIT);
29
30
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: URIs');
31
$add_href = $repository->getPathURI('uri/edit/');
32
33
$action_list->addAction(
34
id(new PhabricatorActionView())
35
->setIcon('fa-plus')
36
->setHref($add_href)
37
->setDisabled(!$can_edit)
38
->setName(pht('Add New URI')));
39
40
$action_list->addAction(
41
id(new PhabricatorActionView())
42
->setIcon('fa-book')
43
->setHref($doc_href)
44
->setName(pht('URI Documentation')));
45
46
return $this->newCurtainView()
47
->setActionList($action_list);
48
}
49
50
public function buildManagementPanelContent() {
51
$repository = $this->getRepository();
52
$viewer = $this->getViewer();
53
$uris = $repository->getURIs();
54
55
Javelin::initBehavior('phabricator-tooltips');
56
$rows = array();
57
foreach ($uris as $uri) {
58
59
$uri_name = $uri->getDisplayURI();
60
$uri_name = phutil_tag(
61
'a',
62
array(
63
'href' => $uri->getViewURI(),
64
),
65
$uri_name);
66
67
if ($uri->getIsDisabled()) {
68
$status_icon = 'fa-times grey';
69
} else {
70
$status_icon = 'fa-check green';
71
}
72
73
$uri_status = id(new PHUIIconView())->setIcon($status_icon);
74
75
$io_type = $uri->getEffectiveIOType();
76
$io_map = PhabricatorRepositoryURI::getIOTypeMap();
77
$io_spec = idx($io_map, $io_type, array());
78
79
$io_icon = idx($io_spec, 'icon');
80
$io_color = idx($io_spec, 'color');
81
$io_label = idx($io_spec, 'label', $io_type);
82
83
$uri_io = array(
84
id(new PHUIIconView())->setIcon("{$io_icon} {$io_color}"),
85
' ',
86
$io_label,
87
);
88
89
$display_type = $uri->getEffectiveDisplayType();
90
$display_map = PhabricatorRepositoryURI::getDisplayTypeMap();
91
$display_spec = idx($display_map, $display_type, array());
92
93
$display_icon = idx($display_spec, 'icon');
94
$display_color = idx($display_spec, 'color');
95
$display_label = idx($display_spec, 'label', $display_type);
96
97
$uri_display = array(
98
id(new PHUIIconView())->setIcon("{$display_icon} {$display_color}"),
99
' ',
100
$display_label,
101
);
102
103
$rows[] = array(
104
$uri_status,
105
$uri_name,
106
$uri_io,
107
$uri_display,
108
);
109
}
110
111
$table = id(new AphrontTableView($rows))
112
->setNoDataString(pht('This repository has no URIs.'))
113
->setHeaders(
114
array(
115
null,
116
pht('URI'),
117
pht('I/O'),
118
pht('Display'),
119
))
120
->setColumnClasses(
121
array(
122
null,
123
'pri wide',
124
null,
125
null,
126
));
127
128
$is_new = $repository->isNewlyInitialized();
129
130
$messages = array();
131
if ($repository->isHosted()) {
132
if ($is_new) {
133
$host_message = pht('This repository will be hosted.');
134
} else {
135
$host_message = pht('This repository is observed.');
136
}
137
138
$messages[] = $host_message;
139
} else {
140
if ($is_new) {
141
$observe_message = pht(
142
'This repository will be observed.');
143
} else {
144
$observe_message = pht(
145
'This remote repository is being observed.');
146
}
147
148
$messages[] = $observe_message;
149
}
150
151
$info_view = id(new PHUIInfoView())
152
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
153
->setErrors($messages);
154
155
$box = $this->newBox(pht('Repository URIs'), $table);
156
157
return array($info_view, $box);
158
}
159
160
}
161
162