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

Conversation

dennisreimann
Copy link
Member

@dennisreimann dennisreimann commented Apr 23, 2024

Breaking changes

Public

  • Remove deprecated CustomCSSLink and EmbeddedCSS properties from Payment Request, Pull Payment, Point of Sale and Crowdfund. They are replaced by the unified store branding functionality.

Internal

  • ...FileId properties (which we use in conjunction with file uploads) are replaced with (relative) URLs, which directly reference the file. This was done to allow retrieval and editing via the API. Closes Branding: Change File IDs to full URL #5953.

@pavlenex pavlenex added this to the 2.0.0 milestone May 3, 2024
@NicolasDorier
Copy link
Member

@dennisreimann can you document the breaking changes in the description of this PR?

I will then add it to #5964

dennisreimann added a commit to dennisreimann/btcpayserver that referenced this pull request May 7, 2024
We recently removed the section the anchor links to and we'll remove the links entirely in btcpayserver#5947.

private async Task<string?> GetRelativeFilePath(string fileId)
{
return (await _fileService.GetFileUrl(new Uri("/"), fileId))?.Replace("file://", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return (await _fileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), fileId))?.Replace("file://", "");

@NicolasDorier
Copy link
Member

NicolasDorier commented May 7, 2024

  1. This PR will not work as intended for people using BTCPAY_ROOTPATH other than / (default).
  2. If a reference to a file was made, and then ROOTPATH is changed, all the links will be broken.
  3. It is also lacking a test on the migration.

It isn't something that is easy to fix, as in the migrations, there isn't any access to the Request.GetAbsoluteRootUri().

Ideally, the FileService should just provide relative paths (like ~/blahblah/blahblah.png), and we would just save this in LogoUrl and resolve the full path when the page is viewed. But this isn't how the API of FileService works and refactoring it is a can of worms.

There is I think two things we could consider:

  1. Keeping the ..FileId and removing the migration. If the FileId is set, the the URL is ignored.
  2. Allows the URL to have a special format like fileid:FILE_ID, then resolve it when in the view.

I think 2. is probably better, though the migration is still needed.
For 2., it means that rather than doing <a href="@Model.LogoUrl", you'd need <a href="@UrlResolver.Resolve(Model.LogoUrl)", where UrlResolver is a Scoped Service (you can then just inject the IHttpContextAccessor to get access to the Context.Request.GetAbsoluteRootUri() required to call the FileService)

About the migration: I will check later on if I can't replace it with just a simple postgres query. But a test is needed.

dennisreimann added a commit to dennisreimann/btcpayserver that referenced this pull request May 7, 2024
We recently removed the section the anchor links to and we'll remove the links entirely in btcpayserver#5947.
NicolasDorier pushed a commit that referenced this pull request May 8, 2024
We recently removed the section the anchor links to and we'll remove the links entirely in #5947.
@NicolasDorier
Copy link
Member

Rebased

@NicolasDorier
Copy link
Member

NicolasDorier commented May 8, 2024

@dennisreimann

  1. I rewrote the test to directly insert into DB legacy data and migrate from that, and test all the properties impacted.
  2. I rewrote the migration to be simple SQL queries, so we can remove obsolete properties from our classes, and not fear of memory issues on instances with lot's of stores.
  3. Now, cssUrl, logoUrl accept fileid:ID which allow reference to a file id rather than a URL.

Two things I noticed:

  1. I noticed that paymentSoundUrl can't be changed through the API. Should we add it in this PR?
  2. The crowdfund page doesn't actually use the StoreBranding but the ViewModel does. Can we clean that up?

@NicolasDorier NicolasDorier force-pushed the deprecated-css-options branch 2 times, most recently from 85fd650 to e93372c Compare May 8, 2024 06:58
@dennisreimann
Copy link
Member Author

I noticed that paymentSoundUrl can't be changed through the API. Should we add it in this PR?

Done in c703a4c.

The crowdfund page doesn't actually use the StoreBranding but the ViewModel does. Can we clean that up?

The view uses it here — it gets passed to the LayoutHead partial via the ViewData. I think I initially implemented it like this because the store branding is optional for the layouts and I didn't want to introduce a separate model for it.

@NicolasDorier NicolasDorier merged commit 4c303d3 into btcpayserver:master May 9, 2024
4 checks passed
@dennisreimann dennisreimann deleted the deprecated-css-options branch May 9, 2024 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Branding: Change File IDs to full URL
3 participants