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

Branding updates for 2.0 #5947

Merged
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
4 changes: 0 additions & 4 deletions BTCPayServer.Client/Models/CreateAppRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ public class CreatePointOfSaleAppRequest : CreateAppRequest
public string CustomAmountPayButtonText { get; set; } = null;
public string FixedAmountPayButtonText { get; set; } = null;
public string TipText { get; set; } = null;
public string CustomCSSLink { get; set; } = null;
public string NotificationUrl { get; set; } = null;
public string RedirectUrl { get; set; } = null;
public bool? RedirectAutomatically { get; set; } = null;
public bool? Archived { get; set; } = null;
public string FormId { get; set; } = null;
public string EmbeddedCSS { get; set; } = null;
}

public enum CrowdfundResetEvery
Expand All @@ -65,9 +63,7 @@ public class CreateCrowdfundAppRequest : CreateAppRequest
[JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))]
public DateTimeOffset? EndDate { get; set; } = null;
public decimal? TargetAmount { get; set; } = null;
public string CustomCSSLink { get; set; } = null;
public string MainImageUrl { get; set; } = null;
public string EmbeddedCSS { get; set; } = null;
public string NotificationUrl { get; set; } = null;
public string Tagline { get; set; } = null;
public string PerksTemplate { get; set; } = null;
Expand Down
3 changes: 0 additions & 3 deletions BTCPayServer.Client/Models/PaymentRequestBaseData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public class PaymentRequestBaseData
public string Title { get; set; }
public string Description { get; set; }
public string Email { get; set; }

public string EmbeddedCSS { get; set; }
public string CustomCSSLink { get; set; }
public bool AllowCustomPaymentAmounts { get; set; }

[JsonExtensionData]
Expand Down
4 changes: 0 additions & 4 deletions BTCPayServer.Client/Models/PointOfSaleAppData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ public class PointOfSaleAppData : AppDataBase
public string FixedAmountPayButtonText { get; set; }
public string CustomAmountPayButtonText { get; set; }
public string TipText { get; set; }
public string CustomCSSLink { get; set; }
public string NotificationUrl { get; set; }
public string RedirectUrl { get; set; }
public string Description { get; set; }
public string EmbeddedCSS { get; set; }
public bool? RedirectAutomatically { get; set; }
}

Expand All @@ -50,9 +48,7 @@ public class CrowdfundAppData : AppDataBase
[JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))]
public DateTimeOffset? EndDate { get; set; }
public decimal? TargetAmount { get; set; }
public string CustomCSSLink { get; set; }
public string MainImageUrl { get; set; }
public string EmbeddedCSS { get; set; }
public string NotificationUrl { get; set; }
public string Tagline { get; set; }
public object Perks { get; set; }
Expand Down
5 changes: 5 additions & 0 deletions BTCPayServer.Client/Models/StoreBaseData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public abstract class StoreBaseData

public string Website { get; set; }

public string BrandColor { get; set; }
public string LogoUrl { get; set; }
public string CssUrl { get; set; }
public string PaymentSoundUrl { get; set; }

public string SupportUrl { get; set; }

[JsonConverter(typeof(TimeSpanJsonConverter.Seconds))]
Expand Down
61 changes: 61 additions & 0 deletions BTCPayServer.Data/Migrations/20240508015052_fileid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240508015052_fileid")]
public partial class fileid : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("""
UPDATE "Settings"
SET "Value" = jsonb_set(
"Value",
'{LogoUrl}',
to_jsonb('fileid:' || ("Value"->>'LogoFileId'))) - 'LogoFileId'
WHERE "Id" = 'BTCPayServer.Services.ThemeSettings'
AND "Value"->>'LogoFileId' IS NOT NULL;

UPDATE "Settings"
SET "Value" = jsonb_set(
"Value",
'{CustomThemeCssUrl}',
to_jsonb('fileid:' || ("Value"->>'CustomThemeFileId'))) - 'CustomThemeFileId'
WHERE "Id" = 'BTCPayServer.Services.ThemeSettings'
AND "Value"->>'CustomThemeFileId' IS NOT NULL;

UPDATE "Stores"
SET "StoreBlob" = jsonb_set(
"StoreBlob",
'{logoUrl}',
to_jsonb('fileid:' || ("StoreBlob"->>'logoFileId'))) - 'logoFileId'
WHERE "StoreBlob"->>'logoFileId' IS NOT NULL;

UPDATE "Stores"
SET "StoreBlob" = jsonb_set(
"StoreBlob",
'{cssUrl}',
to_jsonb('fileid:' || ("StoreBlob"->>'cssFileId'))) - 'cssFileId'
WHERE "StoreBlob"->>'cssFileId' IS NOT NULL;

UPDATE "Stores"
SET "StoreBlob" = jsonb_set(
"StoreBlob",
'{paymentSoundUrl}',
to_jsonb('fileid:' || ("StoreBlob"->>'soundFileId'))) - 'soundFileId'
WHERE "StoreBlob"->>'soundFileId' IS NOT NULL;
""");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
6 changes: 6 additions & 0 deletions BTCPayServer.Tests/BTCPayServerTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public Uri ServerUri
get;
set;
}
public Uri ServerUriWithIP
{
get;
set;
}

