Plugins can now build apps (#4608)

* Plugins can now build apps

* fix tests

* fixup

* pluginize existing apps

* Test fixes part 1

* Test fixes part 2

* Fix Crowdfund namespace

* Syntax

* More namespace fixes

* Markup

* Test fix

* upstream fixes

* Add plugin icon

* Fix nullable build warnings

* allow pre popualting app creation

* Fixes after merge

* Make link methods async

* Use AppData as parameter for ConfigureLink

* GetApps by AppType

* Use ConfigureLink on dashboard

* Rename method

* Add properties to indicate stats support

* Property updates

* Test fixes

* Clean up imports

* Fixes after merge

---------

Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
This commit is contained in:
Andrew Camilleri
2023-03-17 03:56:32 +01:00
committed by GitHub
parent a671632fde
commit f74ea14d8b
42 changed files with 899 additions and 652 deletions

View File

@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using BTCPayServer.Data;
using BTCPayServer.Plugins.PointOfSale;
using BTCPayServer.Services.Apps;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -11,17 +10,16 @@ namespace BTCPayServer.Models.AppViewModels
{
public CreateAppViewModel()
{
SetApps();
}
class Format
public CreateAppViewModel(AppService appService)
{
public string Name { get; set; }
public string Value { get; set; }
SetApps(appService);
}
[Required]
[MaxLength(50)]
[MinLength(1)]
[Display(Name = "App Name")]
public string AppName { get; set; }
@@ -33,16 +31,14 @@ namespace BTCPayServer.Models.AppViewModels
public SelectList AppTypes { get; set; }
void SetApps()
private void SetApps(AppService appService)
{
var defaultAppType = AppType.PointOfSale.ToString();
var choices = typeof(AppType).GetEnumNames().Select(o => new Format
{
Name = typeof(AppType).DisplayName(o),
Value = o
}).ToArray();
var defaultAppType = PointOfSaleApp.AppType;
var choices = appService.GetAvailableAppTypes().Select(pair =>
new SelectListItem(pair.Value, pair.Key, pair.Key == defaultAppType));
var chosen = choices.FirstOrDefault(f => f.Value == defaultAppType) ?? choices.FirstOrDefault();
AppTypes = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
AppTypes = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Text), chosen);
SelectedAppType = chosen.Value;
}