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

Setup proxy to convert SVG to PNG #7982

Closed
johnnymetz opened this issue Mar 19, 2024 · 6 comments
Closed

Setup proxy to convert SVG to PNG #7982

johnnymetz opened this issue Mar 19, 2024 · 6 comments
Assignees
Labels

Comments

@johnnymetz
Copy link
Collaborator

User Story

As an end user, I want to convert an SVG to a PNG, so that it can be used as a theme icon.

Motivation

In #7925, we need to convert an SVG to a PNG (see here).

Note this is a temporary workaround until browsers support dynamic SVG icons: w3c/webextensions#462

Acceptance Criteria

  • A user can convert an SVG to a PNG in the Extension

Implementation Notes

@twschiller
Copy link
Contributor

twschiller commented Mar 19, 2024

Can we just have the user upload in the Admin Console, convert it, and then store the PNG on S3? Or is there a reason to do it on the fly given that the icon won't change frequently?

@johnnymetz
Copy link
Collaborator Author

Can we just have the user upload in the Admin Console, convert it, and then store the PNG on S3?

That should work. @grahamlangford mentioned we need the icon to load for unauthenticated users but we can design the backend so that works (e.g. construct the icon URL in Chrome instead of returning the icon from an authenticated PixieBrix endpoint).

How often will this feature be used? I'm wondering if it's better to just require teams to contact PixieBrix support to do this (convert to PNG + upload to S3) manually? Considering we don't need this feature once w3c/webextensions#462 is done.

@fregante
Copy link
Contributor

Considering that https://github.com/GewoonJaap/svg-to-png-cf-worker is already tested and it works, I'd probably say it's the quickest solution, at least until someone finds it and starts spamming it. A rate limiter (via CF page rules) can certainly help.

@twschiller
Copy link
Contributor

twschiller commented Mar 19, 2024

@grahamlangford mentioned we need the icon to load for unauthenticated users but we can design the backend so that works (e.g. construct the icon URL in Chrome instead of returning the icon from an authenticated PixieBrix endpoint).

Don't we return the icon URL via the theme currently?

How often will this feature be used? I'm wondering if it's better to just require teams to contact PixieBrix support to do this (convert to PNG + upload to S3) manually?

It would be whenever we onboard an enterprise customer, or want to demo custom branding to an enterprise customer. @BrandonPxBx this would be good to triage vs. the other self-serve administration efforts. In many cases, the png is already publicly available, we'd just need a way to provide the png URL to the extension

@grahamlangford
Copy link
Collaborator

Don't we return the icon URL via the theme currently?

This is correct, when I was speaking with Johnny earlier, I mistakenly thought we were managing the theme with managedStorage, but we're just checking for a partnerId and organizationId:

export async function getActiveTheme(): Promise<ThemeAssets> {
expectContext("extension");
try {
const client = await getApiClient();
const [
{ partnerId: managedPartnerId, managedOrganizationId },
{ data: meApiResponse },
{ partnerId: settingsPartnerId },
] = await Promise.all([
// Enterprise managed storage, if provided, always takes precedence over the user's theme settings
readManagedStorage(),
client.get<components["schemas"]["Me"]>("/api/me/"),
getSettingsState(),
]);

@twschiller
Copy link
Contributor

Closing - we'll instead do icon upload/hosting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants