π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Refresh delete confirmation dialog
Aswin Asok868d6316379a
diff --git a/web/apps/photos/src/components/SelectedFileOptions.tsx b/web/apps/photos/src/components/SelectedFileOptions.tsxindex f93b079eb1..0c8aa38b26 100644--- a/web/apps/photos/src/components/SelectedFileOptions.tsx+++ b/web/apps/photos/src/components/SelectedFileOptions.tsx@@ -30,6 +30,7 @@ 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 { useBaseContext } from "ente-base/context";+import { trashFilesDialogAttributes } from "ente-gallery/components/trash-files-dialog";import type { Collection } from "ente-media/collection";import type { CollectionSummary } from "ente-new/photos/services/collection-summary";import { t } from "i18next";@@ -104,8 +105,7 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({const handleDelete = () =>showMiniDialog({- title: t("trash_files_title"),- message: t("trash_files_message"),+ ...trashFilesDialogAttributes(selectedOwnFileCount),continue: {text: t("move_to_trash"),color: "critical",diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 8860944961..982f4151da 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -91,6 +91,7 @@ import { initContacts, pullContacts } from "ente-contacts";import { DownloadStatusNotifications } from "ente-gallery/components/DownloadStatusNotifications";import { FullScreenDropZone } from "ente-gallery/components/FullScreenDropZone";import type { UploadTypeSelectorIntent } from "ente-gallery/components/Upload";+import { trashFilesDialogAttributes } from "ente-gallery/components/trash-files-dialog";import { useSaveGroups } from "ente-gallery/components/utils/save-groups";import type { FileViewerInitialSidebar } from "ente-gallery/components/viewer/FileViewer";import type { Collection } from "ente-media/collection";@@ -1636,8 +1637,7 @@ const Page: React.FC = () => {break;case "trash":showMiniDialog({- title: t("trash_files_title"),- message: t("trash_files_message"),+ ...trashFilesDialogAttributes(selectedOwnCount),continue: {text: t("move_to_trash"),color: "critical",diff --git a/web/apps/photos/src/pages/large-files.tsx b/web/apps/photos/src/pages/large-files.tsxindex 5e123e6592..69c9fef9f5 100644--- a/web/apps/photos/src/pages/large-files.tsx+++ b/web/apps/photos/src/pages/large-files.tsx@@ -25,6 +25,7 @@ import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";import { useBaseContext } from "ente-base/context";import log from "ente-base/log";+import { trashFilesDialogAttributes } from "ente-gallery/components/trash-files-dialog";import { FileViewer } from "ente-gallery/components/viewer/FileViewer";import { formattedByteSize } from "ente-gallery/utils/units";import {@@ -90,8 +91,7 @@ const Page: React.FC = () => {const handleDeleteFiles = useCallback(() => {showMiniDialog({- title: t("trash_files_title"),- message: t("trash_files_message"),+ ...trashFilesDialogAttributes(state.selectedCount),continue: {text: t("move_to_trash"),color: "critical",@@ -112,7 +112,7 @@ const Page: React.FC = () => {},},});- }, [showMiniDialog, onGenericError, state.largeFiles]);+ }, [showMiniDialog, onGenericError, state.largeFiles, state.selectedCount]);const handleOpenViewer = useCallback((index: number) => {diff --git a/web/packages/base/components/MiniDialog.tsx b/web/packages/base/components/MiniDialog.tsxindex 2506167e9e..d2347556f0 100644--- a/web/packages/base/components/MiniDialog.tsx+++ b/web/packages/base/components/MiniDialog.tsx@@ -1,9 +1,11 @@+import CloseIcon from "@mui/icons-material/Close";import type { ButtonProps, ModalProps } from "@mui/material";import {Box,Dialog,DialogContent,DialogTitle,+ IconButton,Stack,Typography,type DialogProps,@@ -18,6 +20,7 @@ import { InlineErrorIndicator } from "./ErrorIndicator";export interface MiniDialogAttributes {title?: React.ReactNode;icon?: React.ReactNode;+ illustration?: React.ReactNode;message?: React.ReactNode;nonClosable?: boolean;nonReplaceable?: boolean;@@ -140,9 +143,56 @@ export const AttributedMiniDialog: React.FC<{...{ open, sx }}onClose={handleClose}fullWidth- slotProps={{ paper: { sx: { maxWidth: "360px" } } }}+ slotProps={{+ paper: {+ sx: attributes.illustration+ ? {+ maxWidth: "440px",+ borderRadius: "24px",+ position: "relative",+ textAlign: "center",+ "& .MuiDialogContent-root": {+ padding: "16px 28px 24px",+ },+ "& .MuiButton-root": {+ fontWeight: 500,+ minHeight: "48px",+ padding: "14px 24px",+ borderRadius: "20px",+ },+ }+ : { maxWidth: "360px" },+ },+ }}>- {(attributes.icon ?? attributes.title) ? (+ {attributes.illustration ? (+ <Stack sx={{ alignItems: "center", pt: "38px", px: 3.5 }}>+ {!attributes.nonClosable && (+ <IconButton+ aria-label={t("close")}+ disabled={+ phase == "loading" ||+ phase == "secondary-loading"+ }+ onClick={resetPhaseAndClose}+ sx={{+ position: "absolute",+ top: 16,+ right: 16,+ width: 36,+ height: 36,+ backgroundColor: "fill.faint",+ }}+ >+ <CloseIcon sx={{ fontSize: 20 }} />+ </IconButton>+ )}+ {attributes.illustration}+ <DialogTitle sx={{ "&&&": { p: 0, mt: 3 }, fontSize: 20 }}>+ {attributes.title}+ </DialogTitle>+ </Stack>+ ) : (attributes.icon ?? attributes.title) ? (<Stackdirection="row"sx={[diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex 596ef01b3c..b96a241bdd 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -202,6 +202,10 @@"upload_dropzone_hint": "Drop to backup your files","upload_dropzone_hint_public_album": "Drop to add your photos","watch_folder_dropzone_hint": "Drop to add watched folder",+ "trash_items_title_one": "Delete {{count}} item?",+ "trash_items_title_other": "Delete {{count}} items?",+ "trash_items_message_one": "This item will be deleted from all albums. You can recover it from Trash.",+ "trash_items_message_other": "These items will be deleted from all albums. You can recover them from Trash.","trash_files_title": "Delete files?","trash_file_title": "Delete file?","delete_files_title": "Delete immediately?",diff --git a/web/packages/gallery/components/assets/warning-red.png b/web/packages/gallery/components/assets/warning-red.pngnew file mode 100644index 0000000000..e924db1481Binary files /dev/null and b/web/packages/gallery/components/assets/warning-red.png differdiff --git a/web/packages/gallery/components/trash-files-dialog.tsx b/web/packages/gallery/components/trash-files-dialog.tsxnew file mode 100644index 0000000000..85c54a322e--- /dev/null+++ b/web/packages/gallery/components/trash-files-dialog.tsx@@ -0,0 +1,19 @@+import { Box } from "@mui/material";+import type { MiniDialogAttributes } from "ente-base/components/MiniDialog";+import { t } from "i18next";+import warningRed from "./assets/warning-red.png";++export const trashFilesDialogAttributes = (+ count: number,+): Pick<MiniDialogAttributes, "title" | "message" | "illustration"> => ({+ title: t("trash_items_title", { count }),+ message: t("trash_items_message", { count }),+ illustration: (+ <Box+ component="img"+ src={warningRed.src}+ alt=""+ sx={{ width: 68, height: 64, objectFit: "contain" }}+ />+ ),+});diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex 8e131fb741..c87dbd848f 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -15,19 +15,14 @@ import {DialogTitle,Menu,MenuItem,- Stack,styled,Typography,- type ModalProps,} from "@mui/material";import type { LocalUser } from "ente-accounts/services/user";import { isDesktop } from "ente-base/app";import { SpacedRow } from "ente-base/components/containers";-import { InlineErrorIndicator } from "ente-base/components/ErrorIndicator";-import { TitledMiniDialog } from "ente-base/components/MiniDialog";+import { AttributedMiniDialog } from "ente-base/components/MiniDialog";import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton";-import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";-import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { useInterval, useIsSmallWidth } from "ente-base/components/utils/hooks";import type { ModalVisibilityProps } from "ente-base/components/utils/modal";import { useBaseContext } from "ente-base/context";@@ -39,6 +34,7 @@ import {type FileInfoExif,type FileInfoProps,} from "ente-gallery/components/FileInfo";+import { trashFilesDialogAttributes } from "ente-gallery/components/trash-files-dialog";import type { Collection } from "ente-media/collection";import {fileFileName,@@ -1934,10 +1930,25 @@ export const FileViewer: React.FC<FileViewerProps> = ({</Typography></MoreMenuItem></MoreMenu>- <ConfirmDeleteFileDialog+ <AttributedMiniDialogopen={openConfirmDelete}onClose={handleConfirmDeleteClose}- onConfirm={handleDelete}+ attributes={{+ ...trashFilesDialogAttributes(1),+ continue: {+ text: t("move_to_trash"),+ color: "critical",+ autoFocus: true,+ action: handleDelete,+ },+ }}+ sx={(theme) => ({+ ...theme.applyStyles("light", {+ ".MuiBackdrop-root": {+ backgroundColor: theme.vars.palette.backdrop.faint,+ },+ }),+ })}/>{handleSaveEditedCopy && (<ImageEditorOverlay@@ -1994,78 +2005,6 @@ const MoreMenuItemTitle: React.FC<React.PropsWithChildren> = ({ children }) => (<Typography sx={{ fontWeight: "medium" }}>{children}</Typography>);-type ConfirmDeleteFileDialogProps = ModalVisibilityProps & {- onConfirm: () => Promise<void>;-};--const ConfirmDeleteFileDialog: React.FC<ConfirmDeleteFileDialogProps> = ({- open,- onClose,- onConfirm,-}) => {- const [phase, setPhase] = useState<"loading" | "failed" | undefined>();-- const resetPhaseAndClose = () => {- setPhase(undefined);- onClose();- };-- const handleClick = async () => {- setPhase("loading");- try {- await onConfirm();- resetPhaseAndClose();- } catch (e) {- log.error(e);- setPhase("failed");- }- };-- const handleClose: ModalProps["onClose"] = (_, reason) => {- if (reason == "backdropClick" && phase == "loading") return;- resetPhaseAndClose();- };-- return (- <TitledMiniDialog- open={open}- onClose={handleClose}- title={t("trash_file_title")}- sx={(theme) => ({- ...theme.applyStyles("light", {- ".MuiBackdrop-root": {- backgroundColor: theme.vars.palette.backdrop.faint,- },- }),- })}- >- <Typography sx={{ color: "text.muted" }}>- {t("trash_file_message")}- </Typography>- <Stack sx={{ pt: 3, gap: 1 }}>- {phase == "failed" && <InlineErrorIndicator />}- <LoadingButton- loading={phase == "loading"}- fullWidth- color="critical"- autoFocus- onClick={handleClick}- >- {t("move_to_trash")}- </LoadingButton>- <FocusVisibleButton- fullWidth- color="secondary"- disabled={phase == "loading"}- onClick={resetPhaseAndClose}- >- {t("cancel")}- </FocusVisibleButton>- </Stack>- </TitledMiniDialog>- );-};-type ShortcutsProps = ModalVisibilityProps &Pick<FileViewerProps, "disableDownload"> & { haveUser: boolean };diff --git a/web/packages/gallery/global-images.d.ts b/web/packages/gallery/global-images.d.tsnew file mode 100644index 0000000000..c43105779d--- /dev/null+++ b/web/packages/gallery/global-images.d.ts@@ -0,0 +1 @@+/// <reference types="next/image-types/global" />