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