Skip to content

Commit fa81628

Browse files
authored
Merge pull request #490 from serverlessworkflow/fix-458-unnecessary-namespace-listing
Disabled unnecessary namespace listing in the Dashboard
2 parents 19a61fa + b3a8d3c commit fa81628

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/NamespacedResourceManagementComponentState.cs

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public record NamespacedResourceManagementComponentState<TResource>
2222
where TResource : Resource, new()
2323
{
2424

25+
/// <summary>
26+
/// Gets/sets a boolean value that indicates whether to list <see cref="Neuroglia.Data.Infrastructure.ResourceOriented.Namespace"/>s
27+
/// </summary>
28+
public bool ListNamespaces { get; set; } = true;
29+
2530
/// <summary>
2631
/// Gets a <see cref="EquatableList{T}"/> that contains all <see cref="Neuroglia.Data.Infrastructure.ResourceOriented.Namespace"/>s
2732
/// </summary>

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/NamespacedResourceManagementComponentStore.cs

+28-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ public class NamespacedResourceManagementComponentStore<TState, TResource>(ILogg
3030
{
3131

3232
/// <summary>
33-
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="Namespace"/>s
33+
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="NamespacedResourceManagementComponentState{T}.ListNamespaces"/>
34+
/// </summary>
35+
public IObservable<bool> ListNamespaces => this.Select(s => s.ListNamespaces).DistinctUntilChanged();
36+
37+
/// <summary>
38+
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="NamespacedResourceManagementComponentState{T}.Namespace"/>s
3439
/// </summary>
3540
public IObservable<EquatableList<Namespace>?> Namespaces => this.Select(s => s.Namespaces).DistinctUntilChanged();
3641

@@ -51,6 +56,27 @@ public class NamespacedResourceManagementComponentStore<TState, TResource>(ILogg
5156
)
5257
.DistinctUntilChanged();
5358

59+
/// <summary>
60+
/// Sets the <see cref="NamespacedResourceManagementComponentState{TResource}.ListNamespaces"/> to true
61+
/// </summary>
62+
public void EnableNamespaceListing()
63+
{
64+
this.Reduce(state => state with
65+
{
66+
ListNamespaces = true
67+
});
68+
}
69+
/// <summary>
70+
/// Sets the <see cref="NamespacedResourceManagementComponentState{TResource}.ListNamespaces"/> to false
71+
/// </summary>
72+
public void DisableNamespaceListing()
73+
{
74+
this.Reduce(state => state with
75+
{
76+
ListNamespaces = false
77+
});
78+
}
79+
5480
/// <summary>
5581
/// Sets the <see cref="NamespacedResourceManagementComponentState{TResource}.Namespace"/>
5682
/// </summary>
@@ -85,8 +111,8 @@ public override async Task DeleteResourceAsync(TResource resource)
85111
/// <inheritdoc/>
86112
public override async Task InitializeAsync()
87113
{
88-
await this.ListNamespacesAsync().ConfigureAwait(false);
89114
await base.InitializeAsync();
115+
if (this.Get(state => state.ListNamespaces)) await this.ListNamespacesAsync().ConfigureAwait(false);
90116
}
91117

92118
}

src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/View.razor

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
/// <inheritdoc/>
171171
protected override async Task OnInitializedAsync()
172172
{
173+
Store.DisableNamespaceListing();
173174
UpdateBreadcrumb();
174175
Store.WorkflowInstanceName.Subscribe(value => OnStateChanged(_ => instanceName = value), token: CancellationTokenSource.Token);
175176
Store.WorkflowDefinition.Where(value => value != null).Subscribe(value => OnStateChanged(_ => workflowDefinition = value!), token: CancellationTokenSource.Token);

0 commit comments

Comments
 (0)