Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contactgroup configuration #188

Merged
merged 20 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b44c22b
feat: add contact group configuration links
ncosta-ic May 17, 2024
9cf0401
fix: controller links
ncosta-ic May 17, 2024
c0ad0c7
feat: add contact group permission
ncosta-ic May 17, 2024
466c92d
feat,fix: contact group configuration & references
ncosta-ic May 17, 2024
6fe792b
Fix code style
sukhwinder33445 May 22, 2024
c7704c1
ContactGroupsController: Add $filter property and getter
sukhwinder33445 May 22, 2024
fca5e6f
Simplify `ContactGroupFrom` and `MemberSuggestions`
sukhwinder33445 May 22, 2024
a7aa42c
Contactgroup: Add detail view and make contactgroup editable/removable
sukhwinder33445 May 22, 2024
286c8fc
Remove `cancel` button from model
sukhwinder33445 May 23, 2024
e051c5c
ContactGroupController: Use `Links` instaance when redirecting
sukhwinder33445 May 23, 2024
3f80a86
ContactGroupForm: Drop `termInput` property
sukhwinder33445 May 31, 2024
7682050
Use `Links` for form action with `showCompact` and `_disableLayout` p…
sukhwinder33445 May 31, 2024
c77bf5b
ContactGroupForm::addGroup: Fix return type and remove superfluous er…
sukhwinder33445 Jun 10, 2024
9713801
ContactGroupsController::getTabs: Remove superfluous condition
sukhwinder33445 Jun 10, 2024
548c2dc
ContactGroupForm::fetchDbValues: Add HttpNotFoundException
sukhwinder33445 Jun 10, 2024
7231ce2
Links: Remove modal specific params
sukhwinder33445 Jun 11, 2024
152f036
ContactGroupForm: Use given $db property for db connection
sukhwinder33445 Jun 11, 2024
4e59346
Fix form success and remove PhpDoc for void return type
sukhwinder33445 Jun 11, 2024
4c66253
`ContactForm::removeContact`: Remove reference from `contactgroup_mem…
sukhwinder33445 Jun 11, 2024
bdaf57f
ContactGroupForm: Make `members` field optional
sukhwinder33445 Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions application/controllers/ContactGroupController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php

/* Icinga Notifications Web | (c) 2024 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Notifications\Controllers;

use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Forms\ContactGroupForm;
use Icinga\Module\Notifications\Model\Contactgroup;
use Icinga\Module\Notifications\Widget\ItemList\ContactList;
use Icinga\Web\Notification;
use ipl\Html\Attributes;
use ipl\Html\Form;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\Stdlib\Filter;
use ipl\Web\Common\BaseItemList;
use ipl\Web\Compat\CompatController;
use ipl\Web\Widget\ButtonLink;

class ContactGroupController extends CompatController
{
public function init(): void
{
$this->assertPermission('notifications/config/contact-groups');
}

public function indexAction(): void
{
$groupId = $this->params->getRequired('id');

$query = Contactgroup::on(Database::get())
->columns(['id', 'name'])
->filter(Filter::equal('id', $groupId));

Check failure on line 36 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array|bool|float|int|string, mixed given.

Check failure on line 36 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array|bool|float|int|string, mixed given.

Check failure on line 36 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array|bool|float|int|string, mixed given.

Check failure on line 36 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array|bool|float|int|string, mixed given.

Check failure on line 36 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array|bool|float|int|string, mixed given.

Check failure on line 36 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array|bool|float|int|string, mixed given.

Check failure on line 36 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #2 $value of static method ipl\Stdlib\Filter::equal() expects array|bool|float|int|string, mixed given.

$group = $query->first();
if ($group === null) {
$this->httpNotFound(t('Contact group not found'));
}

$this->controls->addAttributes(['class' => 'contactgroup-detail']);

$this->addControl(new HtmlElement('div', new Attributes(['class' => 'header']), Text::create($group->name)));

Check failure on line 45 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $content of static method ipl\Html\Text::create() expects string, mixed given.

Check failure on line 45 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $content of static method ipl\Html\Text::create() expects string, mixed given.

Check failure on line 45 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $content of static method ipl\Html\Text::create() expects string, mixed given.

Check failure on line 45 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #1 $content of static method ipl\Html\Text::create() expects string, mixed given.

Check failure on line 45 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $content of static method ipl\Html\Text::create() expects string, mixed given.

Check failure on line 45 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #1 $content of static method ipl\Html\Text::create() expects string, mixed given.

Check failure on line 45 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #1 $content of static method ipl\Html\Text::create() expects string, mixed given.

$this->addControl($this->createPaginationControl($group->contact));

Check failure on line 47 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $paginatable of method ipl\Web\Compat\CompatController::createPaginationControl() expects ipl\Stdlib\Contract\Paginatable, mixed given.

Check failure on line 47 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $paginatable of method ipl\Web\Compat\CompatController::createPaginationControl() expects ipl\Stdlib\Contract\Paginatable, mixed given.

Check failure on line 47 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $paginatable of method ipl\Web\Compat\CompatController::createPaginationControl() expects ipl\Stdlib\Contract\Paginatable, mixed given.

Check failure on line 47 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #1 $paginatable of method ipl\Web\Compat\CompatController::createPaginationControl() expects ipl\Stdlib\Contract\Paginatable, mixed given.

Check failure on line 47 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $paginatable of method ipl\Web\Compat\CompatController::createPaginationControl() expects ipl\Stdlib\Contract\Paginatable, mixed given.

Check failure on line 47 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #1 $paginatable of method ipl\Web\Compat\CompatController::createPaginationControl() expects ipl\Stdlib\Contract\Paginatable, mixed given.

Check failure on line 47 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #1 $paginatable of method ipl\Web\Compat\CompatController::createPaginationControl() expects ipl\Stdlib\Contract\Paginatable, mixed given.
$this->addControl($this->createLimitControl());

$this->addContent(
(new ButtonLink(
Text::create(t('Edit Contact Group')),
Links::contactGroupEdit($groupId)->with(['showCompact' => true, '_disableLayout' => 1]),

Check failure on line 53 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $id of static method Icinga\Module\Notifications\Common\Links::contactGroupEdit() expects int, mixed given.

Check failure on line 53 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $id of static method Icinga\Module\Notifications\Common\Links::contactGroupEdit() expects int, mixed given.

Check failure on line 53 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $id of static method Icinga\Module\Notifications\Common\Links::contactGroupEdit() expects int, mixed given.

Check failure on line 53 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #1 $id of static method Icinga\Module\Notifications\Common\Links::contactGroupEdit() expects int, mixed given.

Check failure on line 53 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $id of static method Icinga\Module\Notifications\Common\Links::contactGroupEdit() expects int, mixed given.

Check failure on line 53 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #1 $id of static method Icinga\Module\Notifications\Common\Links::contactGroupEdit() expects int, mixed given.

Check failure on line 53 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #1 $id of static method Icinga\Module\Notifications\Common\Links::contactGroupEdit() expects int, mixed given.
'edit',
['class' => 'add-new-component']
))->openInModal()
);

$this->addContent(new ContactList($group->contact));

Check failure on line 59 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $data of class Icinga\Module\Notifications\Widget\ItemList\ContactList constructor expects ipl\Orm\ResultSet|iterable<object>, mixed given.

Check failure on line 59 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $data of class Icinga\Module\Notifications\Widget\ItemList\ContactList constructor expects ipl\Orm\ResultSet|iterable<object>, mixed given.

Check failure on line 59 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $data of class Icinga\Module\Notifications\Widget\ItemList\ContactList constructor expects ipl\Orm\ResultSet|iterable<object>, mixed given.

Check failure on line 59 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #1 $data of class Icinga\Module\Notifications\Widget\ItemList\ContactList constructor expects ipl\Orm\ResultSet|iterable<object>, mixed given.

Check failure on line 59 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $data of class Icinga\Module\Notifications\Widget\ItemList\ContactList constructor expects ipl\Orm\ResultSet|iterable<object>, mixed given.

Check failure on line 59 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #1 $data of class Icinga\Module\Notifications\Widget\ItemList\ContactList constructor expects ipl\Orm\ResultSet|iterable<object>, mixed given.

Check failure on line 59 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #1 $data of class Icinga\Module\Notifications\Widget\ItemList\ContactList constructor expects ipl\Orm\ResultSet|iterable<object>, mixed given.

$this->addTitleTab(t('Contact Group'));
$this->setTitle(sprintf(t('Contact Group: %s'), $group->name));

Check failure on line 62 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.

Check failure on line 62 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.

Check failure on line 62 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.

Check failure on line 62 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.

Check failure on line 62 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.

Check failure on line 62 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.

Check failure on line 62 in application/controllers/ContactGroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
}

public function editAction(): void
{
$groupId = $this->params->getRequired('id');

$form = (new ContactGroupForm(Database::get()))
->loadContactgroup($groupId)
->setAction(
(string) Links::contactGroupEdit($groupId)->with(['showCompact' => true, '_disableLayout' => 1])
)
->on(Form::ON_SENT, function (ContactGroupForm $form) {
if ($form->hasBeenRemoved()) {
$form->removeContactgroup();
Notification::success(sprintf(
t('Successfully removed contact group %s'),
$form->getValue('group_name')
));
$this->switchToSingleColumnLayout();
} elseif (! $form->hasBeenSubmitted()) {
foreach ($form->getPartUpdates() as $update) {
if (! is_array($update)) {
$update = [$update];
}

$this->addPart(...$update);
}
}
})
->on(Form::ON_SUCCESS, function (ContactGroupForm $form) use ($groupId) {
if ($form->editGroup()) {
Notification::success(sprintf(
t('Successfully updated contact group %s'),
$form->getValue('group_name')
));
}

$this->closeModalAndRefreshRemainingViews(Links::contactGroup($groupId));
})
->handleRequest($this->getServerRequest());

$this->addContent($form);
$this->setTitle(t('Edit Contact Group'));
}

protected function addContent(ValidHtml $content): self
{
if ($content instanceof BaseItemList) {
$this->content->getAttributes()->add('class', 'full-width');
}

return parent::addContent($content);
}
}
177 changes: 177 additions & 0 deletions application/controllers/ContactGroupsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?php

/* Icinga Notifications Web | (c) 2024 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Notifications\Controllers;

use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Forms\ContactGroupForm;
use Icinga\Module\Notifications\Model\Contactgroup;
use Icinga\Module\Notifications\Widget\ItemList\ContactGroupList;
use Icinga\Module\Notifications\Widget\MemberSuggestions;
use Icinga\Web\Notification;
use ipl\Html\Form;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\Stdlib\Filter;
use ipl\Web\Common\BaseItemList;
use ipl\Web\Compat\CompatController;
use ipl\Web\Compat\SearchControls;
use ipl\Web\Filter\QueryString;
use ipl\Web\Widget\ButtonLink;
use ipl\Web\Widget\Tabs;

class ContactGroupsController extends CompatController
{
use SearchControls;

/** @var Filter\Rule Filter from query string parameters */
private $filter;

public function init(): void
{
$this->assertPermission('notifications/config/contact-groups');
}

public function indexAction(): void
{
$groups = Contactgroup::on(Database::get());

$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($groups);
$sortControl = $this->createSortControl(
$groups,
[
'name' => t('Group Name'),
]
);

$searchBar = $this->createSearchBar(
$groups,
[
$limitControl->getLimitParam(),
$sortControl->getSortParam()
]
);

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
} else {
$this->addControl($searchBar);
$this->sendMultipartUpdate();

return;
}
} else {
$filter = $searchBar->getFilter();
}

$groups->filter($filter);

$this->addControl($paginationControl);
$this->addControl($sortControl);
$this->addControl($limitControl);
$this->addControl($searchBar);
$this->addContent(
(new ButtonLink(
Text::create(t('Add Contact Group')),
Links::contactGroupsAdd()->with(['showCompact' => true, '_disableLayout' => 1]),
'plus',
['class' => 'add-new-component']
))->openInModal()
);

$this->addContent(new ContactGroupList($groups));

if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) {
$this->sendMultipartUpdate();
}

$this->setTitle(t('Contact Groups'));
$this->getTabs()->activate('contact-groups');
}

public function addAction(): void
{
$form = (new ContactGroupForm(Database::get()))
->setAction((string) Links::contactGroupsAdd()->with(['showCompact' => true, '_disableLayout' => 1]))
->on(Form::ON_SENT, function (ContactGroupForm $form) {
if (! $form->hasBeenSubmitted()) {
foreach ($form->getPartUpdates() as $update) {
if (! is_array($update)) {
$update = [$update];
}

$this->addPart(...$update);
}
}
})
->on(Form::ON_SUCCESS, function (ContactGroupForm $form) {
$groupIdentifier = $form->addGroup();

Notification::success(t('New contact group has been successfully added'));
$this->sendExtraUpdates(['#col1']);
$this->getResponse()->setHeader('X-Icinga-Container', 'col2');
$this->redirectNow(Links::contactGroup($groupIdentifier));
})
->handleRequest($this->getServerRequest());

$this->addContent($form);
$this->setTitle(t('Add Contact Group'));
}

public function suggestMemberAction(): void
{
$members = new MemberSuggestions();
$members->forRequest($this->getServerRequest());

$this->getDocument()->addHtml($members);
}

public function getTabs(): Tabs
{
return parent::getTabs()
->add('schedules', [
'label' => t('Schedules'),
'url' => Links::schedules(),
'baseTarget' => '_main'
])->add('event-rules', [
'label' => t('Event Rules'),
'url' => Links::eventRules(),
'baseTarget' => '_main'
])->add('contacts', [
'label' => t('Contacts'),
'url' => Links::contacts(),
'baseTarget' => '_main'
])->add('contact-groups', [
'label' => t('Contact Groups'),
'url' => Links::contactGroups(),
'baseTarget' => '_main'
]);
}

protected function addContent(ValidHtml $content): self
{
if ($content instanceof BaseItemList) {
$this->content->getAttributes()->add('class', 'full-width');
}

return parent::addContent($content);
}

/**
* Get the filter created from query string parameters
*
* @return Filter\Rule
*/
private function getFilter(): Filter\Rule
{
if ($this->filter === null) {
$this->filter = QueryString::parse((string) $this->params);
}

return $this->filter;
}
}
16 changes: 10 additions & 6 deletions application/controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Notifications\Controllers;

use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Model\Contact;
Expand All @@ -21,7 +22,6 @@
use ipl\Web\Url;
use ipl\Web\Widget\ButtonLink;
use ipl\Html\ValidHtml;
use ipl\Web\Widget\Tabs;

class ContactsController extends CompatController
{
Expand Down Expand Up @@ -172,16 +172,20 @@ public function getTabs()
if ($this->getRequest()->getActionName() === 'index') {
return parent::getTabs()
->add('schedules', [
'label' => $this->translate('Schedules'),
'url' => Url::fromPath('notifications/schedules'),
'baseTarget' => '_main'
'label' => $this->translate('Schedules'),
'url' => Links::schedules(),
'baseTarget' => '_main'
])->add('event-rules', [
'label' => $this->translate('Event Rules'),
'url' => Url::fromPath('notifications/event-rules'),
'url' => Links::eventRules(),
'baseTarget' => '_main'
])->add('contacts', [
'label' => $this->translate('Contacts'),
'url' => Url::fromRequest(),
'url' => Links::contacts(),
'baseTarget' => '_main'
])->add('contact-groups', [
'label' => $this->translate('Contact Groups'),
'url' => Links::contactGroups(),
'baseTarget' => '_main'
]);
}
Expand Down
18 changes: 9 additions & 9 deletions application/controllers/EventRulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@

namespace Icinga\Module\Notifications\Controllers;

use Icinga\Exception\ProgrammingError;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Forms\EventRuleForm;
use Icinga\Module\Notifications\Forms\SaveEventRuleForm;
use Icinga\Module\Notifications\Model\ObjectExtraTag;
use Icinga\Module\Notifications\Model\Rule;
use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Notifications\Widget\EventRuleConfig;
use Icinga\Module\Notifications\Widget\ItemList\EventRuleList;
use Icinga\Web\Notification;
use Icinga\Web\Session;
use ipl\Html\Form;
use ipl\Html\Html;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;
Expand Down Expand Up @@ -241,16 +237,20 @@ public function getTabs()
if ($this->getRequest()->getActionName() === 'index') {
return parent::getTabs()
->add('schedules', [
'label' => $this->translate('Schedules'),
'url' => Url::fromPath('notifications/schedules'),
'baseTarget' => '_main'
'label' => $this->translate('Schedules'),
'url' => Links::schedules(),
'baseTarget' => '_main'
])->add('event-rules', [
'label' => $this->translate('Event Rules'),
'url' => Url::fromPath('notifications/event-rules'),
'url' => Links::eventRules(),
'baseTarget' => '_main'
])->add('contacts', [
'label' => $this->translate('Contacts'),
'url' => Url::fromPath('notifications/contacts'),
'url' => Links::contacts(),
'baseTarget' => '_main'
])->add('contact-groups', [
'label' => $this->translate('Contact Groups'),
'url' => Links::contactGroups(),
'baseTarget' => '_main'
]);
}
Expand Down
4 changes: 4 additions & 0 deletions application/controllers/SchedulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public function getTabs(): Tabs
])->add('contacts', [
'label' => $this->translate('Contacts'),
'url' => Links::contacts()
])->add('contact-groups', [
'label' => $this->translate('Contact Groups'),
'url' => Links::contactGroups(),
'baseTarget' => '_main'
]);
}

Expand Down
Loading
Loading