Files
NTBug/web/Helpdesk.Web/Infrastructure/Navigation.cs
T
PatTheEvil 2fe939ba5c web: seznam Moje hlášení
Závady nahlášené přihlášeným uživatelem od nejnovějších: filtr podle stavu,
stránkování, štítky stavů, kategorie a místo z číselníků a čas v českém
pásmu. Položka v menu a site.js pro automatické odeslání filtru (bez
inline skriptů kvůli CSP).

Refs #22
2026-12-02 13:50:01 +01:00

27 lines
948 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Security.Claims;
using Helpdesk.Web.Auth;
namespace Helpdesk.Web.Infrastructure;
/// <summary>Položka hlavního menu. Bez rolí ji vidí každý přihlášený uživatel.</summary>
public sealed record NavItem(string Text, string Controller, string Action, params string[] Roles)
{
public bool IsVisibleTo(ClaimsPrincipal user) =>
user.Identity?.IsAuthenticated == true && (Roles.Length == 0 || Roles.Any(user.IsInRole));
}
/// <summary>
/// Hlavní menu na jednom místě. Viditelnost podle role je jen pohodlí pro uživatele –
/// oprávnění skutečně kontroluje API (kap. 9.3 návrhu).
/// </summary>
public static class Navigation
{
public static readonly IReadOnlyList<NavItem> Items =
[
new("Nástěnka", "Home", "Index"),
new("Moje hlášení", "Issues", "Index"),
];
public static IEnumerable<NavItem> For(ClaimsPrincipal user) => Items.Where(i => i.IsVisibleTo(user));
}