Skip to content

Commit 0f1d448

Browse files
committed
feat(action-builder): enhance agent selection logic with conditional rendering and improved exclusion handling
1 parent f8d76cd commit 0f1d448

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

frontend/src/app/incident-response/shared/component/action-builder/action-builder.component.html

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,39 @@ <h4 class="panel-title m-0">Flow Actions</h4>
5353
{{ group.get('agentType').value ? 'Default agent' : 'Exclude agents' }}
5454
</label>
5555

56+
<!-- Default agent select -->
5657
<ng-select
58+
*ngIf="group.get('agentType')?.value"
5759
[clearable]="false"
5860
[items]="agents$ | async"
59-
[placeholder]="group.get('agentType').value ? 'Select agent' : 'Select agents to exclude'"
61+
placeholder="Select agent"
6062
[loading]="loadingAgents"
6163
[virtualScroll]="true"
62-
[multiple]="!group.get('agentType').value"
64+
[multiple]="false"
6365
[loadingText]="'Loading agents...'"
64-
[formControlName]="group.get('agentType').value ? 'defaultAgent' : 'excludedAgents'"
66+
formControlName="defaultAgent"
6567
[bindValue]="'assetName'"
6668
[bindLabel]="'assetName'"
67-
[id]="group.get('agentType').value ? 'default' : 'exclude'"
68-
(change)="!group.get('agentType').value && onChangeExclude($event)">
69+
id="default">
6970
</ng-select>
71+
72+
<!-- Excluded agents select -->
73+
<ng-select
74+
*ngIf="!group.get('agentType')?.value"
75+
[clearable]="false"
76+
[items]="agents$ | async"
77+
placeholder="Select agents to exclude"
78+
[loading]="loadingAgents"
79+
[virtualScroll]="true"
80+
[multiple]="true"
81+
[loadingText]="'Loading agents...'"
82+
formControlName="excludedAgents"
83+
[bindValue]="'assetName'"
84+
[bindLabel]="'assetName'"
85+
id="exclude"
86+
(change)="onChangeExclude($event)">
87+
</ng-select>
88+
7089
</div>
7190
</div>
7291

frontend/src/app/incident-response/shared/component/action-builder/action-builder.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ export class ActionBuilderComponent implements OnInit, OnDestroy {
8787
}
8888

8989
onChangeExclude($event: any) {
90-
const hostnames = $event.map(value => value.assetName);
91-
this.group.get('excludedAgents').setValue(hostnames);
90+
const agentType = this.group.get('agentType').value;
91+
if (!agentType) {
92+
const hostnames = $event.map((value: { assetName: any; }) => value.assetName);
93+
this.group.get('excludedAgents').setValue(hostnames);
94+
}
9295
}
9396

9497
fetchAgents(platform: string) {

0 commit comments

Comments
 (0)