mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Store centric UI: Part 3 (#3224)
* 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>
This commit is contained in:
@@ -10,7 +10,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace BTCPayServer
|
||||
{
|
||||
// Classes here remember users preferences on certain pages and store them in unified blob cookie "UserPreferCookie"
|
||||
// Classes here remember users preferences on certain pages and store them in unified blob cookie "UserPrefsCookie"
|
||||
public static class ControllerBaseExtension
|
||||
{
|
||||
public static T ParseListQuery<T>(this ControllerBase ctrl, T model) where T : BasePagingViewModel
|
||||
@@ -34,7 +34,7 @@ namespace BTCPayServer
|
||||
|
||||
private static T ProcessParse<T>(ControllerBase ctrl, T model, PropertyInfo prop) where T : BasePagingViewModel
|
||||
{
|
||||
var prefCookie = parsePrefCookie(ctrl);
|
||||
var prefCookie = ctrl.HttpContext.GetUserPrefsCookie();
|
||||
|
||||
// If the user enter an empty searchTerm, then the variable will be null and not empty string
|
||||
// but we want searchTerm to be null only if the user is browsing the page via some link
|
||||
@@ -46,7 +46,7 @@ namespace BTCPayServer
|
||||
if (searchTerm is null)
|
||||
{
|
||||
var section = prop.GetValue(prefCookie) as ListQueryDataHolder;
|
||||
if (section != null && !String.IsNullOrEmpty(section.SearchTerm))
|
||||
if (section != null && !string.IsNullOrEmpty(section.SearchTerm))
|
||||
{
|
||||
model.SearchTerm = section.SearchTerm;
|
||||
model.TimezoneOffset = section.TimezoneOffset ?? 0;
|
||||
@@ -60,45 +60,5 @@ namespace BTCPayServer
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private static UserPrefsCookie parsePrefCookie(ControllerBase ctrl)
|
||||
{
|
||||
var prefCookie = new UserPrefsCookie();
|
||||
ctrl.Request.Cookies.TryGetValue(nameof(UserPrefsCookie), out var strPrefCookie);
|
||||
if (!String.IsNullOrEmpty(strPrefCookie))
|
||||
{
|
||||
try
|
||||
{
|
||||
prefCookie = JsonConvert.DeserializeObject<UserPrefsCookie>(strPrefCookie);
|
||||
}
|
||||
catch { /* ignore cookie deserialization failures */ }
|
||||
}
|
||||
|
||||
return prefCookie;
|
||||
}
|
||||
|
||||
class UserPrefsCookie
|
||||
{
|
||||
public ListQueryDataHolder InvoicesQuery { get; set; }
|
||||
|
||||
public ListQueryDataHolder PaymentRequestsQuery { get; set; }
|
||||
public ListQueryDataHolder UsersQuery { get; set; }
|
||||
public ListQueryDataHolder PayoutsQuery { get; set; }
|
||||
public ListQueryDataHolder PullPaymentsQuery { get; set; }
|
||||
}
|
||||
|
||||
class ListQueryDataHolder
|
||||
{
|
||||
public ListQueryDataHolder() { }
|
||||
|
||||
public ListQueryDataHolder(string searchTerm, int? timezoneOffset)
|
||||
{
|
||||
SearchTerm = searchTerm;
|
||||
TimezoneOffset = timezoneOffset;
|
||||
}
|
||||
|
||||
public int? TimezoneOffset { get; set; }
|
||||
public string SearchTerm { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user