mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-09 05:14:31 +01:00
* Update layout structure and header * Implement store selector * Simplify homepage * Update layout * Use dropdown for store selector * Hide global nav in store context * Horizontal section nav * Remove outer section and container from content views * Update nav * Set store context for invoice and payment request lists * Test fixes * Persist menu collapse state on client-side * MainNav as view component * Update app routes to incorporate store context * Test fixes * Display ticker for altcoins build only * Plugins nav * Incorporate category for active page as well * Update invoice icon * Add apps list to nav * Add store context to app type controllers * Incorporate id for active page as well * Test fixes * AppsController cleanup * Nav: Display only apps for the current store * Remove leftover from merge * Nav styles optimization * Left-align content container * Increase sidebar padding on desktop * Use min-width for store selector menu * Store settings nav update * Update app and payment request routes * Test fixes * Refactor MainNav component to use StoresController * Set store context for invoice actions * Cleanups * Remove CurrentStore checks The response will be "Access denied" in case the CookieAuthorizationHandler cannot resolve the store. * Remove unnecessary store context setters * Test fix
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Controllers;
|
|
using BTCPayServer.Data;
|
|
using BTCPayServer.Models.StoreViewModels;
|
|
using BTCPayServer.Payments;
|
|
using BTCPayServer.Payments.Lightning;
|
|
using BTCPayServer.Services.Apps;
|
|
using BTCPayServer.Services.Invoices;
|
|
using BTCPayServer.Services.Stores;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
using NBitcoin;
|
|
using NBitcoin.Secp256k1;
|
|
|
|
namespace BTCPayServer.Components.MainNav
|
|
{
|
|
public class MainNav : ViewComponent
|
|
{
|
|
private const string RootName = "Global";
|
|
private readonly AppService _appService;
|
|
private readonly StoreRepository _storeRepo;
|
|
private readonly StoresController _storesController;
|
|
private readonly BTCPayNetworkProvider _networkProvider;
|
|
private readonly UserManager<ApplicationUser> _userManager;
|
|
private readonly PaymentMethodHandlerDictionary _paymentMethodHandlerDictionary;
|
|
|
|
public MainNav(
|
|
AppService appService,
|
|
StoreRepository storeRepo,
|
|
StoresController storesController,
|
|
BTCPayNetworkProvider networkProvider,
|
|
UserManager<ApplicationUser> userManager,
|
|
PaymentMethodHandlerDictionary paymentMethodHandlerDictionary)
|
|
{
|
|
_storeRepo = storeRepo;
|
|
_appService = appService;
|
|
_userManager = userManager;
|
|
_networkProvider = networkProvider;
|
|
_storesController = storesController;
|
|
_paymentMethodHandlerDictionary = paymentMethodHandlerDictionary;
|
|
}
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync()
|
|
{
|
|
var store = ViewContext.HttpContext.GetStoreData();
|
|
var vm = new MainNavViewModel { Store = store };
|
|
#if ALTCOINS
|
|
vm.AltcoinsBuild = true;
|
|
#endif
|
|
if (store != null)
|
|
{
|
|
var storeBlob = store.GetStoreBlob();
|
|
|
|
// Wallets
|
|
_storesController.AddPaymentMethods(store, storeBlob,
|
|
out var derivationSchemes, out var lightningNodes);
|
|
vm.DerivationSchemes = derivationSchemes;
|
|
vm.LightningNodes = lightningNodes;
|
|
|
|
// Apps
|
|
var apps = await _appService.GetAllApps(UserId, false, store.Id);
|
|
vm.Apps = apps.Select(a => new StoreApp
|
|
{
|
|
Id = a.Id,
|
|
AppName = a.AppName,
|
|
AppType = a.AppType,
|
|
IsOwner = a.IsOwner
|
|
}).ToList();
|
|
}
|
|
|
|
return View(vm);
|
|
}
|
|
|
|
private string UserId => _userManager.GetUserId(HttpContext.User);
|
|
}
|
|
}
|