@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
1<?php
2
3final class PhabricatorNotificationStatusView extends AphrontTagView {
4
5 protected function getTagAttributes() {
6 if (!$this->getID()) {
7 $this->setID(celerity_generate_unique_node_id());
8 }
9
10 Javelin::initBehavior(
11 'aphlict-status',
12 array(
13 'nodeID' => $this->getID(),
14 'pht' => array(
15 'setup' => pht('Setting Up Client'),
16 'open' => pht('Connected'),
17 'closed' => pht('Disconnected'),
18 ),
19 'icon' => array(
20 'open' => array(
21 'icon' => 'fa-circle',
22 'color' => 'green',
23 ),
24 'setup' => array(
25 'icon' => 'fa-circle',
26 'color' => 'yellow',
27 ),
28 'closed' => array(
29 'icon' => 'fa-circle',
30 'color' => 'red',
31 ),
32 ),
33 ));
34
35 return array(
36 'class' => 'aphlict-connection-status',
37 );
38 }
39
40 protected function getTagContent() {
41 $have = PhabricatorEnv::getEnvConfig('notification.servers');
42 if ($have) {
43 return $this->buildMessageView(
44 'aphlict-connection-status-connecting',
45 'fa-circle-o yellow',
46 pht('Connecting...'));
47 } else {
48 return $this->buildMessageView(
49 'aphlict-connection-status-notenabled',
50 'fa-circle-o grey',
51 pht('Notification server not enabled'));
52 }
53 }
54
55 /**
56 * Create an icon and a message.
57 *
58 * @param string $class_name Raw CSS class name(s) space separated
59 * @param string $icon_name Icon name
60 * @param string $text Text to be shown
61 * @return array
62 */
63 private function buildMessageView($class_name, $icon_name, $text) {
64 $icon = id(new PHUIIconView())
65 ->setIcon($icon_name);
66
67 $message = phutil_tag(
68 'span',
69 array(
70 'class' => 'connection-status-text '.$class_name,
71 ),
72 $text);
73
74 return array(
75 $icon,
76 $message,
77 );
78 }
79
80}