Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions scripts/run-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,24 @@ function Switch-DockerDaemon([string]$targetOS) {
throw "docker is not on PATH. Install Docker Desktop and ensure it is available."
}

$dockerCli = Join-Path (Split-Path (Split-Path $dockerCmd.Source)) "DockerCli.exe"
# Docker Desktop layout has changed across versions: newer installs put DockerCli.exe at
# 'C:\Program Files\Docker\Docker\DockerCli.exe', older installs at '...\resources\DockerCli.exe'.
# Try the canonical sibling-of-resources path first (newer layout), then the older
# resources-relative path, then a recursive scan.
$resourcesDir = Split-Path (Split-Path $dockerCmd.Source)
$dockerCli = Join-Path (Split-Path $resourcesDir) "DockerCli.exe"

if (-not (Test-Path $dockerCli)) {
throw "DockerCli.exe not found at '$dockerCli'. Cannot switch Docker daemon mode."
$dockerCli = Join-Path $resourcesDir "DockerCli.exe"
}

if (-not (Test-Path $dockerCli)) {
$found = Get-ChildItem (Split-Path $resourcesDir) -Recurse -Filter "DockerCli.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($found) { $dockerCli = $found.FullName }
}

if (-not (Test-Path $dockerCli)) {
throw "DockerCli.exe not found near '$resourcesDir'. Cannot switch Docker daemon mode."
}

& $dockerCli -SwitchDaemon 2>$null
Expand Down
29 changes: 16 additions & 13 deletions src/EventLogExpert.Runtime/Alerts/AlertDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@

using EventLogExpert.Runtime.Banner;
using EventLogExpert.Runtime.Common.Threading;
using EventLogExpert.Runtime.Modal;

namespace EventLogExpert.Runtime.Alerts;

public sealed class AlertDialogService(
IInlineAlertHostBroker inlineAlertHostBroker,
IModalCoordinator modalCoordinator,
IMainThreadService mainThreadService,
IBannerService bannerService,
IErrorBannerService errorBannerService,
IInfoBannerService infoBannerService,
Func<IReadOnlyDictionary<string, object?>, Task<bool>> openStandaloneAlert,
Func<IReadOnlyDictionary<string, object?>, Task<string>> openStandalonePrompt) : IAlertDialogService
{
private readonly IBannerService _bannerService = bannerService;
private readonly IInlineAlertHostBroker _inlineAlertHostBroker = inlineAlertHostBroker;
private readonly IErrorBannerService _errorBannerService = errorBannerService;
private readonly IInfoBannerService _infoBannerService = infoBannerService;
private readonly IMainThreadService _mainThreadService = mainThreadService;
private readonly IModalCoordinator _modalCoordinator = modalCoordinator;
private readonly Func<IReadOnlyDictionary<string, object?>, Task<bool>> _openStandaloneAlert = openStandaloneAlert;
private readonly Func<IReadOnlyDictionary<string, object?>, Task<string>> _openStandalonePrompt =
openStandalonePrompt;
Expand Down Expand Up @@ -54,15 +57,15 @@ public Task<bool> ShowAlert(

public Task ShowErrorAlert(string title, string message, string? actionLabel = null, Func<Task>? action = null)
{
_bannerService.ReportError(title, message, actionLabel, action);
_errorBannerService.ReportError(title, message, actionLabel, action);

return Task.CompletedTask;
}

private Task<string> DisplayPromptCore(string title, string message, string? initialValue) =>
InvokeOnMainThreadAsync(async () =>
{
if (!_inlineAlertHostBroker.TryGet(out var host))
if (!_modalCoordinator.TryGetInlineAlertHost(out var host))
{
return await _openStandalonePrompt(new Dictionary<string, object?>
{
Expand All @@ -74,7 +77,7 @@ private Task<string> DisplayPromptCore(string title, string message, string? ini

try
{
InlineAlertResult result = await host!.ShowInlineAlertAsync(
InlineAlertResult result = await host.ShowInlineAlertAsync(
new InlineAlertRequest(title, message, "OK", "Cancel", true, initialValue),
CancellationToken.None);

Expand Down Expand Up @@ -104,16 +107,16 @@ private Task<bool> ShowAlertCore(
{
if (presentation == AlertPresentation.Banner)
{
_bannerService.ReportInfoBanner(title, message, BannerSeverity.Warning);
_infoBannerService.ReportInfoBanner(title, message, BannerSeverity.Warning);

return Task.FromResult(false);
}

return InvokeOnMainThreadAsync(async () =>
{
bool hostAvailable = _inlineAlertHostBroker.TryGet(out var host);
_modalCoordinator.TryGetInlineAlertHost(out var host);

if (presentation == AlertPresentation.InlineOnly && !hostAvailable)
if (presentation == AlertPresentation.InlineOnly && host is null)
{
throw new InvalidOperationException(
$"{nameof(AlertPresentation)}.{nameof(AlertPresentation.InlineOnly)} requires an active inline " +
Expand All @@ -122,10 +125,10 @@ private Task<bool> ShowAlertCore(

if (presentation == AlertPresentation.PopupOnly)
{
hostAvailable = false;
host = null;
}

if (!hostAvailable)
if (host is null)
{
return await _openStandaloneAlert(new Dictionary<string, object?>
{
Expand All @@ -138,7 +141,7 @@ private Task<bool> ShowAlertCore(

try
{
InlineAlertResult result = await host!.ShowInlineAlertAsync(
InlineAlertResult result = await host.ShowInlineAlertAsync(
new InlineAlertRequest(title, message, accept, cancel, false, null),
CancellationToken.None);

Expand Down
2 changes: 1 addition & 1 deletion src/EventLogExpert.Runtime/Alerts/AlertPresentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum AlertPresentation
Auto,

/// <summary>
/// Route to <see cref="IBannerService.ReportInfoBanner" /> with <see cref="BannerSeverity.Warning" /> severity.
/// Route to <see cref="IInfoBannerService.ReportInfoBanner" /> with <see cref="BannerSeverity.Warning" /> severity.
/// Only valid for one-button overloads (the banner has no accept/cancel pair); using it on a two-button overload
/// throws.
/// </summary>
Expand Down
30 changes: 0 additions & 30 deletions src/EventLogExpert.Runtime/Alerts/IInlineAlertHostBroker.cs

This file was deleted.

57 changes: 0 additions & 57 deletions src/EventLogExpert.Runtime/Alerts/InlineAlertHostBroker.cs

This file was deleted.

Loading
Loading