6
6
7
7
use DateTime ;
8
8
use Icinga \Exception \Http \HttpNotFoundException ;
9
+ use Icinga \Module \Notifications \Common \Links ;
9
10
use Icinga \Module \Notifications \Model \AvailableChannelType ;
10
11
use Icinga \Module \Notifications \Model \Channel ;
11
12
use Icinga \Module \Notifications \Model \Contact ;
17
18
use ipl \Html \Contract \FormSubmitElement ;
18
19
use ipl \Html \FormElement \FieldsetElement ;
19
20
use ipl \Html \HtmlElement ;
21
+ use ipl \Html \TemplateString ;
20
22
use ipl \Html \Text ;
21
23
use ipl \Sql \Connection ;
22
24
use ipl \Stdlib \Filter ;
26
28
use ipl \Web \Common \CsrfCounterMeasure ;
27
29
use ipl \Web \Compat \CompatForm ;
28
30
use ipl \Web \Url ;
31
+ use ipl \Web \Widget \ActionLink ;
32
+ use ipl \Web \Widget \EmptyStateBar ;
29
33
30
34
class ContactForm extends CompatForm
31
35
{
@@ -170,6 +174,15 @@ protected function assemble()
170
174
->registerElement ($ defaultChannel )
171
175
->decorate ($ defaultChannel );
172
176
177
+ if (empty ($ channelNames )) {
178
+ $ this ->prependHtml (new EmptyStateBar (
179
+ TemplateString::create (
180
+ $ this ->translate ('No channels available. Please create a {{#link}}channel{{/link}} first ' ),
181
+ ['link ' => new ActionLink (null , Links::channels (), attributes: ['data-base-target ' => '_next ' ])]
182
+ )
183
+ ));
184
+ }
185
+
173
186
$ this ->addAddressElements ($ channelTypes [$ this ->getValue ('default_channel_id ' )] ?? null );
174
187
$ this ->addHtml ($ defaultChannel );
175
188
$ this ->addHtml (new HtmlElement (
@@ -190,6 +203,7 @@ protected function assemble()
190
203
$ this ->translate ('Save Changes ' )
191
204
]
192
205
);
206
+
193
207
if ($ this ->contactId !== null ) {
194
208
/** @var FormSubmitElement $deleteButton */
195
209
$ deleteButton = $ this ->createElement (
0 commit comments