forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiffusionRepositoryURIsManagementPanel.php
158 lines (131 loc) · 4.02 KB
/
DiffusionRepositoryURIsManagementPanel.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
final class DiffusionRepositoryURIsManagementPanel
extends DiffusionRepositoryManagementPanel {
const PANELKEY = 'uris';
public function getManagementPanelLabel() {
return pht('URIs');
}
public function getManagementPanelIcon() {
return 'fa-cogs';
}
public function getManagementPanelOrder() {
return 400;
}
public function buildManagementPanelContent() {
$repository = $this->getRepository();
$viewer = $this->getViewer();
$uris = $repository->getURIs();
Javelin::initBehavior('phabricator-tooltips');
$rows = array();
foreach ($uris as $uri) {
$uri_name = $uri->getDisplayURI();
$uri_name = phutil_tag(
'a',
array(
'href' => $uri->getViewURI(),
),
$uri_name);
if ($uri->getIsDisabled()) {
$status_icon = 'fa-times grey';
} else {
$status_icon = 'fa-check green';
}
$uri_status = id(new PHUIIconView())->setIcon($status_icon);
$io_type = $uri->getEffectiveIOType();
$io_map = PhabricatorRepositoryURI::getIOTypeMap();
$io_spec = idx($io_map, $io_type, array());
$io_icon = idx($io_spec, 'icon');
$io_color = idx($io_spec, 'color');
$io_label = idx($io_spec, 'label', $io_type);
$uri_io = array(
id(new PHUIIconView())->setIcon("{$io_icon} {$io_color}"),
' ',
$io_label,
);
$display_type = $uri->getEffectiveDisplayType();
$display_map = PhabricatorRepositoryURI::getDisplayTypeMap();
$display_spec = idx($display_map, $display_type, array());
$display_icon = idx($display_spec, 'icon');
$display_color = idx($display_spec, 'color');
$display_label = idx($display_spec, 'label', $display_type);
$uri_display = array(
id(new PHUIIconView())->setIcon("{$display_icon} {$display_color}"),
' ',
$display_label,
);
$rows[] = array(
$uri_status,
$uri_name,
$uri_io,
$uri_display,
);
}
$table = id(new AphrontTableView($rows))
->setNoDataString(pht('This repository has no URIs.'))
->setHeaders(
array(
null,
pht('URI'),
pht('I/O'),
pht('Display'),
))
->setColumnClasses(
array(
null,
'pri wide',
null,
null,
));
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: URIs');
$add_href = $repository->getPathURI('uri/edit/');
$header = id(new PHUIHeaderView())
->setHeader(pht('Repository URIs'))
->addActionLink(
id(new PHUIButtonView())
->setIcon('fa-plus')
->setHref($add_href)
->setTag('a')
->setText(pht('Add New URI')))
->addActionLink(
id(new PHUIButtonView())
->setIcon('fa-book')
->setHref($doc_href)
->setTag('a')
->setText(pht('Documentation')));
$is_new = $repository->isNewlyInitialized();
$messages = array();
if ($repository->isHosted()) {
if ($is_new) {
$host_message = pht('Phabricator will host this repository.');
} else {
$host_message = pht('Phabricator is hosting this repository.');
}
$messages[] = array(
id(new PHUIIconView())->setIcon('fa-folder'),
' ',
$host_message,
);
} else {
if ($is_new) {
$observe_message = pht(
'Phabricator will observe a remote repository.');
} else {
$observe_message = pht(
'This repository is hosted remotely. Phabricator is observing it.');
}
$messages[] = array(
id(new PHUIIconView())->setIcon('fa-download'),
' ',
$observe_message,
);
}
$info_view = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setErrors($messages);
return id(new PHUIObjectBoxView())
->setHeader($header)
->setInfoView($info_view)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table);
}
}