Skip to content

Commit dcecd16

Browse files
Merge branch 'develop' of https://github.com/CactuseSecurity/firewall-orchestrator into develop
2 parents ea242d4 + 26781d0 commit dcecd16

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditAppRole.razor

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
ondragover="event.preventDefault();"
9797
ondragstart="event.dataTransfer.setData('', event.target.id);"
9898
@ondrop="HandleServerDrop">
99-
<EditList ElementType="ModellingAppServer" Elements="ModellingAppServerWrapper.Resolve(AppRoleHandler.ActAppRole.AppServers)" ElementsToAdd="AppRoleHandler.AppServerToAdd" ElementsToDelete="AppRoleHandler.AppServerToDelete" StdLayout="false">
99+
<EditList ElementType="ModellingAppServer" Elements="ModellingAppServerWrapper.Resolve(AppRoleHandler.ActAppRole.AppServers)" ElementsToAdd="AppRoleHandler.AppServerToAdd" ElementsToDelete="AppRoleHandler.AppServerToDelete" StdLayout="false" ElementsRemoved="OnAppServerRemovedFromEditList">
100100
<Display>
101101
<div class="row">
102102
<div class="col-sm-12 ms-2 bg-transparent">@((MarkupString)context.DisplayWithIcon())</div>
@@ -296,4 +296,12 @@
296296
{
297297
areas.Sort((ModellingNetworkArea a, ModellingNetworkArea b) => a?.CompareTo(b) ?? -1);
298298
}
299+
300+
/// <summary>
301+
/// Updates the view after removing an app server from the list of app role's app servers.
302+
/// </summary>
303+
private void OnAppServerRemovedFromEditList()
304+
{
305+
InvokeAsync(StateHasChanged);
306+
}
299307
}

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditAppRoleLeftSide.razor

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{
1515
<div class="form-group row">
1616
<div class="col-sm-10">
17-
<DraggableList AllElements="AppRoleHandler.AppServersInArea" @bind-SelectedElements="selectedAppServers"
17+
<DraggableList AllElements="selectableAppServers" @bind-SelectedElements="selectedAppServers"
1818
HandleDragStart="HandleDragStart" Display="@(x => x.DisplayWithIcon())" MaxHeight="50"/>
1919
</div>
2020
@if(selectedAppServers.Count > 0)
@@ -56,6 +56,11 @@
5656
private List<ModellingAppServer> selectedAppServers = [];
5757
private int sidebarLeftWidth { get { return Width; } set { Width = value; WidthChanged.InvokeAsync(Width);}}
5858

59+
/// <summary>
60+
/// The app servers which are available for adding (i.e. which are not already in the AppServerToAdd collection).
61+
/// </summary>
62+
private List<ModellingAppServer> selectableAppServers => AppRoleHandler.AppServersInArea.Except(AppRoleHandler.AppServerToAdd).ToList();
63+
5964

6065
private bool HandleDragStart(DragEventArgs e, ModellingAppServer appServer)
6166
{

roles/ui/files/FWO.UI/Shared/EditList.razor

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
int j = i;
1111
<li class="@(StdLayout ? StdClass : AltClass) d-flex justify-content-between">
1212
<div class="@(StdLayout ? "" : AltElemClass)">@(Display(ElementsToAdd[i]))</div>
13-
<span @onclick="() => {ElementsToAdd.Remove(ElementsToAdd[j]);AfterRemoveAction();}" class="@(StdLayout ? "" : AltButtonClass) badge bg-danger">
13+
<span @onclick="() => OnRemoveElementButtonClick(j)" class="@(StdLayout ? "" : AltButtonClass) badge bg-danger">
1414
<i class="@(Icons.Close) text-light"></i>
1515
</span>
1616
</li>
@@ -53,6 +53,12 @@
5353
[Parameter]
5454
public Func<bool> AfterRemoveAction { get; set; } = DefaultInit.DoNothingSync;
5555

56+
/// <summary>
57+
/// Gets invoked after user removes element from the ElementsToAdd collection via button.
58+
/// </summary>
59+
[Parameter]
60+
public EventCallback ElementsRemoved { get; set; }
61+
5662
private string StdClass = "bg-success-subtle list-group-item pb-2 pt-2";
5763
private string AltClass = "draggable-selected pb-0 pt-0";
5864
private string AltElemClass = "col-sm-11";
@@ -69,4 +75,14 @@
6975
ElementsToDelete.Add(Elements[index]);
7076
}
7177
}
72-
}
78+
79+
/// <summary>
80+
/// Handles the click on an 'x' button of a server that is in the list of configured servers.
81+
/// </summary>
82+
private void OnRemoveElementButtonClick(int index)
83+
{
84+
ElementsToAdd.Remove(ElementsToAdd[index]);
85+
AfterRemoveAction();
86+
ElementsRemoved.InvokeAsync();
87+
}
88+
}

0 commit comments

Comments
 (0)