From 46c588c5120d5fca1a897c2d6d88a03082ca0477 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 8 Aug 2025 11:50:49 +0530 Subject: [PATCH 01/10] Button --- web/apps/photos/src/components/Sidebar.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 8c9769d0c5..8fdf4c1697 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -51,6 +51,7 @@ import { import { useBaseContext } from "ente-base/context"; import { getLocaleInUse, + pt, setLocaleInUse, supportedLocales, ut, @@ -816,6 +817,26 @@ const Preferences: React.FC = ({ /> )} + + + + + } + onClick={showMapSettings} + /> } label={t("map")} From b099d16a32aa178a178ae4a22bd694db238b58a0 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 8 Aug 2025 13:07:36 +0530 Subject: [PATCH 02/10] Screen outline --- web/apps/photos/src/components/Sidebar.tsx | 91 +++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 8fdf4c1697..a1b799a15f 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -777,6 +777,8 @@ const Preferences: React.FC = ({ onClose, onRootClose, }) => { + const { show: showDomainSettings, props: domainSettingsVisibilityProps } = + useModalVisibility(); const { show: showMapSettings, props: mapSettingsVisibilityProps } = useModalVisibility(); const { @@ -835,7 +837,7 @@ const Preferences: React.FC = ({ } - onClick={showMapSettings} + onClick={showDomainSettings} /> } @@ -857,6 +859,10 @@ const Preferences: React.FC = ({ )} + { ); }; +const DomainSettings: React.FC = ({ + open, + onClose, + onRootClose, +}) => { + // const { showMiniDialog } = useBaseContext(); + + // const { mapEnabled } = useSettingsSnapshot(); + + // const confirmToggle = useCallback( + // () => + // showMiniDialog( + // mapEnabled + // ? confirmDisableMapsDialogAttributes(() => + // updateMapEnabled(false), + // ) + // : confirmEnableMapsDialogAttributes(() => + // updateMapEnabled(true), + // ), + // ), + // [showMiniDialog, mapEnabled], + // ); + + const handleRootClose = () => { + onClose(); + onRootClose(); + }; + + return ( + + + + + + + + + + + + + + + + ); +}; + +interface DomainSectionProps { + title: string; + ordinal: string; +} + +const DomainItem: React.FC> = ({ + title, + ordinal, + children, +}) => ( + + + {title} + + {ordinal} + + + {children} + +); + const MapSettings: React.FC = ({ open, onClose, From 18e7a52848cd927c1908d102379aec5eab54cbcb Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 8 Aug 2025 14:30:00 +0530 Subject: [PATCH 03/10] Sketch 1 --- web/apps/photos/src/components/Sidebar.tsx | 62 ++++++++++++++++++---- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index a1b799a15f..1d7665521f 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -1,3 +1,4 @@ +import { SingleInputForm } from "ente-base/components/SingleInputForm"; import ArchiveOutlinedIcon from "@mui/icons-material/ArchiveOutlined"; import CategoryIcon from "@mui/icons-material/Category"; import ChevronRightIcon from "@mui/icons-material/ChevronRight"; @@ -990,8 +991,9 @@ const DomainSettings: React.FC = ({ // const { mapEnabled } = useSettingsSnapshot(); - // const confirmToggle = useCallback( - // () => + const handleSubmit = useCallback(() => { + console.log("test"); + }, []); // showMiniDialog( // mapEnabled // ? confirmDisableMapsDialogAttributes(() => @@ -1009,24 +1011,62 @@ const DomainSettings: React.FC = ({ onRootClose(); }; + const customDomain = ""; + return ( - + - + + // {`.${extension}`} + // + // ), + }, + }} + /> - - - + + + + On your DNS provider, add a CNAME from your domain to{" "} + my.ente.io + - + - + + Within 1 hour, your public albums will be accessible via + your domain! + + + For more information, see + + {" help "} + + From 440818f1af3be015246660224b0f9958a13e9c2c Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 8 Aug 2025 18:06:10 +0530 Subject: [PATCH 04/10] Read from remote store --- web/apps/photos/src/components/Sidebar.tsx | 55 +++++++++----------- web/packages/new/photos/services/settings.ts | 24 +++++++++ 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 1d7665521f..11562c26c0 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -989,29 +989,35 @@ const DomainSettings: React.FC = ({ }) => { // const { showMiniDialog } = useBaseContext(); - // const { mapEnabled } = useSettingsSnapshot(); + const { customDomain, customDomainCNAME } = useSettingsSnapshot(); + // const handleSubmit = useCallback(async (newName: string) => { + // const newFileName = [newName, extension].filter((x) => !!x).join("."); + // if (newFileName != fileName) { + // await onRename(newFileName); + // } + // onClose(); + // }; const handleSubmit = useCallback(() => { - console.log("test"); + // customDomain + // showMiniDialog( + // mapEnabled + // ? confirmDisableMapsDialogAttributes(() => + // updateMapEnabled(false), + // ) + // : confirmEnableMapsDialogAttributes(() => + // updateMapEnabled(true), + // ), + // ), + // [showMiniDialog, mapEnabled], }, []); - // showMiniDialog( - // mapEnabled - // ? confirmDisableMapsDialogAttributes(() => - // updateMapEnabled(false), - // ) - // : confirmEnableMapsDialogAttributes(() => - // updateMapEnabled(true), - // ), - // ), - // [showMiniDialog, mapEnabled], - // ); const handleRootClose = () => { onClose(); onRootClose(); }; - const customDomain = ""; + // const customDomain = ""; return ( = ({ placeholder={ut("photos.example.org")} initialValue={customDomain} submitButtonColor="accent" - submitButtonTitle={pt("Set")} + submitButtonTitle={ + customDomain ? pt("Update") : pt("Set") + } onSubmit={handleSubmit} - // onCancel={onClose} - slotProps={{ - input: { - // Align the adornment text to the input text. - sx: { alignItems: "baseline" }, - - // endAdornment: extension && ( - // - // {`.${extension}`} - // - // ), - }, - }} /> - + On your DNS provider, add a CNAME from your domain to{" "} - my.ente.io + {customDomainCNAME} diff --git a/web/packages/new/photos/services/settings.ts b/web/packages/new/photos/services/settings.ts index aedda42384..fc988edbdb 100644 --- a/web/packages/new/photos/services/settings.ts +++ b/web/packages/new/photos/services/settings.ts @@ -66,6 +66,24 @@ export interface Settings { * Default: "https://cast.ente.io" */ castURL: string; + + /** + * Set to the domain (host, e.g. "photos.example.org") that the user wishes + * to use for sharing their public albums. + * + * An empty string is treated as `undefined`. + */ + customDomain?: string; + + /** + * The URL we should ask the user to CNAME their {@link customDomain} to + * for wiring up their domain to the public albums app. + * + * See also `apps.custom-domain.cname` in `server/local.yaml`. + * + * Default: "my.ente.io" + */ + customDomainCNAME: string; } const createDefaultSettings = (): Settings => ({ @@ -73,6 +91,7 @@ const createDefaultSettings = (): Settings => ({ mapEnabled: false, cfUploadProxyDisabled: false, castURL: "https://cast.ente.io", + customDomainCNAME: "my.ente.io", }); /** @@ -147,6 +166,8 @@ const FeatureFlags = z.object({ betaUser: z.boolean().nullish().transform(nullToUndefined), mapEnabled: z.boolean().nullish().transform(nullToUndefined), castUrl: z.string().nullish().transform(nullToUndefined), + customDomain: z.string().nullish().transform(nullToUndefined), + customDomainCNAME: z.string().nullish().transform(nullToUndefined), }); type FeatureFlags = z.infer; @@ -158,6 +179,9 @@ const syncSettingsSnapshotWithLocalStorage = () => { settings.mapEnabled = flags?.mapEnabled || false; settings.cfUploadProxyDisabled = savedCFProxyDisabled(); if (flags?.castUrl) settings.castURL = flags.castUrl; + if (flags?.customDomain) settings.customDomain = flags.customDomain; + if (flags?.customDomainCNAME) + settings.customDomainCNAME = flags.customDomainCNAME; setSettingsSnapshot(settings); }; From 3d12812671a887c17a71bada0ad479dd2458a79e Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 8 Aug 2025 19:19:23 +0530 Subject: [PATCH 05/10] Use --- .../Collections/CollectionShare.tsx | 21 ++++++++++++-- web/apps/photos/src/components/Sidebar.tsx | 28 ++----------------- web/packages/new/photos/services/settings.ts | 17 ++++++++++- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx index e22740e1eb..b23778551f 100644 --- a/web/apps/photos/src/components/Collections/CollectionShare.tsx +++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx @@ -58,6 +58,7 @@ import type { import { type CollectionUser } from "ente-media/collection"; import type { RemotePullOpts } from "ente-new/photos/components/gallery"; import { PublicLinkCreated } from "ente-new/photos/components/share/PublicLinkCreated"; +import { useSettingsSnapshot } from "ente-new/photos/components/utils/use-snapshot"; import { avatarTextColor } from "ente-new/photos/services/avatar"; import { createPublicURL, @@ -1105,6 +1106,8 @@ const PublicShare: React.FC = ({ setBlockingLoad, onRemotePull, }) => { + const { customDomain } = useSettingsSnapshot(); + const { show: showPublicLinkCreated, props: publicLinkCreatedVisibilityProps, @@ -1126,11 +1129,15 @@ const PublicShare: React.FC = ({ void appendCollectionKeyToShareURL( publicURL.url, collection.key, - ).then((url) => setResolvedURL(url)); + ).then((url) => + setResolvedURL( + substituteCustomDomainIfNeeded(url, customDomain), + ), + ); } else { setResolvedURL(undefined); } - }, [collection.key, publicURL]); + }, [collection.key, publicURL, customDomain]); const handleCopyLink = () => { if (resolvedURL) void navigator.clipboard.writeText(resolvedURL); @@ -1164,6 +1171,16 @@ const PublicShare: React.FC = ({ ); }; +const substituteCustomDomainIfNeeded = ( + url: string, + customDomain: string | undefined, +) => { + if (!customDomain) return url; + const u = new URL(url); + u.host = customDomain; + return u.href; +}; + type EnablePublicShareOptionsProps = { setPublicURL: (value: PublicURL) => void; onLinkCreated: () => void; diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 11562c26c0..537299588c 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -90,6 +90,7 @@ import { isDevBuildAndUser, pullSettings, updateCFProxyDisabledPreference, + updateCustomDomain, updateMapEnabled, } from "ente-new/photos/services/settings"; import { @@ -987,38 +988,13 @@ const DomainSettings: React.FC = ({ onClose, onRootClose, }) => { - // const { showMiniDialog } = useBaseContext(); - const { customDomain, customDomainCNAME } = useSettingsSnapshot(); - // const handleSubmit = useCallback(async (newName: string) => { - // const newFileName = [newName, extension].filter((x) => !!x).join("."); - // if (newFileName != fileName) { - // await onRename(newFileName); - // } - // onClose(); - // }; - const handleSubmit = useCallback(() => { - // customDomain - // showMiniDialog( - // mapEnabled - // ? confirmDisableMapsDialogAttributes(() => - // updateMapEnabled(false), - // ) - // : confirmEnableMapsDialogAttributes(() => - // updateMapEnabled(true), - // ), - // ), - // [showMiniDialog, mapEnabled], - }, []); - const handleRootClose = () => { onClose(); onRootClose(); }; - // const customDomain = ""; - return ( = ({ submitButtonTitle={ customDomain ? pt("Update") : pt("Set") } - onSubmit={handleSubmit} + onSubmit={updateCustomDomain} /> diff --git a/web/packages/new/photos/services/settings.ts b/web/packages/new/photos/services/settings.ts index fc988edbdb..e09844ce7b 100644 --- a/web/packages/new/photos/services/settings.ts +++ b/web/packages/new/photos/services/settings.ts @@ -8,7 +8,11 @@ import log from "ente-base/log"; import { updateShouldDisableCFUploadProxy } from "ente-gallery/services/upload"; import { nullToUndefined } from "ente-utils/transform"; import { z } from "zod/v4"; -import { fetchFeatureFlags, updateRemoteFlag } from "./remote-store"; +import { + fetchFeatureFlags, + updateRemoteFlag, + updateRemoteValue, +} from "./remote-store"; /** * In-memory flags that tracks various settings. @@ -222,6 +226,17 @@ export const isDevBuildAndUser = () => isDevBuild && isDevUserViaEmail(); const isDevUserViaEmail = () => !!savedPartialLocalUser()?.email?.endsWith("@ente.io"); +/** + * Persist the user's custom domain preference both locally and on remote. + * + * Setting the value to a blank string is equivalent to deleting the custom + * domain value altogether. + */ +export const updateCustomDomain = async (customDomain: string) => { + await updateRemoteValue("customDomain", customDomain); + return pullSettings(); +}; + /** * Persist the user's map enabled preference both locally and on remote. */ From 4c57c6b30f1d7b26ae26175ef11738b8e0bdcec0 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 8 Aug 2025 20:02:22 +0530 Subject: [PATCH 06/10] Tweak --- web/apps/photos/src/components/Sidebar.tsx | 41 +++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 537299588c..18bb82ce5f 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -1,4 +1,3 @@ -import { SingleInputForm } from "ente-base/components/SingleInputForm"; import ArchiveOutlinedIcon from "@mui/icons-material/ArchiveOutlined"; import CategoryIcon from "@mui/icons-material/Category"; import ChevronRightIcon from "@mui/icons-material/ChevronRight"; @@ -36,6 +35,7 @@ import { RowButtonGroupHint, RowSwitch, } from "ente-base/components/RowButton"; +import { SingleInputForm } from "ente-base/components/SingleInputForm"; import { SpacedRow } from "ente-base/components/containers"; import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton"; import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton"; @@ -831,8 +831,25 @@ const Preferences: React.FC = ({ + + @@ -999,28 +1016,36 @@ const DomainSettings: React.FC = ({ - + + + Any domain or subdomain you own + - + On your DNS provider, add a CNAME from your domain to{" "} - {customDomainCNAME} + + {customDomainCNAME} + @@ -1029,7 +1054,7 @@ const DomainSettings: React.FC = ({ Within 1 hour, your public albums will be accessible via your domain! - + For more information, see Date: Tue, 12 Aug 2025 10:44:46 +0530 Subject: [PATCH 07/10] Not required --- web/apps/photos/src/components/Sidebar.tsx | 62 +++++++++++++++++----- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 18bb82ce5f..4acac1929e 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -17,6 +17,7 @@ import { Skeleton, Stack, styled, + TextField, Tooltip, useColorScheme, } from "@mui/material"; @@ -35,10 +36,10 @@ import { RowButtonGroupHint, RowSwitch, } from "ente-base/components/RowButton"; -import { SingleInputForm } from "ente-base/components/SingleInputForm"; import { SpacedRow } from "ente-base/components/containers"; import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton"; import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton"; +import { LoadingButton } from "ente-base/components/mui/LoadingButton"; import { SidebarDrawer, TitledNestedSidebarDrawer, @@ -113,6 +114,7 @@ import { import { usePhotosAppContext } from "ente-new/photos/types/context"; import { initiateEmail, openURL } from "ente-new/photos/utils/web"; import { wait } from "ente-utils/promise"; +import { useFormik } from "formik"; import { t } from "i18next"; import { useRouter } from "next/router"; import React, { @@ -1007,6 +1009,22 @@ const DomainSettings: React.FC = ({ }) => { const { customDomain, customDomainCNAME } = useSettingsSnapshot(); + const formik = useFormik({ + initialValues: { domain: customDomain ?? "" }, + onSubmit: async (values, { setFieldError }) => { + const domain = values.domain; + const setValueFieldError = (message: string) => + setFieldError("domain", message); + + try { + await updateCustomDomain(domain); + } catch (e) { + log.error(`Failed to submit input ${domain}`, e); + setValueFieldError(t("generic_error")); + } + }, + }); + const handleRootClose = () => { onClose(); onRootClose(); @@ -1023,18 +1041,32 @@ const DomainSettings: React.FC = ({ - Any domain or subdomain you own + {pt("Any domain or subdomain you own")} - +
+ + + {customDomain ? pt("Update") : pt("Save")} + +
@@ -1049,7 +1081,7 @@ const DomainSettings: React.FC = ({
- + Within 1 hour, your public albums will be accessible via your domain! @@ -1072,11 +1104,13 @@ const DomainSettings: React.FC = ({ interface DomainSectionProps { title: string; ordinal: string; + isEmoji?: boolean; } const DomainItem: React.FC> = ({ title, ordinal, + isEmoji, children, }) => ( @@ -1084,7 +1118,7 @@ const DomainItem: React.FC> = ({ direction="row" sx={{ alignItems: "center", justifyContent: "space-between" }} > - {title} + {title} Date: Tue, 12 Aug 2025 11:03:37 +0530 Subject: [PATCH 08/10] Handle errors --- web/apps/photos/src/components/Sidebar.tsx | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 4acac1929e..d52cc92578 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -51,6 +51,7 @@ import { type ModalVisibilityProps, } from "ente-base/components/utils/modal"; import { useBaseContext } from "ente-base/context"; +import { isHTTPErrorWithStatus } from "ente-base/http"; import { getLocaleInUse, pt, @@ -1020,7 +1021,13 @@ const DomainSettings: React.FC = ({ await updateCustomDomain(domain); } catch (e) { log.error(`Failed to submit input ${domain}`, e); - setValueFieldError(t("generic_error")); + if (isHTTPErrorWithStatus(e, 400)) { + setValueFieldError(pt("Invalid domain")); + } else if (isHTTPErrorWithStatus(e, 409)) { + setValueFieldError(pt("Domain already linked by a user")); + } else { + setValueFieldError(t("generic_error")); + } } }, }); @@ -1040,9 +1047,6 @@ const DomainSettings: React.FC = ({ > - - {pt("Any domain or subdomain you own")} -
= ({ type={"text"} fullWidth autoFocus={true} - margin="normal" + margin="dense" disabled={formik.isSubmitting} error={!!formik.errors.domain} - helperText={formik.errors.domain ?? " "} + helperText={ + formik.errors.domain ?? + pt("Any domain or subdomain you own") + } label={t("Domain")} placeholder={ut("photos.example.org")} + sx={{ mb: 2 }} /> = ({
- + On your DNS provider, add a CNAME from your domain to{" "} @@ -1080,9 +1088,9 @@ const DomainSettings: React.FC = ({
- + - + Within 1 hour, your public albums will be accessible via your domain! From 95ed8d23de1a630e892f7f9e7859323635e71a14 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 12 Aug 2025 11:30:03 +0530 Subject: [PATCH 09/10] Prep for merge --- web/apps/photos/src/components/Sidebar.tsx | 228 +++++++++++---------- 1 file changed, 121 insertions(+), 107 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index d52cc92578..27f6aca66c 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -824,43 +824,50 @@ const Preferences: React.FC = ({ /> )} - - - - - -
- } - onClick={showDomainSettings} - /> + { + /* TODO: CD */ process.env.NEXT_PUBLIC_ENTE_WIP_CD && ( + + + + + + + } + onClick={showDomainSettings} + /> + ) + } } label={t("map")} @@ -1008,6 +1015,27 @@ const DomainSettings: React.FC = ({ onClose, onRootClose, }) => { + const handleRootClose = () => { + onClose(); + onRootClose(); + }; + + return ( + + + + ); +}; + +// Separate component to reset state on back. +const DomainSettingsContents: React.FC = () => { const { customDomain, customDomainCNAME } = useSettingsSnapshot(); const formik = useFormik({ @@ -1032,80 +1060,66 @@ const DomainSettings: React.FC = ({ }, }); - const handleRootClose = () => { - onClose(); - onRootClose(); - }; + // TODO: CD: help return ( - - - -
- - - {customDomain ? pt("Update") : pt("Save")} - - -
- - - - On your DNS provider, add a CNAME from your domain to{" "} - - {customDomainCNAME} - + + +
+ + + {customDomain ? pt("Update") : pt("Save")} + + +
+ + + + On your DNS provider, add a CNAME from your domain to{" "} + + {customDomainCNAME} - - - - - Within 1 hour, your public albums will be accessible via - your domain! + + + + + + Within 1 hour, your public albums will be accessible via + your domain! + + + For more information, see + + {" help "} - - For more information, see - - {" help "} - - - -
-
+ + + ); }; From 633caa7883686831ffe12f373898f926f4fdb40b Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 12 Aug 2025 12:15:30 +0530 Subject: [PATCH 10/10] Custom albums build for custom domains --- .github/workflows/web-deploy.yml | 12 ++++++++++++ web/apps/photos/src/pages/index.tsx | 9 +++++++-- web/packages/base/origins.ts | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/web-deploy.yml b/.github/workflows/web-deploy.yml index 6c2691ca35..ee6e1d6e7b 100644 --- a/.github/workflows/web-deploy.yml +++ b/.github/workflows/web-deploy.yml @@ -54,6 +54,18 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} command: pages deploy --project-name=ente --commit-dirty=true --branch=deploy/photos web/apps/photos/out + - name: Build custom-albums + run: yarn build:photos + env: + NEXT_PUBLIC_ENTE_ONLY_SERVE_ALBUMS_APP: 1 + + - name: Publish custom-albums + uses: cloudflare/wrangler-action@v3 + with: + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + command: pages deploy --project-name=ente --commit-dirty=true --branch=deploy/custom-albums web/apps/photos/out + - name: Build accounts run: yarn build:accounts diff --git a/web/apps/photos/src/pages/index.tsx b/web/apps/photos/src/pages/index.tsx index d276aad67b..1796318bca 100644 --- a/web/apps/photos/src/pages/index.tsx +++ b/web/apps/photos/src/pages/index.tsx @@ -7,7 +7,11 @@ import { EnteLogo } from "ente-base/components/EnteLogo"; import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator"; import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton"; import { useBaseContext } from "ente-base/context"; -import { albumsAppOrigin, customAPIHost } from "ente-base/origins"; +import { + albumsAppOrigin, + customAPIHost, + shouldOnlyServeAlbumsApp, +} from "ente-base/origins"; import { masterKeyFromSession, updateSessionFromElectronSafeStorageIfNeeded, @@ -41,7 +45,8 @@ const Page: React.FC = () => { const albumsURL = new URL(albumsAppOrigin()); currentURL.pathname = router.pathname; if ( - currentURL.host == albumsURL.host && + (shouldOnlyServeAlbumsApp || + currentURL.host == albumsURL.host) && currentURL.pathname != "/shared-albums" ) { const end = currentURL.hash.lastIndexOf("&"); diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.ts index 8e1ef1ddac..e6c8b89ebd 100644 --- a/web/packages/base/origins.ts +++ b/web/packages/base/origins.ts @@ -97,3 +97,9 @@ export const isCustomAlbumsAppOrigin = */ export const albumsAppOrigin = () => process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT ?? "https://albums.ente.io"; + +/** + * Return true if this build is meant to only serve public albums. + */ +export const shouldOnlyServeAlbumsApp = + !!process.env.NEXT_PUBLIC_ENTE_ONLY_SERVE_ALBUMS_APP;