From dd35af3c55aa4977c4e0790b0244fd2576cef048 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 7 Oct 2024 21:33:53 +0900 Subject: [PATCH] Use AddUIExtension --- BTCPayServer.Abstractions/Services/UIExtension.cs | 2 ++ BTCPayServer/Extensions.cs | 2 ++ BTCPayServer/Hosting/BTCPayServerServices.cs | 3 +-- .../Plugins/Altcoins/Monero/AltcoinsPlugin.Monero.cs | 6 +++--- BTCPayServer/Plugins/Altcoins/Zcash/AltcoinsPlugin.Zcash.cs | 4 ++-- BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs | 2 +- BTCPayServer/Plugins/PayButton/PayButtonPlugin.cs | 2 +- BTCPayServer/Plugins/PointOfSale/PointOfSalePlugin.cs | 2 +- BTCPayServer/Plugins/Shopify/ShopifyPlugin.cs | 2 +- BTCPayServer/wwwroot/checkout/checkout.js | 2 +- 10 files changed, 15 insertions(+), 12 deletions(-) diff --git a/BTCPayServer.Abstractions/Services/UIExtension.cs b/BTCPayServer.Abstractions/Services/UIExtension.cs index ba06187dd..601b83e50 100644 --- a/BTCPayServer.Abstractions/Services/UIExtension.cs +++ b/BTCPayServer.Abstractions/Services/UIExtension.cs @@ -1,9 +1,11 @@ +using System; using BTCPayServer.Abstractions.Contracts; namespace BTCPayServer.Abstractions.Services { public class UIExtension : IUIExtension { + [Obsolete("Use extension method BTCPayServer.Extensions.AddUIExtension(this IServiceCollection services, string location, string partialViewName) instead")] public UIExtension(string partial, string location) { Partial = partial; diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index 255f43db8..ab6ace52d 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -294,7 +294,9 @@ namespace BTCPayServer public static IServiceCollection AddUIExtension(this IServiceCollection services, string location, string partialViewName) { +#pragma warning disable CS0618 // Type or member is obsolete services.AddSingleton(new UIExtension(partialViewName, location)); +#pragma warning restore CS0618 // Type or member is obsolete return services; } public static IServiceCollection AddReportProvider(this IServiceCollection services) diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index fadb1ce9c..2103eeb50 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -402,8 +402,7 @@ o.GetRequiredService>().ToDictionary(o => o.P services.AddSingleton(); - services.AddSingleton(new UIExtension("LNURL/LightningAddressNav", - "store-integrations-nav")); + services.AddUIExtension("store-integrations-nav", "LNURL/LightningAddressNav"); services.AddSingleton(); services.AddSingleton(); diff --git a/BTCPayServer/Plugins/Altcoins/Monero/AltcoinsPlugin.Monero.cs b/BTCPayServer/Plugins/Altcoins/Monero/AltcoinsPlugin.Monero.cs index 8f95be4a2..af0ce5568 100644 --- a/BTCPayServer/Plugins/Altcoins/Monero/AltcoinsPlugin.Monero.cs +++ b/BTCPayServer/Plugins/Altcoins/Monero/AltcoinsPlugin.Monero.cs @@ -70,9 +70,9 @@ public partial class AltcoinsPlugin services.AddSingleton(provider => (ICheckoutModelExtension)ActivatorUtilities.CreateInstance(provider, typeof(MoneroCheckoutModelExtension), new object[] { network, pmi })); - services.AddSingleton(new UIExtension("Monero/StoreNavMoneroExtension", "store-nav")); - services.AddSingleton(new UIExtension("Monero/StoreWalletsNavMoneroExtension", "store-wallets-nav")); - services.AddSingleton(new UIExtension("Monero/ViewMoneroLikePaymentData", "store-invoices-payments")); + services.AddUIExtension("store-nav", "Monero/StoreNavMoneroExtension"); + services.AddUIExtension("store-wallets-nav", "Monero/StoreWalletsNavMoneroExtension"); + services.AddUIExtension("store-invoices-payments", "Monero/ViewMoneroLikePaymentData"); services.AddSingleton(); } private static MoneroLikeConfiguration ConfigureMoneroLikeConfiguration(IServiceProvider serviceProvider) diff --git a/BTCPayServer/Plugins/Altcoins/Zcash/AltcoinsPlugin.Zcash.cs b/BTCPayServer/Plugins/Altcoins/Zcash/AltcoinsPlugin.Zcash.cs index 4cb3a7dd1..34ddaf263 100644 --- a/BTCPayServer/Plugins/Altcoins/Zcash/AltcoinsPlugin.Zcash.cs +++ b/BTCPayServer/Plugins/Altcoins/Zcash/AltcoinsPlugin.Zcash.cs @@ -61,8 +61,8 @@ public partial class AltcoinsPlugin services.AddSingleton(); services.AddSingleton(provider => provider.GetRequiredService()); - services.AddSingleton(new UIExtension("Zcash/StoreNavZcashExtension", "store-nav")); - services.AddSingleton(new UIExtension("Zcash/ViewZcashLikePaymentData", "store-invoices-payments")); + services.AddUIExtension("store-nav", "Zcash/StoreNavZcashExtension"); + services.AddUIExtension("store-invoices-payments", "Zcash/ViewZcashLikePaymentData"); services.AddSingleton(); } diff --git a/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs b/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs index c41893585..9dd42b491 100644 --- a/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs +++ b/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs @@ -36,7 +36,7 @@ namespace BTCPayServer.Plugins.Crowdfund public override void Execute(IServiceCollection services) { - services.AddSingleton(new UIExtension("Crowdfund/NavExtension", "header-nav")); + services.AddUIExtension("header-nav", "Crowdfund/NavExtension"); services.AddSingleton(); services.AddSingleton(); diff --git a/BTCPayServer/Plugins/PayButton/PayButtonPlugin.cs b/BTCPayServer/Plugins/PayButton/PayButtonPlugin.cs index bb7a2db4c..2b9c50022 100644 --- a/BTCPayServer/Plugins/PayButton/PayButtonPlugin.cs +++ b/BTCPayServer/Plugins/PayButton/PayButtonPlugin.cs @@ -13,7 +13,7 @@ namespace BTCPayServer.Plugins.PayButton public override void Execute(IServiceCollection services) { - services.AddSingleton(new UIExtension("PayButton/NavExtension", "header-nav")); + services.AddUIExtension("header-nav", "PayButton/NavExtension"); base.Execute(services); } } diff --git a/BTCPayServer/Plugins/PointOfSale/PointOfSalePlugin.cs b/BTCPayServer/Plugins/PointOfSale/PointOfSalePlugin.cs index deb8a6b72..ccd9da1e5 100644 --- a/BTCPayServer/Plugins/PointOfSale/PointOfSalePlugin.cs +++ b/BTCPayServer/Plugins/PointOfSale/PointOfSalePlugin.cs @@ -28,7 +28,7 @@ namespace BTCPayServer.Plugins.PointOfSale public override void Execute(IServiceCollection services) { - services.AddSingleton(new UIExtension("PointOfSale/NavExtension", "header-nav")); + services.AddUIExtension("header-nav", "PointOfSale/NavExtension"); services.AddSingleton(); base.Execute(services); } diff --git a/BTCPayServer/Plugins/Shopify/ShopifyPlugin.cs b/BTCPayServer/Plugins/Shopify/ShopifyPlugin.cs index a2cb98d51..6745d81d3 100644 --- a/BTCPayServer/Plugins/Shopify/ShopifyPlugin.cs +++ b/BTCPayServer/Plugins/Shopify/ShopifyPlugin.cs @@ -16,7 +16,7 @@ namespace BTCPayServer.Plugins.Shopify { applicationBuilder.AddSingleton(); applicationBuilder.AddSingleton(provider => provider.GetRequiredService()); - applicationBuilder.AddSingleton(new UIExtension("Shopify/NavExtension", "header-nav")); + applicationBuilder.AddUIExtension("header-nav", "Shopify/NavExtension"); base.Execute(applicationBuilder); } } diff --git a/BTCPayServer/wwwroot/checkout/checkout.js b/BTCPayServer/wwwroot/checkout/checkout.js index 04770cf5d..ebecf41cb 100644 --- a/BTCPayServer/wwwroot/checkout/checkout.js +++ b/BTCPayServer/wwwroot/checkout/checkout.js @@ -172,7 +172,7 @@ function initApp() { : null; }, paymentMethodIds () { - return this.srvModel.availablePaymentMethod.map(function (c) { return c.paymentMethodId }); + return this.srvModel.availablePaymentMethods.map(function (c) { return c.paymentMethodId }); }, paymentMethodComponent() { return this.isPluginPaymentMethod