mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-21 19:32:35 +10:00
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:
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user