π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[photos][web] Show Links overview by default
AswinAsok9959563b2fe5
diff --git a/web/apps/photos/src/components/gallery/AlbumsOverview.tsx b/web/apps/photos/src/components/gallery/AlbumsOverview.tsxindex 9459c98377..ea3c999c60 100644--- a/web/apps/photos/src/components/gallery/AlbumsOverview.tsx+++ b/web/apps/photos/src/components/gallery/AlbumsOverview.tsx@@ -1,9 +1,12 @@import { useDeleteEmptyAlbums } from "@/components/collections/useDeleteEmptyAlbums";import type { RemotePullOpts } from "@/components/gallery";import type { AlbumFilter } from "@/utils/album-filters";-import { Delete02Icon, ImageAdd02Icon } from "@hugeicons/core-free-icons";+import {+ Delete02Icon,+ ImageAdd02Icon,+ PinIcon,+} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";-import PushPinIcon from "@mui/icons-material/PushPin";import {Box,IconButton,@@ -14,6 +17,7 @@ import {useMediaQuery,useTheme,} from "@mui/material";+import type { Collection } from "ente-media/collection";import { ItemCard } from "ente-new/photos/components/Tiles";import { UnstyledButton } from "ente-new/photos/components/UnstyledButton";import type {@@ -24,11 +28,13 @@ import { t } from "i18next";import { useEffect, useRef, useState } from "react";import AutoSizer from "react-virtualized-auto-sizer";import { FixedSizeList, type ListChildComponentProps } from "react-window";+import { LinkCopyChip } from "./LinkCopyChip";interface AlbumsOverviewProps {albums: CollectionSummary[];title: string;- filter: AlbumFilter;+ filter: AlbumFilter | "links";+ linksByID?: ReadonlyMap<number, Collection>;searchQuery: string;sortBy: CollectionsSortBy;onSelectAlbum: (id: number) => void;@@ -40,6 +46,7 @@ export const AlbumsOverview = ({albums,title,filter,+ linksByID,searchQuery,sortBy,onSelectAlbum,@@ -73,6 +80,7 @@ export const AlbumsOverview = ({const columnGap = compact ? 12 : 22;const rowGap = compact ? 16 : 24;const cardHeight = tileWidth + 8 + 20 + 2 + 16;+ const isLinks = filter == "links";const displayTitle =filter == "shared"? t("album_overview_shared_title")@@ -125,11 +133,15 @@ export const AlbumsOverview = ({fontSize: { xs: 12, md: 14 },lineHeight: "20px",color: "text.muted",+ fontWeight: isLinks ? 500 : undefined,}}>- {t("album_overview_count", {- count: albums.length,- })}+ {t(+ isLinks+ ? "links_count"+ : "album_overview_count",+ { count: albums.length },+ )}</Typography></Stack>{showDeleteEmptyAlbums && (@@ -194,6 +206,7 @@ export const AlbumsOverview = ({style={{ overflowX: "hidden" }}itemData={{albums,+ linksByID,columns,columnGap,tileWidth,@@ -215,6 +228,7 @@ export const AlbumsOverview = ({};interface AlbumRowData {+ linksByID?: ReadonlyMap<number, Collection>;albums: CollectionSummary[];columns: number;columnGap: number;@@ -283,99 +297,110 @@ const AlbumsRow = ({</AlbumButton>);const album = data.albums[itemIndex - Number(data.showCreate)]!;- const badge = album.attributes.has("sharedIncoming")- ? t("album_overview_received_title")- : album.attributes.has("sharedOutgoing") ||- album.attributes.has("sharedViaLink")- ? t("shared_albums_label")- : undefined;+ const link = data.linksByID?.get(album.id);+ const badge =+ !link && album.attributes.has("sharedIncoming")+ ? t("album_overview_received_title")+ : album.attributes.has("sharedOutgoing") ||+ album.attributes.has("sharedViaLink")+ ? t("shared_albums_label")+ : undefined;return (- <AlbumButton+ <Boxkey={album.id}- title={album.name}- onClick={() => data.onSelectAlbum(album.id)}+ sx={{ position: "relative", width: data.tileWidth }}>- <ItemCard- TileComponent={Cover}- coverFile={album.coverFile}- isScrolling={isScrolling}+ <AlbumButton+ title={album.name}+ onClick={() => data.onSelectAlbum(album.id)}>- {badge && (- <Box+ <ItemCard+ TileComponent={Cover}+ coverFile={album.coverFile}+ isScrolling={isScrolling}+ >+ {!link && badge && (+ <Box+ component="span"+ sx={{+ position: "absolute",+ right: 8,+ bottom: 8,+ height: 24,+ px: "8px",+ borderRadius: "8px",+ bgcolor: "rgba(0,0,0,.55)",+ color: "#fff",+ fontSize: 11,+ fontWeight: 600,+ display: "flex",+ alignItems: "center",+ backdropFilter: "blur(6px)",+ maxWidth: "calc(100% - 16px)",+ overflow: "hidden",+ whiteSpace: "nowrap",+ }}+ >+ {badge}+ </Box>+ )}+ </ItemCard>+ <Stack+ component="span"+ sx={{ width: "100%", gap: "2px" }}+ >+ <Stackcomponent="span"+ direction="row"sx={{- position: "absolute",- right: 8,- bottom: 8,- height: 24,- px: "8px",- borderRadius: "8px",- bgcolor: "rgba(0,0,0,.55)",- color: "#fff",- fontSize: 11,- fontWeight: 600,- display: "flex",alignItems: "center",- backdropFilter: "blur(6px)",- maxWidth: "calc(100% - 16px)",- overflow: "hidden",- whiteSpace: "nowrap",+ gap: "4px",+ minWidth: 0,}}>- {badge}- </Box>- )}- </ItemCard>- <Stack- component="span"- sx={{ width: "100%", gap: "2px" }}- >- <Stack- component="span"- direction="row"- sx={{- alignItems: "center",- gap: "4px",- minWidth: 0,- }}- >+ <Typography+ component="span"+ noWrap+ sx={{+ fontSize: "var(--album-name-size)",+ lineHeight: "20px",+ fontWeight: 500,+ }}+ >+ {album.name}+ </Typography>+ {(album.attributes.has("pinned") ||+ album.attributes.has(+ "shareePinned",+ )) && (+ <Box+ component={HugeiconsIcon}+ icon={PinIcon}+ size={12}+ sx={{+ flexShrink: 0,+ color: "text.faint",+ }}+ />+ )}+ </Stack><Typographycomponent="span"- noWrapsx={{- fontSize: "var(--album-name-size)",- lineHeight: "20px",+ fontSize: "var(--album-count-size)",+ lineHeight: "16px",fontWeight: 500,+ color: "text.muted",}}>- {album.name}+ {t("album_items_count", {+ count: album.fileCount,+ })}</Typography>- {(album.attributes.has("pinned") ||- album.attributes.has("shareePinned")) && (- <PushPinIcon- sx={{- flexShrink: 0,- fontSize: 12,- color: "text.faint",- }}- />- )}</Stack>- <Typography- component="span"- sx={{- fontSize: "var(--album-count-size)",- lineHeight: "16px",- fontWeight: 500,- color: "text.muted",- }}- >- {t("album_items_count", {- count: album.fileCount,- })}- </Typography>- </Stack>- </AlbumButton>+ </AlbumButton>+ {link && <LinkCopyChip collection={link} />}+ </Box>);})}</div>diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsxindex 923c1f2a41..b663b77990 100644--- a/web/apps/photos/src/components/gallery/BarImpl.tsx+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx@@ -72,6 +72,7 @@ export interface GalleryBarImplProps extends GalleryBarPresentationProps {onAlbumSearchQueryChange: (query: string) => void;onShowAlbumOverview: (filter: AlbumFilter) => void;onShowPeopleOverview: () => void;+ onShowLinksOverview: () => void;collectionSummaries: CollectionSummary[];visibleAlbumFilters: typeof albumFilters;uncategorizedCollectionSummaryID: number;@@ -98,6 +99,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({onAlbumSearchQueryChange,onShowAlbumOverview,onShowPeopleOverview,+ onShowLinksOverview,collectionSummaries,visibleAlbumFilters,uncategorizedCollectionSummaryID,@@ -169,6 +171,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({}, [albumFilter]);useEffect(() => {setPeopleSearchQuery("");+ if (mode == "links") setLinksExpanded(true);}, [mode]);useEffect(() => {@@ -695,10 +698,20 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({sx={{ flex: 1, minHeight: 0, minWidth: 0 }}><BarCard- aria-expanded={isSearching || linksExpanded}- onClick={() =>- setLinksExpanded((expanded) => !expanded)+ aria-current={+ activeCollectionID === undefined+ ? "page"+ : undefined}+ aria-expanded={isSearching || linksExpanded}+ onClick={() => {+ setLinksExpanded(+ activeCollectionID !== undefined ||+ !linksExpanded,+ );+ onShowLinksOverview();+ mobileDrawerProps.onClose();+ }}sx={{ flexShrink: 0, height: rowHeight }}><CardText>{t("links")}</CardText>diff --git a/web/apps/photos/src/components/gallery/LinkCopyChip.tsx b/web/apps/photos/src/components/gallery/LinkCopyChip.tsxnew file mode 100644index 0000000000..58e8e66882--- /dev/null+++ b/web/apps/photos/src/components/gallery/LinkCopyChip.tsx@@ -0,0 +1,46 @@+import { usePublicLinkURL } from "@/components/utils/use-public-link-url";+import { Copy01Icon, Tick02Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import { IconButton, Tooltip } from "@mui/material";+import { useClipboardCopy } from "ente-base/components/utils/hooks";+import type { Collection } from "ente-media/collection";+import { useSettingsSnapshot } from "ente-new/photos/components/utils/use-snapshot";+import { t } from "i18next";++export const LinkCopyChip = ({ collection }: { collection: Collection }) => {+ const { customDomain } = useSettingsSnapshot();+ const { resolvedURL } = usePublicLinkURL(+ collection,+ collection.publicURLs[0],+ customDomain,+ );+ const [copied, copy] = useClipboardCopy(resolvedURL ?? "");+ const label = t(copied ? "copied" : "copy_link");+ return (+ <Tooltip title={label}>+ <span style={{ position: "absolute", top: 8, right: 8 }}>+ <IconButton+ aria-label={`${label}: ${collection.name}`}+ disabled={!resolvedURL}+ onClick={copy}+ sx={{+ width: 28,+ height: 28,+ p: 0,+ borderRadius: "50%",+ bgcolor: "#FFFFFF",+ color: "#161616",+ boxShadow: "0px 2px 6px rgba(0,0,0,0.15)",+ "&:hover": { bgcolor: "#F4F4F4" },+ }}+ >+ <HugeiconsIcon+ icon={copied ? Tick02Icon : Copy01Icon}+ size={12}+ strokeWidth={1.5}+ />+ </IconButton>+ </span>+ </Tooltip>+ );+};diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsxindex f87986ab2e..0da8225f02 100644--- a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx+++ b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx@@ -126,6 +126,7 @@ export const PhotosNavigationShell: React.FC<if (galleryNavigation &&!props.isInSearchMode &&+ mode != "links" &&((props.mode == mode &&galleryNavigation.activeCollectionID !=PseudoCollectionID.all) ||diff --git a/web/apps/photos/src/components/gallery/reducer.ts b/web/apps/photos/src/components/gallery/reducer.tsindex 582a250b4f..1f3d373fd7 100644--- a/web/apps/photos/src/components/gallery/reducer.ts+++ b/web/apps/photos/src/components/gallery/reducer.ts@@ -1680,7 +1680,7 @@ const stateByUpdatingFilteredFiles = (state: GalleryState) => {const previousLinkID = state.view.selectedLinkID;const selectedLinkID = links.some(({ id }) => id == previousLinkID)? state.view.selectedLinkID- : links[0]?.id;+ : undefined;state = { ...state, view: { type: "links", selectedLinkID } };}if (state.isInSearchMode) {diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 628c9c84e5..a107dc3108 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -2213,6 +2213,8 @@ const Page: React.FC = () => {onAlbumSearchQueryChange: setAlbumSearchQuery,onShowAlbumOverview: handleShowAlbumOverview,onShowPeopleOverview: handleShowPeople,+ onShowLinksOverview: () =>+ handleChangeBarMode("links"),collectionSummaries:sidebarCollectionSummaries,visibleAlbumFilters: sidebarAlbumFilters,@@ -2319,7 +2321,26 @@ const Page: React.FC = () => {onRemotePull={remotePull}coverFile={selectedLinkSummary?.coverFile}/>- ) : null+ ) : (+ <AlbumsOverview+ albums={sidebarCollectionSummaries}+ title={t("links")}+ filter="links"+ linksByID={+ new Map(+ quickLinks.map((link) => [+ link.id,+ link,+ ]),+ )+ }+ searchQuery={albumSearchQuery}+ sortBy={collectionsSortBy}+ onSelectAlbum={selectGalleryCollection}+ onCreateAlbum={showAlbumNameInput}+ onRemotePull={remotePull}+ />+ )) : !isInSearchMode &&!isFirstLoad &&!state.collectionFiles.length &&diff --git a/web/apps/photos/tests/quick-links.test.ts b/web/apps/photos/tests/quick-links.test.tsindex 8f95eae4b8..5760358109 100644--- a/web/apps/photos/tests/quick-links.test.ts+++ b/web/apps/photos/tests/quick-links.test.ts@@ -66,7 +66,7 @@ describe("quick link membership", () => {});describe("Links navigation", () => {- test("selects the latest link and clears stale photo search state", () => {+ test("opens the overview and clears stale photo search state", () => {const state = galleryReducer({...mounted(),@@ -76,7 +76,10 @@ describe("Links navigation", () => {},{ type: "showLinks" },);- expect(state.view).toEqual({ type: "links", selectedLinkID: 2 });+ expect(state.view).toEqual({+ type: "links",+ selectedLinkID: undefined,+ });expect(state.selectedCollectionSummaryID).toBeUndefined();expect(state.filteredFiles).toEqual([]);expect(state.searchResults).toBeUndefined();@@ -84,6 +87,22 @@ describe("Links navigation", () => {expect(state.isRecomputingSearchResults).toBe(false);});+ test("returns to the overview when the Links group is selected again", () => {+ let state = galleryReducer(mounted(), {+ type: "selectLink",+ collectionID: 1,+ });+ state = galleryReducer(state, { type: "showLinks" });+ state = galleryReducer(state, {+ type: "setCollections",+ collections: [link(1), link(2), link(3)],+ });+ expect(state.view).toEqual({+ type: "links",+ selectedLinkID: undefined,+ });+ });+test("preserves selection when the list refreshes", () => {let state = galleryReducer(mounted(), {type: "selectLink",@@ -114,7 +133,10 @@ describe("Links navigation", () => {collections:change == "removed" ? [link(1)] : [link(1), updated],});- expect(state.view).toEqual({ type: "links", selectedLinkID: 1 });+ expect(state.view).toEqual({+ type: "links",+ selectedLinkID: undefined,+ });},);@@ -132,7 +154,10 @@ describe("Links navigation", () => {type: "setCollections",collections: [link(3)],});- expect(state.view).toEqual({ type: "links", selectedLinkID: 3 });+ expect(state.view).toEqual({+ type: "links",+ selectedLinkID: undefined,+ });});test("does not open a hidden link by an explicit ID", () => {@@ -142,7 +167,10 @@ describe("Links navigation", () => {type: "selectLink",collectionID: 3,});- expect(state.view).toEqual({ type: "links", selectedLinkID: 1 });+ expect(state.view).toEqual({+ type: "links",+ selectedLinkID: undefined,+ });});test("supports returning to Home and People", () => {diff --git a/web/apps/photos/tests/sidebar-album-search.test.tsx b/web/apps/photos/tests/sidebar-album-search.test.tsxindex 7c17252b1a..c7bcc292dd 100644--- a/web/apps/photos/tests/sidebar-album-search.test.tsx+++ b/web/apps/photos/tests/sidebar-album-search.test.tsx@@ -115,6 +115,7 @@ const renderSearch = (onAlbumSearchQueryChange: vi.fn(),onShowAlbumOverview: vi.fn(),onShowPeopleOverview: vi.fn(),+ onShowLinksOverview: vi.fn(),onShowCollectionSummary: vi.fn(),onSelectCollectionID: vi.fn(),onCreateAlbum: vi.fn(),diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex cc5c687223..c2ca7d8e39 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -803,6 +803,8 @@"shared_albums_label": "Shared","received_albums_label": "Received","links": "Links",+ "links_count_one": "{{count}} link",+ "links_count_other": "{{count}} links","search_links": "Search links","links_albums_label": "Links","empty_albums": "Empty",