Skip to content

Commit

Permalink
Merge pull request #490 from serverlessworkflow/fix-458-unnecessary-n…
Browse files Browse the repository at this point in the history
…amespace-listing

Disabled unnecessary namespace listing in the Dashboard
  • Loading branch information
cdavernas authored Jan 31, 2025
2 parents 19a61fa + b3a8d3c commit fa81628
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public record NamespacedResourceManagementComponentState<TResource>
where TResource : Resource, new()
{

/// <summary>
/// Gets/sets a boolean value that indicates whether to list <see cref="Neuroglia.Data.Infrastructure.ResourceOriented.Namespace"/>s
/// </summary>
public bool ListNamespaces { get; set; } = true;

/// <summary>
/// Gets a <see cref="EquatableList{T}"/> that contains all <see cref="Neuroglia.Data.Infrastructure.ResourceOriented.Namespace"/>s
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ public class NamespacedResourceManagementComponentStore<TState, TResource>(ILogg
{

/// <summary>
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="Namespace"/>s
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="NamespacedResourceManagementComponentState{T}.ListNamespaces"/>
/// </summary>
public IObservable<bool> ListNamespaces => this.Select(s => s.ListNamespaces).DistinctUntilChanged();

/// <summary>
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="NamespacedResourceManagementComponentState{T}.Namespace"/>s
/// </summary>
public IObservable<EquatableList<Namespace>?> Namespaces => this.Select(s => s.Namespaces).DistinctUntilChanged();

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

/// <summary>
/// Sets the <see cref="NamespacedResourceManagementComponentState{TResource}.ListNamespaces"/> to true
/// </summary>
public void EnableNamespaceListing()
{
this.Reduce(state => state with
{
ListNamespaces = true
});
}
/// <summary>
/// Sets the <see cref="NamespacedResourceManagementComponentState{TResource}.ListNamespaces"/> to false
/// </summary>
public void DisableNamespaceListing()
{
this.Reduce(state => state with
{
ListNamespaces = false
});
}

/// <summary>
/// Sets the <see cref="NamespacedResourceManagementComponentState{TResource}.Namespace"/>
/// </summary>
Expand Down Expand Up @@ -85,8 +111,8 @@ public override async Task DeleteResourceAsync(TResource resource)
/// <inheritdoc/>
public override async Task InitializeAsync()
{
await this.ListNamespacesAsync().ConfigureAwait(false);
await base.InitializeAsync();
if (this.Get(state => state.ListNamespaces)) await this.ListNamespacesAsync().ConfigureAwait(false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
/// <inheritdoc/>
protected override async Task OnInitializedAsync()
{
Store.DisableNamespaceListing();
UpdateBreadcrumb();
Store.WorkflowInstanceName.Subscribe(value => OnStateChanged(_ => instanceName = value), token: CancellationTokenSource.Token);
Store.WorkflowDefinition.Where(value => value != null).Subscribe(value => OnStateChanged(_ => workflowDefinition = value!), token: CancellationTokenSource.Token);
Expand Down

0 comments on commit fa81628

Please sign in to comment.