Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled unnecessary namespace listing in the Dashboard #490

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading