@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

Fix notification message when Aphlict is not configured

Summary:
Before this change the footer in the notification bar was a bit
weird on the message "Notification server not enabled":

| Before | After |
|-----------|-----------|
| {F315024} | {F315001} |

Also a bit wrong on the "Connecting..." message:

| Before | After |
|-----------|-----------|
| {F315061} | {F315072} |

The fix involves a refactor in the HTML structure in order to
match the graphic rendered when Aphlict is configured and running.

In short, we pass from this:

COUNTEREXAMPLE
<span class="connection-status-text aphlict-connection-status-notenabled">
<span class="visual-only phui-icon-view phui-font-fa fa-circle-o grey"></span>
Notification server not enabled
</span>

To this:

<span class="visual-only phui-icon-view phui-font-fa fa-circle-o grey"></span>
<span class="connection-status-text aphlict-connection-status-notenabled">Notification server not enabled</span>

See the Task for additional details.

Closes T15415

Test Plan:
Follow the official Notification documentation about the config `notification.servers`,
open the Notification top-bar, and check the message in these conditions:

- without the config
- with the config
- with/without Aphlict running

https://we.phorge.it/book/phorge/article/notifications/

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15415

Differential Revision: https://we.phorge.it/D25312

+33 -26
+33 -26
src/applications/notification/view/PhabricatorNotificationStatusView.php
··· 40 40 protected function getTagContent() { 41 41 $have = PhabricatorEnv::getEnvConfig('notification.servers'); 42 42 if ($have) { 43 - $icon = id(new PHUIIconView()) 44 - ->setIcon('fa-circle-o yellow'); 45 - $text = pht('Connecting...'); 46 - return phutil_tag( 47 - 'span', 48 - array( 49 - 'class' => 'connection-status-text '. 50 - 'aphlict-connection-status-connecting', 51 - ), 52 - array( 53 - $icon, 54 - $text, 55 - )); 43 + return $this->buildMessageView( 44 + 'aphlict-connection-status-connecting', 45 + 'fa-circle-o yellow', 46 + pht('Connecting...')); 56 47 } else { 57 - $text = pht('Notification server not enabled'); 58 - $icon = id(new PHUIIconView()) 59 - ->setIcon('fa-circle-o grey'); 60 - return phutil_tag( 61 - 'span', 62 - array( 63 - 'class' => 'connection-status-text '. 64 - 'aphlict-connection-status-notenabled', 65 - ), 66 - array( 67 - $icon, 68 - $text, 69 - )); 48 + return $this->buildMessageView( 49 + 'aphlict-connection-status-notenabled', 50 + 'fa-circle-o grey', 51 + pht('Notification server not enabled')); 70 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 + ); 71 78 } 72 79 73 80 }