1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

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
This commit is contained in:
Valerio Bozzolan 2023-06-27 13:29:24 +02:00
parent 659e13fa6d
commit 1005e38160

View file

@ -40,34 +40,41 @@ final class PhabricatorNotificationStatusView extends AphrontTagView {
protected function getTagContent() {
$have = PhabricatorEnv::getEnvConfig('notification.servers');
if ($have) {
$icon = id(new PHUIIconView())
->setIcon('fa-circle-o yellow');
$text = pht('Connecting...');
return phutil_tag(
'span',
array(
'class' => 'connection-status-text '.
'aphlict-connection-status-connecting',
),
array(
$icon,
$text,
));
return $this->buildMessageView(
'aphlict-connection-status-connecting',
'fa-circle-o yellow',
pht('Connecting...'));
} else {
$text = pht('Notification server not enabled');
$icon = id(new PHUIIconView())
->setIcon('fa-circle-o grey');
return phutil_tag(
'span',
array(
'class' => 'connection-status-text '.
'aphlict-connection-status-notenabled',
),
array(
$icon,
$text,
));
return $this->buildMessageView(
'aphlict-connection-status-notenabled',
'fa-circle-o grey',
pht('Notification server not enabled'));
}
}
/**
* Create an icon and a message.
*
* @param string $class_name Raw CSS class name(s) space separated
* @param string $icon_name Icon name
* @param string $text Text to be shown
* @return array
*/
private function buildMessageView($class_name, $icon_name, $text) {
$icon = id(new PHUIIconView())
->setIcon($icon_name);
$message = phutil_tag(
'span',
array(
'class' => 'connection-status-text '.$class_name,
),
$text);
return array(
$icon,
$message,
);
}
}