File tree 2 files changed +11
-10
lines changed
2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -134,11 +134,12 @@ public function indexAction(): void
134
134
$ buttonsWrapper ->add ([$ eventRuleConfigSubmitButton , $ discardChangesButton , $ deleteButton ]);
135
135
136
136
if ($ ruleId > 0 ) {
137
- $ incidents = Incident::on (Database::get ())
137
+ $ incidentCount = Incident::on (Database::get ())
138
138
->with ('rule ' )
139
- ->filter (Filter::equal ('rule.id ' , $ ruleId ));
139
+ ->filter (Filter::equal ('rule.id ' , $ ruleId ))
140
+ ->count ();
140
141
141
- if ($ incidents -> count () > 0 ) {
142
+ if ($ incidentCount ) {
142
143
$ deleteButton ->addAttributes ([
143
144
'disabled ' => true ,
144
145
'title ' => t ('There exist active incidents for this escalation and hence cannot be removed ' )
Original file line number Diff line number Diff line change @@ -270,8 +270,7 @@ public function populate($values): self
270
270
foreach ($ values ['rule_escalation ' ] as $ position => $ escalation ) {
271
271
$ conditions = explode ('| ' , $ escalation ['condition ' ] ?? '' );
272
272
$ conditionFormValues = [];
273
- $ conditionCount = count ($ conditions );
274
- $ conditionFormValues ['condition-count ' ] = $ conditionCount ;
273
+ $ conditionFormValues ['condition-count ' ] = count ($ conditions );
275
274
$ conditionFormValues ['id ' ] = $ escalation ['id ' ] ?? bin2hex (random_bytes (4 ));
276
275
277
276
foreach ($ conditions as $ key => $ condition ) {
@@ -381,11 +380,12 @@ protected function createRemoveButton(string $prefix): SubmitButtonElement
381
380
$ escalationId = $ escalations [$ pos ]['id ' ] ?? null ;
382
381
383
382
if ($ escalationId && ctype_digit ($ escalationId )) {
384
- $ incident = Incident::on (Database::get ())->with ('rule_escalation ' );
385
- $ incident ->filter (Filter::equal ('rule_escalation.id ' , $ escalationId ));
386
- if ($ incident ->count () > 0 ) {
387
- $ disableRemoveButton = true ;
388
- }
383
+ $ incidentCount = Incident::on (Database::get ())
384
+ ->with ('rule_escalation ' )
385
+ ->filter (Filter::equal ('rule_escalation.id ' , $ escalationId ))
386
+ ->count ();
387
+
388
+ $ disableRemoveButton = $ incidentCount > 0 ;
389
389
}
390
390
391
391
$ button = new SubmitButtonElement (
You can’t perform that action at this time.
0 commit comments