221 references to ResourceCommandState
Aspire.Hosting (30)
ApplicationModel\CommandOptions.cs (1)
95public Func<UpdateCommandStateContext, ResourceCommandState>? UpdateState { get; set; }
ApplicationModel\CommandsConfigurationExtensions.cs (10)
40return ResourceCommandState.Disabled; 44return ResourceCommandState.Enabled; 48return ResourceCommandState.Hidden; 73return ResourceCommandState.Disabled; 77return ResourceCommandState.Enabled; 81return ResourceCommandState.Hidden; 113return ResourceCommandState.Disabled; 117return ResourceCommandState.Enabled; 176? ResourceCommandState.Enabled 177: ResourceCommandState.Disabled;
ApplicationModel\CustomResourceSnapshot.cs (1)
466public sealed record ResourceCommandSnapshot(string Name, ResourceCommandState State, string DisplayName, string? DisplayDescription, [property: Obsolete("Use Arguments to describe invocation arguments.")] object? Parameter, string? ConfirmationMessage, string? IconName, IconVariant? IconVariant, bool IsHighlighted)
ApplicationModel\ResourceCommandAnnotation.cs (4)
22Func<UpdateCommandStateContext, ResourceCommandState> updateState, 40Func<UpdateCommandStateContext, ResourceCommandState> updateState, 57Func<UpdateCommandStateContext, ResourceCommandState> updateState, 107public Func<UpdateCommandStateContext, ResourceCommandState> UpdateState { get; }
ApplicationModel\ResourceNotificationService.cs (2)
1112var newState = annotation.UpdateState(new UpdateCommandStateContext { ResourceSnapshot = previousState, Services = _serviceProvider }); 1155var state = annotation.UpdateState(new UpdateCommandStateContext { ResourceSnapshot = previousState, Services = serviceProvider });
Dashboard\proto\Partials.cs (4)
170private static ResourceCommandState MapCommandState(Hosting.ApplicationModel.ResourceCommandState state) 174Hosting.ApplicationModel.ResourceCommandState.Enabled => ResourceCommandState.Enabled, 175Hosting.ApplicationModel.ResourceCommandState.Disabled => ResourceCommandState.Disabled, 176Hosting.ApplicationModel.ResourceCommandState.Hidden => ResourceCommandState.Hidden,
Orchestrator\ParameterProcessor.cs (3)
268updateState: _ => ResourceCommandState.Enabled, 304updateState: _ => HasParameterValue(parameterResource) ? ResourceCommandState.Enabled : ResourceCommandState.Hidden,
ResourceBuilderExtensions.cs (5)
2935return builder.WithAnnotation(new ResourceCommandAnnotation(name, displayName, commandOptions.UpdateState ?? (c => ResourceCommandState.Enabled), executeCommand, commandOptions.Description, commandOptions.Parameter, commandOptions.Arguments, commandOptions.ConfirmationMessage, commandOptions.IconName, commandOptions.IconVariant, commandOptions.IsHighlighted, commandOptions.Visibility, commandOptions.ValidateArguments, commandOptions.Progress)); 2981Func<UpdateCommandStateContext, ResourceCommandState>? updateState = null, 3001return builder.WithAnnotation(new ResourceCommandAnnotation(name, displayName, updateState ?? (c => ResourceCommandState.Enabled), executeCommand, displayDescription, parameter, confirmationMessage, iconName, iconVariant, isHighlighted)); 3704return targetRunning ? ResourceCommandState.Enabled : ResourceCommandState.Disabled;
Aspire.Hosting.Azure (15)
AzureProvisioningController.cs (14)
921internal ResourceCommandState GetEnvironmentCommandState() 928return _state.Status.CurrentIntent is null ? ResourceCommandState.Enabled : ResourceCommandState.Disabled; 932internal ResourceCommandState GetResourceCommandState(string resourceName, AzureResourceCommand command, UpdateCommandStateContext context) 940return ResourceCommandState.Hidden; 953return ResourceCommandState.Enabled; 964return ResourceCommandState.Hidden; 969return ResourceCommandState.Hidden; 972return activeOperation!.CancellationRequested ? ResourceCommandState.Disabled : ResourceCommandState.Enabled; 976? ResourceCommandState.Disabled 977: ResourceCommandState.Enabled; 983AzureResourceCommand.Cancel when !IsCancelableDeploymentState(context.ResourceSnapshot) => ResourceCommandState.Hidden, 984_ => ResourceCommandState.Enabled
AzureResourcePreparer.cs (1)
116commandOptions.UpdateState ?? (_ => ResourceCommandState.Enabled),
Aspire.Hosting.Azure.Kusto (8)
AzureKustoBuilderExtensions.cs (8)
357static ResourceCommandState UpdateStateDesktop(UpdateCommandStateContext context) 362return ResourceCommandState.Hidden; 365return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ? ResourceCommandState.Enabled : ResourceCommandState.Disabled; 368static ResourceCommandState UpdateStateWeb(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, UpdateCommandStateContext context) 373return ResourceCommandState.Hidden; 376return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ? ResourceCommandState.Enabled : ResourceCommandState.Disabled;
Aspire.Hosting.Azure.Tests (39)
AzureEnvironmentResourceExtensionsTests.cs (39)
382Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 709AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Hidden); 710AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 711AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 712AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Enabled); 713AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Enabled); 714AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Enabled); 744AssertCommandState(postgresEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Enabled); 1422AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Disabled); 1423AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 1424AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 1425AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Disabled); 1426AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Disabled); 1427AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Disabled); 1499AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 1670Assert.Equal(ResourceCommandState.Hidden, cancelCommand.State); 1972Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2247Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2261Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2307Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2319Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2343Assert.Equal(ResourceCommandState.Enabled, controller.GetEnvironmentCommandState()); 2461AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 2479AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Disabled); 2540AssertCommandState(runningStorage2Event.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 2727Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 5034AssertCommandState(snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Disabled); 5035AssertCommandState(snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 5036AssertCommandState(snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 5037AssertCommandState(snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Disabled); 5038AssertCommandState(snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Disabled); 5039AssertCommandState(snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Disabled); 5044AssertCommandState(snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Enabled); 5045AssertCommandState(snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 5046AssertCommandState(snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 5047AssertCommandState(snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Enabled); 5048AssertCommandState(snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Enabled); 5049AssertCommandState(snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Enabled); 5052private static void AssertCommandState(CustomResourceSnapshot snapshot, string commandName, ResourceCommandState expectedState)
Aspire.Hosting.Blazor (6)
BrowserDebuggerHelper.cs (6)
212return ResourceCommandState.Hidden; 217return ResourceCommandState.Hidden; 222? ResourceCommandState.Enabled 223: ResourceCommandState.Disabled; 271return ResourceCommandState.Hidden; 274return ResourceCommandState.Enabled;
Aspire.Hosting.Blazor.Tests (12)
BlazorHostedExtensionsTests.cs (2)
218Assert.Equal(ResourceCommandState.Enabled, debugCommand.UpdateState(CreateRunningCommandStateContext())); 244Assert.Equal(ResourceCommandState.Hidden, debugCommand.UpdateState(CreateRunningCommandStateContext()));
WithBlazorAppTests.cs (10)
236[InlineData("Running", ResourceCommandState.Enabled)] 237[InlineData("Starting", ResourceCommandState.Disabled)] 238[InlineData("Exited", ResourceCommandState.Disabled)] 239public void WithClient_DebuggerCommandsHaveExpectedInitialState(string resourceState, ResourceCommandState expectedDebugState) 262Assert.Equal(ResourceCommandState.Hidden, commands["stop-browser-debug"].UpdateState(context)); 266[InlineData(false, null, ResourceCommandState.Disabled)] 267[InlineData(true, null, ResourceCommandState.Disabled)] 268[InlineData(true, false, ResourceCommandState.Disabled)] 269[InlineData(true, true, ResourceCommandState.Enabled)] 273ResourceCommandState expectedState)
Aspire.Hosting.Browsers (7)
BrowserLogsBuilderExtensions.cs (7)
182return ResourceCommandState.Disabled; 191return ResourceCommandState.Enabled; 195return ResourceCommandState.Disabled; 228? ResourceCommandState.Enabled 229: ResourceCommandState.Disabled; 280? ResourceCommandState.Enabled 281: ResourceCommandState.Disabled;
Aspire.Hosting.Browsers.Tests (11)
BrowserLogsBuilderExtensionsTests.cs (4)
1349command.State == ResourceCommandState.Disabled)).DefaultTimeout(); 1351Assert.Equal(ResourceCommandState.Disabled, initialEvent.Snapshot.Commands.Single(command => command.Name == BrowserLogsBuilderExtensions.OpenTrackedBrowserCommandName).State); 1365command.State == ResourceCommandState.Enabled)).DefaultTimeout(); 1367Assert.Equal(ResourceCommandState.Enabled, enabledEvent.Snapshot.Commands.Single(command => command.Name == BrowserLogsBuilderExtensions.OpenTrackedBrowserCommandName).State);
src\Aspire.Hosting.Browsers\BrowserLogsBuilderExtensions.cs (7)
182return ResourceCommandState.Disabled; 191return ResourceCommandState.Enabled; 195return ResourceCommandState.Disabled; 228? ResourceCommandState.Enabled 229: ResourceCommandState.Disabled; 280? ResourceCommandState.Enabled 281: ResourceCommandState.Disabled;
Aspire.Hosting.DevTunnels (2)
DevTunnelResourceBuilderExtensions.cs (2)
623? ResourceCommandState.Enabled 624: ResourceCommandState.Disabled;
Aspire.Hosting.DevTunnels.Tests (6)
DevTunnelResourceBuilderExtensionsTests.cs (6)
435var enabledState = command.UpdateState(new UpdateCommandStateContext 445var stoppedState = command.UpdateState(new UpdateCommandStateContext 456var unavailableState = command.UpdateState(new UpdateCommandStateContext 481Assert.Equal(ResourceCommandState.Enabled, enabledState); 482Assert.Equal(ResourceCommandState.Disabled, stoppedState); 483Assert.Equal(ResourceCommandState.Disabled, unavailableState);
Aspire.Hosting.EntityFrameworkCore (3)
EFResourceBuilderExtensions.cs (3)
789private static ResourceCommandState GetCommandState(UpdateCommandStateContext _, EFMigrationResource migrationResource) 793return ResourceCommandState.Disabled; 796return ResourceCommandState.Enabled;
Aspire.Hosting.EntityFrameworkCore.Tests (9)
EFCoreOperationExecutorTests.cs (1)
222_ => ResourceCommandState.Enabled,
EFMigrationCommandsTests.cs (8)
207var state = command.UpdateState(new UpdateCommandStateContext 212Assert.Equal(ResourceCommandState.Enabled, state); 237var state = command.UpdateState(new UpdateCommandStateContext 242Assert.Equal(ResourceCommandState.Disabled, state); 268var state = command.UpdateState(new UpdateCommandStateContext 273Assert.Equal(ResourceCommandState.Disabled, state); 288var state = command.UpdateState(new UpdateCommandStateContext 293Assert.Equal(ResourceCommandState.Enabled, state);
Aspire.Hosting.Maui (1)
Lifecycle\MauiBuildQueueEventSubscriber.cs (1)
372return ResourceCommandState.Enabled;
Aspire.Hosting.Maui.Tests (3)
MauiBuildQueueTests.cs (3)
565Assert.Equal(ResourceCommandState.Enabled, stopCommand.UpdateState(CreateUpdateStateContext(env, "Building"))); 598Assert.Equal(ResourceCommandState.Enabled, stopCommand.UpdateState(CreateUpdateStateContext(env, KnownResourceStates.Running))); 746updateState: _ => ResourceCommandState.Enabled,
Aspire.Hosting.Tests (69)
Backchannel\AuxiliaryBackchannelRpcTargetTests.cs (3)
208new ResourceCommandSnapshot("start", ResourceCommandState.Enabled, "Start", "Start the resource", null, null, null, null, false) 238new ResourceCommandSnapshot("stop", ResourceCommandState.Disabled, "Stop", "Stop the resource", null, null, null, null, false), 239new ResourceCommandSnapshot("restart", ResourceCommandState.Hidden, "Restart", null, null, null, null, null, true)
Dashboard\DashboardServiceTests.cs (3)
165UpdateState = c => Hosting.ApplicationModel.ResourceCommandState.Enabled, 192UpdateState = c => Hosting.ApplicationModel.ResourceCommandState.Enabled, 201UpdateState = c => (Hosting.ApplicationModel.ResourceCommandState)999
ResourceCommandAnnotationTests.cs (52)
13[InlineData("start", "Starting", ResourceCommandState.Disabled)] 14[InlineData("start", "Stopping", ResourceCommandState.Hidden)] 15[InlineData("start", "Running", ResourceCommandState.Hidden)] 16[InlineData("start", "Exited", ResourceCommandState.Enabled)] 17[InlineData("start", "Finished", ResourceCommandState.Enabled)] 18[InlineData("start", "FailedToStart", ResourceCommandState.Enabled)] 19[InlineData("start", "Unknown", ResourceCommandState.Enabled)] 20[InlineData("start", "Waiting", ResourceCommandState.Enabled)] 21[InlineData("start", "Building", ResourceCommandState.Disabled)] 22[InlineData("start", "RuntimeUnhealthy", ResourceCommandState.Disabled)] 23[InlineData("start", "", ResourceCommandState.Disabled)] 24[InlineData("start", null, ResourceCommandState.Disabled)] 25[InlineData("stop", "Starting", ResourceCommandState.Hidden)] 26[InlineData("stop", "Stopping", ResourceCommandState.Disabled)] 27[InlineData("stop", "Running", ResourceCommandState.Enabled)] 28[InlineData("stop", "Exited", ResourceCommandState.Hidden)] 29[InlineData("stop", "Finished", ResourceCommandState.Hidden)] 30[InlineData("stop", "FailedToStart", ResourceCommandState.Hidden)] 31[InlineData("stop", "Unknown", ResourceCommandState.Hidden)] 32[InlineData("stop", "Waiting", ResourceCommandState.Hidden)] 33[InlineData("stop", "Building", ResourceCommandState.Hidden)] 34[InlineData("stop", "RuntimeUnhealthy", ResourceCommandState.Hidden)] 35[InlineData("stop", "", ResourceCommandState.Hidden)] 36[InlineData("stop", null, ResourceCommandState.Hidden)] 37[InlineData("restart", "Starting", ResourceCommandState.Disabled)] 38[InlineData("restart", "Stopping", ResourceCommandState.Disabled)] 39[InlineData("restart", "Running", ResourceCommandState.Enabled)] 40[InlineData("restart", "Exited", ResourceCommandState.Disabled)] 41[InlineData("restart", "Finished", ResourceCommandState.Disabled)] 42[InlineData("restart", "FailedToStart", ResourceCommandState.Disabled)] 43[InlineData("restart", "Unknown", ResourceCommandState.Disabled)] 44[InlineData("restart", "Waiting", ResourceCommandState.Disabled)] 45[InlineData("restart", "Building", ResourceCommandState.Disabled)] 46[InlineData("restart", "RuntimeUnhealthy", ResourceCommandState.Disabled)] 47[InlineData("restart", "", ResourceCommandState.Disabled)] 48[InlineData("restart", null, ResourceCommandState.Disabled)] 49public void LifeCycleCommands_CommandState(string commandName, string? resourceState, ResourceCommandState commandState) 59var state = startCommand.UpdateState(new UpdateCommandStateContext 120[InlineData("rebuild", "Starting", ResourceCommandState.Disabled)] 121[InlineData("rebuild", "Stopping", ResourceCommandState.Disabled)] 122[InlineData("rebuild", "Running", ResourceCommandState.Enabled)] 123[InlineData("rebuild", "Exited", ResourceCommandState.Enabled)] 124[InlineData("rebuild", "Finished", ResourceCommandState.Enabled)] 125[InlineData("rebuild", "FailedToStart", ResourceCommandState.Enabled)] 126[InlineData("rebuild", "Unknown", ResourceCommandState.Disabled)] 127[InlineData("rebuild", "Waiting", ResourceCommandState.Enabled)] 128[InlineData("rebuild", "RuntimeUnhealthy", ResourceCommandState.Disabled)] 129[InlineData("rebuild", "Building", ResourceCommandState.Disabled)] 130[InlineData("rebuild", "", ResourceCommandState.Disabled)] 131[InlineData("rebuild", null, ResourceCommandState.Disabled)] 132public void RebuildCommand_CommandState(string commandName, string? resourceState, ResourceCommandState commandState) 139var state = rebuildCommand.UpdateState(new UpdateCommandStateContext
ResourceNotificationTests.cs (1)
1837return new("command", ResourceCommandState.Enabled, "Command", DisplayDescription: null, Parameter: null, ConfirmationMessage: null, IconName: null, IconVariant: null, IsHighlighted: false)
WithHttpCommandTests.cs (10)
959Assert.Equal(ResourceCommandState.Disabled, startingEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 971e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Enabled).DefaultTimeout(); 973Assert.Equal(ResourceCommandState.Enabled, runningEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 997return enableCommand ? ResourceCommandState.Enabled : ResourceCommandState.Hidden; 1014e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Hidden).DefaultTimeout(); 1016Assert.Equal(ResourceCommandState.Hidden, runningEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 1028e => e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Enabled).DefaultTimeout(); 1031Assert.Equal(ResourceCommandState.Enabled, enabledEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 1070e.Snapshot.Commands.FirstOrDefault(c => c.Name == commandName)?.State == ResourceCommandState.Enabled).DefaultTimeout();