Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(searchBar-registry):minor-logic-correction

Aswin Asok229fee0f6695
diff --git a/docs/docs/photos/features/sidebar.md b/docs/docs/photos/features/sidebar.md
new file mode 100644
index 0000000000..dad7c2eac2
--- /dev/null
+++ b/docs/docs/photos/features/sidebar.md
@@ -0,0 +1,64 @@
+# Photos sidebar
+
+This page documents the items rendered by `web/apps/photos/src/components/Sidebar.tsx`, along with any conditions that control when they show up or how they behave.
+
+## User details and subscription
+
+- [ ] **Email + subscription card**: always visible; clicking opens the plan selector unless the user is a non-admin family member (then opens Manage member subscription). If the subscription is Stripe + past due, clicking redirects to the customer portal.
+- [ ] **Subscription status message**: shown only when (a) the user is not a non-admin family member and (b) the subscription is not both active and uncancelled. Messages include free plan, cancelled renewal (with expiry date), expired (CTA to plan selector/portal), and storage quota exceeded.
+- [ ] **Manage member subscription dialog**: appears only for family members who are not admins and shows the family admin email plus a Leave family plan action.
+
+## Shortcuts
+
+- [x][x] **Uncategorized**: always available; uses `uncategorizedCollectionSummaryID` and shows its file count.
+- [X][x] **Archive**: always available; uses `PseudoCollectionID.archiveItems` file count.
+- [X][x] **Hidden**: always available; calls `onShowCollectionSummary` with the hidden flag (reauth can fire before showing); caption shows a lock icon.
+- [X][x] **Trash**: always available; uses `PseudoCollectionID.trash` file count.
+
+## Utilities
+
+- [X][x] **Account**: opens the account drawer (see below).
+- [ ][x] **Watch folders**: only shown on desktop builds (`isDesktop`).
+- [X][x] **Deduplicate files**: always shown; navigates to `/duplicates`.
+- [X][x] **Preferences**: opens the preferences drawer (see below).
+- [X][x] **Help**: opens the help drawer (see below).
+- [X][x] **Export data**: always shown; end icon indicates an in-progress export. On desktop it triggers `onShowExport`; on web it shows the "download app" dialog instead.
+
+## Account drawer
+
+- [X][x] **Recovery key**: always available; opens the recovery key flow.
+- [X][x] **Two-factor**: always available; opens the 2FA settings.
+- [X][x] **Passkeys**: always available; closes the sidebar then opens the accounts passkey management page.
+- [X][x] **Change password / Change email**: always available; navigates to the respective routes.
+- [X][x] **Delete account**: always available; uses `onAuthenticateUser` before proceeding.
+
+## Preferences drawer
+
+- [X][x] **Language**: always available; lists `supportedLocales` and triggers a full reload on change.
+- [X][x] **Theme**: shown once a color scheme is available (skips during SSR); options are system, light, dark.
+- [ ][x] **ML search**: shown only when `isMLSupported` is true; opens the ML settings drawer.
+- [X][x] **Custom domains**: always available; opens domain settings (see below).
+- [X][x] **Map**: always available; opens map settings (see below).
+- [X][x] **Advanced**: always available; opens advanced settings (see below).
+- [ ][x] **Streamable videos**: shown only when `isHLSGenerationSupported` is true; toggles HLS generation via `toggleHLSGeneration` using the status snapshot for the initial state.
+
+
+## Advanced settings
+
+- [ ] **Faster upload**: always shown; toggles the Cloudflare upload proxy (`cfUploadProxyDisabled` inverted).
+- [ ] **Open Ente on startup**: only shown when running in the Electron shell (`globalThis.electron` exists); toggles auto-launch and refreshes the current state from `electron.isAutoLaunchEnabled()`.
+
+## Help drawer
+
+- [X][x] **Ente help**: opens https://ente.io/help/photos/.
+- [X][x] **Blog**: opens https://ente.io/blog/.
+- [X][x] **Request feature**: opens GitHub Discussions for feature requests.
+- [X][x] **Support**: opens an email to [email protected].
+- [X][x] **View logs**: always shown; on Electron opens the log directory, otherwise downloads logs as a file.
+- [ ] **Test upload**: only shown on dev builds for dev users (`isDevBuildAndUser()` returns true); runs the `testUpload` helper.
+
+## Exit and app info
+
+- [X][x] **Logout**: always shown; asks for confirmation before calling logout.
+
+
diff --git a/web/packages/new/photos/services/search/sidebar-search-registry.ts b/web/packages/new/photos/services/search/sidebar-search-registry.ts
index 5e1c542a5d..c25077f118 100644
--- a/web/packages/new/photos/services/search/sidebar-search-registry.ts
+++ b/web/packages/new/photos/services/search/sidebar-search-registry.ts
@@ -1,6 +1,7 @@
import { isDesktop } from "ente-base/app";
import { isHLSGenerationSupported } from "ente-gallery/services/video";
import { t } from "i18next";
+import { isMLSupported } from "../ml";
import { isDevBuildAndUser } from "../settings";
import type { SearchOption, SidebarActionID } from "./types";
@@ -39,196 +40,201 @@ export interface SidebarActionContext {
setPendingHelpAction: (a: SidebarActionID | undefined) => void;
}
-const shortcutsCategory = t("shortcuts", { defaultValue: "Shortcuts" });
-const preferencesCategory = t("preferences");
-const accountCategory = t("account");
-const helpCategory = t("help");
+// Construct sidebar actions at call time so we always use initialized i18n
+// strings instead of whatever was available when this module was first loaded.
+const sidebarActions = (): SidebarAction[] => {
+ const shortcutsCategory = t("shortcuts", { defaultValue: "Shortcuts" });
+ const preferencesCategory = t("preferences");
+ const accountCategory = t("account");
+ const helpCategory = t("help");
-export const sidebarActions: SidebarAction[] = [
- {
- id: "shortcuts.uncategorized",
- label: t("section_uncategorized"),
- path: [shortcutsCategory, t("section_uncategorized")],
- keywords: ["uncategorized", "ungrouped"],
- },
- {
- id: "shortcuts.archive",
- label: t("section_archive"),
- path: [shortcutsCategory, t("section_archive")],
- keywords: ["archive", "archived"],
- },
- {
- id: "shortcuts.hidden",
- label: t("section_hidden"),
- path: [shortcutsCategory, t("section_hidden")],
- keywords: ["hidden", "private"],
- },
- {
- id: "shortcuts.trash",
- label: t("section_trash"),
- path: [shortcutsCategory, t("section_trash")],
- keywords: ["trash", "bin", "deleted"],
- },
- {
- id: "utility.account",
- label: t("account"),
- path: [preferencesCategory, t("account")],
- keywords: ["profile", "user"],
- },
- {
- id: "utility.watchFolders",
- label: t("watch_folders"),
- path: [preferencesCategory, t("watch_folders")],
- keywords: ["watch", "folder", "desktop"],
- available: () => isDesktop,
- },
- {
- id: "utility.deduplicate",
- label: t("deduplicate_files"),
- path: [preferencesCategory, t("deduplicate_files")],
- keywords: ["duplicate", "dedupe"],
- },
- {
- id: "utility.preferences",
- label: t("preferences"),
- path: [preferencesCategory],
- keywords: ["settings"],
- },
- {
- id: "utility.help",
- label: t("help"),
- path: [helpCategory],
- keywords: ["support", "docs"],
- },
- {
- id: "utility.export",
- label: t("export_data"),
- path: [preferencesCategory, t("export_data")],
- keywords: ["export", "download"],
- },
- {
- id: "utility.logout",
- label: t("logout"),
- path: [preferencesCategory, t("logout")],
- keywords: ["sign out", "signout"],
- },
- {
- id: "account.recoveryKey",
- label: t("recovery_key"),
- path: [accountCategory, t("recovery_key")],
- keywords: ["recovery", "key", "backup"],
- },
- {
- id: "account.twoFactor",
- label: t("two_factor"),
- path: [accountCategory, t("two_factor")],
- keywords: ["2fa", "otp", "mfa"],
- },
- {
- id: "account.passkeys",
- label: t("passkeys"),
- path: [accountCategory, t("passkeys")],
- keywords: ["webauthn", "security key"],
- },
- {
- id: "account.changePassword",
- label: t("change_password"),
- path: [accountCategory, t("change_password")],
- keywords: ["password"],
- },
- {
- id: "account.changeEmail",
- label: t("change_email"),
- path: [accountCategory, t("change_email")],
- keywords: ["email"],
- },
- {
- id: "account.deleteAccount",
- label: t("delete_account"),
- path: [accountCategory, t("delete_account")],
- keywords: ["delete", "remove"],
- },
- {
- id: "preferences.language",
- label: t("language"),
- path: [preferencesCategory, t("language")],
- keywords: ["locale"],
- },
- {
- id: "preferences.theme",
- label: t("theme"),
- path: [preferencesCategory, t("theme")],
- keywords: ["appearance", "dark mode", "light mode"],
- },
- {
- id: "preferences.customDomains",
- label: t("custom_domains"),
- path: [preferencesCategory, t("custom_domains")],
- keywords: ["domain", "link"],
- },
- {
- id: "preferences.map",
- label: t("map"),
- path: [preferencesCategory, t("map")],
- keywords: ["maps", "location"],
- },
- {
- id: "preferences.advanced",
- label: t("advanced"),
- path: [preferencesCategory, t("advanced")],
- keywords: ["advanced", "proxy", "upload"],
- },
- {
- id: "preferences.mlSearch",
- label: t("ml_search"),
- path: [preferencesCategory, t("ml_search")],
- keywords: ["ml", "search", "magic"],
- },
- {
- id: "preferences.streamableVideos",
- label: t("streamable_videos"),
- path: [preferencesCategory, t("streamable_videos")],
- keywords: ["hls", "video", "stream"],
- available: () => isHLSGenerationSupported,
- },
- {
- id: "help.helpCenter",
- label: t("ente_help"),
- path: [helpCategory, t("ente_help")],
- keywords: ["help", "docs"],
- },
- {
- id: "help.blog",
- label: t("blog"),
- path: [helpCategory, t("blog")],
- keywords: ["news"],
- },
- {
- id: "help.requestFeature",
- label: t("request_feature"),
- path: [helpCategory, t("request_feature")],
- keywords: ["feature", "feedback"],
- },
- {
- id: "help.support",
- label: t("support"),
- path: [helpCategory, t("support")],
- keywords: ["contact", "support"],
- },
- {
- id: "help.viewLogs",
- label: t("view_logs"),
- path: [helpCategory, t("view_logs")],
- keywords: ["logs", "debug"],
- },
- {
- id: "help.testUpload",
- label: t("test_upload"),
- path: [helpCategory, t("test_upload")],
- keywords: ["test", "upload"],
- available: () => isDevBuildAndUser(),
- },
-];
+ return [
+ {
+ id: "shortcuts.uncategorized",
+ label: t("section_uncategorized"),
+ path: [shortcutsCategory, t("section_uncategorized")],
+ keywords: ["uncategorized", "ungrouped"],
+ },
+ {
+ id: "shortcuts.archive",
+ label: t("section_archive"),
+ path: [shortcutsCategory, t("section_archive")],
+ keywords: ["archive", "archived"],
+ },
+ {
+ id: "shortcuts.hidden",
+ label: t("section_hidden"),
+ path: [shortcutsCategory, t("section_hidden")],
+ keywords: ["hidden", "private"],
+ },
+ {
+ id: "shortcuts.trash",
+ label: t("section_trash"),
+ path: [shortcutsCategory, t("section_trash")],
+ keywords: ["trash", "bin", "deleted"],
+ },
+ {
+ id: "utility.account",
+ label: t("account"),
+ path: [preferencesCategory, t("account")],
+ keywords: ["profile", "user"],
+ },
+ {
+ id: "utility.watchFolders",
+ label: t("watch_folders"),
+ path: [preferencesCategory, t("watch_folders")],
+ keywords: ["watch", "folder", "desktop"],
+ available: () => isDesktop,
+ },
+ {
+ id: "utility.deduplicate",
+ label: t("deduplicate_files"),
+ path: [preferencesCategory, t("deduplicate_files")],
+ keywords: ["duplicate", "dedupe"],
+ },
+ {
+ id: "utility.preferences",
+ label: t("preferences"),
+ path: [preferencesCategory],
+ keywords: ["settings"],
+ },
+ {
+ id: "utility.help",
+ label: t("help"),
+ path: [helpCategory],
+ keywords: ["support", "docs"],
+ },
+ {
+ id: "utility.export",
+ label: t("export_data"),
+ path: [preferencesCategory, t("export_data")],
+ keywords: ["export", "download"],
+ },
+ {
+ id: "utility.logout",
+ label: t("logout"),
+ path: [preferencesCategory, t("logout")],
+ keywords: ["sign out", "signout"],
+ },
+ {
+ id: "account.recoveryKey",
+ label: t("recovery_key"),
+ path: [accountCategory, t("recovery_key")],
+ keywords: ["recovery", "key", "backup"],
+ },
+ {
+ id: "account.twoFactor",
+ label: t("two_factor"),
+ path: [accountCategory, t("two_factor")],
+ keywords: ["2fa", "otp", "mfa", "two", "factor", "two factor"],
+ },
+ {
+ id: "account.passkeys",
+ label: t("passkeys"),
+ path: [accountCategory, t("passkeys")],
+ keywords: ["webauthn", "security key"],
+ },
+ {
+ id: "account.changePassword",
+ label: t("change_password"),
+ path: [accountCategory, t("change_password")],
+ keywords: ["password"],
+ },
+ {
+ id: "account.changeEmail",
+ label: t("change_email"),
+ path: [accountCategory, t("change_email")],
+ keywords: ["email"],
+ },
+ {
+ id: "account.deleteAccount",
+ label: t("delete_account"),
+ path: [accountCategory, t("delete_account")],
+ keywords: ["delete", "remove"],
+ },
+ {
+ id: "preferences.language",
+ label: t("language"),
+ path: [preferencesCategory, t("language")],
+ keywords: ["locale"],
+ },
+ {
+ id: "preferences.theme",
+ label: t("theme"),
+ path: [preferencesCategory, t("theme")],
+ keywords: ["appearance", "dark mode", "light mode"],
+ },
+ {
+ id: "preferences.customDomains",
+ label: t("custom_domains"),
+ path: [preferencesCategory, t("custom_domains")],
+ keywords: ["domain", "link"],
+ },
+ {
+ id: "preferences.map",
+ label: t("map"),
+ path: [preferencesCategory, t("map")],
+ keywords: ["maps", "location"],
+ },
+ {
+ id: "preferences.advanced",
+ label: t("advanced"),
+ path: [preferencesCategory, t("advanced")],
+ keywords: ["advanced", "proxy", "upload"],
+ },
+ {
+ id: "preferences.mlSearch",
+ label: t("ml_search"),
+ path: [preferencesCategory, t("ml_search")],
+ keywords: ["ml", "search", "magic"],
+ available: () => isMLSupported,
+ },
+ {
+ id: "preferences.streamableVideos",
+ label: t("streamable_videos"),
+ path: [preferencesCategory, t("streamable_videos")],
+ keywords: ["hls", "video", "stream"],
+ available: () => isHLSGenerationSupported,
+ },
+ {
+ id: "help.helpCenter",
+ label: t("ente_help"),
+ path: [helpCategory, t("ente_help")],
+ keywords: ["help", "docs"],
+ },
+ {
+ id: "help.blog",
+ label: t("blog"),
+ path: [helpCategory, t("blog")],
+ keywords: ["news"],
+ },
+ {
+ id: "help.requestFeature",
+ label: t("request_feature"),
+ path: [helpCategory, t("request_feature")],
+ keywords: ["feature", "feedback"],
+ },
+ {
+ id: "help.support",
+ label: t("support"),
+ path: [helpCategory, t("support")],
+ keywords: ["contact", "support"],
+ },
+ {
+ id: "help.viewLogs",
+ label: t("view_logs"),
+ path: [helpCategory, t("view_logs")],
+ keywords: ["logs", "debug"],
+ },
+ {
+ id: "help.testUpload",
+ label: t("test_upload"),
+ path: [helpCategory, t("test_upload")],
+ keywords: ["test", "upload"],
+ available: () => isDevBuildAndUser(),
+ },
+ ];
+};
export const sidebarSearchOptionsForString = (
searchString: string,
@@ -236,7 +242,7 @@ export const sidebarSearchOptionsForString = (
const normalized = searchString.trim().toLowerCase();
if (normalized.length < 2) return []; // avoid noisy single-letter matches
- return sidebarActions
+ return sidebarActions()
.filter(({ available }) => !available || available())
.filter(({ label, path, keywords }) =>
matchesSearch(normalized, label, path, keywords),