π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Add select all / deselect all button to selection bar
Anand Baburajan398950930bd7
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 7fbf7448fc..de12de1ddb 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -608,6 +608,33 @@ const Page: React.FC = () => {setSelected(selected);};+ const handleSelectAll = () => {+ if (!user || !filteredFiles.length) return;++ const selected = {+ ownCount: 0,+ count: 0,+ collectionID: activeCollectionID,+ context:+ barMode == "people" && activePersonID+ ? { mode: "people" as const, personID: activePersonID }+ : {+ mode: barMode as "albums" | "hidden-albums",+ collectionID: activeCollectionID!,+ },+ };++ filteredFiles.forEach((item) => {+ if (item.ownerID === user.id) {+ selected.ownCount++;+ }+ selected.count++;+ // @ts-expect-error Selection code needs type fixing+ selected[item.id] = true;+ });+ setSelected(selected);+ };+const clearSelection = () => {if (!selected.count) {return;@@ -1290,6 +1317,8 @@ const Page: React.FC = () => {handleRemoveFilesFromCollection}onOpenCollectionSelector={handleOpenCollectionSelector}+ totalFileCount={filteredFiles.length}+ onSelectAll={handleSelectAll}{...{createOnCreateForCollectionOp,createOnSelectForCollectionOp,diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex f8a8549214..99e2595602 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -127,7 +127,7 @@"delete_files_title": "Delete immediately?","delete_files_message": "Selected files will be permanently deleted from your Ente account.","selected_count": "{{selected, number}} selected",- "selected_and_yours_count": "{{selected, number}} selected {{yours, number}} yours",+ "selected_and_yours_count": "{{selected, number}} selected ({{yours, number}} yours)","delete": "Delete","like": "Like","unlike": "Unlike",diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsxindex 42e70d1cda..5503ab0d5f 100644--- a/web/packages/new/photos/components/SelectedFileOptions.tsx+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx@@ -2,6 +2,8 @@ import ClockIcon from "@mui/icons-material/AccessTime";import AddIcon from "@mui/icons-material/Add";import ArchiveIcon from "@mui/icons-material/ArchiveOutlined";import MoveIcon from "@mui/icons-material/ArrowForward";+import CheckCircleIcon from "@mui/icons-material/CheckCircle";+import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";import CloseIcon from "@mui/icons-material/Close";import DeleteIcon from "@mui/icons-material/Delete";import DownloadIcon from "@mui/icons-material/Download";@@ -11,7 +13,7 @@ import RestoreIcon from "@mui/icons-material/Restore";import UnArchiveIcon from "@mui/icons-material/Unarchive";import VisibilityOffOutlinedIcon from "@mui/icons-material/VisibilityOffOutlined";import VisibilityOutlinedIcon from "@mui/icons-material/VisibilityOutlined";-import { IconButton, Tooltip, Typography } from "@mui/material";+import { Box, Button, IconButton, Tooltip, Typography } from "@mui/material";import { SpacedRow } from "ente-base/components/containers";import type { ButtonishProps } from "ente-base/components/mui";import { useModalVisibility } from "ente-base/components/utils/modal";@@ -145,6 +147,14 @@ interface SelectedFileOptionsProps {* person will be shown (when ML is enabled and there are named people).*/onAddPersonToSelectedFiles?: (personID: string) => Promise<void>;+ /**+ * The total number of files available in the current view.+ */+ totalFileCount: number;+ /**+ * Called when the user wants to select all files.+ */+ onSelectAll: () => void;}/**@@ -165,6 +175,8 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({createOnSelectForCollectionOp,createFileOpHandler,onAddPersonToSelectedFiles,+ totalFileCount,+ onSelectAll,}) => {const { showMiniDialog } = useBaseContext();@@ -319,7 +331,7 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({<IconButton onClick={onClearSelection}><CloseIcon /></IconButton>- <Typography sx={{ mr: "auto" }}>+ <Typography>{selectedFileCount == selectedOwnFileCount? t("selected_count", { selected: selectedFileCount }): t("selected_and_yours_count", {@@ -327,6 +339,16 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({yours: selectedOwnFileCount,})}</Typography>+ <SelectAllToggleButton+ isAllSelected={selectedFileCount >= totalFileCount}+ onClick={+ selectedFileCount < totalFileCount+ ? onSelectAll+ : onClearSelection+ }+ />++ <Box sx={{ mr: "auto" }} />{isInSearchMode ? (<>@@ -555,3 +577,40 @@ const RemoveFromCollectionButton: React.FC<ButtonishProps> = ({ onClick }) => (</IconButton></Tooltip>);++interface SelectAllToggleButtonProps {+ isAllSelected: boolean;+ onClick: () => void;+}++const SelectAllToggleButton: React.FC<SelectAllToggleButtonProps> = ({+ isAllSelected,+ onClick,+}) => (+ <Tooltip title={isAllSelected ? t("deselect_all") : t("select_all")}>+ <Button+ onClick={onClick}+ size="small"+ color="secondary"+ sx={{+ textTransform: "none",+ minWidth: "auto",+ px: 2,+ ml: 2,+ borderRadius: 9999,+ }}+ endIcon={+ isAllSelected ? (+ <CheckCircleIcon fontSize="small" />+ ) : (+ <CheckCircleOutlineIcon+ fontSize="small"+ sx={{ color: "text.muted" }}+ />+ )+ }+ >+ {t("all")}+ </Button>+ </Tooltip>+);