Skip to content

armgit / ente

Public Imported from GitHub
0

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

Merge main into Links sidebar listing

AswinAsok94f6ef66e0c1
diff --cc web/apps/photos/src/components/gallery/BarImpl.tsx
index eb7040efd4,d8275f28ff..3ce9ff1fe8
--- a/web/apps/photos/src/components/gallery/BarImpl.tsx
+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx
@@@ -171,8 -196,7 +196,8 @@@ export const GalleryBarImpl: React.FC<G
case "albums":
case "hidden-albums":
case "archive-albums":
+ case "links":
- i = collectionSummaries.findIndex(
+ i = displayedCollectionSummaries.findIndex(
({ id }) => id == activeCollectionID,
);
break;
@@@ -200,11 -224,10 +225,11 @@@
() =>
mode == "albums" ||
mode == "hidden-albums" ||
- mode == "archive-albums"
+ mode == "archive-albums" ||
+ mode == "links"
? {
type: "collections",
- collectionSummaries: collectionSummaries,
+ collectionSummaries: displayedCollectionSummaries,
indented: mode == "albums",
activeCollectionID: activeCollectionID!,
onSelectCollectionID,
diff --cc web/apps/photos/src/pages/gallery.tsx
index b8a434742e,0b7bb9ae97..c2a8dfb850
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@@ -2176,19 -2137,9 +2177,15 @@@ const Page: React.FC = () =>
(state.view?.type == "people"
? state.view.visiblePeople
: undefined) ?? [],
- allPeople:
- (state.view?.type == "people"
- ? state.view.people
- : undefined) ?? [],
setBlockingLoad,
setActiveCollectionID:
- handleShowCollectionSummaryWithID,
+ barMode == "links"
+ ? (collectionID) =>
+ dispatch({
+ type: "selectLink",
+ collectionID,
+ })
+ : handleShowCollectionSummaryWithID,
hasActiveFileSelection,
onRemotePull: remotePull,
onSelectPerson: handleSelectPerson,
diff --cc web/apps/photos/tests/album-filters.test.ts
index 66ff147112,bf216f406b..ae694f197b
--- a/web/apps/photos/tests/album-filters.test.ts
+++ b/web/apps/photos/tests/album-filters.test.ts
@@@ -138,6 -137,34 +138,34 @@@ describe("album filters shared by the d
"ente",
]);
});
+
+ test("search shows only groups containing a matching album", () => {
+ const albums = [
+ { ...album(1), name: "Summer" },
+ { ...album(2, ["sharedOutgoing"]), name: "Winter" },
+ { ...album(3, ["sharedIncoming"]), name: "Winter" },
+ { ...album(4, ["quickLink"]), name: "Holiday link" },
+ ];
+ const groups = (query: string) =>
+ visibleAlbumFilters(albums, query).map(({ value }) => value);
- expect(groups(" HOLIDAY ")).toEqual(["links"]);
- expect(groups("winter")).toEqual(["ente", "shared", "received"]);
++ expect(groups("holiday")).toEqual([]);
++ expect(groups(" WINTER ")).toEqual(["ente", "shared", "received"]);
+ expect(groups("summer")).toEqual(["ente"]);
+ expect(groups("missing")).toEqual([]);
- expect(groups(" ")).toEqual(["ente", "shared", "received", "links"]);
++ expect(groups(" ")).toEqual(["ente", "shared", "received"]);
+ });
+
+ test("search preserves empty-group availability when only one empty album matches", () => {
+ const albums = [album(1, [], 0), album(2, [], 0), album(3, [], 0)];
+ expect(
+ visibleAlbumFilters(albums, "Album 1").map(({ value }) => value),
+ ).toEqual(["ente", "empty-albums"]);
+ expect(
+ visibleAlbumFilters(albums.slice(0, 2), "Album 1").map(
+ ({ value }) => value,
+ ),
+ ).toEqual(["ente"]);
+ });
});
describe("album overview search", () => {
diff --cc web/apps/photos/tests/sidebar-album-search.test.tsx
index 0000000000,82026f59de..22bf2613c1
mode 000000,100644..100644
--- a/web/apps/photos/tests/sidebar-album-search.test.tsx
+++ b/web/apps/photos/tests/sidebar-album-search.test.tsx
@@@ -1,0 -1,119 +1,148 @@@
+ import { ThemeProvider } from "@mui/material";
+ import { photosTheme } from "ente-base/components/utils/theme";
+ import type { CollectionSummary } from "ente-new/photos/services/collection-summary";
+ import { renderToStaticMarkup } from "react-dom/server";
+ import { describe, expect, test, vi } from "vitest";
+ import {
+ GalleryBarImpl,
+ type GalleryBarImplProps,
+ } from "../src/components/gallery/BarImpl";
+ import { visibleAlbumFilters } from "../src/utils/album-filters";
+
+ vi.mock("@/components/CollectionsSortOptions", () => ({
+ CollectionsSortOptions: () => null,
+ }));
+ 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("ente-new/photos/components/Tiles", () => ({ ItemCard: () => null }));
+ vi.mock("react-virtualized-auto-sizer", () => ({
+ default: ({
+ children,
+ }: {
+ children: (size: { width: number; height: number }) => React.ReactNode;
+ }) => children({ width: 300, height: 400 }),
+ }));
+
+ const owned: CollectionSummary = {
+ id: 1,
+ name: "Family",
+ type: "album",
+ attributes: new Set(),
+ fileCount: 1,
+ latestFile: undefined,
+ coverFile: undefined,
+ updationTime: undefined,
+ sortPriority: 0,
+ };
-const link: CollectionSummary = {
++const shared: CollectionSummary = {
+ ...owned,
+ id: 2,
- name: "Holiday link",
- attributes: new Set(["quickLink"]),
++ name: "Holiday album",
++ attributes: new Set(["sharedOutgoing"]),
++};
++const link: CollectionSummary = {
++ ...owned,
++ id: 3,
++ name: "Trip link",
++ attributes: new Set(["quickLink", "sharedViaLink"]),
+ };
-const albums = [owned, link];
++const albums = [owned, shared, link];
+
-const renderSearch = (query: string, albumFilter = "ente") => {
++const renderSearch = (
++ query: string,
++ albumFilter: GalleryBarImplProps["albumFilter"] = "ente",
++ mode: GalleryBarImplProps["mode"] = "albums",
++) => {
+ const normalizedQuery = query.trim().toLowerCase();
++ const summaries = mode == "links" ? [link] : albums;
+ const props: GalleryBarImplProps = {
- mode: "albums",
- albumFilter: albumFilter as GalleryBarImplProps["albumFilter"],
++ mode,
++ albumFilter,
+ albumSearchQuery: query,
- collectionSummaries: albums.filter((album) =>
++ collectionSummaries: summaries.filter((album) =>
+ album.name.toLowerCase().includes(normalizedQuery),
+ ),
- visibleAlbumFilters: visibleAlbumFilters(albums, query),
++ visibleAlbumFilters: visibleAlbumFilters(summaries, query),
+ normalCollectionSummaries: new Map(),
+ uncategorizedCollectionSummaryID: 99,
+ activeCollectionID: undefined,
+ collectionsSortBy: "updation-time-desc",
+ peopleSortBy: "name-asc",
+ people: [],
+ activePerson: undefined,
+ collapsed: false,
+ mobileDrawerProps: { open: false, onClose: vi.fn() },
+ onAlbumSearchQueryChange: vi.fn(),
+ onShowAlbumOverview: vi.fn(),
+ onShowPeopleOverview: vi.fn(),
+ onShowCollectionSummary: vi.fn(),
+ onSelectCollectionID: vi.fn(),
+ onCreateAlbum: vi.fn(),
+ onChangeCollectionsSortBy: vi.fn(),
+ onChangePeopleSortBy: vi.fn(),
+ onSelectPerson: vi.fn(),
+ };
+ return renderToStaticMarkup(
+ <ThemeProvider theme={photosTheme}>
+ <GalleryBarImpl {...props} />
+ </ThemeProvider>,
+ );
+ };
+
+ describe("sidebar album search across groups", () => {
- test("reveals matching Links albums while Ente is selected", () => {
++ test("reveals matching Shared albums while Ente is selected", () => {
+ const html = renderSearch("holiday");
- expect(html).toContain('aria-label="links_albums_title"');
++ expect(html).toContain('aria-label="shared_albums_title"');
+ expect(html).toContain('aria-expanded="true"');
- expect(html).toContain("Holiday link");
- expect(html).not.toContain('aria-label="Ente"');
++ expect(html).toContain("Holiday album");
+ expect(html).not.toContain("no-matches.svg");
+ });
+
- test("reveals matching Ente albums while Links is selected", () => {
- const html = renderSearch("family", "links");
++ test("reveals matching Ente albums while Shared is selected", () => {
++ const html = renderSearch("family", "shared");
+ expect(html).toContain('aria-label="Ente"');
+ expect(html).toContain("Family");
- expect(html).not.toContain('aria-label="links_albums_title"');
++ expect(html).not.toContain('aria-label="shared_albums_title"');
+ expect(html).not.toContain("no-matches.svg");
+ });
+
+ test("shows the empty state only when no groups match", () => {
+ const html = renderSearch("missing");
+ expect(html).toContain("no-matches.svg");
+ expect(html).not.toContain('aria-label="filter_albums"');
+ });
+
+ test.each(["", " "])(
+ "restores all group headings for query %j",
+ (query) => {
+ const html = renderSearch(query);
+ expect(html).toContain('aria-label="Ente"');
- expect(html).toContain('aria-label="links_albums_title"');
++ expect(html).toContain('aria-label="shared_albums_title"');
+ expect(html).toContain("Family");
- expect(html).not.toContain("Holiday link");
++ expect(html).toContain("Holiday album");
++ expect(html).not.toContain('aria-label="links_albums_title"');
++ expect(html).not.toContain("Trip link");
+ expect(html).not.toContain("no-matches.svg");
+ },
+ );
+ });
++
++describe("Links sidebar search", () => {
++ test("shows matching links outside album groups", () => {
++ const html = renderSearch(" TRIP ", "ente", "links");
++ expect(html).toContain("Trip link");
++ expect(html).toContain('aria-label="search_links"');
++ expect(html).not.toContain('aria-label="filter_albums"');
++ expect(html).not.toContain("no-matches.svg");
++ });
++
++ test("uses the illustrated empty state when no links match", () => {
++ const html = renderSearch("missing", "ente", "links");
++ expect(html).toContain("no-matches.svg");
++ expect(html).not.toContain("Trip link");
++ expect(html).not.toContain('aria-label="filter_albums"');
++ });
++});