Skip to content

Commit 3504a06

Browse files
committed
ContactListItem: Add icon for webhook
1 parent ba627b4 commit 3504a06

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

application/controllers/ContactsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function init()
4343
public function indexAction()
4444
{
4545
$contacts = Contact::on($this->db)
46-
->withColumns('has_email');
46+
->withColumns(['has_email', 'has_webhook']);
4747

4848
$limitControl = $this->createLimitControl();
4949
$paginationControl = $this->createPaginationControl($contacts);

library/Notifications/Common/Icons.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ private function __construct()
4141
public const RULE_MATCHED = 'filter';
4242

4343
public const UNDEFINED = 'notdef';
44+
45+
public const EMAIL = 'at';
46+
47+
public const WEBHOOK = 'link';
4448
}

library/Notifications/Model/Behavior/HasAddress.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function setQuery(Query $query)
3030
public function rewriteColumn($column, ?string $relation = null)
3131
{
3232
if ($this->isSelectableColumn($column)) {
33-
$type = 'email';
33+
$type = $column === 'has_email' ? 'email' : 'webhook';
3434

3535
$subQueryRelation = $relation !== null ? $relation . '.contact.contact_address' : 'contact.contact_address';
3636

@@ -53,15 +53,17 @@ public function rewriteColumn($column, ?string $relation = null)
5353

5454
public function isSelectableColumn(string $name): bool
5555
{
56-
return $name === 'has_email';
56+
return $name === 'has_email' || $name === 'has_webhook';
5757
}
5858

5959
public function rewriteColumnDefinition(ColumnDefinition $def, string $relation): void
6060
{
6161
$name = $def->getName();
6262

6363
if ($this->isSelectableColumn($name)) {
64-
$def->setLabel(t('Has Email Address'));
64+
$def->setLabel(
65+
$name === 'has_email' ? t('Has Email Address') : t('Has Webhook')
66+
);
6567
}
6668
}
6769

@@ -70,7 +72,7 @@ public function rewriteCondition(Filter\Condition $condition, $relation = null)
7072
$column = substr($condition->getColumn(), strlen($relation));
7173

7274
if ($this->isSelectableColumn($column)) {
73-
$type = 'email';
75+
$type = $column === 'has_email' ? 'email' : 'webhook';
7476

7577
$subQuery = $this->query->createSubQuery(new ContactAddress(), $relation)
7678
->limit(1)

library/Notifications/Widget/ItemList/ContactListItem.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Icons;
78
use Icinga\Module\Notifications\Model\Contact;
89
use ipl\Html\Attributes;
910
use ipl\Html\BaseHtmlElement;
@@ -45,7 +46,9 @@ protected function assembleFooter(BaseHtmlElement $footer): void
4546
$contactIcons = new HtmlElement('div', Attributes::create(['class' => 'contact-icons']));
4647

4748
if (isset($this->item->has_email) && $this->item->has_email) {
48-
$contactIcons->addHtml(new Icon('at'));
49+
$contactIcons->addHtml(new Icon(Icons::EMAIL));
50+
} elseif (isset($this->item->has_webhook) && $this->item->has_webhook) {
51+
$contactIcons->addHtml(new Icon(Icons::WEBHOOK));
4952
}
5053

5154
$footer->addHtml($contactIcons);

0 commit comments

Comments
 (0)