|
7 | 7 | use Icinga\Module\Notifications\Common\Database;
|
8 | 8 | use Icinga\Module\Notifications\Common\Links;
|
9 | 9 | use Icinga\Module\Notifications\Forms\ChannelForm;
|
| 10 | +use Icinga\Module\Notifications\Model\AvailableChannelType; |
10 | 11 | use Icinga\Module\Notifications\Model\Channel;
|
11 | 12 | use Icinga\Module\Notifications\View\ChannelRenderer;
|
12 | 13 | use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
|
|
15 | 16 | use Icinga\Web\Widget\Tab;
|
16 | 17 | use Icinga\Web\Widget\Tabs;
|
17 | 18 | use ipl\Sql\Connection;
|
| 19 | +use ipl\Sql\Expression; |
18 | 20 | use ipl\Stdlib\Filter;
|
19 | 21 | use ipl\Web\Compat\CompatController;
|
20 | 22 | use ipl\Web\Compat\SearchControls;
|
@@ -84,15 +86,25 @@ public function indexAction()
|
84 | 86 | $this->addControl($sortControl);
|
85 | 87 | $this->addControl($limitControl);
|
86 | 88 | $this->addControl($searchBar);
|
87 |
| - $this->addContent( |
88 |
| - (new ButtonLink(t('Add Channel'), Links::channelAdd(), 'plus')) |
89 |
| - ->setBaseTarget('_next') |
90 |
| - ->addAttributes(['class' => 'add-new-component']) |
91 |
| - ); |
92 | 89 |
|
| 90 | + $addButton = (new ButtonLink( |
| 91 | + t('Add Channel'), |
| 92 | + Links::channelAdd(), |
| 93 | + 'plus', |
| 94 | + ['class' => 'add-new-component'] |
| 95 | + ))->setBaseTarget('_next'); |
| 96 | + |
| 97 | + $emptyStateMessage = null; |
| 98 | + if (AvailableChannelType::on($this->db)->columns([new Expression('1')])->first() === null) { |
| 99 | + $emptyStateMessage = t('No channel types available. Make sure Icinga Notifications is running.'); |
| 100 | + $addButton->disable($emptyStateMessage); |
| 101 | + } |
| 102 | + |
| 103 | + $this->addContent($addButton); |
93 | 104 | $this->addContent(
|
94 | 105 | (new ObjectList($channels, new ChannelRenderer()))
|
95 | 106 | ->setItemLayoutClass(MinimalItemLayout::class)
|
| 107 | + ->setEmptyStateMessage($emptyStateMessage) |
96 | 108 | );
|
97 | 109 |
|
98 | 110 | if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) {
|
|
0 commit comments