Skip to content

Commit

Permalink
Enhance incident history list view
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Sep 28, 2023
1 parent e652b8e commit cb51e75
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions library/Notifications/Widget/ItemList/IncidentHistoryListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class IncidentHistoryListItem extends BaseListItem

protected function assembleVisual(BaseHtmlElement $visual): void
{
if ($this->item->type === 'incident_severity_changed' || $this->item->type === 'source_severity_changed') {
if ($this->item->type === 'incident_severity_changed' || $this->item->type === 'opened') {
$content = new Icon($this->getIncidentEventIcon(), ['class' => 'severity-' . $this->item->new_severity]);
} else {
$content = new Icon($this->getIncidentEventIcon(), ['class' => 'type-' . $this->item->type]);
Expand All @@ -48,7 +48,7 @@ protected function assembleVisual(BaseHtmlElement $visual): void

protected function assembleTitle(BaseHtmlElement $title): void
{
if ($this->item->type === 'source_severity_changed') {
if ($this->item->type === 'opened' || $this->item->type == 'incident_severity_changed') {
$event = $this->item->event;
$this->getAttributes()
->set('data-action-item', true);
Expand Down Expand Up @@ -88,7 +88,7 @@ protected function assembleHeader(BaseHtmlElement $header): void
}

$header->addHtml($this->createCaption());
if ($this->item->type === 'source_severity_changed') {
if ($this->item->type === 'opened' || $this->item->type === 'incident_severity_changed') {
$header->add((new SourceIcon(SourceIcon::SIZE_BIG))->addHtml($this->item->event->object->source->getIcon()));
}

Expand All @@ -99,9 +99,7 @@ protected function getIncidentEventIcon(): string
{
switch ($this->item->type) {
case 'opened':
return Icons::OPENED;
case 'incident_severity_changed':
case 'source_severity_changed':
return $this->getSeverityIcon();
case 'recipient_role_changed':
return $this->getRoleIcon();
Expand Down Expand Up @@ -159,7 +157,10 @@ protected function buildMessage(): string
{
switch ($this->item->type) {
case 'opened':
$message = t('Opened this incident');
$message = sprintf(
t('Incident opened at severity %s'),
Event::mapSeverity($this->item->new_severity)
);
break;
case 'closed':
$message = t('All sources recovered, incident closed');
Expand Down Expand Up @@ -187,14 +188,6 @@ protected function buildMessage(): string
);
}
break;
case 'source_severity_changed':
$message = sprintf(
t('Source %s reported a severity change from %s to %s'),
$this->item->event->object->source->name,
Event::mapSeverity($this->item->old_severity),
Event::mapSeverity($this->item->new_severity)
);
break;
case 'incident_severity_changed':
$message = sprintf(
t('Incident severity changed from %s to %s'),
Expand Down

0 comments on commit cb51e75

Please sign in to comment.