π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(searchBar):adding-functionality-on-click
Aswin Asok8b077356abfc
diff --git a/staged-changes.md b/staged-changes.mdnew file mode 100644index 0000000000..a90a6da710--- /dev/null+++ b/staged-changes.md@@ -0,0 +1,191 @@+## Staged code changes (detailed)++### Flow: selecting a sidebar search suggestion in `web/packages/new/photos/components/SearchBar.tsx`+1) The search option emitted by `SearchBar` contains a `suggestion` object that includes `type`. For `type === "sidebarAction"`, the handler in `web/apps/photos/src/pages/gallery.tsx` now:+ - Reads `suggestion.actionID` (a `SidebarActionID`) and stores it in local state `pendingSidebarAction`.+ - Immediately opens the sidebar (`showSidebar()`), so the action can run in the sidebar UI.+ - Exits search mode unless the caller opted out via `options?.shouldExitSearchMode`.+2) `Gallery.tsx` renders `Sidebar` with `pendingAction={pendingSidebarAction}` and an `onActionHandled` callback that clears the pending action once the sidebar confirms it processed it.++Data flow (search β gallery β sidebar):+```+SearchBar (selects suggestion.type === "sidebarAction")+ |+ v+Gallery handleSearchSelect+ - setPendingSidebarAction(actionID)+ - showSidebar()+ - exitSearchMode? (optional)+ |+ v+<Sidebar pendingAction=... onActionHandled=clear>+```++- Handler that captures the sidebar action and opens the drawer (`web/apps/photos/src/pages/gallery.tsx:783-817`):+```ts+const handleSelectSearchOption = (searchOption, options) => {+ if (searchOption) {+ const type = searchOption.suggestion.type;+ if (type == "sidebarAction") {+ setPendingSidebarAction(searchOption.suggestion.actionID);+ showSidebar();+ const shouldExitSearchMode = options?.shouldExitSearchMode ?? true;+ dispatch({ type: "exitSearch", shouldExitSearchMode });+ }+ // ...other cases omitted+ } else {+ dispatch({ type: "exitSearch", shouldExitSearchMode });+ }+};+```++### Mapping action IDs to real UI behavior+- `web/packages/new/photos/services/search/sidebar-search-registry.ts` now exports:+ - `SidebarActionContext`: bundles all callbacks the sidebar needs (close sidebar, open collection summaries including pseudo IDs for uncategorized/archive/hidden/trash, show Account/Preferences/Help drawers, show Export, logout, route to deduplicate, show Watch Folders, and setters to queue nested drawer actions).+ - `performSidebarAction(actionID, ctx)`: a single dispatcher that translates every `SidebarActionID` into concrete UI work using the supplied context:+ - Shortcuts: call `onShowCollectionSummary` with the correct pseudo ID (uncategorized/archive/hidden/trash), then close the sidebar.+ - Utility: open account/preferences/help drawers, trigger export, logout, watch folders, or navigate to /duplicates.+ - Account/Preferences/Help sub-actions: set the relevant pending action state (e.g., `account.recoveryKey`, `preferences.customDomains`, `help.viewLogs`), open the corresponding nested drawer, and return.+ - This consolidates action routing logic in one place so search-triggered sidebar actions reuse the same behavior as clicking buttons inside the sidebar.++Dispatcher snippet (`web/packages/new/photos/services/search/sidebar-search-registry.ts:251-331`):+```ts+export const performSidebarAction = async (actionID, ctx) => {+ switch (actionID) {+ case "shortcuts.uncategorized":+ return ctx.onShowCollectionSummary(ctx.pseudoIDs.uncategorized, false)+ .then(() => ctx.onClose());+ case "utility.export":+ ctx.onShowExport();+ ctx.onClose();+ return Promise.resolve();+ case "account.recoveryKey":+ case "account.deleteAccount":+ ctx.setPendingAccountAction(actionID);+ ctx.showAccount();+ return Promise.resolve();+ case "preferences.customDomains":+ case "preferences.mlSearch":+ ctx.setPendingPreferencesAction(actionID);+ ctx.showPreferences();+ return Promise.resolve();+ case "help.viewLogs":+ case "help.testUpload":+ ctx.setPendingHelpAction(actionID);+ ctx.showHelp();+ return Promise.resolve();+ // ...other switch cases cover archive/hidden/trash/deduplicate/logout/support/etc.+ }+};+```++### How `Sidebar` orchestrates the pending action+- `web/apps/photos/src/components/Sidebar.tsx` now accepts `pendingAction`/`onActionHandled` props and wires them to the registry helper:+ - On render/update, a `useEffect` detects `pendingAction` and calls `performSidebarAction(pendingAction, ctx)` where `ctx` supplies router helpers, modal openers, export/logout hooks, pseudo collection IDs, and setters for nested drawer pending actions. Once the promise settles, it invokes `onActionHandled` to clear the pending ID in the page.+ - The sidebar keeps internal pending states for nested drawers (`pendingAccountAction`, `pendingPreferencesAction`, `pendingHelpAction`). When `performSidebarAction` receives sub-action IDs, it sets these and opens the appropriate drawer.+- Each nested drawer executes its queued action as soon as it is visible:+ - `Account`: on open, switch on `pendingAction` to open Recovery Key / Two-factor / Delete Account modals, push change-password/change-email routes, or launch Passkeys; then call `onActionHandled`.+ - `Preferences`: on open, switch on `pendingAction` to open ML Search, Custom Domains, Map, or Advanced settings; then `onActionHandled`.+ - `Help`: on open, switch on `pendingAction` to open Help Center, Blog, Request Feature, Support email, View Logs (with confirmation), or test upload (dev only); then `onActionHandled`.++Data flow (Sidebar dispatch + nested drawers):+```+Sidebar (pendingAction present)+ |+ v+performSidebarAction(actionID, ctx)+ |-- if shortcut/utility: run action immediately (show collection, export, logout, etc.)+ |+ |-- if nested action:+ sets pendingAccountAction / pendingPreferencesAction / pendingHelpAction+ opens corresponding drawer+ |+ v+ Nested drawer useEffect(on open)+ -> switch(pendingAction) -> run target task+ -> onActionHandled() to clear local pending+ |+ v+Sidebar onActionHandled() -> Gallery clears pendingSidebarAction+```++Sidebar mounting the dispatcher (`web/apps/photos/src/components/Sidebar.tsx:287-333`):+```ts+const performSidebarAction = useCallback(+ async (actionID: SidebarActionID) =>+ performSidebarRegistryAction(actionID, {+ onClose,+ onShowCollectionSummary: showCollectionSummaryWithWorkarounds,+ showAccount,+ showPreferences,+ showHelp,+ onShowExport,+ onLogout: handleLogout,+ onRouteToDeduplicate: () => router.push("/duplicates"),+ onShowWatchFolder: handleOpenWatchFolder,+ pseudoIDs: { uncategorized, archive, hidden, trash },+ setPendingAccountAction: (a) => setPendingAccountAction(a as AccountAction | undefined),+ setPendingPreferencesAction: (a) => setPendingPreferencesAction(a as PreferencesAction | undefined),+ setPendingHelpAction: (a) => setPendingHelpAction(a as HelpAction | undefined),+ } as SidebarActionContext),+ [...deps],+);++useEffect(() => {+ if (!pendingAction) return;+ void performSidebarAction(pendingAction).finally(() =>+ onActionHandled?.(pendingAction),+ );+}, [pendingAction, performSidebarAction, onActionHandled]);+```++Nested drawer execution snippets:+- Account (`web/apps/photos/src/components/Sidebar.tsx:912-935`):+```ts+useEffect(() => {+ if (!open || !pendingAction) return;+ switch (pendingAction) {+ case "account.recoveryKey": showRecoveryKey(); break;+ case "account.twoFactor": showTwoFactor(); break;+ case "account.passkeys": void handlePasskeys(); break;+ case "account.changePassword": handleChangePassword(); break;+ case "account.changeEmail": handleChangeEmail(); break;+ case "account.deleteAccount": showDeleteAccount(); break;+ }+ onActionHandled?.();+}, [open, pendingAction, ...]);+```+- Preferences (`web/apps/photos/src/components/Sidebar.tsx:1038-1059`):+```ts+useEffect(() => {+ if (!open || !pendingAction) return;+ switch (pendingAction) {+ case "preferences.customDomains": showDomainSettings(); break;+ case "preferences.map": showMapSettings(); break;+ case "preferences.advanced": showAdvancedSettings(); break;+ case "preferences.mlSearch": showMLSettings(); break;+ // other preference IDs are no-ops; UI already on the page+ }+ onActionHandled?.();+}, [open, pendingAction, ...]);+```+- Help (`web/apps/photos/src/components/Sidebar.tsx:1600-1625`):+```ts+useEffect(() => {+ if (!open || !pendingAction) return;+ switch (pendingAction) {+ case "help.helpCenter": handleHelp(); break;+ case "help.blog": handleBlog(); break;+ case "help.requestFeature": handleRequestFeature(); break;+ case "help.support": handleSupport(); break;+ case "help.viewLogs": confirmViewLogs(); break;+ case "help.testUpload":+ if (isDevBuildAndUser()) { void testUpload(); }+ break;+ }+ onActionHandled?.();+}, [open, pendingAction, ...]);+```++### Net result+- Selecting a sidebar-oriented suggestion in `SearchBar` now drives a deterministic flow: capture action ID in `Gallery` β open sidebar β `Sidebar` delegates to `performSidebarAction` β action either triggers immediately (e.g., Export, Logout, show pseudo collections) or queues a nested drawer operation that runs as soon as the drawer opens. All pending flags are cleared after execution so repeated actions behave cleanly.diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsxindex 2ae9ac8127..fdf5445fa9 100644--- a/web/apps/photos/src/components/Sidebar.tsx+++ b/web/apps/photos/src/components/Sidebar.tsx@@ -84,6 +84,11 @@ import {} from "ente-new/photos/services/collection-summary";import exportService from "ente-new/photos/services/export";import { isMLSupported } from "ente-new/photos/services/ml";+import {+ performSidebarAction as performSidebarRegistryAction,+ type SidebarActionContext,+} from "ente-new/photos/services/search/sidebar-search-registry";+import type { SidebarActionID } from "ente-new/photos/services/search/types";import {isDevBuildAndUser,pullSettings,@@ -138,6 +143,16 @@ type SidebarProps = ModalVisibilityProps & {* activates the "Uncategorized" section shortcut.*/uncategorizedCollectionSummaryID: number;++ /**+ * Option search-triggered sidebar action to perform+ */+ pendingAction?: SidebarActionID;++ /**+ * Called after a pending sidebar action has been handled+ */+ onActionHandled?: (actionID: SidebarActionID) => void;/*** Called when the plan selection modal should be shown.*/@@ -176,38 +191,195 @@ type SidebarProps = ModalVisibilityProps & {onAuthenticateUser: () => Promise<void>;};+type AccountAction = Extract<+ SidebarActionID,+ | "account.recoveryKey"+ | "account.twoFactor"+ | "account.passkeys"+ | "account.changePassword"+ | "account.changeEmail"+ | "account.deleteAccount"+>;++type PreferencesAction = Extract<+ SidebarActionID,+ | "preferences.language"+ | "preferences.theme"+ | "preferences.customDomains"+ | "preferences.map"+ | "preferences.advanced"+ | "preferences.mlSearch"+ | "preferences.streamableVideos"+>;++type HelpAction = Extract<+ SidebarActionID,+ | "help.helpCenter"+ | "help.blog"+ | "help.requestFeature"+ | "help.support"+ | "help.viewLogs"+ | "help.testUpload"+>;+export const Sidebar: React.FC<SidebarProps> = ({open,onClose,normalCollectionSummaries,uncategorizedCollectionSummaryID,+ pendingAction,+ onActionHandled,onShowPlanSelector,onShowCollectionSummary,onShowExport,onAuthenticateUser,-}) => (- <RootSidebarDrawer open={open} onClose={onClose}>- <HeaderSection onCloseSidebar={onClose} />- <UserDetailsSection sidebarOpen={open} {...{ onShowPlanSelector }} />- <Stack sx={{ gap: 0.5, mb: 3 }}>- <ShortcutSection- onCloseSidebar={onClose}- {...{- normalCollectionSummaries,- uncategorizedCollectionSummaryID,- onShowCollectionSummary,- }}- />- <UtilitySection- onCloseSidebar={onClose}- {...{ onShowExport, onAuthenticateUser }}+}) => {+ const router = useRouter();+ const { show: showHelp, props: helpVisibilityProps } = useModalVisibility();+ const { show: showAccount, props: accountVisibilityProps } =+ useModalVisibility();+ const { show: showPreferences, props: preferencesVisibilityProps } =+ useModalVisibility();+ const { watchFolderView, setWatchFolderView } = usePhotosAppContext();+ const { showMiniDialog, logout } = useBaseContext();++ const [pendingAccountAction, setPendingAccountAction] =+ useState<AccountAction>();+ const [pendingPreferencesAction, setPendingPreferencesAction] =+ useState<PreferencesAction>();+ const [pendingHelpAction, setPendingHelpAction] = useState<HelpAction>();++ const handleLogout = useCallback(+ () =>+ showMiniDialog({+ message: t("logout_message"),+ continue: {+ text: t("logout"),+ color: "critical",+ action: logout,+ },+ buttonDirection: "row",+ }),+ [logout, showMiniDialog],+ );++ const handleOpenWatchFolder = useCallback(+ () => setWatchFolderView(true),+ [setWatchFolderView],+ );++ const handleCloseWatchFolder = useCallback(+ () => setWatchFolderView(false),+ [setWatchFolderView],+ );++ const showCollectionSummaryWithWorkarounds = useCallback(+ (collectionSummaryID: number, isHidden?: boolean) => {+ const action = onShowCollectionSummary(+ collectionSummaryID,+ isHidden,+ );+ return isHidden ? action.then(() => wait(10)) : action;+ },+ [onShowCollectionSummary],+ );++ const performSidebarAction = useCallback(+ async (actionID: SidebarActionID) =>+ performSidebarRegistryAction(actionID, {+ onClose,+ onShowCollectionSummary: showCollectionSummaryWithWorkarounds,+ showAccount,+ showPreferences,+ showHelp,+ onShowExport,+ onLogout: handleLogout,+ onRouteToDeduplicate: () => router.push("/duplicates"),+ onShowWatchFolder: handleOpenWatchFolder,+ pseudoIDs: {+ uncategorized: uncategorizedCollectionSummaryID,+ archive: PseudoCollectionID.archiveItems,+ hidden: PseudoCollectionID.hiddenItems,+ trash: PseudoCollectionID.trash,+ },+ setPendingAccountAction: (a) =>+ setPendingAccountAction(a as AccountAction | undefined),+ setPendingPreferencesAction: (a) =>+ setPendingPreferencesAction(+ a as PreferencesAction | undefined,+ ),+ setPendingHelpAction: (a) =>+ setPendingHelpAction(a as HelpAction | undefined),+ } as SidebarActionContext),+ [+ handleLogout,+ handleOpenWatchFolder,+ onClose,+ showCollectionSummaryWithWorkarounds,+ onShowExport,+ router,+ showAccount,+ showHelp,+ showPreferences,+ uncategorizedCollectionSummaryID,+ ],+ );++ useEffect(() => {+ if (!pendingAction) return;+ void performSidebarAction(pendingAction).finally(() =>+ onActionHandled?.(pendingAction),+ );+ }, [pendingAction, performSidebarAction, onActionHandled]);++ return (+ <RootSidebarDrawer open={open} onClose={onClose}>+ <HeaderSection onCloseSidebar={onClose} />+ <UserDetailsSection+ sidebarOpen={open}+ {...{ onShowPlanSelector }}/>- <Divider sx={{ my: "2px" }} />- <ExitSection />- <InfoSection />- </Stack>- </RootSidebarDrawer>-);+ <Stack sx={{ gap: 0.5, mb: 3 }}>+ <ShortcutSection+ onCloseSidebar={onClose}+ {...{+ normalCollectionSummaries,+ uncategorizedCollectionSummaryID,+ onShowCollectionSummary,+ }}+ />+ <UtilitySection+ onCloseSidebar={onClose}+ {...{+ onShowExport,+ onAuthenticateUser,+ showAccount,+ accountVisibilityProps,+ showPreferences,+ preferencesVisibilityProps,+ showHelp,+ helpVisibilityProps,+ watchFolderView,+ onShowWatchFolder: handleOpenWatchFolder,+ onCloseWatchFolder: handleCloseWatchFolder,+ pendingAccountAction,+ onAccountActionHandled: setPendingAccountAction,+ pendingPreferencesAction,+ onPreferencesActionHandled: setPendingPreferencesAction,+ pendingHelpAction,+ onHelpActionHandled: setPendingHelpAction,+ onRouteToDeduplicate: () => {+ void router.push("/duplicates");+ },+ }}+ />+ <Divider sx={{ my: "2px" }} />+ <ExitSection onLogout={handleLogout} />+ <InfoSection />+ </Stack>+ </RootSidebarDrawer>+ );+};const RootSidebarDrawer = styled(SidebarDrawer)(({ theme }) => ({"& .MuiPaper-root": { padding: theme.spacing(1.5) },@@ -542,29 +714,47 @@ const ShortcutSection: React.FC<ShortcutSectionProps> = ({};type UtilitySectionProps = SectionProps &- Pick<SidebarProps, "onShowExport" | "onAuthenticateUser">;+ Pick<SidebarProps, "onShowExport" | "onAuthenticateUser"> & {+ showAccount: () => void;+ accountVisibilityProps: ModalVisibilityProps;+ showPreferences: () => void;+ preferencesVisibilityProps: ModalVisibilityProps;+ showHelp: () => void;+ helpVisibilityProps: ModalVisibilityProps;+ watchFolderView: boolean;+ onShowWatchFolder: () => void;+ onCloseWatchFolder: () => void;+ pendingAccountAction?: AccountAction;+ onAccountActionHandled: (action?: AccountAction) => void;+ pendingPreferencesAction?: PreferencesAction;+ onPreferencesActionHandled: (action?: PreferencesAction) => void;+ pendingHelpAction?: HelpAction;+ onHelpActionHandled: (action?: HelpAction) => void;+ onRouteToDeduplicate: () => void;+ };const UtilitySection: React.FC<UtilitySectionProps> = ({onCloseSidebar,onShowExport,onAuthenticateUser,+ showAccount,+ accountVisibilityProps,+ showPreferences,+ preferencesVisibilityProps,+ showHelp,+ helpVisibilityProps,+ watchFolderView,+ onShowWatchFolder,+ onCloseWatchFolder,+ pendingAccountAction,+ onAccountActionHandled,+ pendingPreferencesAction,+ onPreferencesActionHandled,+ pendingHelpAction,+ onHelpActionHandled,+ onRouteToDeduplicate,}) => {const { showMiniDialog } = useBaseContext();- const { watchFolderView, setWatchFolderView } = usePhotosAppContext();-- const router = useRouter();-- const { show: showHelp, props: helpVisibilityProps } = useModalVisibility();-- const { show: showAccount, props: accountVisibilityProps } =- useModalVisibility();- const { show: showPreferences, props: preferencesVisibilityProps } =- useModalVisibility();-- const showWatchFolder = () => setWatchFolderView(true);- const handleCloseWatchFolder = () => setWatchFolderView(false);-- const handleDeduplicate = () => router.push("/duplicates");const handleExport = () =>isDesktop@@ -582,13 +772,13 @@ const UtilitySection: React.FC<UtilitySectionProps> = ({<RowButtonvariant="secondary"label={t("watch_folders")}- onClick={showWatchFolder}+ onClick={onShowWatchFolder}/>)}<RowButtonvariant="secondary"label={t("deduplicate_files")}- onClick={handleDeduplicate}+ onClick={onRouteToDeduplicate}/><RowButtonvariant="secondary"@@ -610,47 +800,45 @@ const UtilitySection: React.FC<UtilitySectionProps> = ({}onClick={handleExport}/>- <Help {...helpVisibilityProps} onRootClose={onCloseSidebar} />+ <Help+ {...helpVisibilityProps}+ onRootClose={onCloseSidebar}+ pendingAction={pendingHelpAction}+ onActionHandled={onHelpActionHandled}+ />{isDesktop && (<WatchFolderopen={watchFolderView}- onClose={handleCloseWatchFolder}+ onClose={onCloseWatchFolder}/>)}<Account{...accountVisibilityProps}onRootClose={onCloseSidebar}+ pendingAction={pendingAccountAction}+ onActionHandled={onAccountActionHandled}{...{ onAuthenticateUser }}/><Preferences{...preferencesVisibilityProps}onRootClose={onCloseSidebar}+ pendingAction={pendingPreferencesAction}+ onActionHandled={onPreferencesActionHandled}/></>);};-const ExitSection: React.FC = () => {- const { logout, showMiniDialog } = useBaseContext();-- const handleLogout = () =>- showMiniDialog({- message: t("logout_message"),- continue: { text: t("logout"), color: "critical", action: logout },- buttonDirection: "row",- });-- return (- <>- <RowButton- variant="secondary"- color="critical"- label={t("logout")}- onClick={handleLogout}- />- </>- );-};+const ExitSection: React.FC<{ onLogout: () => void }> = ({ onLogout }) => (+ <>+ <RowButton+ variant="secondary"+ color="critical"+ label={t("logout")}+ onClick={onLogout}+ />+ </>+);const InfoSection: React.FC = () => {const [appVersion, setAppVersion] = useState("");@@ -680,13 +868,18 @@ const InfoSection: React.FC = () => {};type AccountProps = NestedSidebarDrawerVisibilityProps &- Pick<SidebarProps, "onAuthenticateUser">;+ Pick<SidebarProps, "onAuthenticateUser"> & {+ pendingAction?: AccountAction;+ onActionHandled?: (action?: AccountAction) => void;+ };const Account: React.FC<AccountProps> = ({open,onClose,onRootClose,onAuthenticateUser,+ pendingAction,+ onActionHandled,}) => {const { showMiniDialog } = useBaseContext();@@ -704,13 +897,52 @@ const Account: React.FC<AccountProps> = ({onRootClose();};- const handleChangePassword = () => router.push("/change-password");- const handleChangeEmail = () => router.push("/change-email");+ const handleChangePassword = useCallback(() => {+ void router.push("/change-password");+ }, [router]);+ const handleChangeEmail = useCallback(() => {+ void router.push("/change-email");+ }, [router]);- const handlePasskeys = async () => {+ const handlePasskeys = useCallback(async () => {onRootClose();await openAccountsManagePasskeysPage();- };+ }, [onRootClose]);++ useEffect(() => {+ if (!open || !pendingAction) return;+ switch (pendingAction) {+ case "account.recoveryKey":+ showRecoveryKey();+ break;+ case "account.twoFactor":+ showTwoFactor();+ break;+ case "account.passkeys":+ void handlePasskeys();+ break;+ case "account.changePassword":+ handleChangePassword();+ break;+ case "account.changeEmail":+ handleChangeEmail();+ break;+ case "account.deleteAccount":+ showDeleteAccount();+ break;+ }+ onActionHandled?.();+ }, [+ handleChangeEmail,+ handleChangePassword,+ handlePasskeys,+ open,+ onActionHandled,+ pendingAction,+ showDeleteAccount,+ showRecoveryKey,+ showTwoFactor,+ ]);return (<TitledNestedSidebarDrawer@@ -773,10 +1005,17 @@ const Account: React.FC<AccountProps> = ({);};-const Preferences: React.FC<NestedSidebarDrawerVisibilityProps> = ({+type PreferencesProps = NestedSidebarDrawerVisibilityProps & {+ pendingAction?: PreferencesAction;+ onActionHandled?: (action?: PreferencesAction) => void;+};++const Preferences: React.FC<PreferencesProps> = ({open,onClose,onRootClose,+ pendingAction,+ onActionHandled,}) => {const { show: showDomainSettings, props: domainSettingsVisibilityProps } =useModalVisibility();@@ -796,6 +1035,37 @@ const Preferences: React.FC<NestedSidebarDrawerVisibilityProps> = ({if (open) void pullSettings();}, [open]);+ useEffect(() => {+ if (!open || !pendingAction) return;+ switch (pendingAction) {+ case "preferences.customDomains":+ showDomainSettings();+ break;+ case "preferences.map":+ showMapSettings();+ break;+ case "preferences.advanced":+ showAdvancedSettings();+ break;+ case "preferences.mlSearch":+ showMLSettings();+ break;+ case "preferences.language":+ case "preferences.theme":+ case "preferences.streamableVideos":+ break;+ }+ onActionHandled?.();+ }, [+ open,+ onActionHandled,+ pendingAction,+ showAdvancedSettings,+ showDomainSettings,+ showMLSettings,+ showMapSettings,+ ]);+const handleRootClose = () => {onClose();onRootClose();@@ -1271,10 +1541,17 @@ const AdvancedSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({);};-const Help: React.FC<NestedSidebarDrawerVisibilityProps> = ({+type HelpProps = NestedSidebarDrawerVisibilityProps & {+ pendingAction?: HelpAction;+ onActionHandled?: (Action?: HelpAction) => void;+};++const Help: React.FC<HelpProps> = ({open,onClose,onRootClose,+ pendingAction,+ onActionHandled,}) => {const { showMiniDialog } = useBaseContext();@@ -1283,23 +1560,24 @@ const Help: React.FC<NestedSidebarDrawerVisibilityProps> = ({onRootClose();};- const handleHelp = () => openURL("https://ente.io/help/photos/");-- const handleBlog = () => openURL("https://ente.io/blog/");+ const handleHelp = useCallback(+ () => openURL("https://ente.io/help/photos/"),+ [],+ );- const handleRequestFeature = () =>- openURL("https://github.com/ente-io/ente/discussions");+ const handleBlog = useCallback(() => openURL("https://ente.io/blog/"), []);- const handleSupport = () => initiateEmail("[email protected]");+ const handleRequestFeature = useCallback(+ () => openURL("https://github.com/ente-io/ente/discussions"),+ [],+ );- const confirmViewLogs = () =>- showMiniDialog({- title: t("view_logs"),- message: <Trans i18nKey={"view_logs_message"} />,- continue: { text: t("view_logs"), action: viewLogs },- });+ const handleSupport = useCallback(+ () => initiateEmail("[email protected]"),+ [],+ );- const viewLogs = async () => {+ const viewLogs = useCallback(async () => {log.info("Viewing logs");const electron = globalThis.electron;if (electron) {@@ -1307,7 +1585,53 @@ const Help: React.FC<NestedSidebarDrawerVisibilityProps> = ({} else {saveStringAsFile(savedLogs(), `ente-web-logs-${Date.now()}.txt`);}- };+ }, []);++ const confirmViewLogs = useCallback(+ () =>+ showMiniDialog({+ title: t("view_logs"),+ message: <Trans i18nKey={"view_logs_message"} />,+ continue: { text: t("view_logs"), action: viewLogs },+ }),+ [showMiniDialog, viewLogs],+ );++ useEffect(() => {+ if (!open || !pendingAction) return;+ switch (pendingAction) {+ case "help.helpCenter":+ handleHelp();+ break;+ case "help.blog":+ handleBlog();+ break;+ case "help.requestFeature":+ handleRequestFeature();+ break;+ case "help.support":+ handleSupport();+ break;+ case "help.viewLogs":+ confirmViewLogs();+ break;+ case "help.testUpload":+ if (isDevBuildAndUser()) {+ void testUpload();+ }+ break;+ }+ onActionHandled?.();+ }, [+ confirmViewLogs,+ handleBlog,+ handleHelp,+ handleRequestFeature,+ handleSupport,+ open,+ onActionHandled,+ pendingAction,+ ]);return (<TitledNestedSidebarDrawerdiff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 2ebb6e4c62..82d964f844 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -110,7 +110,10 @@ import {filterSearchableFiles,updateSearchCollectionsAndFiles,} from "ente-new/photos/services/search";-import type { SearchOption } from "ente-new/photos/services/search/types";+import {+ type SearchOption,+ type SidebarActionID,+} from "ente-new/photos/services/search/types";import { initSettings } from "ente-new/photos/services/settings";import {redirectToCustomerPortal,@@ -199,6 +202,9 @@ const Page: React.FC = () => {const [, setPostCreateAlbumOp] = useState<CollectionOp | undefined>(undefined,);+ const [pendingSidebarAction, setPendingSidebarAction] = useState<+ SidebarActionID | undefined+ >(undefined);/*** The last time (epoch milliseconds) when we prompted the user for their@@ -790,6 +796,13 @@ const Page: React.FC = () => {type: "showPerson",personID: searchOption.suggestion.person.id,});+ } else if (type == "sidebarAction") {+ setPendingSidebarAction(searchOption.suggestion.actionID);+ showSidebar();++ const shouldExitSearchMode =+ options?.shouldExitSearchMode ?? true;+ dispatch({ type: "exitSearch", shouldExitSearchMode });} else {dispatch({type: "enterSearchMode",@@ -1140,6 +1153,8 @@ const Page: React.FC = () => {uncategorizedCollectionSummaryID={state.uncategorizedCollectionSummaryID}+ pendingAction={pendingSidebarAction}+ onActionHandled={() => setPendingSidebarAction(undefined)}onShowPlanSelector={showPlanSelector}onShowCollectionSummary={handleSidebarShowCollectionSummary}onShowExport={showExport}diff --git a/web/packages/new/photos/services/search/sidebar-search-registry.ts b/web/packages/new/photos/services/search/sidebar-search-registry.tsindex 6f53799ede..5e1c542a5d 100644--- a/web/packages/new/photos/services/search/sidebar-search-registry.ts+++ b/web/packages/new/photos/services/search/sidebar-search-registry.ts@@ -12,6 +12,33 @@ export interface SidebarAction {available?: () => boolean;}+export interface SidebarActionContext {+ // top-level sidebar controls+ onClose: () => void;+ onShowCollectionSummary: (+ collectionSummaryID: number,+ isHidden?: boolean,+ ) => Promise<void>;+ showAccount: () => void;+ showPreferences: () => void;+ showHelp: () => void;+ onShowExport: () => void;+ onLogout: () => void;+ onRouteToDeduplicate: () => Promise<unknown>;+ onShowWatchFolder: () => void;+ pseudoIDs: {+ uncategorized: number;+ archive: number;+ hidden: number;+ trash: number;+ };++ // nested drawer hooks+ setPendingAccountAction: (a: SidebarActionID | undefined) => void;+ setPendingPreferencesAction: (a: SidebarActionID | undefined) => void;+ setPendingHelpAction: (a: SidebarActionID | undefined) => void;+}+const shortcutsCategory = t("shortcuts", { defaultValue: "Shortcuts" });const preferencesCategory = t("preferences");const accountCategory = t("account");@@ -221,6 +248,89 @@ export const sidebarSearchOptionsForString = (}));};+export const performSidebarAction = async (+ actionID: SidebarActionID,+ ctx: SidebarActionContext,+): Promise<void> => {+ switch (actionID) {+ case "shortcuts.uncategorized":+ return ctx+ .onShowCollectionSummary(ctx.pseudoIDs.uncategorized, false)+ .then(() => ctx.onClose());+ case "shortcuts.archive":+ return ctx+ .onShowCollectionSummary(ctx.pseudoIDs.archive, false)+ .then(() => ctx.onClose());+ case "shortcuts.hidden":+ return ctx+ .onShowCollectionSummary(ctx.pseudoIDs.hidden, true)+ .then(() => ctx.onClose());+ case "shortcuts.trash":+ return ctx+ .onShowCollectionSummary(ctx.pseudoIDs.trash, false)+ .then(() => ctx.onClose());++ case "utility.account":+ ctx.showAccount();+ return Promise.resolve();++ case "utility.watchFolders":+ ctx.onShowWatchFolder();+ return Promise.resolve();++ case "utility.deduplicate":+ return ctx.onRouteToDeduplicate().then(() => ctx.onClose());++ case "utility.preferences":+ ctx.showPreferences();+ return Promise.resolve();++ case "utility.help":+ ctx.showHelp();+ return Promise.resolve();++ case "utility.export":+ ctx.onShowExport();+ ctx.onClose();+ return Promise.resolve();++ case "utility.logout":+ ctx.onLogout();+ return Promise.resolve();++ case "account.recoveryKey":+ case "account.twoFactor":+ case "account.passkeys":+ case "account.changePassword":+ case "account.changeEmail":+ case "account.deleteAccount":+ ctx.setPendingAccountAction(actionID);+ ctx.showAccount();+ return Promise.resolve();++ case "preferences.language":+ case "preferences.theme":+ case "preferences.customDomains":+ case "preferences.map":+ case "preferences.advanced":+ case "preferences.mlSearch":+ case "preferences.streamableVideos":+ ctx.setPendingPreferencesAction(actionID);+ ctx.showPreferences();+ return Promise.resolve();++ case "help.helpCenter":+ case "help.blog":+ case "help.requestFeature":+ case "help.support":+ case "help.viewLogs":+ case "help.testUpload":+ ctx.setPendingHelpAction(actionID);+ ctx.showHelp();+ return Promise.resolve();+ }+};+const matchesSearch = (normalized: string,label: string,