mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Refactoring pills navigation
This commit is contained in:
@@ -15,11 +15,5 @@ namespace BTCPayServer.Services
|
|||||||
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||||
public bool LockSubscription { get; set; }
|
public bool LockSubscription { get; set; }
|
||||||
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
|
||||||
public string BootstrapCssUri { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
|
||||||
public string CreativeStartCssUri { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@model EmailsViewModel
|
@model EmailsViewModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = ServerNavPages.Emails;
|
ViewData.SetActivePageAndTitle(ServerNavPages.Pages.Emails);
|
||||||
ViewData.AddActivePage(ServerNavPages.Emails);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@model UsersViewModel
|
@model UsersViewModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Users";
|
ViewData.SetActivePageAndTitle(ServerNavPages.Pages.Users);
|
||||||
ViewData.AddActivePage(ServerNavPages.Users);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@model BTCPayServer.Services.PoliciesSettings
|
@model BTCPayServer.Services.PoliciesSettings
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = ServerNavPages.Policies;
|
ViewData.SetActivePageAndTitle(ServerNavPages.Pages.Policies);
|
||||||
ViewData.AddActivePage(ServerNavPages.Policies);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@model RatesViewModel
|
@model RatesViewModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = ServerNavPages.Rates;
|
ViewData.SetActivePageAndTitle(ServerNavPages.Pages.Rates);
|
||||||
ViewData.AddActivePage(ServerNavPages.Rates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,30 +9,22 @@ namespace BTCPayServer.Views.Server
|
|||||||
{
|
{
|
||||||
public static class ServerNavPages
|
public static class ServerNavPages
|
||||||
{
|
{
|
||||||
public static string ActivePageKey => "ActivePage";
|
public enum Pages
|
||||||
public static string Index => "Index";
|
|
||||||
|
|
||||||
|
|
||||||
public static string Users => "Users";
|
|
||||||
public static string Rates => "Rates";
|
|
||||||
public static string Emails => "Email server";
|
|
||||||
public static string Policies => "Policies";
|
|
||||||
public static string Hangfire => "Hangfire";
|
|
||||||
|
|
||||||
public static string UsersNavClass(ViewContext viewContext) => PageNavClass(viewContext, Users);
|
|
||||||
public static string EmailsNavClass(ViewContext viewContext) => PageNavClass(viewContext, Emails);
|
|
||||||
public static string RatesNavClass(ViewContext viewContext) => PageNavClass(viewContext, Rates);
|
|
||||||
public static string PoliciesNavClass(ViewContext viewContext) => PageNavClass(viewContext, Policies);
|
|
||||||
public static string HangfireNavClass(ViewContext viewContext) => PageNavClass(viewContext, Hangfire);
|
|
||||||
|
|
||||||
public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index);
|
|
||||||
|
|
||||||
public static string PageNavClass(ViewContext viewContext, string page)
|
|
||||||
{
|
{
|
||||||
var activePage = viewContext.ViewData["ActivePage"] as string;
|
Index, Users, Rates, Emails, Policies, Theme, Hangfire
|
||||||
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddActivePage(this ViewDataDictionary viewData, string activePage) => viewData[ActivePageKey] = activePage;
|
public const string ACTIVE_PAGE_KEY = "ActivePage";
|
||||||
|
public static void SetActivePageAndTitle(this ViewDataDictionary viewData, Pages activePage, string titleOverride = null)
|
||||||
|
{
|
||||||
|
viewData["Title"] = titleOverride ?? activePage.ToString();
|
||||||
|
viewData[ACTIVE_PAGE_KEY] = activePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string IsActivePage(this ViewDataDictionary viewData, Pages page)
|
||||||
|
{
|
||||||
|
var activePage = viewData[ACTIVE_PAGE_KEY] as Pages?;
|
||||||
|
return activePage == page ? "active" : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@model UserViewModel
|
@model UserViewModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = Model.Email;
|
ViewData.SetActivePageAndTitle(ServerNavPages.Pages.Users, Model.Email);
|
||||||
ViewData.AddActivePage(ServerNavPages.Users);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
@using BTCPayServer.Views.Server
|
@using BTCPayServer.Views.Server
|
||||||
|
|
||||||
<div class="nav flex-column nav-pills">
|
<div class="nav flex-column nav-pills">
|
||||||
<a class="nav-link @ServerNavPages.UsersNavClass(ViewContext)" asp-action="Users">Users</a>
|
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Pages.Users)" asp-action="Users">Users</a>
|
||||||
<a class="nav-link @ServerNavPages.RatesNavClass(ViewContext)" asp-action="Rates">Rates</a>
|
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Pages.Rates)" asp-action="Rates">Rates</a>
|
||||||
<a class="nav-link @ServerNavPages.EmailsNavClass(ViewContext)" asp-action="Emails">Email server</a>
|
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Pages.Emails)" asp-action="Emails">Email server</a>
|
||||||
<a class="nav-link @ServerNavPages.PoliciesNavClass(ViewContext)" asp-action="Policies">Policies</a>
|
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Pages.Policies)" asp-action="Policies">Policies</a>
|
||||||
<a class="nav-link @ServerNavPages.HangfireNavClass(ViewContext)" href="~/hangfire" target="_blank">Hangfire</a>
|
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Pages.Theme)" asp-action="Theme">Theme</a>
|
||||||
|
<a class="nav-link @ViewData.IsActivePage(ServerNavPages.Pages.Hangfire)" href="~/hangfire" target="_blank">Hangfire</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user