Display and update App Name in settings (#3027)

* Edit and view app name in app settings

Currently the "name" property is not exposed at all in an app's settings/update page, which can result in confusion about which app is being updated, and also a general confusion between the `Title` property and the `Name` property.
This PR gives visibility to the app name in settings, and allows updating of the same.
I also changed the display label for `title` and `name` to make them more distinct and specific.

* Fix tests

* Update AltcoinTests.cs

* Update SeleniumTests.cs

* fix tests

Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
This commit is contained in:
Samuel Adams 2021-10-29 06:29:02 -04:00 committed by GitHub
parent 274be7c1bc
commit 707484709a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 48 additions and 19 deletions

View File

@ -613,7 +613,7 @@ namespace BTCPayServer.Tests
user.RegisterDerivationScheme("LTC");
var apps = user.GetController<AppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp().Result).Model);
vm.Name = "test";
vm.AppName = "test";
vm.SelectedAppType = AppType.PointOfSale.ToString();
Assert.IsType<RedirectToActionResult>(apps.CreateApp(vm).Result);
var appId = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps().Result).Model)

View File

@ -38,8 +38,8 @@ namespace BTCPayServer.Tests
var apps2 = user2.GetController<AppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp().Result).Model);
Assert.NotNull(vm.SelectedAppType);
Assert.Null(vm.Name);
vm.Name = "test";
Assert.Null(vm.AppName);
vm.AppName = "test";
vm.SelectedAppType = AppType.Crowdfund.ToString();
var redirectToAction = Assert.IsType<RedirectToActionResult>(apps.CreateApp(vm).Result);
Assert.Equal(nameof(apps.UpdateCrowdfund), redirectToAction.ActionName);
@ -75,7 +75,7 @@ namespace BTCPayServer.Tests
user.RegisterDerivationScheme("BTC");
var apps = user.GetController<AppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp().Result).Model);
vm.Name = "test";
vm.AppName = "test";
vm.SelectedAppType = AppType.Crowdfund.ToString();
Assert.IsType<RedirectToActionResult>(apps.CreateApp(vm).Result);
var appId = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps().Result).Model)
@ -168,7 +168,7 @@ namespace BTCPayServer.Tests
await user.SetNetworkFeeMode(NetworkFeeMode.Never);
var apps = user.GetController<AppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp().Result).Model);
vm.Name = "test";
vm.AppName = "test";
vm.SelectedAppType = AppType.Crowdfund.ToString();
Assert.IsType<RedirectToActionResult>(apps.CreateApp(vm).Result);
var appId = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps().Result).Model)

View File

@ -29,7 +29,7 @@ namespace BTCPayServer.Tests
user.RegisterDerivationScheme("BTC");
var apps = user.GetController<AppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp().Result).Model);
vm.Name = "test";
vm.AppName = "test";
vm.SelectedAppType = AppType.PointOfSale.ToString();
Assert.IsType<RedirectToActionResult>(apps.CreateApp(vm).Result);
var appId = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps().Result).Model)

View File

@ -524,7 +524,7 @@ namespace BTCPayServer.Tests
s.Driver.FindElement(By.Id("Apps")).Click();
s.Driver.FindElement(By.Id("CreateNewApp")).Click();
s.Driver.FindElement(By.Name("Name")).SendKeys("PoS" + Guid.NewGuid());
s.Driver.FindElement(By.Name("AppName")).SendKeys("PoS" + Guid.NewGuid());
s.Driver.FindElement(By.Id("SelectedAppType")).SendKeys("Point of Sale");
s.Driver.FindElement(By.Id("SelectedStore")).SendKeys(storeName);
s.Driver.FindElement(By.Id("Create")).Click();
@ -565,7 +565,7 @@ namespace BTCPayServer.Tests
s.Driver.FindElement(By.Id("Apps")).Click();
s.Driver.FindElement(By.Id("CreateNewApp")).Click();
s.Driver.FindElement(By.Name("Name")).SendKeys("CF" + Guid.NewGuid());
s.Driver.FindElement(By.Name("AppName")).SendKeys("CF" + Guid.NewGuid());
s.Driver.FindElement(By.Id("SelectedAppType")).SendKeys("Crowdfund");
s.Driver.FindElement(By.Id("SelectedStore")).SendKeys(storeName);
s.Driver.FindElement(By.Id("Create")).Click();

View File

@ -2944,8 +2944,8 @@ namespace BTCPayServer.Tests
var apps2 = user2.GetController<AppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp().Result).Model);
Assert.NotNull(vm.SelectedAppType);
Assert.Null(vm.Name);
vm.Name = "test";
Assert.Null(vm.AppName);
vm.AppName = "test";
vm.SelectedAppType = AppType.PointOfSale.ToString();
var redirectToAction = Assert.IsType<RedirectToActionResult>(apps.CreateApp(vm).Result);
Assert.Equal(nameof(apps.UpdatePointOfSale), redirectToAction.ActionName);

