|
6 | 6 |
|
7 | 7 | use Icinga\Module\Notifications\Common\Database;
|
8 | 8 | use Icinga\Module\Notifications\Forms\ChannelForm;
|
| 9 | +use Icinga\Module\Notifications\Model\AvailableChannelType; |
9 | 10 | use Icinga\Module\Notifications\Model\Channel;
|
10 | 11 | use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
|
11 | 12 | use Icinga\Module\Notifications\Widget\ItemList\ChannelList;
|
|
14 | 15 | use Icinga\Web\Widget\Tabs;
|
15 | 16 | use ipl\Html\ValidHtml;
|
16 | 17 | use ipl\Sql\Connection;
|
| 18 | +use ipl\Sql\Expression; |
17 | 19 | use ipl\Stdlib\Filter;
|
18 | 20 | use ipl\Web\Common\BaseItemList;
|
19 | 21 | use ipl\Web\Compat\CompatController;
|
|
23 | 25 | use ipl\Web\Filter\QueryString;
|
24 | 26 | use ipl\Web\Url;
|
25 | 27 | use ipl\Web\Widget\ButtonLink;
|
| 28 | +use ipl\Web\Widget\EmptyStateBar; |
26 | 29 |
|
27 | 30 | class ChannelsController extends CompatController
|
28 | 31 | {
|
@@ -84,16 +87,27 @@ public function indexAction()
|
84 | 87 | $this->addControl($sortControl);
|
85 | 88 | $this->addControl($limitControl);
|
86 | 89 | $this->addControl($searchBar);
|
87 |
| - $this->addContent( |
88 |
| - (new ButtonLink( |
89 |
| - t('Add Channel'), |
90 |
| - Url::fromPath('notifications/channels/add'), |
91 |
| - 'plus' |
92 |
| - ))->setBaseTarget('_next') |
93 |
| - ->addAttributes(['class' => 'add-new-component']) |
94 |
| - ); |
95 | 90 |
|
96 |
| - $this->addContent(new ChannelList($channels)); |
| 91 | + $typesExists = AvailableChannelType::on($this->db) |
| 92 | + ->columns([new Expression('1')]) |
| 93 | + ->first() !== null; |
| 94 | + |
| 95 | + if ($typesExists) { |
| 96 | + $this->addContent( |
| 97 | + (new ButtonLink( |
| 98 | + t('Add Channel'), |
| 99 | + Url::fromPath('notifications/channels/add'), |
| 100 | + 'plus' |
| 101 | + ))->setBaseTarget('_next') |
| 102 | + ->addAttributes(['class' => 'add-new-component']) |
| 103 | + ); |
| 104 | + |
| 105 | + $this->addContent(new ChannelList($channels)); |
| 106 | + } else { |
| 107 | + $this->addContent(new EmptyStateBar( |
| 108 | + t('No channel types available. Make sure Icinga Notifications is running.') |
| 109 | + )); |
| 110 | + } |
97 | 111 |
|
98 | 112 | if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) {
|
99 | 113 | $this->sendMultipartUpdate();
|
|
0 commit comments