Skip to content

Commit 9a36dc3

Browse files
[release/9.4] Fix ShowDismiss setting not being used with message boxs or confirmations (dotnet#10583)
* Fix ShowDismiss setting not being used with message boxs or confirmations * Clean up --------- Co-authored-by: James Newton-King <[email protected]>
1 parent 0a01254 commit 9a36dc3

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

playground/Stress/Stress.AppHost/InteractionCommands.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,47 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
165165

166166
return CommandResults.Success();
167167
})
168+
.WithCommand("dismiss-interaction", "Dismiss interaction tests", executeCommand: commandContext =>
169+
{
170+
var interactionService = commandContext.ServiceProvider.GetRequiredService<IInteractionService>();
171+
172+
RunInteractionWithDismissValues(nameof(IInteractionService.PromptNotificationAsync), (showDismiss, title) =>
173+
{
174+
return interactionService.PromptNotificationAsync(
175+
title: title,
176+
message: string.Empty,
177+
options: new NotificationInteractionOptions { ShowDismiss = showDismiss },
178+
cancellationToken: commandContext.CancellationToken);
179+
});
180+
RunInteractionWithDismissValues(nameof(IInteractionService.PromptConfirmationAsync), (showDismiss, title) =>
181+
{
182+
return interactionService.PromptConfirmationAsync(
183+
title: title,
184+
message: string.Empty,
185+
options: new MessageBoxInteractionOptions { ShowDismiss = showDismiss },
186+
cancellationToken: commandContext.CancellationToken);
187+
});
188+
RunInteractionWithDismissValues(nameof(IInteractionService.PromptMessageBoxAsync), (showDismiss, title) =>
189+
{
190+
return interactionService.PromptMessageBoxAsync(
191+
title: title,
192+
message: string.Empty,
193+
options: new MessageBoxInteractionOptions { ShowDismiss = showDismiss },
194+
cancellationToken: commandContext.CancellationToken);
195+
});
196+
RunInteractionWithDismissValues(nameof(IInteractionService.PromptInputAsync), (showDismiss, title) =>
197+
{
198+
return interactionService.PromptInputAsync(
199+
title: title,
200+
message: string.Empty,
201+
inputLabel: "Input",
202+
placeHolder: "Enter input",
203+
options: new InputsDialogInteractionOptions { ShowDismiss = showDismiss },
204+
cancellationToken: commandContext.CancellationToken);
205+
});
206+
207+
return Task.FromResult(CommandResults.Success());
208+
})
168209
.WithCommand("many-values", "Many values", executeCommand: async commandContext =>
169210
{
170211
var interactionService = commandContext.ServiceProvider.GetRequiredService<IInteractionService>();
@@ -202,6 +243,14 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
202243

203244
return resource;
204245
}
246+
247+
private static void RunInteractionWithDismissValues(string title, Func<bool?, string, Task> action)
248+
{
249+
// Don't wait for interactions to complete, i.e. await tasks.
250+
_ = action(null, $"{title} - ShowDismiss = null");
251+
_ = action(true, $"{title} - ShowDismiss = true");
252+
_ = action(false, $"{title} - ShowDismiss = false");
253+
}
205254
}
206255

207256
#pragma warning restore ASPIREINTERACTION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

src/Aspire.Dashboard/Components/Interactions/InteractionsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ public async Task<IDialogReference> ShowMessageBoxAsync(IDialogService dialogSer
560560
DialogType = DialogType.MessageBox,
561561
Alignment = HorizontalAlignment.Center,
562562
Title = content.Title,
563-
ShowDismiss = false,
563+
ShowDismiss = parameters.ShowDismiss,
564564
PrimaryAction = parameters.PrimaryAction,
565565
SecondaryAction = parameters.SecondaryAction,
566566
Width = parameters.Width,

src/Aspire.Hosting/IInteractionService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public class InteractionOptions
342342
public bool? ShowSecondaryButton { get; set; }
343343

344344
/// <summary>
345-
/// Gets or sets a value indicating whether show the dismiss button in the header.
345+
/// Gets or sets a value indicating whether show the dismiss button.
346346
/// </summary>
347347
public bool? ShowDismiss { get; set; }
348348

0 commit comments

Comments
 (0)