Skip to content

Commit 4b1380c

Browse files
committed
WIP: Recheck implementation
1 parent 163112c commit 4b1380c

File tree

8 files changed

+132
-146
lines changed

8 files changed

+132
-146
lines changed

application/controllers/EventRuleController.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ public function indexAction(): void
8383
})
8484
->on(EventRuleConfigForm::ON_DISCARD, function () use ($ruleId, $configValues) {
8585
$this->sessionNamespace->delete($ruleId);
86-
Notification::success(sprintf(
87-
t('Successfully discarded changes to event rule %s'),
88-
$configValues['name']
89-
));
86+
Notification::success(
87+
sprintf(
88+
t('Successfully discarded changes to event rule %s'),
89+
$configValues['name']
90+
)
91+
);
9092
$this->redirectNow(Links::eventRule((int) $ruleId));
9193
})
9294
->on(EventRuleConfigForm::ON_CHANGE, function (EventRuleConfigForm $form) use ($ruleId, $configValues) {
@@ -195,7 +197,7 @@ public function fromDb(int $ruleId): array
195197
$requiredValues = [];
196198

197199
foreach ($recipient as $k => $v) {
198-
if (in_array($k, ['contact_id', 'contactgroup_id', 'schedule_id']) && $v !== null) {
200+
if (in_array($k, ['contact_id', 'contactgroup_id', 'schedule_id']) && $v !== null) {
199201
$requiredValues[$k] = (string) $v;
200202
} elseif (in_array($k, ['id', 'channel_id'])) {
201203
$requiredValues[$k] = $v ? (string) $v : null;
@@ -247,10 +249,12 @@ public function searchEditorAction(): void
247249
$objectFilter = $eventRule['object_filter'] ?? '';
248250
$editor->setQueryString($objectFilter);
249251
$editor->setAction(Url::fromRequest()->getAbsoluteUrl());
250-
$editor->setSuggestionUrl(Url::fromPath(
251-
"notifications/event-rule/complete",
252-
['_disableLayout' => true, 'showCompact' => true, 'id' => Url::fromRequest()->getParams()->get('id')]
253-
));
252+
$editor->setSuggestionUrl(
253+
Url::fromPath(
254+
"notifications/event-rule/complete",
255+
['_disableLayout' => true, 'showCompact' => true, 'id' => Url::fromRequest()->getParams()->get('id')]
256+
)
257+
);
254258

255259
$editor->on(SearchEditor::ON_SUCCESS, function (SearchEditor $form) use ($ruleId, $eventRule) {
256260
$filter = self::createFilterString($form->getFilter());

application/controllers/EventRulesController.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Icinga\Module\Notifications\Forms\EventRuleConfigForm;
99
use Icinga\Module\Notifications\Model\Rule;
1010
use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
11-
use Icinga\Module\Notifications\Widget\EventRuleConfig;
1211
use Icinga\Module\Notifications\Widget\ItemList\EventRuleList;
1312
use Icinga\Web\Notification;
1413
use Icinga\Web\Session;
@@ -122,8 +121,8 @@ public function addAction(): void
122121
$eventRuleConfigSubmitButton = (new SubmitButtonElement(
123122
'save',
124123
[
125-
'label' => t('Add Event Rule'),
126-
'form' => 'event-rule-config-form',
124+
'label' => t('Add Event Rule'),
125+
'form' => 'event-rule-config-form',
127126
'formnovalidate' => true
128127
]
129128
))->setWrapper(new HtmlElement('div', Attributes::create(['class' => ['icinga-controls', 'save-config']])));
@@ -197,10 +196,12 @@ public function searchEditorAction(): void
197196
$objectFilter = $eventRule['object_filter'] ?? '';
198197
$editor->setQueryString($objectFilter);
199198
$editor->setAction(Url::fromRequest()->getAbsoluteUrl());
200-
$editor->setSuggestionUrl(Url::fromPath(
201-
"notifications/event-rule/complete",
202-
['_disableLayout' => true, 'showCompact' => true, 'id' => Url::fromRequest()->getParams()->get('id')]
203-
));
199+
$editor->setSuggestionUrl(
200+
Url::fromPath(
201+
"notifications/event-rule/complete",
202+
['_disableLayout' => true, 'showCompact' => true, 'id' => Url::fromRequest()->getParams()->get('id')]
203+
)
204+
);
204205

205206
$editor->on(SearchEditor::ON_SUCCESS, function (SearchEditor $form) use ($ruleId, $eventRule) {
206207
$filter = self::createFilterString($form->getFilter());

application/forms/EventRuleConfigElements/EscalationCondition.php

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,25 @@ protected function assemble(): void
6060
'submitButton',
6161
'add-condition',
6262
[
63-
'class' => ['add-button', 'control-button', 'spinner'],
64-
'label' => new Icon('plus'),
65-
'title' => $this->translate('Add Condition'),
66-
'formnovalidate' => true
63+
'class' => ['add-button', 'control-button', 'spinner'],
64+
'label' => new Icon('plus'),
65+
'title' => $this->translate('Add Condition'),
66+
'formnovalidate' => true
6767
]
6868
);
6969

7070
$this->registerElement($addCondition);
7171

7272
/** @var string|int $conditionCount */
7373
$conditionCount = $this->getValue('condition-count');
74+
$conditionCount = (int) $conditionCount;
7475
$this->addElement(
7576
'hidden',
7677
'id'
7778
);
7879

7980
if ($addCondition->hasBeenPressed()) {
80-
$conditionCount += 1;
81+
$conditionCount = $conditionCount + 1;
8182
$this->getElement('condition-count')->setValue($conditionCount);
8283
}
8384

@@ -92,14 +93,14 @@ protected function assemble(): void
9293
'select',
9394
$colName,
9495
[
95-
'class' => ['autosubmit', 'left-operand'],
96-
'options' => [
97-
'' => sprintf(' - %s - ', $this->translate('Please choose')),
96+
'class' => ['autosubmit', 'left-operand'],
97+
'options' => [
98+
'' => sprintf(' - %s - ', $this->translate('Please choose')),
9899
'incident_severity' => $this->translate('Incident Severity'),
99-
'incident_age' => $this->translate('Incident Age')
100+
'incident_age' => $this->translate('Incident Age')
100101
],
101-
'disabledOptions' => [''],
102-
'required' => true
102+
'disabledOptions' => [''],
103+
'required' => true
103104
]
104105
);
105106

@@ -109,8 +110,8 @@ protected function assemble(): void
109110
'select',
110111
$opName,
111112
[
112-
'class' => ['class' => 'operator-input', 'autosubmit'],
113-
'options' => array_combine($operators, $operators),
113+
'class' => ['class' => 'operator-input', 'autosubmit'],
114+
'options' => array_combine($operators, $operators),
114115
'required' => true
115116
]
116117
);
@@ -146,7 +147,7 @@ protected function assemble(): void
146147
}
147148

148149
$this->addElement('hidden', $typeName, [
149-
'value' => 'incident_severity'
150+
'value' => 'incident_severity'
150151
]);
151152

152153
break;
@@ -156,15 +157,17 @@ protected function assemble(): void
156157
'text',
157158
$valName,
158159
[
159-
'required' => true,
160-
'class' => ['autosubmit', 'right-operand'],
160+
'required' => true,
161+
'class' => ['autosubmit', 'right-operand'],
161162
'validators' => [
162163
new CallbackValidator(function ($value, $validator) {
163164
if (! preg_match('~^\d+(?:\.?\d*)?[hms]{1}$~', $value)) {
164-
$validator->addMessage($this->translate(
165-
'Only numbers with optional fractions (separated by a dot)'
166-
. ' and one of these suffixes are allowed: h, m, s'
167-
));
165+
$validator->addMessage(
166+
$this->translate(
167+
'Only numbers with optional fractions (separated by a dot)'
168+
. ' and one of these suffixes are allowed: h, m, s'
169+
)
170+
);
168171

169172
return false;
170173
}
@@ -194,7 +197,7 @@ protected function assemble(): void
194197
$val = $this->createElement('text', $valName, [
195198
'class' => 'right-operand',
196199
'placeholder' => $this->translate('Please make a decision'),
197-
'disabled' => true
200+
'disabled' => true
198201
]);
199202
}
200203

@@ -269,11 +272,11 @@ protected function createRemoveButton(int $count): ?SubmitButtonElement
269272
'submitButton',
270273
'remove',
271274
[
272-
'class' => ['remove-button', 'control-button', 'spinner'],
273-
'label' => new Icon('minus'),
274-
'title' => $this->translate('Remove'),
275-
'formnovalidate' => true,
276-
'value' => (string) $count
275+
'class' => ['remove-button', 'control-button', 'spinner'],
276+
'label' => new Icon('minus'),
277+
'title' => $this->translate('Remove'),
278+
'formnovalidate' => true,
279+
'value' => (string) $count
277280
]
278281
);
279282

application/forms/EventRuleConfigElements/EscalationRecipient.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EscalationRecipient extends FieldsetElement
2020
{
2121
protected $defaultAttributes = ['class' => 'escalation-recipient'];
2222

23-
/** @var EscalationRecipientListItem[] */
23+
/** @var EscalationRecipientListItem[] */
2424
protected $recipients = [];
2525

2626
protected function assemble(): void
@@ -36,9 +36,9 @@ protected function assemble(): void
3636
'submitButton',
3737
'add-recipient',
3838
[
39-
'class' => ['add-button', 'control-button', 'spinner'],
40-
'label' => new Icon('plus'),
41-
'title' => $this->translate('Add Recipient'),
39+
'class' => ['add-button', 'control-button', 'spinner'],
40+
'label' => new Icon('plus'),
41+
'title' => $this->translate('Add Recipient'),
4242
'formnovalidate' => true
4343
]
4444
);
@@ -63,13 +63,13 @@ protected function assemble(): void
6363
'select',
6464
'column_' . $i,
6565
[
66-
'class' => ['autosubmit', 'left-operand'],
67-
'options' => [
66+
'class' => ['autosubmit', 'left-operand'],
67+
'options' => [
6868
'' => sprintf(' - %s - ', $this->translate('Please choose'))
6969
] + $this->fetchOptions(),
70-
'disabledOptions' => [''],
71-
'required' => true,
72-
'value' => $this->getPopulatedValue('column_' . $i)
70+
'disabledOptions' => [''],
71+
'required' => true,
72+
'value' => $this->getPopulatedValue('column_' . $i)
7373
]
7474
);
7575

@@ -83,10 +83,10 @@ protected function assemble(): void
8383
'select',
8484
'val_' . $i,
8585
[
86-
'class' => ['autosubmit', 'right-operand'],
87-
'options' => $options,
88-
'disabledOptions' => [''],
89-
'value' => $this->getPopulatedValue('val_' . $i)
86+
'class' => ['autosubmit', 'right-operand'],
87+
'options' => $options,
88+
'disabledOptions' => [''],
89+
'value' => $this->getPopulatedValue('val_' . $i)
9090
]
9191
);
9292

@@ -200,11 +200,11 @@ protected function createRemoveButton(int $pos): ?FormElement
200200
'submitButton',
201201
'remove',
202202
[
203-
'class' => ['remove-button', 'control-button', 'spinner'],
204-
'label' => new Icon('minus'),
205-
'title' => $this->translate('Remove'),
206-
'formnovalidate' => true,
207-
'value' => (string) $pos
203+
'class' => ['remove-button', 'control-button', 'spinner'],
204+
'label' => new Icon('minus'),
205+
'title' => $this->translate('Remove'),
206+
'formnovalidate' => true,
207+
'value' => (string) $pos
208208
]
209209
);
210210

application/forms/EventRuleConfigElements/EventRuleConfigFilter.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class EventRuleConfigFilter extends FieldsetElement
1616
/** @var Url Url of the search editor */
1717
protected $searchEditorUrl;
1818

19-
/** @var ?string Event rule's object filter*/
19+
/** @var ?string Event rule's object filter */
2020
protected $objectFilter;
2121

2222
protected $defaultAttributes = ['class' => 'config-filter'];
@@ -34,10 +34,10 @@ protected function assemble(): void
3434
'submitButton',
3535
'add-filter',
3636
[
37-
'class' => ['add-button', 'control-button', 'spinner'],
38-
'label' => new Icon('plus'),
37+
'class' => ['add-button', 'control-button', 'spinner'],
38+
'label' => new Icon('plus'),
3939
'formnovalidate' => true,
40-
'title' => $this->translate('Add filter')
40+
'title' => $this->translate('Add filter')
4141
]
4242
);
4343

@@ -57,19 +57,19 @@ protected function assemble(): void
5757
new Icon('cog'),
5858
$this->getSearchEditorUrl(),
5959
Attributes::create([
60-
'class' => 'search-editor-opener control-button',
61-
'title' => t('Adjust Filter'),
62-
'data-icinga-modal' => true,
63-
'data-no-icinga-ajax' => true,
60+
'class' => 'search-editor-opener control-button',
61+
'title' => t('Adjust Filter'),
62+
'data-icinga-modal' => true,
63+
'data-no-icinga-ajax' => true,
6464
])
6565
);
6666

6767
$searchBar = new TextElement(
6868
'searchbar',
6969
[
70-
'class' => 'filter-input control-button',
71-
'readonly' => true,
72-
'value' => $this->objectFilter
70+
'class' => 'filter-input control-button',
71+
'readonly' => true,
72+
'value' => $this->objectFilter
7373
]
7474
);
7575

0 commit comments

Comments
 (0)