83 references to ResourceCommandState
Aspire.Hosting (26)
ApplicationModel\CommandOptions.cs (1)
51public Func<UpdateCommandStateContext, ResourceCommandState>? UpdateState { get; set; }
ApplicationModel\CommandsConfigurationExtensions.cs (8)
34return ResourceCommandState.Disabled; 38return ResourceCommandState.Enabled; 42return ResourceCommandState.Hidden; 67return ResourceCommandState.Disabled; 71return ResourceCommandState.Enabled; 75return ResourceCommandState.Hidden; 107return ResourceCommandState.Disabled; 111return ResourceCommandState.Enabled;
ApplicationModel\CustomResourceSnapshot.cs (1)
296public sealed record ResourceCommandSnapshot(string Name, ResourceCommandState State, string DisplayName, string? DisplayDescription, object? Parameter, string? ConfirmationMessage, string? IconName, IconVariant? IconVariant, bool IsHighlighted);
ApplicationModel\ResourceCommandAnnotation.cs (2)
20Func<UpdateCommandStateContext, ResourceCommandState> updateState, 60public Func<UpdateCommandStateContext, ResourceCommandState> UpdateState { get; }
ApplicationModel\ResourceNotificationService.cs (2)
741var newState = annotation.UpdateState(new UpdateCommandStateContext { ResourceSnapshot = previousState, ServiceProvider = _serviceProvider }); 784var state = annotation.UpdateState(new UpdateCommandStateContext { ResourceSnapshot = previousState, ServiceProvider = serviceProvider });
Dashboard\proto\Partials.cs (4)
145private static ResourceCommandState MapCommandState(Hosting.ApplicationModel.ResourceCommandState state) 149Hosting.ApplicationModel.ResourceCommandState.Enabled => ResourceCommandState.Enabled, 150Hosting.ApplicationModel.ResourceCommandState.Disabled => ResourceCommandState.Disabled, 151Hosting.ApplicationModel.ResourceCommandState.Hidden => ResourceCommandState.Hidden,
Orchestrator\ParameterProcessor.cs (3)
205updateState: _ => ResourceCommandState.Enabled, 221updateState: _ => HasParameterValue(parameterResource) ? ResourceCommandState.Enabled : ResourceCommandState.Hidden,
ResourceBuilderExtensions.cs (5)
2031return builder.WithAnnotation(new ResourceCommandAnnotation(name, displayName, commandOptions.UpdateState ?? (c => ResourceCommandState.Enabled), executeCommand, commandOptions.Description, commandOptions.Parameter, commandOptions.ConfirmationMessage, commandOptions.IconName, commandOptions.IconVariant, commandOptions.IsHighlighted)); 2076Func<UpdateCommandStateContext, ResourceCommandState>? updateState = null, 2096return builder.WithAnnotation(new ResourceCommandAnnotation(name, displayName, updateState ?? (c => ResourceCommandState.Enabled), executeCommand, displayDescription, parameter, confirmationMessage, iconName, iconVariant, isHighlighted)); 2277return targetRunning ? ResourceCommandState.Enabled : ResourceCommandState.Disabled;
Aspire.Hosting.Azure.Kusto (8)
AzureKustoBuilderExtensions.cs (8)
336static ResourceCommandState UpdateStateDesktop(UpdateCommandStateContext context) 341return ResourceCommandState.Hidden; 344return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ? ResourceCommandState.Enabled : ResourceCommandState.Disabled; 347static ResourceCommandState UpdateStateWeb(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, UpdateCommandStateContext context) 352return ResourceCommandState.Hidden; 355return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ? ResourceCommandState.Enabled : ResourceCommandState.Disabled;
Aspire.Hosting.Tests (49)
Backchannel\AuxiliaryBackchannelRpcTargetTests.cs (3)
121new ResourceCommandSnapshot("start", ResourceCommandState.Enabled, "Start", "Start the resource", null, null, null, null, false), 122new ResourceCommandSnapshot("stop", ResourceCommandState.Disabled, "Stop", "Stop the resource", null, null, null, null, false), 123new ResourceCommandSnapshot("restart", ResourceCommandState.Hidden, "Restart", null, null, null, null, null, true)
Dashboard\DashboardServiceTests.cs (1)
160UpdateState = c => Aspire.Hosting.ApplicationModel.ResourceCommandState.Enabled,
ResourceCommandAnnotationTests.cs (35)
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", "RuntimeUnhealthy", ResourceCommandState.Disabled)] 22[InlineData("start", "", ResourceCommandState.Disabled)] 23[InlineData("start", null, ResourceCommandState.Disabled)] 24[InlineData("stop", "Starting", ResourceCommandState.Hidden)] 25[InlineData("stop", "Stopping", ResourceCommandState.Disabled)] 26[InlineData("stop", "Running", ResourceCommandState.Enabled)] 27[InlineData("stop", "Exited", ResourceCommandState.Hidden)] 28[InlineData("stop", "Finished", ResourceCommandState.Hidden)] 29[InlineData("stop", "FailedToStart", ResourceCommandState.Hidden)] 30[InlineData("stop", "Unknown", ResourceCommandState.Hidden)] 31[InlineData("stop", "Waiting", ResourceCommandState.Hidden)] 32[InlineData("stop", "RuntimeUnhealthy", ResourceCommandState.Hidden)] 33[InlineData("stop", "", ResourceCommandState.Hidden)] 34[InlineData("stop", null, ResourceCommandState.Hidden)] 35[InlineData("restart", "Starting", ResourceCommandState.Disabled)] 36[InlineData("restart", "Stopping", ResourceCommandState.Disabled)] 37[InlineData("restart", "Running", ResourceCommandState.Enabled)] 38[InlineData("restart", "Exited", ResourceCommandState.Disabled)] 39[InlineData("restart", "Finished", ResourceCommandState.Disabled)] 40[InlineData("restart", "FailedToStart", ResourceCommandState.Disabled)] 41[InlineData("restart", "Unknown", ResourceCommandState.Disabled)] 42[InlineData("restart", "Waiting", ResourceCommandState.Disabled)] 43[InlineData("restart", "RuntimeUnhealthy", ResourceCommandState.Disabled)] 44[InlineData("restart", "", ResourceCommandState.Disabled)] 45[InlineData("restart", null, ResourceCommandState.Disabled)] 46public void LifeCycleCommands_CommandState(string commandName, string? resourceState, ResourceCommandState commandState) 56var state = startCommand.UpdateState(new UpdateCommandStateContext
WithHttpCommandTests.cs (10)
428Assert.Equal(ResourceCommandState.Disabled, startingEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 440e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Enabled).DefaultTimeout(); 442Assert.Equal(ResourceCommandState.Enabled, runningEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 466return enableCommand ? ResourceCommandState.Enabled : ResourceCommandState.Hidden; 483e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Hidden).DefaultTimeout(); 485Assert.Equal(ResourceCommandState.Hidden, runningEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 497e => e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Enabled).DefaultTimeout(); 500Assert.Equal(ResourceCommandState.Enabled, enabledEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 539e.Snapshot.Commands.FirstOrDefault(c => c.Name == commandName)?.State == ResourceCommandState.Enabled).DefaultTimeout();