π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Filter album shortcuts in sidebar search
AswinAsok17d560261f5f
diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsxindex f26129b978..338c5d7ed1 100644--- a/web/apps/photos/src/components/gallery/BarImpl.tsx+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx@@ -271,7 +271,9 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({label: t("section_trash"),active: activeCollectionID == PseudoCollectionID.trash,},- ];+ ].filter(({ label }) =>+ label.toLowerCase().includes(normalizedSearchQuery),+ );const albumListID = `${titleID}-albums`;const items = (@@ -347,17 +349,19 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({</Stack>);- const albumShortcutItems = (+ const albumShortcutItems = albumShortcuts.length > 0 && (<Stack sx={{ flexShrink: 0, gap: "2px", pb: "8px" }}>- <Divider- sx={{- mb: "8px",- height: "2px",- border: 0,- bgcolor: "divider",- opacity: 0.5,- }}- />+ {visibleAlbumFilters.length > 0 && (+ <Divider+ sx={{+ mb: "8px",+ height: "2px",+ border: 0,+ bgcolor: "divider",+ opacity: 0.5,+ }}+ />+ )}{albumShortcuts.map(({ id, label, active }) => (<BarCardkey={id}@@ -570,7 +574,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({</Stack>{isSearching &&(mode == "albums"- ? !visibleAlbumFilters.length+ ? !visibleAlbumFilters.length && !albumShortcuts.length: !getItemCount(itemData)) ? (searchEmptyState) : mode == "albums" ? (@@ -635,8 +639,6 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({) : (items)}- {(mode == "hidden-albums" || mode == "archive-albums") &&- albumShortcutItems}</Stack>);diff --git a/web/apps/photos/tests/sidebar-album-search.test.tsx b/web/apps/photos/tests/sidebar-album-search.test.tsxindex 6dcd1314df..9f7e4eccbc 100644--- a/web/apps/photos/tests/sidebar-album-search.test.tsx+++ b/web/apps/photos/tests/sidebar-album-search.test.tsx@@ -16,7 +16,15 @@ vi.mock("@/components/PeopleSortOptions", () => ({PeopleSortOptions: () => null,}));vi.mock("@/utils/album-filters", () => import("../src/utils/album-filters"));-vi.mock("i18next", () => ({ t: (key: string) => key }));+vi.mock("i18next", () => ({+ t: (key: string) =>+ ({+ section_uncategorized: "Uncategorized",+ section_hidden: "Hidden",+ section_archive: "Archive",+ section_trash: "Trash",+ })[key] ?? key,+}));vi.mock("ente-new/photos/components/Tiles", () => ({ ItemCard: () => null }));vi.mock("react-virtualized-auto-sizer", () => ({default: ({@@ -116,10 +124,24 @@ describe("sidebar album search across groups", () => {expect(html).not.toContain("no-matches.svg");});- test("shows the empty state only when no groups match", () => {+ test("shows the empty state when neither albums nor shortcuts match", () => {const html = renderSearch("missing");expect(html).toContain("no-matches.svg");- expect(html).not.toContain('aria-label="filter_albums"');+ for (const label of ["Uncategorized", "Hidden", "Archive", "Trash"])+ expect(html).not.toContain(`aria-label="${label}"`);+ });++ test.each([+ [" TRASH ", "Trash"],+ ["hid", "Hidden"],+ ["uncat", "Uncategorized"],+ ["archive", "Archive"],+ ])("shows only the matching shortcut for %j", (query, match) => {+ const html = renderSearch(query);+ expect(html).not.toContain("no-matches.svg");+ for (const label of ["Uncategorized", "Hidden", "Archive", "Trash"])+ if (label == match) expect(html).toContain(`aria-label="${label}"`);+ else expect(html).not.toContain(`aria-label="${label}"`);});test.each(["", " "])(@@ -151,3 +173,14 @@ describe("Links sidebar search", () => {expect(html).not.toContain('aria-label="filter_albums"');});});++describe("Hidden and Archive sidebars", () => {+ test.each(["hidden-albums", "archive-albums"] as const)(+ "%s omits the album shortcuts",+ (mode) => {+ const html = renderSearch("", "ente", mode);+ for (const label of ["Uncategorized", "Hidden", "Archive", "Trash"])+ expect(html).not.toContain(`aria-label="${label}"`);+ },+ );+});