mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
Plugins: Pass the current Model to the Ui extension points
This commit is contained in:
parent
4a6088b6b9
commit
7aa4cd8104
12 changed files with 32 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
|||
@model IEnumerable<string>
|
||||
@model BTCPayServer.Components.UIExtensionPoint.UiExtensionPointViewModel
|
||||
|
||||
@foreach (var partial in Model)
|
||||
@foreach (var partial in Model.Partials)
|
||||
{
|
||||
await Html.RenderPartialAsync(partial);
|
||||
await Html.RenderPartialAsync(partial, Model.Model);
|
||||
}
|
||||
|
|
|
@ -15,9 +15,22 @@ namespace BTCPayServer.Components.UIExtensionPoint
|
|||
_uiExtensions = uiExtensions;
|
||||
}
|
||||
|
||||
public IViewComponentResult Invoke(string location)
|
||||
public IViewComponentResult Invoke(string location, object model)
|
||||
{
|
||||
return View(_uiExtensions.Where(extension => extension.Location.Equals(location, StringComparison.InvariantCultureIgnoreCase)).Select(extension => extension.Partial));
|
||||
return View(new UiExtensionPointViewModel()
|
||||
{
|
||||
Partials = _uiExtensions
|
||||
.Where(extension =>
|
||||
extension.Location.Equals(location, StringComparison.InvariantCultureIgnoreCase))
|
||||
.Select(extension => extension.Partial).ToArray(),
|
||||
Model = model
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class UiExtensionPointViewModel
|
||||
{
|
||||
public string[] Partials { get; set; }
|
||||
public object Model { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,6 +374,6 @@
|
|||
{
|
||||
<partial name="@paymentMethodHandler.ExtensionPartial" model="@Model"/>
|
||||
}
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-end"})
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-end", model = Model})
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
<a id="@ManageNavPages.TwoFactorAuthentication.ToString()" class="nav-link @ViewData.IsActivePage(ManageNavPages.TwoFactorAuthentication)" asp-controller="Manage" asp-action="TwoFactorAuthentication">Two-factor authentication</a>
|
||||
<a id="@ManageNavPages.APIKeys.ToString()" class="nav-link @ViewData.IsActivePage(ManageNavPages.APIKeys)" asp-controller="Manage" asp-action="APIKeys">API Keys</a>
|
||||
<a id="@ManageNavPages.Notifications.ToString()" class="nav-link @ViewData.IsActivePage(ManageNavPages.Notifications)" asp-controller="Manage" asp-action="NotificationSettings">Notifications</a>
|
||||
<vc:ui-extension-point location="user-nav"/>
|
||||
<vc:ui-extension-point location="user-nav" model="@Model"/>
|
||||
</nav>
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
<a asp-controller="Server" id="Server-@ServerNavPages.Logs" class="nav-link @ViewData.IsActivePage(ServerNavPages.Logs)" asp-action="LogsView">Logs</a>
|
||||
<a asp-controller="Server" id="Server-@ServerNavPages.Files" class="nav-link @ViewData.IsActivePage(ServerNavPages.Files)" asp-action="Files">Files</a>
|
||||
<a asp-controller="Server" id="Server-@ServerNavPages.Plugins" class="nav-link @ViewData.IsActivePage(ServerNavPages.Plugins)" asp-action="ListPlugins">Plugins (experimental)</a>
|
||||
<vc:ui-extension-point location="server-nav" />
|
||||
<vc:ui-extension-point location="server-nav" model="@Model"/>
|
||||
</nav>
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-bitcoin-post-content"})
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-bitcoin-post-content", model = Model})
|
||||
</div>
|
||||
@if (Model.ShowRecommendedFee) {
|
||||
<div id="recommended-fee" class="recommended-fee" v-bind:class="{ hide: !srvModel.feeRate }">
|
||||
|
@ -69,7 +69,7 @@
|
|||
<div class="payment-tabs__tab" id="copy-tab" v-on:click="switchTab('copy')" v-bind:class="{ 'active': currentTab == 'copy'}" >
|
||||
<span>{{$t("Copy")}}</span>
|
||||
</div>
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-bitcoin-post-tabs"})
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-bitcoin-post-tabs", model = Model})
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-ethereum-post-content"})
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-ethereum-post-content", model = Model})
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
|||
<div class="payment-tabs__tab" id="copy-tab" v-on:click="switchTab('copy')" v-bind:class="{ 'active': currentTab == 'copy'}" >
|
||||
<span>{{$t("Copy")}}</span>
|
||||
</div>
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-ethereum-post-tabs"})
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-ethereum-post-tabs", model = Model})
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-lightning-post-content"})
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-lightning-post-content", model = Model})
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
|||
<div class="payment-tabs__tab" id="copy-tab" v-on:click="switchTab('copy')" v-bind:class="{ 'active': currentTab == 'copy'}" >
|
||||
<span>{{$t("Copy")}}</span>
|
||||
</div>
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-lightning-post-tabs"})
|
||||
@await Component.InvokeAsync("UiExtensionPoint" , new { location="checkout-lightning-post-tabs", model = Model})
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<li class="nav-item"><a asp-area="" asp-controller="Wallets" asp-action="ListWallets" class="nav-link js-scroll-trigger @ViewData.IsActiveCategory(typeof(WalletsNavPages))" id="Wallets">Wallets</a></li>
|
||||
<li class="nav-item"><a asp-area="" asp-controller="Invoice" asp-action="ListInvoices" class="nav-link js-scroll-trigger @ViewData.IsActiveCategory(typeof(InvoiceNavPages))" id="Invoices">Invoices</a></li>
|
||||
<li class="nav-item"><a asp-area="" asp-controller="PaymentRequest" asp-action="GetPaymentRequests" class="nav-link js-scroll-trigger @ViewData.IsActiveCategory(typeof(PaymentRequestsNavPages))" id="PaymentRequests">Payment Requests</a></li>
|
||||
<vc:ui-extension-point location="header-nav"/>
|
||||
<vc:ui-extension-point location="header-nav" model="@Model"/>
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
|
@ -112,7 +112,7 @@
|
|||
<li class="nav-item"><a asp-area="" asp-controller="Account" asp-action="Register" class="nav-link js-scroll-trigger" id="Register">Register</a></li>
|
||||
}
|
||||
<li class="nav-item"><a asp-area="" asp-controller="Account" asp-action="Login" class="nav-link js-scroll-trigger" id="Login">Log in</a></li>
|
||||
<vc:ui-extension-point location="header-nav"/>
|
||||
<vc:ui-extension-point location="header-nav" model="@Model"/>
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
}
|
||||
|
||||
<ul class="list-group mb-3">
|
||||
<vc:ui-extension-point location="store-integrations-list"></vc:ui-extension-point>
|
||||
<vc:ui-extension-point location="store-integrations-list" model="@Model"></vc:ui-extension-point>
|
||||
</ul>
|
||||
|
||||
<h4 class="mt-5 mb-3">Other Integrations</h4>
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
<a id="@(nameof(StoreNavPages.PayButton))" class="nav-link @ViewData.IsActivePage(StoreNavPages.PayButton)" asp-controller="Stores" asp-action="PayButton" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Pay Button</a>
|
||||
<a id="@(nameof(StoreNavPages.Integrations))" class="nav-link @ViewData.IsActivePage(StoreNavPages.Integrations)" asp-controller="Stores" asp-action="Integrations" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Integrations</a>
|
||||
<a id="@(nameof(StoreNavPages.Webhooks))" class="nav-link @ViewData.IsActivePage(StoreNavPages.Webhooks)" asp-controller="Stores" asp-action="Webhooks" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Webhooks</a>
|
||||
<vc:ui-extension-point location="store-nav" />
|
||||
<vc:ui-extension-point location="store-nav" model="@Model" />
|
||||
</nav>
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
<a class="nav-link @ViewData.IsActivePage(WalletsNavPages.PSBT)" asp-action="WalletPSBT" asp-route-walletId="@Context.GetRouteValue("walletId")">PSBT</a>
|
||||
<a class="nav-link @ViewData.IsActivePage(WalletsNavPages.Settings)" asp-action="WalletSettings" asp-route-walletId="@Context.GetRouteValue("walletId")" id="WalletSettings">Settings</a>
|
||||
}
|
||||
<vc:ui-extension-point location="wallet-nav" />
|
||||
<vc:ui-extension-point location="wallet-nav" model="@Model" />
|
||||
</nav>
|
||||
|
|
Loading…
Add table
Reference in a new issue