Refactoring: Allow ViewsRazor extension to be used by plugins

Moves the `ViewsRazor` extension into Abstractions, so that it can be used by plugins.

Separated out of #2701, prerequisite for the LNbank plugin integration.
This commit is contained in:
Dennis Reimann
2021-07-27 20:00:33 +02:00
committed by Andrew Camilleri
parent 68595be323
commit ad8f347989
31 changed files with 48 additions and 25 deletions

View File

@@ -3,7 +3,7 @@ using System.Globalization;
using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace BTCPayServer.Views namespace BTCPayServer.Abstractions.Extensions
{ {
public static class ViewsRazor public static class ViewsRazor
{ {

View File

@@ -3,6 +3,7 @@
@inject ISettingsRepository SettingsRepository @inject ISettingsRepository SettingsRepository
@using BTCPayServer.HostedServices @using BTCPayServer.HostedServices
@using BTCPayServer.Views.Notifications @using BTCPayServer.Views.Notifications
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Abstractions.Contracts @using BTCPayServer.Abstractions.Contracts
@using BTCPayServer.Client @using BTCPayServer.Client
@using BTCPayServer.Services @using BTCPayServer.Services

View File

@@ -1,4 +1,5 @@
using System; using System;
using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Services; using BTCPayServer.Services;
namespace BTCPayServer.Models.ServerViewModels namespace BTCPayServer.Models.ServerViewModels
@@ -23,7 +24,7 @@ namespace BTCPayServer.Models.ServerViewModels
{ {
if (Settings?.LastUpdated is DateTimeOffset date) if (Settings?.LastUpdated is DateTimeOffset date)
{ {
return Views.ViewsRazor.ToTimeAgo(date); return ViewsRazor.ToTimeAgo(date);
} }
return null; return null;
} }

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
using BTCPayServer.Views;
using PullPaymentData = BTCPayServer.Data.PullPaymentData; using PullPaymentData = BTCPayServer.Data.PullPaymentData;
namespace BTCPayServer.Models namespace BTCPayServer.Models

View File

@@ -1,2 +1,3 @@
@using BTCPayServer.Views.Apps @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.Apps
@using BTCPayServer.Models.AppViewModels @using BTCPayServer.Models.AppViewModels

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views
@using BTCPayServer.Views.Apps @using BTCPayServer.Views.Apps
@{ @{
ViewBag.CategoryTitle = "Apps"; ViewBag.CategoryTitle = "Apps";

View File

@@ -1,5 +1,5 @@
@using Microsoft.AspNetCore.Mvc.Rendering @using BTCPayServer.Views.Stores
@using BTCPayServer.Views.Stores @using BTCPayServer.Abstractions.Extensions
@model UpdateCoinSwitchSettingsViewModel @model UpdateCoinSwitchSettingsViewModel
@{ @{
Layout = "../Shared/_NavLayout.cshtml"; Layout = "../Shared/_NavLayout.cshtml";

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores
@using BTCPayServer.Abstractions.Extensions
@model BTCPayServer.Services.Altcoins.Ethereum.UI.EditEthereumPaymentMethodViewModel @model BTCPayServer.Services.Altcoins.Ethereum.UI.EditEthereumPaymentMethodViewModel
@{ @{

View File

@@ -1,5 +1,6 @@
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores
@using BTCPayServer.Abstractions.Extensions
@model BTCPayServer.Services.Altcoins.Ethereum.UI.ViewEthereumStoreOptionsViewModel @model BTCPayServer.Services.Altcoins.Ethereum.UI.ViewEthereumStoreOptionsViewModel
@inject SignInManager<ApplicationUser> SignInManager; @inject SignInManager<ApplicationUser> SignInManager;
@inject BTCPayNetworkProvider BTCPayNetworkProvider; @inject BTCPayNetworkProvider BTCPayNetworkProvider;

View File

@@ -1 +1,2 @@
@using BTCPayServer.Views.Manage @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.Manage

View File

@@ -1,2 +1,3 @@
@using BTCPayServer.Services.Invoices @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Services.Invoices
@using BTCPayServer.Views.Invoice @using BTCPayServer.Views.Invoice

View File

@@ -1,3 +1,4 @@
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views @using BTCPayServer.Views
@using BTCPayServer.Views.Invoice @using BTCPayServer.Views.Invoice
@{ @{

View File

@@ -1 +1,2 @@
@using BTCPayServer.Views.Manage @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.Manage

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views
@using BTCPayServer.Views.Manage @using BTCPayServer.Views.Manage
@{ @{
Layout = "../Shared/_NavLayout.cshtml"; Layout = "../Shared/_NavLayout.cshtml";

View File

@@ -1,5 +1,5 @@
@using BTCPayServer.Controllers
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores
@using BTCPayServer.Abstractions.Extensions
@model BTCPayServer.Services.Altcoins.Monero.UI.MoneroLikeStoreController.MoneroLikePaymentMethodViewModel @model BTCPayServer.Services.Altcoins.Monero.UI.MoneroLikeStoreController.MoneroLikePaymentMethodViewModel
@{ @{

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores
@using BTCPayServer.Abstractions.Extensions
@model BTCPayServer.Services.Altcoins.Monero.UI.MoneroLikeStoreController.MoneroLikePaymentMethodListViewModel @model BTCPayServer.Services.Altcoins.Monero.UI.MoneroLikeStoreController.MoneroLikePaymentMethodListViewModel
@{ @{

View File

@@ -1 +1 @@
 @using BTCPayServer.Abstractions.Extensions

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views
@using BTCPayServer.Views.Notifications @using BTCPayServer.Views.Notifications
@{ @{

View File

@@ -1 +1,2 @@
@using BTCPayServer.Views.PaymentRequest @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.PaymentRequest

View File

@@ -1,3 +1,4 @@
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views @using BTCPayServer.Views
@using BTCPayServer.Views.PaymentRequest @using BTCPayServer.Views.PaymentRequest
@{ @{

View File

@@ -1,2 +1,3 @@
@using BTCPayServer.Views.Server @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.Server
@using BTCPayServer.Models.ServerViewModels @using BTCPayServer.Models.ServerViewModels

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views
@using BTCPayServer.Views.Server @using BTCPayServer.Views.Server
@{ @{
Layout = "../Shared/_NavLayout.cshtml"; Layout = "../Shared/_NavLayout.cshtml";

View File

@@ -1,6 +1,6 @@
@using BTCPayServer.Services.Altcoins.Ethereum.UI
@using BTCPayServer.Views.Server @using BTCPayServer.Views.Server
@using System.Net.Http @using System.Net.Http
@using BTCPayServer.Abstractions.Extensions
@model BTCPayServer.Services.Altcoins.Ethereum.Configuration.EthereumLikeConfiguration @model BTCPayServer.Services.Altcoins.Ethereum.Configuration.EthereumLikeConfiguration
@inject BTCPayNetworkProvider BTCPayNetworkProvider; @inject BTCPayNetworkProvider BTCPayNetworkProvider;
@inject IHttpClientFactory HttpClientFactory; @inject IHttpClientFactory HttpClientFactory;

View File

@@ -6,6 +6,7 @@
@using BTCPayServer.Views.PaymentRequest @using BTCPayServer.Views.PaymentRequest
@using BTCPayServer.Views.Wallets @using BTCPayServer.Views.Wallets
@using BTCPayServer.Abstractions.Contracts @using BTCPayServer.Abstractions.Contracts
@using BTCPayServer.Abstractions.Extensions
@inject SignInManager<ApplicationUser> SignInManager @inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager @inject UserManager<ApplicationUser> UserManager
@inject RoleManager<IdentityRole> RoleManager @inject RoleManager<IdentityRole> RoleManager

View File

@@ -1,13 +1,12 @@
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores
@using BTCPayServer.Abstractions.Extensions
@model BTCPayServer.Plugins.Shopify.Models.ShopifySettings @model BTCPayServer.Plugins.Shopify.Models.ShopifySettings
@{ @{
Layout = "../Shared/_NavLayout.cshtml"; Layout = "../Shared/_NavLayout.cshtml";
ViewData["NavPartialName"] = "../Stores/_Nav"; ViewData["NavPartialName"] = "../Stores/_Nav";
ViewData.SetActivePageAndTitle(StoreNavPages.Integrations, "Integrations"); ViewData.SetActivePageAndTitle(StoreNavPages.Integrations, "Integrations");
var shopifyCredsSet = Model?.IntegratedAt.HasValue is true; var shopifyCredsSet = Model?.IntegratedAt.HasValue is true;
var shopifyUrl = Model?.ShopifyUrl; var shopifyUrl = Model?.ShopifyUrl;
} }

View File

@@ -1,2 +1,3 @@
@using BTCPayServer.Views.Stores @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.Stores
@using BTCPayServer.Models.StoreViewModels @using BTCPayServer.Models.StoreViewModels

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores
@{ @{

View File

@@ -1,2 +1,3 @@
@using BTCPayServer.Views.Stores @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.Stores
@using BTCPayServer.Models.StoreViewModels @using BTCPayServer.Models.StoreViewModels

View File

@@ -1,3 +1,4 @@
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views @using BTCPayServer.Views
@using BTCPayServer.Views.Stores @using BTCPayServer.Views.Stores

View File

@@ -1,3 +1,4 @@
@using BTCPayServer.Views.Wallets @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views.Wallets
@using BTCPayServer.Models.WalletViewModels @using BTCPayServer.Models.WalletViewModels
@addTagHelper *, BundlerMinifier.TagHelpers @addTagHelper *, BundlerMinifier.TagHelpers

View File

@@ -1,4 +1,5 @@
@using BTCPayServer.Views @using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Views
@using BTCPayServer.Views.Wallets @using BTCPayServer.Views.Wallets
@{ @{
ViewBag.CategoryTitle = "Wallets"; ViewBag.CategoryTitle = "Wallets";