public string MySQL
{
Expand Down Expand Up @@ -164,6 +169,7 @@ public async Task StartAsync()
await File.WriteAllTextAsync(confPath, config.ToString());

ServerUri = new Uri("http://" + HostName + ":" + Port + "/");
ServerUriWithIP = new Uri("http://127.0.0.1:" + Port + "/");
HttpClient = new HttpClient();
HttpClient.BaseAddress = ServerUri;
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
Expand Down
15 changes: 15 additions & 0 deletions BTCPayServer.Tests/GreenfieldAPITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,13 +1365,25 @@ public async Task StoresControllerTests()
//create store
var newStore = await client.CreateStore(new CreateStoreRequest { Name = "A" });
Assert.Equal("A", newStore.Name);

// validate
await AssertValidationError(["CssUrl", "LogoUrl", "BrandColor"], async () =>
await client.UpdateStore(newStore.Id, new UpdateStoreRequest
{
CssUrl = "style.css",
LogoUrl = "logo.svg",
BrandColor = "invalid"
}));

//update store
Assert.Empty(newStore.PaymentMethodCriteria);
await client.GenerateOnChainWallet(newStore.Id, "BTC", new GenerateOnChainWalletRequest());
var updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest
{
Name = "B",
CssUrl = "https://example.org/style.css",
LogoUrl = "https://example.org/logo.svg",
BrandColor = "#003366",
PaymentMethodCriteria = new List<PaymentMethodCriteriaData>
{
new()
Expand All @@ -1384,6 +1396,9 @@ public async Task StoresControllerTests()
}
});
Assert.Equal("B", updatedStore.Name);
Assert.Equal("https://example.org/style.css", updatedStore.CssUrl);
Assert.Equal("https://example.org/logo.svg", updatedStore.LogoUrl);
Assert.Equal("#003366", updatedStore.BrandColor);
var s = (await client.GetStore(newStore.Id));
Assert.Equal("B", s.Name);
var pmc = Assert.Single(s.PaymentMethodCriteria);
Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer.Tests/TestAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public async Task SetNetworkFeeMode(NetworkFeeMode mode)
public async Task ModifyPayment(Action<GeneralSettingsViewModel> modify)
{
var storeController = GetController<UIStoresController>();
var response = storeController.GeneralSettings();
var response = await storeController.GeneralSettings();
GeneralSettingsViewModel settings = (GeneralSettingsViewModel)((ViewResult)response).Model;
modify(settings);
await storeController.GeneralSettings(settings);
Expand Down
6 changes: 2 additions & 4 deletions BTCPayServer.Tests/ThirdPartyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public async Task CanUseAzureBlobStorage()
Assert.IsType<ViewResult>(
await controller.EditAzureBlobStorageStorageProvider(azureBlobStorageConfiguration));


var shouldBeRedirectingToAzureStorageConfigPage =
Assert.IsType<RedirectToActionResult>(await controller.Storage());
Assert.Equal(nameof(StorageProvider), shouldBeRedirectingToAzureStorageConfigPage.ActionName);
Expand All @@ -72,9 +71,8 @@ public async Task CanUseAzureBlobStorage()
await controller.StorageProvider(StorageProvider.AzureBlobStorage.ToString()))
.Model).ConnectionString);



await UnitTest1.CanUploadRemoveFiles(controller);
var fileId = await UnitTest1.CanUploadFile(controller);
await UnitTest1.CanRemoveFile(controller, fileId);
}

[Fact(Skip = "Fail on CI")]
Expand Down