66
77use DateTime ;
88use Icinga \Exception \Http \HttpNotFoundException ;
9+ use Icinga \Module \Notifications \Common \Links ;
910use Icinga \Module \Notifications \Model \AvailableChannelType ;
1011use Icinga \Module \Notifications \Model \Channel ;
1112use Icinga \Module \Notifications \Model \Contact ;
1718use ipl \Html \Contract \FormSubmitElement ;
1819use ipl \Html \FormElement \FieldsetElement ;
1920use ipl \Html \HtmlElement ;
21+ use ipl \Html \TemplateString ;
2022use ipl \Html \Text ;
2123use ipl \Sql \Connection ;
2224use ipl \Stdlib \Filter ;
2628use ipl \Web \Common \CsrfCounterMeasure ;
2729use ipl \Web \Compat \CompatForm ;
2830use ipl \Web \Url ;
31+ use ipl \Web \Widget \ActionLink ;
32+ use ipl \Web \Widget \EmptyStateBar ;
2933
3034class ContactForm extends CompatForm
3135{
@@ -170,6 +174,15 @@ protected function assemble()
170174 ->registerElement ($ defaultChannel )
171175 ->decorate ($ defaultChannel );
172176
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+
173186 $ this ->addAddressElements ($ channelTypes [$ this ->getValue ('default_channel_id ' )] ?? null );
174187 $ this ->addHtml ($ defaultChannel );
175188 $ this ->addHtml (new HtmlElement (
@@ -190,6 +203,7 @@ protected function assemble()
190203 $ this ->translate ('Save Changes ' )
191204 ]
192205 );
206+
193207 if ($ this ->contactId !== null ) {
194208 /** @var FormSubmitElement $deleteButton */
195209 $ deleteButton = $ this ->createElement (
0 commit comments