mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
* Set store context in cookie * Fix page id usages in view * Move Pay Button to nav * Move integrations to plugins nav * Store switch links to wallet if present * Test fixes * Nav fixes * Fix altcoin view * Main nav updates * Wallet setttings nav update * Move storeId cookie fallback to cookie auth handler * View fixes * Test fixes * Fix profile check * Rename integrations nav extension point to store-integrations-nav-list * Allow strings for Active page/category for plugins * Make invoice list filter based on store context * Do not set context if we are running authorizer through tag helper * Fix test and unfiltered invoices * Add permission helper for wallet links * Add sanity checks for payment requests and invoices * Store context in home controller * Fix PayjoinViaUI test * Store context for notifications * Minor UI improvements * Store context for userstores and vault controller * Bring back integrations page * Rename notifications nav pages file * Fix user stores controller policies * Controller policy fixes from code review * CookieAuthHandler: Simplify CanViewInvoices case * Revert "Controller policy fixes from code review" This reverts commit 97e8b8379c2f2f373bac15a96632d2c8913ef4bd. * Simplify LayoutSimple * Fix CanViewInvoices condition Co-authored-by: Kukks <evilkukka@gmail.com>
62 lines
2.1 KiB
C#
62 lines
2.1 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Data;
|
|
using BTCPayServer.Services.Stores;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
namespace BTCPayServer.Components.StoreSelector
|
|
{
|
|
public class StoreSelector : ViewComponent
|
|
{
|
|
private readonly StoreRepository _storeRepo;
|
|
private readonly BTCPayNetworkProvider _networkProvider;
|
|
private readonly UserManager<ApplicationUser> _userManager;
|
|
|
|
public StoreSelector(
|
|
StoreRepository storeRepo,
|
|
BTCPayNetworkProvider networkProvider,
|
|
UserManager<ApplicationUser> userManager)
|
|
{
|
|
_storeRepo = storeRepo;
|
|
_userManager = userManager;
|
|
_networkProvider = networkProvider;
|
|
}
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync()
|
|
{
|
|
var userId = _userManager.GetUserId(UserClaimsPrincipal);
|
|
var stores = await _storeRepo.GetStoresByUserId(userId);
|
|
var currentStore = ViewContext.HttpContext.GetStoreData();
|
|
var options = stores
|
|
.Select(store =>
|
|
{
|
|
var cryptoCode = store
|
|
.GetSupportedPaymentMethods(_networkProvider)
|
|
.OfType<DerivationSchemeSettings>()
|
|
.FirstOrDefault()?
|
|
.Network.CryptoCode;
|
|
var walletId = cryptoCode != null ? new WalletId(store.Id, cryptoCode) : null;
|
|
return new StoreSelectorOption
|
|
{
|
|
Text = store.StoreName,
|
|
Value = store.Id,
|
|
Selected = store.Id == currentStore?.Id,
|
|
WalletId = walletId
|
|
};
|
|
})
|
|
.ToList();
|
|
|
|
var vm = new StoreSelectorViewModel
|
|
{
|
|
Options = options,
|
|
CurrentStoreId = currentStore?.Id,
|
|
CurrentDisplayName = currentStore?.StoreName
|
|
};
|
|
|
|
return View(vm);
|
|
}
|
|
}
|
|
}
|