Refactor settings modal to use ISettingsModalService and SettingsModalSections

- Replace SettingsModalContext with SettingsModalSections
- Add SettingsModalService for modal state management
- Add StatusSection.razor.css for status-dot styles
- Update layout, NavMenu, and modal components
- Update tests for config/settings changes
This commit is contained in:
2026-02-09 14:59:01 +10:00
parent d06d6ef6c9
commit b70aa02017
26 changed files with 754 additions and 317 deletions
@@ -0,0 +1,23 @@
using DnsmasqWebUI.Models.Client;
namespace DnsmasqWebUI.Infrastructure.Services.Abstractions;
/// <summary>
/// Scoped service to open the app-level settings modal from anywhere (e.g. NavMenu, pages).
/// MainLayout subscribes to <see cref="OpenRequested"/> and hosts the modal.
/// Subscribe to <see cref="SettingsChanged"/> to refresh when settings are saved/closed.
/// </summary>
public interface ISettingsModalService
{
/// <summary>Raised when <see cref="Open"/> is called. MainLayout subscribes and shows the modal.</summary>
event Action<SettingsModalContext, string>? OpenRequested;
/// <summary>Raised when the modal is closed (save or cancel). Pages subscribe to reload their intervals.</summary>
event Action? SettingsChanged;
/// <summary>Opens the settings modal with the given context and title.</summary>
void Open(SettingsModalContext context, string title);
/// <summary>Called when the modal closes. Raises <see cref="SettingsChanged"/>.</summary>
void NotifySettingsChanged();
}
@@ -0,0 +1,15 @@
using DnsmasqWebUI.Infrastructure.Services.Abstractions;
using DnsmasqWebUI.Models.Client;
namespace DnsmasqWebUI.Infrastructure.Services;
/// <inheritdoc cref="ISettingsModalService" />
public sealed class SettingsModalService : ISettingsModalService
{
public event Action<SettingsModalContext, string>? OpenRequested;
public event Action? SettingsChanged;
public void Open(SettingsModalContext context, string title) => OpenRequested?.Invoke(context, title);
public void NotifySettingsChanged() => SettingsChanged?.Invoke();
}