3 abstract class AlmanacController
4 extends PhabricatorController
{
6 protected function buildAlmanacPropertiesTable(
7 AlmanacPropertyInterface
$object) {
9 $viewer = $this->getViewer();
10 $properties = $object->getAlmanacProperties();
12 $this->requireResource('almanac-css');
13 Javelin
::initBehavior('phabricator-tooltips', array());
15 $can_edit = PhabricatorPolicyFilter
::hasCapability(
18 PhabricatorPolicyCapability
::CAN_EDIT
);
20 $properties = $object->getAlmanacProperties();
22 $icon_builtin = id(new PHUIIconView())
23 ->setIcon('fa-circle')
24 ->addSigil('has-tooltip')
27 'tip' => pht('Builtin Property'),
31 $icon_custom = id(new PHUIIconView())
32 ->setIcon('fa-circle-o grey')
33 ->addSigil('has-tooltip')
36 'tip' => pht('Custom Property'),
40 $builtins = $object->getAlmanacPropertyFieldSpecifications();
41 $defaults = mpull($builtins, 'getValueForTransaction');
43 // Sort fields so builtin fields appear first, then fields are ordered
45 $properties = msort($properties, 'getFieldName');
49 foreach ($properties as $property) {
50 $key = $property->getFieldName();
51 if (isset($builtins[$key])) {
52 $head[$key] = $property;
54 $tail[$key] = $property;
58 $properties = $head +
$tail;
60 $delete_base = $this->getApplicationURI('property/delete/');
61 $edit_base = $this->getApplicationURI('property/update/');
64 foreach ($properties as $key => $property) {
65 $value = $property->getFieldValue();
67 $is_builtin = isset($builtins[$key]);
68 $is_persistent = (bool)$property->getID();
72 'objectPHID' => $object->getPHID(),
75 $delete_uri = new PhutilURI($delete_base, $params);
76 $edit_uri = new PhutilURI($edit_base, $params);
78 $delete = javelin_tag(
81 'class' => (($can_edit && $is_persistent)
82 ?
'button button-grey small'
83 : 'button button-grey small disabled'),
84 'sigil' => 'workflow',
85 'href' => $delete_uri,
87 $is_builtin ?
pht('Reset') : pht('Delete'));
89 $default = idx($defaults, $key);
90 $is_default = ($default !== null && $default === $value);
92 $display_value = PhabricatorConfigJSON
::prettyPrintJSON($value);
94 $display_value = phutil_tag(
97 'class' => 'almanac-default-property-value',
104 $display_key = javelin_tag(
108 'sigil' => 'workflow',
114 ($is_builtin ?
$icon_builtin : $icon_custom),
121 $table = id(new AphrontTableView($rows))
122 ->setNoDataString(pht('No properties.'))
138 $phid = $object->getPHID();
139 $add_uri = id(new PhutilURI($edit_base))
140 ->replaceQueryParam('objectPHID', $object->getPHID());
142 $can_edit = PhabricatorPolicyFilter
::hasCapability(
145 PhabricatorPolicyCapability
::CAN_EDIT
);
147 $add_button = id(new PHUIButtonView())
151 ->setDisabled(!$can_edit)
152 ->setText(pht('Add Property'))
153 ->setIcon('fa-plus');
155 $header = id(new PHUIHeaderView())
156 ->setHeader(pht('Properties'))
157 ->addActionLink($add_button);
159 return id(new PHUIObjectBoxView())
161 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
165 protected function addClusterMessage(
169 $can_manage = $this->hasApplicationCapability(
170 AlmanacManageClusterServicesCapability
::CAPABILITY
);
172 $doc_link = phutil_tag(
175 'href' => PhabricatorEnv
::getDoclink(
176 'Clustering Introduction'),
177 'target' => '_blank',
182 $severity = PHUIInfoView
::SEVERITY_NOTICE
;
183 $message = $positive;
185 $severity = PHUIInfoView
::SEVERITY_WARNING
;
186 $message = $negative;
189 $icon = id(new PHUIIconView())
190 ->setIcon('fa-sitemap');
192 return id(new PHUIInfoView())
193 ->setSeverity($severity)
196 array($icon, ' ', $message, ' ', $doc_link),
201 protected function getPropertyDeleteURI($object) {
205 protected function getPropertyUpdateURI($object) {