Skip to content

Commit

Permalink
fix(Dashboard): disabled unnecessary namespace listing
Browse files Browse the repository at this point in the history
- Disabled unnecessary namespace listing in the workflow details view

Related to #458

Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
  • Loading branch information
JBBianchi committed Jan 31, 2025
1 parent b451093 commit b3a8d3c
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 @@ -167,6 +167,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 b3a8d3c

Please sign in to comment.