View File

@ -33,6 +33,7 @@ namespace BTCPayServer.Controllers
Title = settings.Title,
StoreId = app.StoreDataId,
StoreName = app.StoreData?.StoreName,
AppName = app.Name,
Enabled = settings.Enabled,
EnforceTargetAmount = settings.EnforceTargetAmount,
StartDate = settings.StartDate,
@ -121,6 +122,7 @@ namespace BTCPayServer.Controllers
return View(vm);
}
app.Name = vm.AppName;
var newSettings = new CrowdfundSettings()
{
Title = vm.Title,

View File

@ -103,6 +103,7 @@ namespace BTCPayServer.Controllers
Id = appId,
StoreId = app.StoreDataId,
StoreName = app.StoreData?.StoreName,
AppName = app.Name,
Title = settings.Title,
DefaultView = settings.DefaultView,
ShowCustomAmount = settings.ShowCustomAmount,
@ -187,6 +188,8 @@ namespace BTCPayServer.Controllers
{
return View(vm);
}
app.Name = vm.AppName;
app.SetSettings(new PointOfSaleSettings
{
Title = vm.Title,

View File

@ -163,7 +163,7 @@ namespace BTCPayServer.Controllers
var appData = new AppData
{
StoreDataId = selectedStore,
Name = vm.Name,
Name = vm.AppName,
AppType = appType.ToString()
};

View File

@ -21,7 +21,7 @@ namespace BTCPayServer.Models.AppViewModels
[Required]
[MaxLength(50)]
[MinLength(1)]
public string Name { get; set; }
public string AppName { get; set; }
[Display(Name = "Store")]
public string SelectedStore { get; set; }

View File

@ -10,9 +10,16 @@ namespace BTCPayServer.Models.AppViewModels
{
public string StoreId { get; set; }
public string StoreName { get; set; }
[Required]
[MaxLength(50)]
[MinLength(1)]
[Display(Name = "App Name")]
public string AppName { get; set; }
[Required]
[MaxLength(30)]
[Display(Name = "Display Title")]
public string Title { get; set; }
public string Tagline { get; set; }

View File

@ -10,9 +10,16 @@ namespace BTCPayServer.Models.AppViewModels
{
public string StoreId { get; set; }
public string StoreName { get; set; }
[Required]
[MaxLength(50)]
[MinLength(1)]
[Display(Name = "App Name")]
public string AppName { get; set; }
[Required]
[MaxLength(30)]
[Display(Name = "Display Title")]
public string Title { get; set; }
[MaxLength(5)]
public string Currency { get; set; }

View File

@ -26,9 +26,9 @@
<select asp-for="SelectedAppType" asp-items="Model.AppTypes" class="form-select"></select>
</div>
<div class="form-group">
<label asp-for="Name" class="form-label" data-required></label>
<input asp-for="Name" class="form-control" required />
<span asp-validation-for="Name" class="text-danger"></span>
<label asp-for="AppName" class="form-label" data-required></label>
<input asp-for="AppName" class="form-control" required />
<span asp-validation-for="AppName" class="text-danger"></span>
</div>
<div class="form-group mt-4">
<input type="submit" value="Create" class="btn btn-primary" id="Create" />

View File

@ -19,7 +19,7 @@
<div class="container">
<partial name="_StatusMessage" />
<h2 class="mb-4">@ViewData["PageTitle"]</h2>
<h2 class="mb-4">@ViewData["PageTitle"] - @Model.AppName</h2>
<form method="post">
<input type="hidden" asp-for="StoreId" />
@ -27,6 +27,11 @@
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label asp-for="AppName" class="form-label" data-required></label>
<input asp-for="AppName" class="form-control" required />
<span asp-validation-for="AppName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Title" class="form-label" data-required></label>
<input asp-for="Title" class="form-control" required />

View File

@ -1,4 +1,4 @@
@using BTCPayServer.Services.Apps
@using BTCPayServer.Services.Apps
@addTagHelper *, BundlerMinifier.TagHelpers
@model UpdatePointOfSaleViewModel
@{
@ -8,14 +8,19 @@
<div class="container">
<partial name="_StatusMessage" />
<h2 class="mb-4">@ViewData["PageTitle"]</h2>
<h2 class="mb-4">@ViewData["PageTitle"] - @Model.AppName</h2>
<form method="post">
<form method="post">
<input type="hidden" asp-for="StoreId" />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label asp-for="AppName" class="form-label" data-required></label>
<input asp-for="AppName" class="form-control" required />
<span asp-validation-for="AppName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Title" class="form-label" data-required></label>
<input asp-for="Title" class="form-control" required />