From 63dd6a197bbb8be83c481849ea121649fecfe50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Wiktorski?= Date: Thu, 26 Jun 2025 10:23:31 +0200 Subject: [PATCH 1/3] logo fix for opensource --- .env.example | 3 ++- .github/workflows/pages.yml | 1 + entrypoint.sh | 4 ++++ src/components/_App/Navbar/index.tsx | 31 ++++++++++++++++++++++++++-- src/config/index.ts | 5 +++++ src/index.tsx | 1 + 6 files changed, 42 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 968ce637c..44cc3da79 100644 --- a/.env.example +++ b/.env.example @@ -13,4 +13,5 @@ VITE_APP_FIREBASE_MESSAGINGSENDERID= VITE_APP_FIREBASE_APPID= VITE_APP_IOS_APIKEY= VITE_APP_ANDROID_APIKEY= -VITE_APP_PUBLIC_IMG_URL= \ No newline at end of file +VITE_APP_PUBLIC_IMG_URL= +VITE_APP_PUBLIC_IMG_BUCKET_FOLDER= \ No newline at end of file diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index cf80748c6..e3a7cfd2d 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -23,6 +23,7 @@ jobs: # VITE_APP_PUBLIC_MOBILE_DEVICE: false VITE_APP_PUBLIC_URL: https://demo-stage.app.s.wellms.io VITE_APP_PUBLIC_IMG_URL: https://wellms-multidomain-demo-stage.s3.pl-waw.scw.cloud + VITE_APP_PUBLIC_IMG_BUCKET_FOLDER: "" run: | npm i --legacy-peer-deps npm run build diff --git a/entrypoint.sh b/entrypoint.sh index 16f4c36b7..1dd81efcd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,6 +11,8 @@ sed -ie "s~YBUG_ID = null~YBUG_ID=\"$YBUG_ID\"~" /var/www/html/index.html sed -ie "s~BASENAME = null~BASENAME=\"$BASENAME\"~" /var/www/html/index.html sed -ie "s~ROUTING_TYPE = null~ROUTING_TYPE=\"$ROUTING_TYPE\"~" /var/www/html/index.html sed -ie "s~APP_URL = null~APP_URL=\"$APP_URL\"~" /var/www/html/index.html +sed -ie "s~IMG_URL = null~IMG_URL=\"$IMG_URL\"~" /var/www/html/index.html +sed -ie "s~IMG_BUCKET_FOLDER = null~IMG_BUCKET_FOLDER=\"$IMG_BUCKET_FOLDER\"~" /var/www/html/index.html sed -ie "s~APP_FIREBASE_VAPID_KEY = null~APP_FIREBASE_VAPID_KEY=\"$APP_FIREBASE_VAPID_KEY\"~" /var/www/html/index.html sed -ie "s~APP_FIREBASE_APIKEY = null~APP_FIREBASE_APIKEY=\"$APP_FIREBASE_APIKEY\"~" /var/www/html/index.html sed -ie "s~APP_FIREBASE_AUTHDOMAIN = null~APP_FIREBASE_AUTHDOMAIN=\"$APP_FIREBASE_AUTHDOMAIN\"~" /var/www/html/index.html @@ -27,6 +29,8 @@ echo "YBUG_ID= " $YBUG_ID echo "BASENAME= " $BASENAME echo "ROUTING_TYPE= " $ROUTING_TYPE echo "APP_URL= " $APP_URL +echo "IMG_URL=" $IMG_URL +echo "IMG_BUCKET_FOLDER= " $IMG_BUCKET_FOLDER echo "APP_FIREBASE_VAPID_KEY= " $APP_FIREBASE_VAPID_KEY echo "APP_FIREBASE_APIKEY= " $APP_FIREBASE_APIKEY echo "APP_FIREBASE_AUTHDOMAIN= " $APP_FIREBASE_AUTHDOMAIN diff --git a/src/components/_App/Navbar/index.tsx b/src/components/_App/Navbar/index.tsx index 62719dc8a..040af77de 100644 --- a/src/components/_App/Navbar/index.tsx +++ b/src/components/_App/Navbar/index.tsx @@ -27,6 +27,10 @@ import useDeleteAccountModal from "@/hooks/useDeleteAccount"; import DeleteAccountModal from "@/components/Authentication/DeleteAccountModal"; import { isMobilePlatform } from "@/utils/index"; import { metaDataKeys } from "@/utils/meta"; +import { + VITE_APP_PUBLIC_IMG_BUCKET_FOLDER, + VITE_APP_PUBLIC_IMG_URL, +} from "@/config/index"; const StyledHeader = styled.header` width: 100%; @@ -286,6 +290,29 @@ const Navbar = () => { return cart?.value?.items?.length ?? 0; }, [cart]); + const getProperLogoPath = useMemo(() => { + const bucket = VITE_APP_PUBLIC_IMG_BUCKET_FOLDER.replace(/^\/|\/$/g, ""); // e.g. "/wellms" // -> "wellms" + + // Full link, e.g. "https://s3.ca-central-1.amazonaws.com/wellms/avatars/testimg.jpg" + const url = settings.value.global.logo; + + // 1. Extract pathname: "/wellms/avatars/testimg.jpg" + let relativePath = new URL(url).pathname; + + // 2. Remove the bucket prefix + const bucketPrefix = `/${bucket}`; // "/wellms" + if (relativePath.startsWith(bucketPrefix)) { + relativePath = relativePath.slice(bucketPrefix.length); + } + + // 3. Make sure the result begins with one leading slash + if (!relativePath.startsWith("/")) { + relativePath = "/" + relativePath; + } + + return relativePath; + }, [settings.value.global.logo]); + const menuItems = [ { title: ( @@ -373,7 +400,7 @@ const Navbar = () => {
@@ -550,7 +577,7 @@ const Navbar = () => {
diff --git a/src/config/index.ts b/src/config/index.ts index 14280e927..492867383 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -52,3 +52,8 @@ export const VITE_APP_PUBLIC_IMG_URL = window.VITE_APP_PUBLIC_IMG_URL || import.meta.env.VITE_APP_PUBLIC_IMG_URL || null; + +export const VITE_APP_PUBLIC_IMG_BUCKET_FOLDER = + window.VITE_APP_PUBLIC_IMG_BUCKET_FOLDER || + import.meta.env.VITE_APP_PUBLIC_IMG_BUCKET_FOLDER || + ""; diff --git a/src/index.tsx b/src/index.tsx index a5171d869..1a60bc49c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -22,6 +22,7 @@ declare global { VITE_APP_IOS_APIKEY: string; VITE_APP_ANDROID_APIKEY: string; VITE_APP_PUBLIC_IMG_URL: string; + VITE_APP_PUBLIC_IMG_BUCKET_FOLDER: string; } } From 7a24e7ba79bc4e4f6a7afb9cc333d6893cdc2017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Wiktorski?= Date: Thu, 26 Jun 2025 10:23:52 +0200 Subject: [PATCH 2/3] logo fix for opensource --- src/components/_App/Navbar/index.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/_App/Navbar/index.tsx b/src/components/_App/Navbar/index.tsx index 040af77de..c4034e68e 100644 --- a/src/components/_App/Navbar/index.tsx +++ b/src/components/_App/Navbar/index.tsx @@ -27,10 +27,7 @@ import useDeleteAccountModal from "@/hooks/useDeleteAccount"; import DeleteAccountModal from "@/components/Authentication/DeleteAccountModal"; import { isMobilePlatform } from "@/utils/index"; import { metaDataKeys } from "@/utils/meta"; -import { - VITE_APP_PUBLIC_IMG_BUCKET_FOLDER, - VITE_APP_PUBLIC_IMG_URL, -} from "@/config/index"; +import { VITE_APP_PUBLIC_IMG_BUCKET_FOLDER } from "@/config/index"; const StyledHeader = styled.header` width: 100%; From f101e96f957c103aa8ad360de0ce6df39829d239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Wiktorski?= Date: Thu, 26 Jun 2025 10:25:54 +0200 Subject: [PATCH 3/3] logo fix for opensource --- src/components/_App/Navbar/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/_App/Navbar/index.tsx b/src/components/_App/Navbar/index.tsx index c4034e68e..50d37cccd 100644 --- a/src/components/_App/Navbar/index.tsx +++ b/src/components/_App/Navbar/index.tsx @@ -290,7 +290,7 @@ const Navbar = () => { const getProperLogoPath = useMemo(() => { const bucket = VITE_APP_PUBLIC_IMG_BUCKET_FOLDER.replace(/^\/|\/$/g, ""); // e.g. "/wellms" // -> "wellms" - // Full link, e.g. "https://s3.ca-central-1.amazonaws.com/wellms/avatars/testimg.jpg" + // Full link, e.g. "https://randomdomain/somefolder/folder/testimg.jpg" const url = settings.value.global.logo; // 1. Extract pathname: "/wellms/avatars/testimg.jpg"