|
7 | 7 | use Icinga\Module\Notifications\Common\Database; |
8 | 8 | use Icinga\Module\Notifications\Common\Links; |
9 | 9 | use Icinga\Module\Notifications\Forms\ContactGroupForm; |
| 10 | +use Icinga\Module\Notifications\Model\Channel; |
10 | 11 | use Icinga\Module\Notifications\Model\Contact; |
11 | 12 | use Icinga\Module\Notifications\Model\Contactgroup; |
12 | 13 | use Icinga\Module\Notifications\View\ContactgroupRenderer; |
|
15 | 16 | use Icinga\Module\Notifications\Widget\MemberSuggestions; |
16 | 17 | use Icinga\Web\Notification; |
17 | 18 | use ipl\Html\Form; |
| 19 | +use ipl\Html\HtmlString; |
18 | 20 | use ipl\Html\TemplateString; |
19 | 21 | use ipl\Stdlib\Filter; |
20 | 22 | use ipl\Web\Compat\CompatController; |
@@ -90,15 +92,27 @@ public function indexAction(): void |
90 | 92 |
|
91 | 93 | $emptyStateMessage = null; |
92 | 94 | if (Contact::on(Database::get())->columns('1')->limit(1)->first() === null) { |
93 | | - $addButton->disable($this->translate('A contact is required to add a contact group')); |
94 | | - |
95 | | - $emptyStateMessage = TemplateString::create( |
96 | | - $this->translate( |
97 | | - 'No contact groups found. To add a new contact group,' |
98 | | - . ' please {{#link}}add a contact{{/link}} first.' |
99 | | - ), |
100 | | - ['link' => (new ActionLink(null, Links::contactAdd()))->setBaseTarget('_next')] |
101 | | - ); |
| 95 | + if (Channel::on(Database::get())->columns('1')->limit(1)->first() === null) { |
| 96 | + $addButton->disable($this->translate('A channel is required to add a contact group')); |
| 97 | + |
| 98 | + $emptyStateMessage = TemplateString::create( |
| 99 | + // translators: %1$s will be replaced by a line break |
| 100 | + 'No contact groups found.%1$sTo add new contact group, please {{#link}}configure a Channel{{/link}}' |
| 101 | + . ' first.%1$sOnce done, you should proceed by creating your first contact.', |
| 102 | + ['link' => (new ActionLink(null, Links::channelAdd()))->setBaseTarget('_next')], |
| 103 | + [HtmlString::create('<br>')] |
| 104 | + ); |
| 105 | + } else { |
| 106 | + $emptyStateMessage = TemplateString::create( |
| 107 | + $this->translate( |
| 108 | + 'No contact groups found. Do not forget to also' |
| 109 | + . ' {{#link}}create your first contact!{{/link}}' |
| 110 | + ), |
| 111 | + ['link' => (new ActionLink(null, Links::contactAdd()))->setBaseTarget('_next')] |
| 112 | + ); |
| 113 | + |
| 114 | + $addButton->openInModal(); |
| 115 | + } |
102 | 116 | } else { |
103 | 117 | $addButton->openInModal(); |
104 | 118 | } |
|
0 commit comments