- SimplifiedPermissionEntry wraps PermissionEntry with computed labels and risk level - Passthrough properties preserve DataGrid binding compatibility - PermissionSummary record for grouped risk-level counts - PermissionSummaryBuilder always returns all 4 risk levels for consistent UI Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
using SharepointToolbox.Core.Helpers;
|
|
|
|
namespace SharepointToolbox.Core.Models;
|
|
|
|
/// <summary>
|
|
/// Presentation wrapper around PermissionEntry that adds simplified labels
|
|
/// and risk level classification without modifying the immutable source record.
|
|
/// Used as the DataGrid ItemsSource when simplified mode is active.
|
|
/// </summary>
|
|
public class SimplifiedPermissionEntry
|
|
{
|
|
/// <summary>The original immutable PermissionEntry.</summary>
|
|
public PermissionEntry Inner { get; }
|
|
|
|
/// <summary>
|
|
/// Human-readable labels for the permission levels.
|
|
/// E.g. "Can edit files and list items" instead of "Contribute".
|
|
/// </summary>
|
|
public string SimplifiedLabels { get; }
|
|
|
|
/// <summary>
|
|
/// The highest risk level across all permission levels on this entry.
|
|
/// Used for row-level color coding.
|
|
/// </summary>
|
|
public RiskLevel RiskLevel { get; }
|
|
|
|
/// <summary>
|
|
/// Individual mapping results for each permission level in the entry.
|
|
/// Used when detailed breakdown per-role is needed.
|
|
/// </summary>
|
|
public IReadOnlyList<PermissionLevelMapping.MappingResult> Mappings { get; }
|
|
|
|
// ── Passthrough properties for DataGrid binding ──
|
|
|
|
public string ObjectType => Inner.ObjectType;
|
|
public string Title => Inner.Title;
|
|
public string Url => Inner.Url;
|
|
public bool HasUniquePermissions => Inner.HasUniquePermissions;
|
|
public string Users => Inner.Users;
|
|
public string UserLogins => Inner.UserLogins;
|
|
public string PermissionLevels => Inner.PermissionLevels;
|
|
public string GrantedThrough => Inner.GrantedThrough;
|
|
public string PrincipalType => Inner.PrincipalType;
|
|
|
|
public SimplifiedPermissionEntry(PermissionEntry entry)
|
|
{
|
|
Inner = entry;
|
|
Mappings = PermissionLevelMapping.GetMappings(entry.PermissionLevels);
|
|
SimplifiedLabels = PermissionLevelMapping.GetSimplifiedLabels(entry.PermissionLevels);
|
|
RiskLevel = PermissionLevelMapping.GetHighestRisk(entry.PermissionLevels);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates SimplifiedPermissionEntry wrappers for a collection of entries.
|
|
/// </summary>
|
|
public static IReadOnlyList<SimplifiedPermissionEntry> WrapAll(
|
|
IEnumerable<PermissionEntry> entries)
|
|
{
|
|
return entries.Select(e => new SimplifiedPermissionEntry(e)).ToList();
|
|
}
|
|
}
|