Skip to content

Commit 7c6437a

Browse files
rockstardevb0l0k
authored andcommitted
Fixing navigation to server and store pages
1 parent d4a4e5e commit 7c6437a

9 files changed

Lines changed: 24 additions & 27 deletions

File tree

BTCPayServer.Plugins.USDt/USDtPlugin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace BTCPayServer.Plugins.USDt;
2323

2424
public class USDtPlugin : BaseBTCPayServerPlugin
2525
{
26+
public const string PluginNavKey = "USDtPlugin";
2627
public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } =
2728
[
2829
new IBTCPayServerPlugin.PluginDependency { Identifier = nameof(BTCPayServer), Condition = ">=2.0.0" }

BTCPayServer.Plugins.USDt/Views/Shared/EthErc20/ServerNavEthErc20Extension.cshtml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@using BTCPayServer.Abstractions.Extensions
44
@using BTCPayServer.Client
55
@using BTCPayServer.Data
6+
@using BTCPayServer.Plugins.USDt
67
@using BTCPayServer.Plugins.USDt.Configuration
78
@using BTCPayServer.Plugins.USDt.Controllers
89
@using BTCPayServer.Views.Server
@@ -11,16 +12,11 @@
1112
@inject SignInManager<ApplicationUser> SignInManager;
1213
@inject USDtPluginConfiguration USDtPluginConfiguration;
1314
@inject IScopeProvider ScopeProvider
14-
@{
15-
var storeId = ScopeProvider.GetCurrentStoreId();
16-
var isSettingsActive = ViewData.IsCategoryActive(typeof(ServerNavPages)) && !ViewData.IsPageActive([ServerNavPages.Plugins]);
17-
var isActive = !string.IsNullOrEmpty(storeId) && ViewContext.RouteData.Values.TryGetValue("Controller", out var controller) && controller is not null &&
18-
nameof(UIEthErc20LikeServerController).StartsWith(controller.ToString() ?? string.Empty, StringComparison.InvariantCultureIgnoreCase);
19-
}
2015

21-
@if ((isSettingsActive && SignInManager.IsSignedIn(User) && User.IsInRole(Roles.ServerAdmin) && USDtPluginConfiguration.EthereumErc20LikeConfigurationItems.Any()) || isActive)
16+
@if (SignInManager.IsSignedIn(User) && User.IsInRole(Roles.ServerAdmin) && USDtPluginConfiguration.EthereumErc20LikeConfigurationItems.Any())
2217
{
2318
<li class="nav-item nav-item-sub" permission="@Policies.CanModifyServerSettings">
24-
<a asp-controller="UIEthErc20LikeServer" class="nav-link @(isActive ? "active" : string.Empty)" asp-action="GetServerConfig">USDon ETHEREUM</a>
19+
<a asp-controller="UIEthErc20LikeServer" asp-action="GetServerConfig"
20+
class="nav-link @ViewData.ActivePageClass(USDtPlugin.PluginNavKey, typeof(BTCPayServer.Views.Server.ServerNavPages).ToString(), "EthServer")">USDon ETHEREUM</a>
2521
</li>
2622
}

BTCPayServer.Plugins.USDt/Views/Shared/TronUSDtLike/ServerNavTronUSDtExtension.cshtml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@using BTCPayServer.Abstractions.Extensions
44
@using BTCPayServer.Client
55
@using BTCPayServer.Data
6+
@using BTCPayServer.Plugins.USDt
67
@using BTCPayServer.Plugins.USDt.Configuration
78
@using BTCPayServer.Plugins.USDt.Controllers
89
@using BTCPayServer.Views.Server
@@ -11,16 +12,10 @@
1112
@inject SignInManager<ApplicationUser> SignInManager;
1213
@inject USDtPluginConfiguration USDtPluginConfiguration;
1314
@inject IScopeProvider ScopeProvider
14-
@{
15-
var storeId = ScopeProvider.GetCurrentStoreId();
16-
var isSettingsActive = ViewData.IsCategoryActive(typeof(ServerNavPages)) && !ViewData.IsPageActive([ServerNavPages.Plugins]);
17-
var isActive = !string.IsNullOrEmpty(storeId) && ViewContext.RouteData.Values.TryGetValue("Controller", out var controller) && controller is not null &&
18-
nameof(UITronUSDtLikeServerController).StartsWith(controller.ToString() ?? string.Empty, StringComparison.InvariantCultureIgnoreCase);
19-
}
2015

21-
@if ((isSettingsActive && SignInManager.IsSignedIn(User) && User.IsInRole(Roles.ServerAdmin) && USDtPluginConfiguration.TronUSDtLikeConfigurationItems.Any()) || isActive)
16+
@if (SignInManager.IsSignedIn(User) && User.IsInRole(Roles.ServerAdmin) && USDtPluginConfiguration.TronUSDtLikeConfigurationItems.Any())
2217
{
2318
<li class="nav-item nav-item-sub" permission="@Policies.CanModifyServerSettings">
24-
<a asp-controller="UITronUSDtLikeServer" class="nav-link @(isActive ? "active" : string.Empty)" asp-action="GetServerConfig">USDon TRON</a>
19+
<a asp-controller="UITronUSDtLikeServer" asp-action="GetServerConfig" class="nav-link @ViewData.ActivePageClass(USDtPlugin.PluginNavKey, typeof(BTCPayServer.Views.Server.ServerNavPages).ToString(), "TronServer")">USDon TRON</a>
2520
</li>
2621
}

BTCPayServer.Plugins.USDt/Views/UIEthErc20LikeServer/GetServerConfig.cshtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
@using BTCPayServer.Abstractions.Extensions
2+
@using BTCPayServer.Plugins.USDt
3+
@using BTCPayServer.Views.Server
24
@using Microsoft.AspNetCore.Mvc.TagHelpers
35
@model BTCPayServer.Plugins.USDt.Controllers.ViewModels.EthErc20LikeServerConfigViewModel;
46
@{
5-
ViewData.SetActivePage("USD\u20ae on ETHEREUM server settings", "USD\u20ae on ETHEREUM server settings", "USD\u20ae on ETHEREUM server settings");
6-
ViewData["NavPartialName"] = "../UIStores/_Nav";
7+
// Use ServerNavPages category so the Server Settings sub-nav renders
8+
ViewData.SetActivePage(USDtPlugin.PluginNavKey, typeof(ServerNavPages).ToString(), "USD\u20ae on ETHEREUM", "EthServer");
79
}
810

911
<form method="post" enctype="multipart/form-data">

BTCPayServer.Plugins.USDt/Views/UIEthErc20LikeStore/GetStoreEthErc20LikePaymentMethod.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
@using BTCPayServer.Abstractions.Extensions
22
@using BTCPayServer.Abstractions.Models
33
@using BTCPayServer.Client
4+
@using BTCPayServer.Plugins.USDt
5+
@using BTCPayServer.Views.Stores
46
@using Microsoft.AspNetCore.Mvc.TagHelpers
57
@using Microsoft.AspNetCore.Routing
68
@model BTCPayServer.Plugins.USDt.Controllers.ViewModels.EditEthErc20PaymentMethodViewModel;
79

810
@{
911
// ReSharper disable once Razor.LayoutNotResolved
10-
ViewData["NavPartialName"] = "../UIStores/_Nav";
11-
ViewData.SetActivePage("USD\u20ae on ETHEREUM payment settings", "USD\u20ae on ETHEREUM payment settings", "USD\u20ae on ETHEREUM payment settings");
12+
ViewData.SetActivePage(USDtPlugin.PluginNavKey, typeof(StoreNavPages).ToString(), "USD\u20ae on ETHEREUM payment settings", "EthStore");
1213
}
1314
<h3 class="mb-3">USD₮ on ETHEREUM payment settings</h3>
1415
<div class="row">

BTCPayServer.Plugins.USDt/Views/UIEthErc20LikeStore/GetStoreEthErc20LikePaymentMethods.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
@using BTCPayServer.Abstractions.Extensions
2+
@using BTCPayServer.Plugins.USDt
3+
@using BTCPayServer.Views.Stores
24
@using Microsoft.AspNetCore.Mvc.TagHelpers
35
@using Microsoft.AspNetCore.Routing
46
@model BTCPayServer.Plugins.USDt.Controllers.ViewModels.ViewEthErc20StoreOptionsViewModel;
57
@{
68
// ReSharper disable once Razor.LayoutNotResolved
7-
ViewData.SetActivePage("USD\u20ae on ETHEREUM payment settings", "USD\u20ae on ETHEREUM payment settings", "USD\u20ae on ETHEREUM payment settings");
8-
ViewData["NavPartialName"] = "../UIStores/_Nav";
9+
ViewData.SetActivePage(USDtPlugin.PluginNavKey, typeof(StoreNavPages).ToString(), "USD\u20ae on ETHEREUM payment settings", "EthStore");
910
}
1011

1112
<h3 class="mb-3">USD₮ on ETHEREUM payment settings</h3>

BTCPayServer.Plugins.USDt/Views/UITronUSDtLikeServer/GetServerConfig.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
@using BTCPayServer.Abstractions.Extensions
2+
@using BTCPayServer.Plugins.USDt
3+
@using BTCPayServer.Views.Server
24
@using Microsoft.AspNetCore.Mvc.TagHelpers
35
@model BTCPayServer.Plugins.USDt.Controllers.ViewModels.TronUSDtLikeServerConfigViewModel;
46
@{
5-
ViewData.SetActivePage("USD\u20ae on TRON server settings", "USD\u20ae on TRON server settings", "USD\u20ae on TRON server settings");
6-
ViewData["NavPartialName"] = "../UIStores/_Nav";
7+
ViewData.SetActivePage(USDtPlugin.PluginNavKey, typeof(ServerNavPages).ToString(), "USD\u20ae on TRON", "TronServer");
78
}
89

910
<form method="post" enctype="multipart/form-data">

BTCPayServer.Plugins.USDt/Views/UITronUSDtLikeStore/GetStoreTronUSDtLikePaymentMethod.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
@using BTCPayServer.Abstractions.Extensions
22
@using BTCPayServer.Abstractions.Models
33
@using BTCPayServer.Client
4+
@using BTCPayServer.Plugins.USDt
5+
@using BTCPayServer.Views.Stores
46
@using Microsoft.AspNetCore.Mvc.TagHelpers
57
@using Microsoft.AspNetCore.Routing
68
@model BTCPayServer.Plugins.USDt.Controllers.ViewModels.EditTronUSDtPaymentMethodViewModel;
79

810
@{
911
// ReSharper disable once Razor.LayoutNotResolved
10-
ViewData["NavPartialName"] = "../UIStores/_Nav";
11-
ViewData.SetActivePage("USD\u20ae on TRON payment settings", "USD\u20ae on TRON payment settings", "USD\u20ae on TRON payment settings");
12+
ViewData.SetActivePage(USDtPlugin.PluginNavKey, typeof(StoreNavPages).ToString(), "USD\u20ae on TRON payment settings", "TronStore");
1213
}
1314
<h3 class="mb-3">USD₮ on TRON payment settings</h3>
1415
<div class="row">

BTCPayServer.Plugins.USDt/Views/UITronUSDtLikeStore/GetStoreTronUSDtLikePaymentMethods.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
@{
66
// ReSharper disable once Razor.LayoutNotResolved
77
ViewData.SetActivePage("USD\u20ae on TRON payment settings", "USD\u20ae on TRON payment settings", "USD\u20ae on TRON payment settings");
8-
ViewData["NavPartialName"] = "../UIStores/_Nav";
98
}
109

1110
<h3 class="mb-3">USD₮ on TRON payment settings</h3>

0 commit comments

Comments
 (0)