102 references to ResourceCommandState
Aspire.Hosting (28)
ApplicationModel\CommandOptions.cs (1)
51
public Func<UpdateCommandStateContext,
ResourceCommandState
>? UpdateState { get; set; }
ApplicationModel\CommandsConfigurationExtensions.cs (10)
37
return
ResourceCommandState
.Disabled;
41
return
ResourceCommandState
.Enabled;
45
return
ResourceCommandState
.Hidden;
70
return
ResourceCommandState
.Disabled;
74
return
ResourceCommandState
.Enabled;
78
return
ResourceCommandState
.Hidden;
110
return
ResourceCommandState
.Disabled;
114
return
ResourceCommandState
.Enabled;
171
?
ResourceCommandState
.Enabled
172
:
ResourceCommandState
.Disabled;
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)
760
var
newState = annotation.UpdateState(new UpdateCommandStateContext { ResourceSnapshot = previousState, ServiceProvider = _serviceProvider });
803
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)
2206
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));
2251
Func<UpdateCommandStateContext,
ResourceCommandState
>? updateState = null,
2271
return builder.WithAnnotation(new ResourceCommandAnnotation(name, displayName, updateState ?? (c =>
ResourceCommandState
.Enabled), executeCommand, displayDescription, parameter, confirmationMessage, iconName, iconVariant, isHighlighted));
2456
return targetRunning ?
ResourceCommandState
.Enabled :
ResourceCommandState
.Disabled;
Aspire.Hosting.Azure.Kusto (8)
AzureKustoBuilderExtensions.cs (8)
340
static
ResourceCommandState
UpdateStateDesktop(UpdateCommandStateContext context)
345
return
ResourceCommandState
.Hidden;
348
return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ?
ResourceCommandState
.Enabled :
ResourceCommandState
.Disabled;
351
static
ResourceCommandState
UpdateStateWeb(IResourceBuilder<AzureKustoClusterResource> resourceBuilder, UpdateCommandStateContext context)
356
return
ResourceCommandState
.Hidden;
359
return context.ResourceSnapshot.State?.Text == KnownResourceStates.Running ?
ResourceCommandState
.Enabled :
ResourceCommandState
.Disabled;
Aspire.Hosting.Tests (66)
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 (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)]
49
public void LifeCycleCommands_CommandState(string commandName, string? resourceState,
ResourceCommandState
commandState)
59
var
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)]
132
public void RebuildCommand_CommandState(string commandName, string? resourceState,
ResourceCommandState
commandState)
139
var
state = rebuildCommand.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();