Skip to content

Commit

Permalink
Rule: Remove column is_active and its usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jul 4, 2024
1 parent dfc17ee commit 195ca73
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 69 deletions.
3 changes: 1 addition & 2 deletions application/controllers/EventRuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function indexAction(): void
public function fromDb(int $ruleId): array
{
$query = Rule::on(Database::get())
->columns(['id', 'name', 'object_filter', 'is_active'])
->columns(['id', 'name', 'object_filter'])
->filter(Filter::all(
Filter::equal('id', $ruleId),
Filter::equal('deleted', 'n')
Expand Down Expand Up @@ -260,7 +260,6 @@ public function editAction(): void
->setAction(Url::fromRequest()->getAbsoluteUrl())
->on(Form::ON_SUCCESS, function ($form) use ($ruleId, $cache, $config) {
$config['name'] = $form->getValue('name');
$config['is_active'] = $form->getValue('is_active');

if ($cache || $ruleId === '-1') {
$this->sessionNamespace->set($ruleId, $config);
Expand Down
9 changes: 0 additions & 9 deletions application/forms/EventRuleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ protected function assemble()
]
);

$this->addElement(
'checkbox',
'is_active',
[
'label' => $this->translate('Event Rule is active'),
'value' => 'y'
]
);

$this->addElement('submit', 'btn_submit', [
'label' => $this->translate('Save')
]);
Expand Down
12 changes: 3 additions & 9 deletions application/forms/SaveEventRuleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ public function addRule(array $config): int
$db->insert('rule', [
'name' => $config['name'],
'timeperiod_id' => $config['timeperiod_id'] ?? null,
'object_filter' => $config['object_filter'] ?? null,
'is_active' => $config['is_active'] ?? 'n'
'object_filter' => $config['object_filter'] ?? null
]);
$ruleId = $db->lastInsertId();

Expand Down Expand Up @@ -411,8 +410,7 @@ public function editRule(int $id, array $config): void
$values = $this->getChanges($storedValues, $config);

$data = array_filter([
'name' => $values['name'] ?? null,
'is_active' => $values['is_active'] ?? null
'name' => $values['name'] ?? null
]);

if (array_key_exists('object_filter', $values)) {
Expand Down Expand Up @@ -537,7 +535,7 @@ protected function onError()
private function fetchDbValues(): array
{
$query = Rule::on(Database::get())
->columns(['id', 'name', 'object_filter', 'is_active'])
->columns(['id', 'name', 'object_filter'])
->filter(Filter::all(
Filter::equal('id', $this->ruleId),
Filter::equal('deleted', 'n')
Expand Down Expand Up @@ -595,10 +593,6 @@ public function getChanges(array $storedValues, array $formValues): array
unset($formValues['object_filter']);
}

if ($formValues['is_active'] === $dbValuesToCompare['is_active']) {
unset($formValues['is_active']);
}

return $formValues;
}

Expand Down
3 changes: 0 additions & 3 deletions library/Notifications/Model/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* @property string $name
* @property ?int $timeperiod_id
* @property ?string $object_filter
* @property string $is_active
* @property DateTime $changed_at
* @property bool $deleted
*
Expand All @@ -43,7 +42,6 @@ public function getColumns(): array
'name',
'timeperiod_id',
'object_filter',
'is_active',
'changed_at',
'deleted'
];
Expand All @@ -55,7 +53,6 @@ public function getColumnDefinitions(): array
'name' => t('Name'),
'timeperiod_id' => t('Timeperiod ID'),
'object_filter' => t('Object Filter'),
'is_active' => t('Is Active'),
'changed_at' => t('Changed At')
];
}
Expand Down
40 changes: 0 additions & 40 deletions library/Notifications/Widget/CheckboxIcon.php

This file was deleted.

6 changes: 0 additions & 6 deletions library/Notifications/Widget/ItemList/EventRuleListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Model\Rule;
use Icinga\Module\Notifications\Widget\CheckboxIcon;
use Icinga\Module\Notifications\Widget\RuleEscalationRecipientBadge;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
Expand All @@ -31,11 +30,6 @@ protected function init(): void
->set('data-action-item', true);
}

protected function assembleVisual(BaseHtmlElement $visual): void
{
$visual->add(new CheckboxIcon($this->item->is_active === 'y'));
}

protected function assembleFooter(BaseHtmlElement $footer): void
{
$meta = Html::tag('span', ['class' => 'meta']);
Expand Down

0 comments on commit 195ca73

Please sign in to comment.