@using BTCPayServer.Client @using BTCPayServer.Views.Server @using Microsoft.AspNetCore.Mvc.TagHelpers @using BTCPayServer.Abstractions.TagHelpers @using BTCPayServer.Controllers @using BTCPayServer.Views.Stores @model UpdateRoleViewModel @{ var role = Context.GetRouteValue("role") as string; if (role == "create") role = null; var storeId = Context.GetRouteValue("storeId") as string; if (storeId is null) ViewData.SetActivePage(ServerNavPages.Roles, role is null ? "Create role" : "Update Role"); else { ViewData.SetActivePage(StoreNavPages.Roles, role is null ? "Create role" : "Update Role"); } var storePolicies = Policies.AllPolicies.Where(Policies.IsStorePolicy).ToArray(); }
@if (!ViewContext.ModelState.IsValid) {
}
@if (role == null) { } else { }

Permissions

@{ var storePolicyMap = Permission.PolicyMap.Where(pair => Policies.IsStorePolicy(pair.Key)).ToArray(); var topMostPolicies = storePolicyMap.Where(pair => !storePolicyMap.Any(valuePair => valuePair.Value.Contains(pair.Key))); @foreach (var policy in topMostPolicies) { RenderTree(policy, storePolicyMap, Model.Policies.Contains(policy.Key)); } }
@{ void RenderTree(KeyValuePair> policy, KeyValuePair>[] storePolicyMap, bool isChecked) {

@UIManageController.AddApiKeyViewModel.PermissionValueItem.PermissionDescriptions[policy.Key].Description

@if (policy.Value?.Any() is true) {
@foreach (var subPolicy in policy.Value) { var match = storePolicyMap.SingleOrDefault(pair => pair.Key == subPolicy); RenderTree(match.Key is not null ? match : new KeyValuePair>(subPolicy, null), storePolicyMap, !isChecked && Model.Policies.Contains(subPolicy)); }
}
} }