Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow admin update default rate provider and default currency for stores #5918

Merged
merged 7 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions BTCPayServer/Controllers/UIUserStoresController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using BTCPayServer.Client;
using BTCPayServer.Data;
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Services;
using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Authorization;
Expand All @@ -20,18 +21,21 @@ namespace BTCPayServer.Controllers
public class UIUserStoresController : Controller
{
private readonly StoreRepository _repo;
private readonly SettingsRepository _settingsRepository;
private readonly UserManager<ApplicationUser> _userManager;
private readonly RateFetcher _rateFactory;
public string CreatedStoreId { get; set; }

public UIUserStoresController(
UserManager<ApplicationUser> userManager,
StoreRepository storeRepository,
RateFetcher rateFactory)
RateFetcher rateFactory,
SettingsRepository settingsRepository)
{
_repo = storeRepository;
_userManager = userManager;
_rateFactory = rateFactory;
_settingsRepository = settingsRepository;
}

[HttpGet]
Expand Down Expand Up @@ -62,7 +66,7 @@ public async Task<IActionResult> CreateStore(bool skipWizard)
var vm = new CreateStoreViewModel
{
IsFirstStore = !(stores.Any() || skipWizard),
DefaultCurrency = StoreBlob.StandardDefaultCurrency,
DefaultCurrency = (await _settingsRepository.GetSettingAsync<PoliciesSettings>())?.DefaultCurrency ?? StoreBlob.StandardDefaultCurrency,
Exchanges = GetExchangesSelectList(null)
};

Expand Down
2 changes: 2 additions & 0 deletions BTCPayServer/Services/PoliciesSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public bool EnableNonAdminCreateUserApi

[Display(Name = "Show plugins in pre-release")]
public bool PluginPreReleases { get; set; }
[Display(Name = "Select the Default Currency during Store Creation")]
public string DefaultCurrency { get; set; }

public bool DisableSSHService { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions BTCPayServer/Views/UIServer/Policies.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
</div>

<h4 class="mt-5">Customization</h4>
<div class="form-group mb-3">
<label asp-for="DefaultCurrency" class="form-label"></label>
<input asp-for="DefaultCurrency" placeholder="Default Store Currency" class="form-control" currency-selection />
</div>
<div class="form-group mb-5">
<label asp-for="RootAppId" class="form-label"></label>
<select asp-for="RootAppId" asp-items="@(new SelectList(ViewBag.AppsList, nameof(SelectListItem.Value), nameof(SelectListItem.Text), Model.RootAppId))" class="form-select"></select>
Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer/Views/UIServer/_Nav.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using BTCPayServer.Configuration
@using BTCPayServer.Configuration
@inject BTCPayServerOptions _btcPayServerOptions

<div class="sticky-header mb-l">
Expand Down