-
Notifications
You must be signed in to change notification settings - Fork 44
Add typed launchers routing menu and FilterPane modal opens through coordinator #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jschick04
merged 1 commit into
jschick/modal-coordinator-refactor
from
jschick/modal-coordinator-pr4
May 26, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // // Copyright (c) Microsoft Corporation. | ||
| // // Licensed under the MIT License. | ||
|
|
||
| using EventLogExpert.Runtime.Modal; | ||
| using EventLogExpert.Runtime.Update.ReleaseNotes; | ||
| using EventLogExpert.UI.DatabaseTools; | ||
| using EventLogExpert.UI.DebugLog; | ||
| using EventLogExpert.UI.FilterCache; | ||
| using EventLogExpert.UI.FilterGroup; | ||
| using EventLogExpert.UI.Settings; | ||
| using EventLogExpert.UI.Update; | ||
|
|
||
| namespace EventLogExpert.UI.Modal; | ||
|
|
||
| /// <summary>Typed launchers that route production modal opens through the coordinator's veto pipeline.</summary> | ||
| public static class ModalCoordinatorLaunchers | ||
| { | ||
| extension(IModalCoordinator coordinator) | ||
| { | ||
| public Task<ModalOpenResult<bool>> OpenDatabaseToolsAsync() | ||
| { | ||
| ArgumentNullException.ThrowIfNull(coordinator); | ||
|
|
||
| return coordinator.PushAsync<DatabaseToolsModal, bool>(); | ||
| } | ||
|
|
||
| public Task<ModalOpenResult<bool>> OpenDebugLogsAsync() | ||
| { | ||
| ArgumentNullException.ThrowIfNull(coordinator); | ||
|
|
||
| return coordinator.PushAsync<DebugLogModal, bool>(); | ||
| } | ||
|
|
||
| public Task<ModalOpenResult<bool>> OpenFilterCacheAsync() | ||
| { | ||
| ArgumentNullException.ThrowIfNull(coordinator); | ||
|
|
||
| return coordinator.PushAsync<FilterCacheModal, bool>(); | ||
| } | ||
|
|
||
| public Task<ModalOpenResult<bool>> OpenFilterGroupAsync() | ||
| { | ||
| ArgumentNullException.ThrowIfNull(coordinator); | ||
|
|
||
| return coordinator.PushAsync<FilterGroupModal, bool>(); | ||
| } | ||
|
|
||
| public Task<ModalOpenResult<bool>> OpenReleaseNotesAsync(ReleaseNotesContent content) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(coordinator); | ||
|
|
||
| return coordinator.PushAsync<ReleaseNotesModal, bool>(new Dictionary<string, object?> { [nameof(ReleaseNotesModal.Content)] = content }); | ||
| } | ||
|
|
||
| public Task<ModalOpenResult<bool>> OpenSettingsAsync() | ||
| { | ||
| ArgumentNullException.ThrowIfNull(coordinator); | ||
|
|
||
| return coordinator.PushAsync<SettingsModal, bool>(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
tests/Unit/EventLogExpert.UI.Tests/Modal/ModalCoordinatorLaunchersTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| // // Copyright (c) Microsoft Corporation. | ||
| // // Licensed under the MIT License. | ||
|
|
||
| using EventLogExpert.Runtime.Modal; | ||
| using EventLogExpert.Runtime.Update.ReleaseNotes; | ||
| using EventLogExpert.UI.DatabaseTools; | ||
| using EventLogExpert.UI.DebugLog; | ||
| using EventLogExpert.UI.FilterCache; | ||
| using EventLogExpert.UI.FilterGroup; | ||
| using EventLogExpert.UI.Modal; | ||
| using EventLogExpert.UI.Settings; | ||
| using EventLogExpert.UI.Update; | ||
| using NSubstitute; | ||
|
|
||
| namespace EventLogExpert.UI.Tests.Modal; | ||
|
|
||
| public sealed class ModalCoordinatorLaunchersTests | ||
| { | ||
| [Fact] | ||
| public async Task OpenDatabaseToolsAsync_DelegatesToPushAsync() | ||
| { | ||
| // Arrange | ||
| var coordinator = Substitute.For<IModalCoordinator>(); | ||
| coordinator.PushAsync<DatabaseToolsModal, bool>(Arg.Any<IDictionary<string, object?>?>()) | ||
| .Returns(new ModalOpenResult<bool>(false, WasOpened: true)); | ||
|
|
||
| // Act | ||
| await coordinator.OpenDatabaseToolsAsync(); | ||
|
|
||
| // Assert | ||
| await coordinator.Received(1).PushAsync<DatabaseToolsModal, bool>(Arg.Any<IDictionary<string, object?>?>()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task OpenDebugLogsAsync_DelegatesToPushAsync() | ||
| { | ||
| // Arrange | ||
| var coordinator = Substitute.For<IModalCoordinator>(); | ||
| coordinator.PushAsync<DebugLogModal, bool>(Arg.Any<IDictionary<string, object?>?>()) | ||
| .Returns(new ModalOpenResult<bool>(false, WasOpened: true)); | ||
|
|
||
| // Act | ||
| await coordinator.OpenDebugLogsAsync(); | ||
|
|
||
| // Assert | ||
| await coordinator.Received(1).PushAsync<DebugLogModal, bool>(Arg.Any<IDictionary<string, object?>?>()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task OpenFilterCacheAsync_DelegatesToPushAsync() | ||
| { | ||
| // Arrange | ||
| var coordinator = Substitute.For<IModalCoordinator>(); | ||
| coordinator.PushAsync<FilterCacheModal, bool>(Arg.Any<IDictionary<string, object?>?>()) | ||
| .Returns(new ModalOpenResult<bool>(false, WasOpened: true)); | ||
|
|
||
| // Act | ||
| await coordinator.OpenFilterCacheAsync(); | ||
|
|
||
| // Assert | ||
| await coordinator.Received(1).PushAsync<FilterCacheModal, bool>(Arg.Any<IDictionary<string, object?>?>()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task OpenFilterGroupAsync_DelegatesToPushAsync() | ||
| { | ||
| // Arrange | ||
| var coordinator = Substitute.For<IModalCoordinator>(); | ||
| coordinator.PushAsync<FilterGroupModal, bool>(Arg.Any<IDictionary<string, object?>?>()) | ||
| .Returns(new ModalOpenResult<bool>(false, WasOpened: true)); | ||
|
|
||
| // Act | ||
| await coordinator.OpenFilterGroupAsync(); | ||
|
|
||
| // Assert | ||
| await coordinator.Received(1).PushAsync<FilterGroupModal, bool>(Arg.Any<IDictionary<string, object?>?>()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task OpenReleaseNotesAsync_PassesContentParameter() | ||
| { | ||
| // Arrange | ||
| var coordinator = Substitute.For<IModalCoordinator>(); | ||
| coordinator.PushAsync<ReleaseNotesModal, bool>(Arg.Any<IDictionary<string, object?>?>()) | ||
| .Returns(new ModalOpenResult<bool>(false, WasOpened: true)); | ||
| var content = new ReleaseNotesContent("v1.0", "## Notes"); | ||
|
|
||
| // Act | ||
| await coordinator.OpenReleaseNotesAsync(content); | ||
|
|
||
| // Assert | ||
| await coordinator.Received(1).PushAsync<ReleaseNotesModal, bool>( | ||
| Arg.Is<IDictionary<string, object?>?>(d => d != null && d.ContainsKey(nameof(ReleaseNotesModal.Content)) && content.Equals((ReleaseNotesContent)d[nameof(ReleaseNotesModal.Content)]!))); | ||
| } | ||
|
jschick04 marked this conversation as resolved.
|
||
|
|
||
| [Fact] | ||
| public async Task OpenSettingsAsync_DelegatesToPushAsync() | ||
| { | ||
| // Arrange | ||
| var coordinator = Substitute.For<IModalCoordinator>(); | ||
| coordinator.PushAsync<SettingsModal, bool>(Arg.Any<IDictionary<string, object?>?>()) | ||
| .Returns(new ModalOpenResult<bool>(false, WasOpened: true)); | ||
|
|
||
| // Act | ||
| await coordinator.OpenSettingsAsync(); | ||
|
|
||
| // Assert | ||
| await coordinator.Received(1).PushAsync<SettingsModal, bool>(Arg.Any<IDictionary<string, object?>?>()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void OpenSettingsAsync_NullCoordinator_ThrowsArgumentNullException() | ||
| { | ||
| // Arrange + Act + Assert — discard the Task to avoid xUnit2014; the throw happens synchronously in the guard. | ||
| Assert.Throws<ArgumentNullException>(static () => { _ = ModalCoordinatorLaunchers.OpenSettingsAsync(coordinator: null!); }); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task OpenSettingsAsync_WhenActiveModalVetoesPreemption_ReturnsNotOpened() | ||
| { | ||
| // Arrange — simulates PR 4's veto-preempt path: PushAsync returns WasOpened=false when the existing modal | ||
| // vetoes via OnRequestCloseAsync (e.g., SettingsModal IsCloseBlocked, DatabaseToolsModal AnyTabIsRunning). | ||
| var coordinator = Substitute.For<IModalCoordinator>(); | ||
| coordinator.PushAsync<SettingsModal, bool>(Arg.Any<IDictionary<string, object?>?>()) | ||
| .Returns(new ModalOpenResult<bool>(false, WasOpened: false)); | ||
|
|
||
| // Act | ||
| ModalOpenResult<bool> result = await coordinator.OpenSettingsAsync(); | ||
|
|
||
| // Assert | ||
| Assert.False(result.WasOpened); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.