π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
rename(upload):remove-v2-suffix
Aswin Asokf4274109e274
diff --git a/web/apps/albums/src/public-album/upload/components/Upload.tsx b/web/apps/albums/src/public-album/upload/components/Upload.tsxindex 272cea4d74..9a0caaedef 100644--- a/web/apps/albums/src/public-album/upload/components/Upload.tsx+++ b/web/apps/albums/src/public-album/upload/components/Upload.tsx@@ -35,9 +35,9 @@ import { useBaseContext } from "ente-base/context";import { basename } from "ente-base/file-name";import type { PublicAlbumsCredentials } from "ente-base/http";import log from "ente-base/log";-import { UploadProgressV2 } from "ente-gallery/components/upload-progress-v2/UploadProgressV2";+import { UploadProgress } from "ente-gallery/components/upload-progress/UploadProgress";import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";-import { DefaultOptionsV2 } from "ente-gallery/components/upload/DefaultOptionsV2";+import { DefaultOptions } from "ente-gallery/components/upload/DefaultOptions";import { useFileInput } from "ente-gallery/components/utils/use-file-input";import { hasReliableCanvasReadback } from "ente-gallery/utils/upload/canvas-integrity";import type { Collection } from "ente-media/collection";@@ -452,7 +452,7 @@ export const Upload: React.FC<UploadProps> = ({}onSelect={handleUploadTypeSelect}/>- <UploadProgressV2+ <UploadProgressopen={uploadProgressView}onClose={closeUploadProgress}percentComplete={percentComplete}@@ -579,7 +579,7 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({},}}>- <DefaultOptionsV2+ <DefaultOptionsintent="collect"isFileSelectionPending={pendingUploadType == "files"}isFolderSelectionPending={pendingUploadType == "folders"}diff --git a/web/apps/photos/src/components/TakeoutOptionsV2.tsx b/web/apps/photos/src/components/TakeoutOptions.tsxsimilarity index 97%rename from web/apps/photos/src/components/TakeoutOptionsV2.tsxrename to web/apps/photos/src/components/TakeoutOptions.tsxindex f8056adc7c..f745da4936 100644--- a/web/apps/photos/src/components/TakeoutOptionsV2.tsx+++ b/web/apps/photos/src/components/TakeoutOptions.tsx@@ -9,21 +9,21 @@ import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton"import { t } from "i18next";import React from "react";-interface TakeoutOptionsV2Props {+interface TakeoutOptionsProps {onBack: () => void;onClose: () => void;onSelectFolder: () => void;onSelectZips: () => void;}-export function TakeoutOptionsV2({+export function TakeoutOptions({onBack,onClose,onSelectFolder,onSelectZips,-}: TakeoutOptionsV2Props): React.JSX.Element {+}: TakeoutOptionsProps): React.JSX.Element {return (- <Stack data-takeout-options-v2 sx={{ gap: "36px", p: "20px" }}>+ <Stack data-takeout-options sx={{ gap: "36px", p: "20px" }}><Stackdirection="row"sx={{ alignItems: "center", justifyContent: "space-between" }}diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsxindex ad984694eb..a8be1c5825 100644--- a/web/apps/photos/src/components/Upload.tsx+++ b/web/apps/photos/src/components/Upload.tsx@@ -3,7 +3,7 @@/* eslint-disable react-hooks/exhaustive-deps *//* eslint-disable @typescript-eslint/no-misused-promises *//* eslint-disable @typescript-eslint/no-floating-promises */-import { TakeoutOptionsV2 } from "@/components/TakeoutOptionsV2";+import { TakeoutOptions } from "@/components/TakeoutOptions";import { UploadConfirmationDialog } from "@/components/UploadConfirmationDialog";import type {InProgressUpload,@@ -44,9 +44,9 @@ import type {ZipItem,} from "ente-base/types/ipc";import type { UploadTypeSelectorIntent } from "ente-gallery/components/Upload";-import { UploadProgressV2 } from "ente-gallery/components/upload-progress-v2/UploadProgressV2";+import { UploadProgress } from "ente-gallery/components/upload-progress/UploadProgress";import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";-import { DefaultOptionsV2 } from "ente-gallery/components/upload/DefaultOptionsV2";+import { DefaultOptions } from "ente-gallery/components/upload/DefaultOptions";import { useFileInput } from "ente-gallery/components/utils/use-file-input";import {groupItemsBasedOnParentFolder,@@ -1399,7 +1399,7 @@ export const Upload: React.FC<UploadProps> = ({}onSelect={handleUploadTypeSelect}/>- <UploadProgressV2+ <UploadProgressopen={uploadProgressView}onClose={closeUploadProgress}percentComplete={percentComplete}@@ -1774,7 +1774,7 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({boxShadow: "none",border: "1px solid",borderColor: "stroke.faint",- "&:has([data-default-options-v2], [data-takeout-options-v2])":+ "&:has([data-default-options], [data-takeout-options])":{maxWidth: "621px",p: 0,@@ -1848,14 +1848,14 @@ const UploadOptions: React.FC<UploadOptionsProps> = ({const handleSelectFolder = () => handleSelect("folders");return showTakeoutOptions ? (- <TakeoutOptionsV2+ <TakeoutOptionsonBack={handleTakeoutClose}onSelectFolder={handleSelectFolder}onSelectZips={handleSelectGooglePhotos}{...{ onClose }}/>) : (- <DefaultOptionsV2+ <DefaultOptionsintent={intent}isFileSelectionPending={pendingUploadType == "files"}isFolderSelectionPending={pendingUploadType == "folders"}diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 4f33884cbd..03b85857ab 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -79,7 +79,7 @@ import {} from "ente-new/photos/components/SelectedFileOptions";import { WhatsNew } from "ente-new/photos/components/WhatsNew";import {- GalleryEmptyStateV2,+ GalleryEmptyState,PeopleEmptyState,SearchResultsHeader,type RemotePullOpts,@@ -2216,7 +2216,7 @@ const Page: React.FC = () => {!isFirstLoad &&!state.collectionFiles.length &&activeCollectionID === PseudoCollectionID.all ? (- <GalleryEmptyStateV2+ <GalleryEmptyStateisUploadInProgress={uploadManager.isUploadInProgress()}onUpload={openUploader}/>diff --git a/web/packages/gallery/components/UploadCompletionV2.tsx b/web/packages/gallery/components/UploadCompletion.tsxsimilarity index 97%rename from web/packages/gallery/components/UploadCompletionV2.tsxrename to web/packages/gallery/components/UploadCompletion.tsxindex e9b70876bb..f15c070b22 100644--- a/web/packages/gallery/components/UploadCompletionV2.tsx+++ b/web/packages/gallery/components/UploadCompletion.tsx@@ -18,7 +18,7 @@ import {type SegregatedFinishedUploads,} from "./uploadProgressStats";-export function UploadCompletionV2({+export function UploadCompletion({open,onClose,onReviewFailed,@@ -50,7 +50,7 @@ export function UploadCompletionV2({openonClose={handleClose}maxWidth={false}- aria-labelledby="upload-completion-v2-title"+ aria-labelledby="upload-completion-title"slotProps={{ paper: { sx: completionDialogPaperSx } }}><Stack sx={completionDialogContentSx}>@@ -72,7 +72,7 @@ export function UploadCompletionV2({/><Stack sx={{ gap: "6px", alignItems: "center" }}><Typography- id="upload-completion-v2-title"+ id="upload-completion-title"component="h2"sx={completionTitleSx}>diff --git a/web/packages/gallery/components/upload-progress-v2/MinimizedUploadProgress.tsx b/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsxsimilarity index 100%rename from web/packages/gallery/components/upload-progress-v2/MinimizedUploadProgress.tsxrename to web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsxdiff --git a/web/packages/gallery/components/upload-progress-v2/StopUploadConfirmationDialog.tsx b/web/packages/gallery/components/upload-progress/StopUploadConfirmationDialog.tsxsimilarity index 100%rename from web/packages/gallery/components/upload-progress-v2/StopUploadConfirmationDialog.tsxrename to web/packages/gallery/components/upload-progress/StopUploadConfirmationDialog.tsxdiff --git a/web/packages/gallery/components/upload-progress-v2/UploadFileList.tsx b/web/packages/gallery/components/upload-progress/UploadFileList.tsxsimilarity index 100%rename from web/packages/gallery/components/upload-progress-v2/UploadFileList.tsxrename to web/packages/gallery/components/upload-progress/UploadFileList.tsxdiff --git a/web/packages/gallery/components/upload-progress-v2/UploadProgressV2.tsx b/web/packages/gallery/components/upload-progress/UploadProgress.tsxsimilarity index 94%rename from web/packages/gallery/components/upload-progress-v2/UploadProgressV2.tsxrename to web/packages/gallery/components/upload-progress/UploadProgress.tsxindex 40d66ce16d..ab3d367ade 100644--- a/web/packages/gallery/components/upload-progress-v2/UploadProgressV2.tsx+++ b/web/packages/gallery/components/upload-progress/UploadProgress.tsx@@ -1,7 +1,7 @@import type { PreUploadSkippedFile } from "ente-base/types/ipc";import type { UploadPhase } from "ente-gallery/services/upload";import { useEffect, useState } from "react";-import { UploadCompletionV2 } from "../UploadCompletionV2";+import { UploadCompletion } from "../UploadCompletion";import type {InProgressUpload,SegregatedFinishedUploads,@@ -30,13 +30,13 @@ interface UploadProgressProps {const emptyPreUploadSkippedFiles: PreUploadSkippedFile[] = [];-export function UploadProgressV2(props: UploadProgressProps) {+export function UploadProgress(props: UploadProgressProps) {if (!props.open) return null;- return <UploadProgress {...props} />;+ return <UploadProgressBody {...props} />;}-function UploadProgress({+function UploadProgressBody({onClose,uploadCounter,uploadPhase,@@ -93,7 +93,7 @@ function UploadProgress({if (uploadPhase == "done" && expanded && !summaryMode) {return (- <UploadCompletionV2+ <UploadCompletionopenonClose={onClose}onReviewFailed={handleReviewFailed}diff --git a/web/packages/gallery/components/upload-progress-v2/UploadProgressDetails.tsx b/web/packages/gallery/components/upload-progress/UploadProgressDetails.tsxsimilarity index 100%rename from web/packages/gallery/components/upload-progress-v2/UploadProgressDetails.tsxrename to web/packages/gallery/components/upload-progress/UploadProgressDetails.tsxdiff --git a/web/packages/gallery/components/upload-progress-v2/UploadProgressDialog.tsx b/web/packages/gallery/components/upload-progress/UploadProgressDialog.tsxsimilarity index 97%rename from web/packages/gallery/components/upload-progress-v2/UploadProgressDialog.tsxrename to web/packages/gallery/components/upload-progress/UploadProgressDialog.tsxindex 198598297e..f26f9f27e6 100644--- a/web/packages/gallery/components/upload-progress-v2/UploadProgressDialog.tsx+++ b/web/packages/gallery/components/upload-progress/UploadProgressDialog.tsx@@ -34,16 +34,16 @@ export function UploadProgressDialog() {openonClose={handleClose}maxWidth={false}- aria-labelledby="upload-progress-v2-title"+ aria-labelledby="upload-progress-title"slotProps={{ paper: { sx: uploadProgressDialogPaperSx } }}><Box sx={uploadProgressDialogContentSx(isDone)}>- <UploadProgressV2Header />+ <UploadProgressHeader />{isDone ? (<UploadProgressDetails />) : (<Stack sx={{ gap: 3 }}>- <UploadProgressV2Summary />+ <UploadProgressSummary /><UploadProgressDetails /></Stack>)}@@ -52,7 +52,7 @@ export function UploadProgressDialog() {);}-function UploadProgressV2Header() {+function UploadProgressHeader() {const { onClose, setExpanded, uploadPhase } = useUploadProgressContext();const isDone = uploadPhase == "done";const title = t(isDone ? "upload_details" : "file_upload");@@ -62,7 +62,7 @@ function UploadProgressV2Header() {return (<Stack direction="row" sx={[headerSx, isDone && quietHeaderSx]}><Typography- id="upload-progress-v2-title"+ id="upload-progress-title"component="h2"sx={uploadTitleSx}>@@ -88,7 +88,7 @@ function UploadProgressV2Header() {);}-function UploadProgressV2Summary() {+function UploadProgressSummary() {const context = useUploadProgressContext();const { uploadPhase, percentComplete } = context;const isUploading = uploadPhase == "uploading";diff --git a/web/packages/gallery/components/upload-progress-v2/context.ts b/web/packages/gallery/components/upload-progress/context.tssimilarity index 100%rename from web/packages/gallery/components/upload-progress-v2/context.tsrename to web/packages/gallery/components/upload-progress/context.tsdiff --git a/web/packages/gallery/components/upload-progress-v2/helpers.ts b/web/packages/gallery/components/upload-progress/helpers.tssimilarity index 100%rename from web/packages/gallery/components/upload-progress-v2/helpers.tsrename to web/packages/gallery/components/upload-progress/helpers.tsdiff --git a/web/packages/gallery/components/upload-progress-v2/useMinimizedUploadDrag.ts b/web/packages/gallery/components/upload-progress/useMinimizedUploadDrag.tssimilarity index 100%rename from web/packages/gallery/components/upload-progress-v2/useMinimizedUploadDrag.tsrename to web/packages/gallery/components/upload-progress/useMinimizedUploadDrag.tsdiff --git a/web/packages/gallery/components/upload/DefaultOptionsV2.tsx b/web/packages/gallery/components/upload/DefaultOptions.tsxsimilarity index 98%rename from web/packages/gallery/components/upload/DefaultOptionsV2.tsxrename to web/packages/gallery/components/upload/DefaultOptions.tsxindex 9a18001341..9fdc2082c0 100644--- a/web/packages/gallery/components/upload/DefaultOptionsV2.tsx+++ b/web/packages/gallery/components/upload/DefaultOptions.tsx@@ -18,7 +18,7 @@ import { t } from "i18next";import React from "react";import type { UploadTypeSelectorIntent } from "../Upload";-interface DefaultOptionsV2BaseProps {+interface DefaultOptionsBaseProps {isFileSelectionPending: boolean;isFolderSelectionPending: boolean;onClose: () => void;@@ -26,13 +26,13 @@ interface DefaultOptionsV2BaseProps {onSelectFolder: () => void;}-type DefaultOptionsV2Props = DefaultOptionsV2BaseProps &+type DefaultOptionsProps = DefaultOptionsBaseProps &(| { intent: UploadTypeSelectorIntent; onSelectGooglePhotos: () => void }| { intent: "collect"; onSelectGooglePhotos?: never });-export function DefaultOptionsV2({+export function DefaultOptions({intent,isFileSelectionPending,isFolderSelectionPending,@@ -40,12 +40,12 @@ export function DefaultOptionsV2({onSelectFiles,onSelectGooglePhotos,onSelectFolder,-}: DefaultOptionsV2Props): React.JSX.Element {+}: DefaultOptionsProps): React.JSX.Element {const usesUploadSpacing = intent == "upload" || intent == "collect";return (<Stack- data-default-options-v2+ data-default-optionssx={{gap: usesUploadSpacing ? "20px" : "36px",p: "20px",@@ -127,7 +127,7 @@ export function DefaultOptionsV2({}type ImportOptionsProps = Pick<- DefaultOptionsV2BaseProps,+ DefaultOptionsBaseProps,"isFolderSelectionPending" | "onSelectFolder"> & { onSelectGooglePhotos: () => void };@@ -170,7 +170,7 @@ function ImportOptions({}type UploadOptionsProps = Pick<- DefaultOptionsV2BaseProps,+ DefaultOptionsBaseProps,| "isFileSelectionPending"| "isFolderSelectionPending"| "onSelectFiles"@@ -232,7 +232,7 @@ function UploadOptions({}type CollectOptionsProps = Pick<- DefaultOptionsV2BaseProps,+ DefaultOptionsBaseProps,| "isFileSelectionPending"| "isFolderSelectionPending"| "onSelectFiles"diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsxindex 3ddd37d4a3..4cf9b84f33 100644--- a/web/packages/new/photos/components/CollectionSelector.tsx+++ b/web/packages/new/photos/components/CollectionSelector.tsx@@ -1,8 +1,37 @@+import AddIcon from "@mui/icons-material/Add";+import CloseIcon from "@mui/icons-material/Close";+import FavoriteIcon from "@mui/icons-material/Favorite";+import PushPinIcon from "@mui/icons-material/PushPin";+import SearchIcon from "@mui/icons-material/Search";+import {+ Box,+ Dialog,+ IconButton,+ InputBase,+ Stack,+ styled,+ Tooltip,+ Typography,+ useMediaQuery,+ type SxProps,+ type Theme,+} from "@mui/material";import type { ModalVisibilityProps } from "ente-base/components/utils/modal";import type { Collection } from "ente-media/collection";-import type { CollectionSummaries } from "ente-new/photos/services/collection-summary";-import React from "react";-import { CollectionSelectorV2 } from "./CollectionSelectorV2";+import { CollectionsSortOptions } from "ente-new/photos/components/CollectionsSortOptions";+import { BaseTileButton, ItemCard } from "ente-new/photos/components/Tiles";+import {+ canAddToCollection,+ canMoveToCollection,+ collectionsSortBy,+ sortCollectionSummaries,+ type CollectionsSortBy,+ type CollectionSummaries,+ type CollectionSummary,+} from "ente-new/photos/services/collection-summary";+import { includes } from "ente-utils/type-guards";+import { t } from "i18next";+import React, { useCallback, useEffect, useMemo, useState } from "react";export type CollectionSelectorAction =| "upload"@@ -96,10 +125,476 @@ export type CollectionSelectorProps = ModalVisibilityProps & {/*** A dialog allowing the user to select one of their existing collections or- * create a new one.+ * create a new one, styled to match the upload design system.*/export const CollectionSelector: React.FC<CollectionSelectorProps> = (props,) => {- return <CollectionSelectorV2 {...props} />;+ const {+ open,+ onClose,+ onExited,+ attributes,+ collectionSummaries,+ collectionForCollectionSummaryID,+ } = props;++ // Make the dialog fullscreen if the screen is <= the dialog's max width.+ const isFullScreen = useMediaQuery("(max-width: 490px)");++ const [searchTerm, setSearchTerm] = useState("");+ const [sortBy, setSortBy] =+ useCollectionSelectorSortByLocalState("name-asc");+ const [filteredCollections, setFilteredCollections] = useState<+ CollectionSummary[]+ >([]);++ const handleExited = useCallback(() => {+ setSearchTerm("");+ onExited?.();+ }, [onExited]);++ useEffect(() => {+ if (!attributes || !open) return;++ const activeCollectionID = attributes.activeCollectionID;+ const selectableCollections = [...collectionSummaries.values()].filter(+ (collectionSummary) => {+ if (+ collectionSummary.id ===+ attributes.sourceCollectionSummaryID+ ) {+ return false;+ }++ const isUserFavorites =+ collectionSummary.type === "userFavorites";+ if (+ attributes.action === "add" ||+ attributes.action === "move"+ ) {+ return (+ canAddToCollection(collectionSummary) &&+ !isUserFavorites+ );+ }+ if (attributes.action === "upload") {+ return (+ (canAddToCollection(collectionSummary) ||+ collectionSummary.type === "uncategorized") &&+ !isUserFavorites+ );+ }+ if (attributes.action === "restore") {+ return (+ (canMoveToCollection(collectionSummary) ||+ collectionSummary.type === "uncategorized") &&+ !isUserFavorites+ );+ }+ return (+ canMoveToCollection(collectionSummary) && !isUserFavorites+ );+ },+ );++ const collections = sortCollectionSummaries(+ selectableCollections,+ sortBy,+ )+ .sort((a, b) => b.sortPriority - a.sortPriority)+ .sort((a, b) => {+ if (a.id === activeCollectionID) return -1;+ if (b.id === activeCollectionID) return 1;+ return 0;+ });++ if (collections.length === 0) {+ onClose();+ attributes.onCreateCollection();+ handleExited();+ }++ setFilteredCollections(collections);+ }, [collectionSummaries, attributes, open, onClose, sortBy, handleExited]);++ const searchFilteredCollections = useMemo(() => {+ if (!searchTerm.trim()) return filteredCollections;+ const searchLower = searchTerm.toLowerCase();+ return filteredCollections.filter((collectionSummary) =>+ collectionSummary.name.toLowerCase().includes(searchLower),+ );+ }, [filteredCollections, searchTerm]);++ const showCreateButton =+ !searchTerm.trim() ||+ t("create_albums").toLowerCase().includes(searchTerm.toLowerCase());++ if (!filteredCollections.length || !attributes) return null;++ const { action, onCancel, onCreateCollection, onSelectCollection } =+ attributes;++ const handleCollectionSummaryClick = async (id: number) => {+ onSelectCollection(await collectionForCollectionSummaryID(id));+ onClose();+ };++ const handleClose = () => {+ onCancel?.();+ onClose();+ };++ return (+ <Dialog+ open={open}+ onClose={handleClose}+ fullScreen={isFullScreen}+ maxWidth={false}+ slotProps={{+ paper: { sx: paperSx },+ transition: { onExited: handleExited },+ }}+ >+ <Stack sx={headerSx}>+ <Stack direction="row" sx={headerRowSx}>+ <Stack sx={{ minWidth: 0, gap: "2px" }}>+ <Typography sx={titleSx}>+ {collectionSelectorTitle(action)}+ </Typography>+ <Typography sx={countSx}>+ {searchTerm+ ? `${searchFilteredCollections.length} / ${filteredCollections.length} ${t("albums")}`+ : t("albums_count", {+ count: filteredCollections.length,+ })}+ </Typography>+ </Stack>+ <Stack direction="row" sx={headerActionsSx}>+ <CollectionsSortOptions+ activeSortBy={sortBy}+ onChangeSortBy={setSortBy}+ nestedInDialog+ variant="v2"+ />+ <IconButton+ aria-label={t("close")}+ onClick={handleClose}+ sx={iconButtonSx}+ >+ <CloseIcon sx={{ fontSize: 18 }} />+ </IconButton>+ </Stack>+ </Stack>+ <SearchField value={searchTerm} onChange={setSearchTerm} />+ </Stack>+ <Box sx={dividerSx} />+ {searchFilteredCollections.length === 0 && !showCreateButton ? (+ <Box sx={noResultsSx}>+ <Typography sx={{ color: "text.muted" }}>+ {t("no_results")}+ </Typography>+ </Box>+ ) : (+ <Box sx={gridSx}>+ {showCreateButton && (+ <CreateAlbumTile onClick={onCreateCollection} />+ )}+ {searchFilteredCollections.map((collectionSummary) => (+ <CollectionSummaryButton+ key={collectionSummary.id}+ collectionSummary={collectionSummary}+ onClick={handleCollectionSummaryClick}+ />+ ))}+ </Box>+ )}+ </Dialog>+ );+};++const collectionSelectorTitle = (action: CollectionSelectorAction) => {+ switch (action) {+ case "upload":+ return t("upload_to_album");+ case "add":+ return t("add_to_album");+ case "move":+ return t("move_to_album");+ case "restore":+ return t("restore_to_album");+ case "unhide":+ return t("unhide_to_album");+ }};++const useCollectionSelectorSortByLocalState = (+ initialValue: CollectionsSortBy,+) => {+ const key = "collectionSelectorSortBy";+ const [value, setValue] = useState(initialValue);++ useEffect(() => {+ const storedValue = localStorage.getItem(key);+ if (storedValue && includes(collectionsSortBy, storedValue)) {+ setValue(storedValue);+ }+ }, []);++ const setter = (newValue: CollectionsSortBy) => {+ localStorage.setItem(key, newValue);+ setValue(newValue);+ };++ return [value, setter] as const;+};++const surfaceStroke = "#e0e0e0";+const surfaceStrokeDark = "rgba(255 255 255 / 0.12)";++const paperSx: SxProps<Theme> = (theme) => ({+ width: "min(500px, calc(100svw - 32px))",+ maxWidth: "500px",+ boxSizing: "content-box",+ borderRadius: "20px",+ border: `1px solid ${surfaceStroke}`,+ backgroundColor: "#f4f4f4",+ backgroundImage: "none",+ boxShadow: "none",+ color: "text.base",+ "@media (min-width: 491px)": { height: "100%" },+ "@media (max-width: 490px)": {+ width: "100%",+ maxWidth: "100%",+ height: "100%",+ boxSizing: "border-box",+ borderRadius: 0,+ border: "none",+ },+ ...theme.applyStyles("dark", {+ borderColor: surfaceStrokeDark,+ backgroundColor: "#1b1b1b",+ }),+});++const headerSx = { p: "20px", gap: "16px" };+const headerRowSx = {+ alignItems: "flex-start",+ justifyContent: "space-between",+ gap: "12px",+};+const headerActionsSx = { alignItems: "center", gap: 1, flexShrink: 0 };+const titleSx = {+ fontSize: 24,+ lineHeight: "32px",+ fontWeight: 600,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+};+const countSx = {+ fontSize: 14,+ lineHeight: "20px",+ fontWeight: 500,+ color: "text.muted",+};+const iconButtonSx = (theme: Theme) => ({+ width: 38,+ height: 38,+ p: 0,+ color: "text.base",+ backgroundColor: "background.paper",+ "&:hover": { backgroundColor: "fill.faintHover" },+ ...theme.applyStyles("dark", {+ backgroundColor: "rgba(255 255 255 / 0.12)",+ }),+});+const dividerSx = (theme: Theme) => ({+ height: "1px",+ backgroundColor: "rgba(0 0 0 / 0.06)",+ ...theme.applyStyles("dark", {+ backgroundColor: "rgba(255 255 255 / 0.08)",+ }),+});+const gridSx = {+ flex: 1,+ minHeight: 0,+ p: "16px 20px 20px",+ display: "grid",+ gridTemplateColumns: "repeat(3, minmax(0, 1fr))",+ gridAutoRows: "max-content",+ gap: "8px",+ alignContent: "start",+ overflowY: "auto",+};+const noResultsSx = {+ flex: 1,+ display: "flex",+ justifyContent: "center",+ alignItems: "center",+ minHeight: 154,+};++const TileButton = styled(BaseTileButton)`+ width: 100%;+ aspect-ratio: 1;+ height: auto;+ border-radius: 16px;+`;++const TopGradientOverlay = styled("div")`+ position: absolute;+ inset: 0;+ padding: 10px;+ color: #fff;+ background: linear-gradient(+ -10deg,+ rgba(0, 0, 0, 0.1) 0%,+ rgba(0, 0, 0, 0.2) 50%,+ rgba(0, 0, 0, 0.4) 60%,+ rgba(0, 0, 0, 0.6) 100%+ );+`;++interface CollectionSummaryButtonProps {+ collectionSummary: CollectionSummary;+ onClick: (collectionSummaryID: number) => void;+}++const CollectionSummaryButton: React.FC<CollectionSummaryButtonProps> = ({+ collectionSummary,+ onClick,+}) => {+ const isFavorite = collectionSummary.type === "userFavorites";+ const isPinned =+ collectionSummary.attributes.has("pinned") ||+ collectionSummary.attributes.has("shareePinned");++ return (+ <ItemCard+ TileComponent={TileButton}+ coverFile={collectionSummary.coverFile}+ onClick={() => onClick(collectionSummary.id)}+ >+ <TopGradientOverlay>+ <Tooltip title={collectionSummary.name} arrow>+ <Typography+ sx={{+ fontSize: 14,+ lineHeight: "20px",+ fontWeight: 500,+ overflow: "hidden",+ textOverflow: "ellipsis",+ display: "-webkit-box",+ WebkitLineClamp: 3,+ WebkitBoxOrient: "vertical",+ }}+ >+ {collectionSummary.name}+ </Typography>+ </Tooltip>+ </TopGradientOverlay>+ {(isFavorite || isPinned) && (+ <Box+ sx={{+ position: "absolute",+ bottom: 8,+ right: 8,+ display: "flex",+ gap: 0.5,+ }}+ >+ {isFavorite && (+ <FavoriteIcon sx={{ fontSize: 20, color: "white" }} />+ )}+ {isPinned && (+ <PushPinIcon sx={{ fontSize: 20, color: "white" }} />+ )}+ </Box>+ )}+ </ItemCard>+ );+};++const CreateAlbumTile: React.FC<{ onClick: () => void }> = ({ onClick }) => (+ <TileButton+ aria-label={t("new_album")}+ onClick={onClick}+ sx={{ borderRadius: "16px" }}+ >+ <CreateTileInner>+ <AddIcon />+ </CreateTileInner>+ </TileButton>+);++const CreateTileInner = styled("span")(({ theme }) => ({+ position: "absolute",+ inset: 0,+ padding: 10,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ border: "1px dashed",+ borderColor: theme.vars.palette.stroke.muted,+ borderRadius: 16,+ color: theme.vars.palette.text.muted,+ "&:hover": { borderColor: "rgba(0 0 0 / 0.45)" },+ ...theme.applyStyles("dark", {+ "&:hover": { borderColor: "rgba(255 255 255 / 0.45)" },+ }),+}));++interface SearchFieldProps {+ value: string;+ onChange: (value: string) => void;+}++const SearchField: React.FC<SearchFieldProps> = ({ value, onChange }) => (+ <Stack direction="row" sx={searchFieldSx}>+ <SearchIcon sx={searchIconSx} />+ <InputBase+ fullWidth+ autoFocus+ placeholder={t("albums_search_hint")}+ value={value}+ onChange={(e) => onChange(e.target.value)}+ sx={{+ fontSize: 14,+ lineHeight: "20px",+ fontWeight: 500,+ color: "text.base",+ "& input::placeholder": { color: "text.muted", opacity: 1 },+ }}+ endAdornment={+ value ? (+ <CloseIcon+ fontSize="small"+ onClick={() => onChange("")}+ sx={{+ color: "stroke.muted",+ cursor: "pointer",+ "&:hover": { color: "text.base" },+ }}+ />+ ) : undefined+ }+ />+ </Stack>+);++const searchFieldSx = (theme: Theme) => ({+ alignItems: "center",+ gap: "10px",+ height: 44,+ borderRadius: "16px",+ backgroundColor: "background.paper",+ px: "14px",+ ...theme.applyStyles("dark", { backgroundColor: "#282828" }),+});+const searchIconSx = (theme: Theme) => ({+ fontSize: 20,+ flexShrink: 0,+ color: "rgba(0 0 0 / 0.4)",+ ...theme.applyStyles("dark", { color: "rgba(255 255 255 / 0.4)" }),+});diff --git a/web/packages/new/photos/components/CollectionSelectorV2.tsx b/web/packages/new/photos/components/CollectionSelectorV2.tsxdeleted file mode 100644index 3a6a6c922e..0000000000--- a/web/packages/new/photos/components/CollectionSelectorV2.tsx+++ /dev/null@@ -1,516 +0,0 @@-import AddIcon from "@mui/icons-material/Add";-import CloseIcon from "@mui/icons-material/Close";-import FavoriteIcon from "@mui/icons-material/Favorite";-import PushPinIcon from "@mui/icons-material/PushPin";-import SearchIcon from "@mui/icons-material/Search";-import {- Box,- Dialog,- IconButton,- InputBase,- Stack,- styled,- Tooltip,- Typography,- useMediaQuery,- type SxProps,- type Theme,-} from "@mui/material";-import { CollectionsSortOptions } from "ente-new/photos/components/CollectionsSortOptions";-import { BaseTileButton, ItemCard } from "ente-new/photos/components/Tiles";-import {- canAddToCollection,- canMoveToCollection,- collectionsSortBy,- sortCollectionSummaries,- type CollectionsSortBy,- type CollectionSummary,-} from "ente-new/photos/services/collection-summary";-import { includes } from "ente-utils/type-guards";-import { t } from "i18next";-import React, { useCallback, useEffect, useMemo, useState } from "react";-import type {- CollectionSelectorAction,- CollectionSelectorProps,-} from "./CollectionSelector";--/**- * The V2 variant of {@link CollectionSelector}, restyled to match the upload- * design system (paper surfaces, hairline borders, radius 20 dialog, 16px- * tiles, paper-filled 38px icon buttons).- *- * It preserves the exact same behaviour and props as the classic selector; only- * the presentation differs. See {@link CollectionSelector} for a description of- * the props.- */-export const CollectionSelectorV2: React.FC<CollectionSelectorProps> = (- props,-) => {- const {- open,- onClose,- onExited,- attributes,- collectionSummaries,- collectionForCollectionSummaryID,- } = props;-- // Make the dialog fullscreen if the screen is <= the dialog's max width.- const isFullScreen = useMediaQuery("(max-width: 490px)");-- const [searchTerm, setSearchTerm] = useState("");- const [sortBy, setSortBy] =- useCollectionSelectorSortByLocalState("name-asc");- const [filteredCollections, setFilteredCollections] = useState<- CollectionSummary[]- >([]);-- const handleExited = useCallback(() => {- setSearchTerm("");- onExited?.();- }, [onExited]);-- useEffect(() => {- if (!attributes || !open) return;-- const activeCollectionID = attributes.activeCollectionID;- const selectableCollections = [...collectionSummaries.values()].filter(- (collectionSummary) => {- if (- collectionSummary.id ===- attributes.sourceCollectionSummaryID- ) {- return false;- }-- const isUserFavorites =- collectionSummary.type === "userFavorites";- if (- attributes.action === "add" ||- attributes.action === "move"- ) {- return (- canAddToCollection(collectionSummary) &&- !isUserFavorites- );- }- if (attributes.action === "upload") {- return (- (canAddToCollection(collectionSummary) ||- collectionSummary.type === "uncategorized") &&- !isUserFavorites- );- }- if (attributes.action === "restore") {- return (- (canMoveToCollection(collectionSummary) ||- collectionSummary.type === "uncategorized") &&- !isUserFavorites- );- }- return (- canMoveToCollection(collectionSummary) && !isUserFavorites- );- },- );-- const collections = sortCollectionSummaries(- selectableCollections,- sortBy,- )- .sort((a, b) => b.sortPriority - a.sortPriority)- .sort((a, b) => {- if (a.id === activeCollectionID) return -1;- if (b.id === activeCollectionID) return 1;- return 0;- });-- if (collections.length === 0) {- onClose();- attributes.onCreateCollection();- handleExited();- }-- setFilteredCollections(collections);- }, [collectionSummaries, attributes, open, onClose, sortBy, handleExited]);-- const searchFilteredCollections = useMemo(() => {- if (!searchTerm.trim()) return filteredCollections;- const searchLower = searchTerm.toLowerCase();- return filteredCollections.filter((collectionSummary) =>- collectionSummary.name.toLowerCase().includes(searchLower),- );- }, [filteredCollections, searchTerm]);-- const showCreateButton =- !searchTerm.trim() ||- t("create_albums").toLowerCase().includes(searchTerm.toLowerCase());-- if (!filteredCollections.length || !attributes) return null;-- const { action, onCancel, onCreateCollection, onSelectCollection } =- attributes;-- const handleCollectionSummaryClick = async (id: number) => {- onSelectCollection(await collectionForCollectionSummaryID(id));- onClose();- };-- const handleClose = () => {- onCancel?.();- onClose();- };-- return (- <Dialog- open={open}- onClose={handleClose}- fullScreen={isFullScreen}- maxWidth={false}- slotProps={{- paper: { sx: paperSx },- transition: { onExited: handleExited },- }}- >- <Stack sx={headerSx}>- <Stack direction="row" sx={headerRowSx}>- <Stack sx={{ minWidth: 0, gap: "2px" }}>- <Typography sx={titleSx}>- {collectionSelectorTitle(action)}- </Typography>- <Typography sx={countSx}>- {searchTerm- ? `${searchFilteredCollections.length} / ${filteredCollections.length} ${t("albums")}`- : t("albums_count", {- count: filteredCollections.length,- })}- </Typography>- </Stack>- <Stack direction="row" sx={headerActionsSx}>- <CollectionsSortOptions- activeSortBy={sortBy}- onChangeSortBy={setSortBy}- nestedInDialog- variant="v2"- />- <IconButton- aria-label={t("close")}- onClick={handleClose}- sx={iconButtonSx}- >- <CloseIcon sx={{ fontSize: 18 }} />- </IconButton>- </Stack>- </Stack>- <SearchFieldV2 value={searchTerm} onChange={setSearchTerm} />- </Stack>- <Box sx={dividerSx} />- {searchFilteredCollections.length === 0 && !showCreateButton ? (- <Box sx={noResultsSx}>- <Typography sx={{ color: "text.muted" }}>- {t("no_results")}- </Typography>- </Box>- ) : (- <Box sx={gridSx}>- {showCreateButton && (- <CreateAlbumTile onClick={onCreateCollection} />- )}- {searchFilteredCollections.map((collectionSummary) => (- <CollectionSummaryButtonV2- key={collectionSummary.id}- collectionSummary={collectionSummary}- onClick={handleCollectionSummaryClick}- />- ))}- </Box>- )}- </Dialog>- );-};--const collectionSelectorTitle = (action: CollectionSelectorAction) => {- switch (action) {- case "upload":- return t("upload_to_album");- case "add":- return t("add_to_album");- case "move":- return t("move_to_album");- case "restore":- return t("restore_to_album");- case "unhide":- return t("unhide_to_album");- }-};--const useCollectionSelectorSortByLocalState = (- initialValue: CollectionsSortBy,-) => {- const key = "collectionSelectorSortBy";- const [value, setValue] = useState(initialValue);-- useEffect(() => {- const storedValue = localStorage.getItem(key);- if (storedValue && includes(collectionsSortBy, storedValue)) {- setValue(storedValue);- }- }, []);-- const setter = (newValue: CollectionsSortBy) => {- localStorage.setItem(key, newValue);- setValue(newValue);- };-- return [value, setter] as const;-};--const surfaceStroke = "#e0e0e0";-const surfaceStrokeDark = "rgba(255 255 255 / 0.12)";--const paperSx: SxProps<Theme> = (theme) => ({- width: "min(500px, calc(100svw - 32px))",- maxWidth: "500px",- boxSizing: "content-box",- borderRadius: "20px",- border: `1px solid ${surfaceStroke}`,- backgroundColor: "#f4f4f4",- backgroundImage: "none",- boxShadow: "none",- color: "text.base",- "@media (min-width: 491px)": { height: "100%" },- "@media (max-width: 490px)": {- width: "100%",- maxWidth: "100%",- height: "100%",- boxSizing: "border-box",- borderRadius: 0,- border: "none",- },- ...theme.applyStyles("dark", {- borderColor: surfaceStrokeDark,- backgroundColor: "#1b1b1b",- }),-});--const headerSx = { p: "20px", gap: "16px" };-const headerRowSx = {- alignItems: "flex-start",- justifyContent: "space-between",- gap: "12px",-};-const headerActionsSx = { alignItems: "center", gap: 1, flexShrink: 0 };-const titleSx = {- fontSize: 24,- lineHeight: "32px",- fontWeight: 600,- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",-};-const countSx = {- fontSize: 14,- lineHeight: "20px",- fontWeight: 500,- color: "text.muted",-};-const iconButtonSx = (theme: Theme) => ({- width: 38,- height: 38,- p: 0,- color: "text.base",- backgroundColor: "background.paper",- "&:hover": { backgroundColor: "fill.faintHover" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255 255 255 / 0.12)",- }),-});-const dividerSx = (theme: Theme) => ({- height: "1px",- backgroundColor: "rgba(0 0 0 / 0.06)",- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255 255 255 / 0.08)",- }),-});-const gridSx = {- flex: 1,- minHeight: 0,- p: "16px 20px 20px",- display: "grid",- gridTemplateColumns: "repeat(3, minmax(0, 1fr))",- gridAutoRows: "max-content",- gap: "8px",- alignContent: "start",- overflowY: "auto",-};-const noResultsSx = {- flex: 1,- display: "flex",- justifyContent: "center",- alignItems: "center",- minHeight: 154,-};--const TileButtonV2 = styled(BaseTileButton)`- width: 100%;- aspect-ratio: 1;- height: auto;- border-radius: 16px;-`;--const TopGradientOverlay = styled("div")`- position: absolute;- inset: 0;- padding: 10px;- color: #fff;- background: linear-gradient(- -10deg,- rgba(0, 0, 0, 0.1) 0%,- rgba(0, 0, 0, 0.2) 50%,- rgba(0, 0, 0, 0.4) 60%,- rgba(0, 0, 0, 0.6) 100%- );-`;--interface CollectionSummaryButtonV2Props {- collectionSummary: CollectionSummary;- onClick: (collectionSummaryID: number) => void;-}--const CollectionSummaryButtonV2: React.FC<CollectionSummaryButtonV2Props> = ({- collectionSummary,- onClick,-}) => {- const isFavorite = collectionSummary.type === "userFavorites";- const isPinned =- collectionSummary.attributes.has("pinned") ||- collectionSummary.attributes.has("shareePinned");-- return (- <ItemCard- TileComponent={TileButtonV2}- coverFile={collectionSummary.coverFile}- onClick={() => onClick(collectionSummary.id)}- >- <TopGradientOverlay>- <Tooltip title={collectionSummary.name} arrow>- <Typography- sx={{- fontSize: 14,- lineHeight: "20px",- fontWeight: 500,- overflow: "hidden",- textOverflow: "ellipsis",- display: "-webkit-box",- WebkitLineClamp: 3,- WebkitBoxOrient: "vertical",- }}- >- {collectionSummary.name}- </Typography>- </Tooltip>- </TopGradientOverlay>- {(isFavorite || isPinned) && (- <Box- sx={{- position: "absolute",- bottom: 8,- right: 8,- display: "flex",- gap: 0.5,- }}- >- {isFavorite && (- <FavoriteIcon sx={{ fontSize: 20, color: "white" }} />- )}- {isPinned && (- <PushPinIcon sx={{ fontSize: 20, color: "white" }} />- )}- </Box>- )}- </ItemCard>- );-};--const CreateAlbumTile: React.FC<{ onClick: () => void }> = ({ onClick }) => (- <TileButtonV2- aria-label={t("new_album")}- onClick={onClick}- sx={{ borderRadius: "16px" }}- >- <CreateTileInner>- <AddIcon />- </CreateTileInner>- </TileButtonV2>-);--const CreateTileInner = styled("span")(({ theme }) => ({- position: "absolute",- inset: 0,- padding: 10,- display: "flex",- alignItems: "center",- justifyContent: "center",- border: "1px dashed",- borderColor: theme.vars.palette.stroke.muted,- borderRadius: 16,- color: theme.vars.palette.text.muted,- "&:hover": { borderColor: "rgba(0 0 0 / 0.45)" },- ...theme.applyStyles("dark", {- "&:hover": { borderColor: "rgba(255 255 255 / 0.45)" },- }),-}));--interface SearchFieldV2Props {- value: string;- onChange: (value: string) => void;-}--const SearchFieldV2: React.FC<SearchFieldV2Props> = ({ value, onChange }) => (- <Stack direction="row" sx={searchFieldSx}>- <SearchIcon sx={searchIconSx} />- <InputBase- fullWidth- autoFocus- placeholder={t("albums_search_hint")}- value={value}- onChange={(e) => onChange(e.target.value)}- sx={{- fontSize: 14,- lineHeight: "20px",- fontWeight: 500,- color: "text.base",- "& input::placeholder": { color: "text.muted", opacity: 1 },- }}- endAdornment={- value ? (- <CloseIcon- fontSize="small"- onClick={() => onChange("")}- sx={{- color: "stroke.muted",- cursor: "pointer",- "&:hover": { color: "text.base" },- }}- />- ) : undefined- }- />- </Stack>-);--const searchFieldSx = (theme: Theme) => ({- alignItems: "center",- gap: "10px",- height: 44,- borderRadius: "16px",- backgroundColor: "background.paper",- px: "14px",- ...theme.applyStyles("dark", { backgroundColor: "#282828" }),-});-const searchIconSx = (theme: Theme) => ({- fontSize: 20,- flexShrink: 0,- color: "rgba(0 0 0 / 0.4)",- ...theme.applyStyles("dark", { color: "rgba(255 255 255 / 0.4)" }),-});diff --git a/web/packages/new/photos/components/gallery/GalleryEmptyStateV2.tsx b/web/packages/new/photos/components/gallery/GalleryEmptyState.tsxsimilarity index 99%rename from web/packages/new/photos/components/gallery/GalleryEmptyStateV2.tsxrename to web/packages/new/photos/components/gallery/GalleryEmptyState.tsxindex f952dfeed8..28795d41fc 100644--- a/web/packages/new/photos/components/gallery/GalleryEmptyStateV2.tsx+++ b/web/packages/new/photos/components/gallery/GalleryEmptyState.tsx@@ -10,7 +10,7 @@ import { t } from "i18next";import React, { useEffect, useState } from "react";import { Trans } from "react-i18next";-interface GalleryEmptyStateV2Props {+interface GalleryEmptyStateProps {/*** If `true`, then an upload is already in progress (the empty state will* then disable the prompts for uploads).@@ -41,10 +41,10 @@ const memoriesPreservedSince = (nextCount: number,) => Math.max(0, nextCount - (initialCount ?? nextCount));-export function GalleryEmptyStateV2({+export function GalleryEmptyState({isUploadInProgress,onUpload,-}: GalleryEmptyStateV2Props): React.JSX.Element {+}: GalleryEmptyStateProps): React.JSX.Element {const handleImport = () => onUpload("import");const handleUpload = () => onUpload("upload");diff --git a/web/packages/new/photos/components/gallery/index.tsx b/web/packages/new/photos/components/gallery/index.tsxindex 11b3915763..5fbb6a3a3e 100644--- a/web/packages/new/photos/components/gallery/index.tsx+++ b/web/packages/new/photos/components/gallery/index.tsx@@ -29,7 +29,7 @@ import { useMLStatusSnapshot } from "../utils/use-snapshot";import { useWrapAsyncOperation } from "../utils/use-wrap-async";import { GalleryItemsHeaderAdapter, GalleryItemsSummary } from "./ListHeader";-export { GalleryEmptyStateV2 } from "./GalleryEmptyStateV2";+export { GalleryEmptyState } from "./GalleryEmptyState";/*** Options to customize the behaviour of the remote pull that gets triggered on