π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
update(locker):dialogs-and-menus
Aswin Asokd225fd867c46
diff --git a/web/apps/locker/public/images/file_delete_icon.png b/web/apps/locker/public/images/file_delete_icon.pngnew file mode 100644index 0000000000..98fdc2aa46Binary files /dev/null and b/web/apps/locker/public/images/file_delete_icon.png differdiff --git a/web/apps/locker/public/images/warning-grey.png b/web/apps/locker/public/images/warning-grey.pngnew file mode 100644index 0000000000..df21e1522aBinary files /dev/null and b/web/apps/locker/public/images/warning-grey.png differdiff --git a/web/apps/locker/public/images/warning-red.png b/web/apps/locker/public/images/warning-red.pngnew file mode 100644index 0000000000..24f78ced23Binary files /dev/null and b/web/apps/locker/public/images/warning-red.png differdiff --git a/web/apps/locker/src/components/ItemCard.tsx b/web/apps/locker/src/components/ItemCard.tsxindex bf5a4a301f..e7553df2a7 100644--- a/web/apps/locker/src/components/ItemCard.tsx+++ b/web/apps/locker/src/components/ItemCard.tsx@@ -1,4 +1,5 @@import { lockerItemIcon } from "@/components/locker-item-icons";+import { LockerMenuOption, LockerOverflowMenu } from "@/components/LockerMenu";import { downloadLockerFile } from "@/services/remote";import type { GenericFileData, LockerItem } from "@/types";import { getItemTitle, hasDownloadableObject } from "@/types";@@ -18,16 +19,10 @@ import {Box,ButtonBase,CircularProgress,- IconButton,Snackbar,Stack,- Tooltip,Typography,} from "@mui/material";-import {- OverflowMenu,- OverflowMenuOption,-} from "ente-base/components/OverflowMenu";import { formatTimeAgo } from "ente-base/date";import log from "ente-base/log";import { t } from "i18next";@@ -356,7 +351,7 @@ const ItemOverflowMenu: React.FC<{deleteDisabledHint?: string;onShareLink?: (item: LockerItem) => void;}> = ({ item, onEdit, onDelete, deleteDisabledHint, onShareLink }) => (- <OverflowMenu+ <LockerOverflowMenuariaID={`item-menu-${item.id}`}triggerButtonIcon={<MoreVertIcon sx={{ fontSize: 20 }} />}triggerButtonSxProps={(theme) => ({@@ -367,42 +362,42 @@ const ItemOverflowMenu: React.FC<{})}>{onEdit && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<EditOutlinedIcon />}onClick={() => onEdit(item)}>{t("edit")}- </OverflowMenuOption>+ </LockerMenuOption>)}{onShareLink && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<ShareOutlinedIcon />}onClick={() => onShareLink(item)}>{t("share")}- </OverflowMenuOption>+ </LockerMenuOption>)}{onDelete ? (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<DeleteOutlinedIcon />}- color="critical"+ criticalonClick={() => onDelete(item)}>{t("delete")}- </OverflowMenuOption>+ </LockerMenuOption>) : (deleteDisabledHint && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<DeleteOutlinedIcon />}- color="critical"+ criticaldisabledonClick={() => undefined}>{t("delete")}- </OverflowMenuOption>+ </LockerMenuOption>))}- </OverflowMenu>+ </LockerOverflowMenu>);const TrashActions: React.FC<{@@ -413,38 +408,49 @@ const TrashActions: React.FC<{<Stackdirection="row"sx={{ gap: 0, flexShrink: 0 }}+ data-no-long-press="true"onClick={(e) => e.stopPropagation()}>- {onRestore && (- <Tooltip title={t("restore")}>- <IconButton- size="small"+ <LockerOverflowMenu+ ariaID={`trash-item-menu-${item.id}`}+ triggerButtonIcon={<MoreVertIcon sx={{ fontSize: 20 }} />}+ triggerButtonSxProps={(theme) => ({+ width: 24,+ height: 24,+ p: 0,+ ...lockerColorSx(theme, { color: "textLight" }),+ })}+ >+ {onRestore && (+ <LockerMenuOptiononClick={() => onRestore(item)}- sx={(theme) => lockerColorSx(theme, { color: "iconColor" })}+ startIcon={+ <HugeiconsIcon+ icon={ArrowReloadHorizontalIcon}+ size={18}+ strokeWidth={1.5}+ />+ }>- <HugeiconsIcon- icon={ArrowReloadHorizontalIcon}- size={18}- strokeWidth={1.5}- />- </IconButton>- </Tooltip>- )}- {onPermanentlyDelete && (- <Tooltip title={t("permanentlyDelete")}>- <IconButton- size="small"+ {t("restore")}+ </LockerMenuOption>+ )}+ {onPermanentlyDelete && (+ <LockerMenuOptiononClick={() => onPermanentlyDelete([item])}- sx={(theme) => lockerColorSx(theme, { color: "warning" })}+ startIcon={+ <HugeiconsIcon+ icon={Delete02Icon}+ size={18}+ strokeWidth={1.5}+ />+ }+ critical>- <HugeiconsIcon- icon={Delete02Icon}- size={18}- strokeWidth={1.5}- />- </IconButton>- </Tooltip>- )}+ {t("permanentlyDelete")}+ </LockerMenuOption>+ )}+ </LockerOverflowMenu></Stack>);diff --git a/web/apps/locker/src/components/ItemList.tsx b/web/apps/locker/src/components/ItemList.tsxindex c1d02a7432..1956c0a97d 100644--- a/web/apps/locker/src/components/ItemList.tsx+++ b/web/apps/locker/src/components/ItemList.tsx@@ -1,3 +1,4 @@+import { LockerMenuOption, LockerOverflowMenu } from "@/components/LockerMenu";import {deleteLockerFileShareLink,downloadLockerFile,@@ -46,10 +47,6 @@ import {Typography,} from "@mui/material";import { savedLocalUser } from "ente-accounts/services/accounts-db";-import {- OverflowMenu,- OverflowMenuOption,-} from "ente-base/components/OverflowMenu";import { isHTTPErrorWithStatus } from "ente-base/http";import log from "ente-base/log";import { t } from "i18next";@@ -1193,6 +1190,7 @@ export const ItemList: React.FC<ItemListProps> = ({: undefined}onRename={+ canEditSelectedCollection &&onRenameCollection? () => {setRenameCollectionID(@@ -1205,6 +1203,7 @@ export const ItemList: React.FC<ItemListProps> = ({: undefined}onDelete={+ canEditSelectedCollection &&onDeleteCollection? () =>onDeleteCollection(@@ -1675,11 +1674,11 @@ const SelectionActionBar: React.FC<{}}><CheckCircleRoundedIcon- sx={{+ sx={(theme) => ({fontSize: 18,- color: "#1071FF",+ ...lockerColorSx(theme, { color: "primary" }),flexShrink: 0,- }}+ })}/><Typographyvariant="body"@@ -2272,45 +2271,45 @@ const CollectionContextMenu: React.FC<{onRename?: () => void;onDelete?: () => void;}> = ({ ariaID, onShare, onLeave, onRename, onDelete }) => (- <OverflowMenu+ <LockerOverflowMenuariaID={ariaID}triggerButtonSxProps={{ p: 0.25, color: "text.muted" }}>{onShare && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<ShareOutlinedIcon />}onClick={onShare}>- {t("share")}- </OverflowMenuOption>+ {t(onLeave ? "sharedWith" : "share")}+ </LockerMenuOption>)}{onLeave && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<LogoutOutlinedIcon />}- color="critical"+ criticalonClick={onLeave}>{t("leaveCollection")}- </OverflowMenuOption>+ </LockerMenuOption>)}{onRename && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<EditOutlinedIcon />}onClick={onRename}>{t("renameCollection")}- </OverflowMenuOption>+ </LockerMenuOption>)}{onDelete && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<DeleteOutlinedIcon />}- color="critical"+ criticalonClick={onDelete}>{t("deleteCollection")}- </OverflowMenuOption>+ </LockerMenuOption>)}- </OverflowMenu>+ </LockerOverflowMenu>);const CollectionHeaderMenu: React.FC<{@@ -2319,43 +2318,43 @@ const CollectionHeaderMenu: React.FC<{onRename?: () => void;onDelete?: () => void;}> = ({ onShare, onLeave, onRename, onDelete }) => (- <OverflowMenu+ <LockerOverflowMenuariaID="collection-header-menu"triggerButtonSxProps={{ color: "text.muted" }}>{onShare && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<ShareOutlinedIcon />}onClick={onShare}>- {t("share")}- </OverflowMenuOption>+ {t(onLeave ? "sharedWith" : "share")}+ </LockerMenuOption>)}{onLeave && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<LogoutOutlinedIcon />}- color="critical"+ criticalonClick={onLeave}>{t("leaveCollection")}- </OverflowMenuOption>+ </LockerMenuOption>)}{onRename && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<EditOutlinedIcon />}onClick={onRename}>{t("renameCollection")}- </OverflowMenuOption>+ </LockerMenuOption>)}{onDelete && (- <OverflowMenuOption+ <LockerMenuOptionstartIcon={<DeleteOutlinedIcon />}- color="critical"+ criticalonClick={onDelete}>{t("deleteCollection")}- </OverflowMenuOption>+ </LockerMenuOption>)}- </OverflowMenu>+ </LockerOverflowMenu>);diff --git a/web/apps/locker/src/components/LockerCollectionShareDrawer.tsx b/web/apps/locker/src/components/LockerCollectionShareDrawer.tsxindex f5555b0250..e106a1acd5 100644--- a/web/apps/locker/src/components/LockerCollectionShareDrawer.tsx+++ b/web/apps/locker/src/components/LockerCollectionShareDrawer.tsx@@ -1,3 +1,4 @@+import { LockerMenuOption, LockerOverflowMenu } from "@/components/LockerMenu";import {canLeaveCollection,canManageCollectionSharing,@@ -17,14 +18,9 @@ import {DialogTitle,IconButton,Stack,- TextField,Typography,} from "@mui/material";import { savedLocalUser } from "ente-accounts/services/accounts-db";-import {- OverflowMenu,- OverflowMenuOption,-} from "ente-base/components/OverflowMenu";import { SidebarDrawer } from "ente-base/components/mui/SidebarDrawer";import { useBaseContext } from "ente-base/context";import { isHTTPErrorWithStatus } from "ente-base/http";@@ -35,6 +31,16 @@ import {} from "ente-contacts";import { t } from "i18next";import React, { useCallback, useEffect, useMemo, useState } from "react";+import { FormField } from "./createItemDialog/ItemFormFields";+import {+ lockerSheetContainerSx,+ lockerSheetPaperSx,+} from "./locker-dialog-styles";+import {+ lockerColorSx,+ lockerTextBodyBoldSx,+ lockerTextH2Sx,+} from "./locker-tokens";interface LockerCollectionShareDrawerProps {open: boolean;@@ -278,18 +284,18 @@ export const LockerCollectionShareDrawer: React.FC<canManageParticipants &&participant.id !== currentUser.id &&participant.email ? (- <OverflowMenu+ <LockerOverflowMenuariaID={`sharee-${participant.id}`}triggerButtonIcon={<MoreVertIcon />}triggerButtonSxProps={{ color: "text.faint" }}>- <OverflowMenuOption- color="critical"+ <LockerMenuOption+ criticalonClick={() => confirmRemoveViewer(participant)}>{t("removeParticipant")}- </OverflowMenuOption>- </OverflowMenu>+ </LockerMenuOption>+ </LockerOverflowMenu>) : undefined,})),];@@ -419,11 +425,23 @@ export const LockerCollectionShareDrawer: React.FC<{canLeaveSharedCollection && (<Button- color="critical"- variant="outlined"+ color="primary"+ variant="contained"startIcon={<LogoutOutlinedIcon />}onClick={() => onLeaveCollection(collection)}- sx={{ minHeight: 48, borderRadius: "14px" }}+ sx={(theme) => ({+ ...lockerTextBodyBoldSx,+ minHeight: 52,+ borderRadius: "20px",+ textTransform: "none",+ ...lockerColorSx(theme, {+ backgroundColor: "primary",+ color: "specialWhite",+ }),+ "&:hover": lockerColorSx(theme, {+ backgroundColor: "primaryDark",+ }),+ })}>{t("leaveCollection")}</Button>@@ -433,6 +451,10 @@ export const LockerCollectionShareDrawer: React.FC<</SidebarDrawer><Dialog+ slotProps={{+ paper: { sx: lockerSheetPaperSx },+ container: { sx: lockerSheetContainerSx },+ }}open={addViewerOpen}onClose={handleCloseAddViewer}fullWidth@@ -440,15 +462,20 @@ export const LockerCollectionShareDrawer: React.FC<><DialogTitlesx={(theme) => ({- ...theme.applyStyles("light", {}),- color: "#FFFFFF",+ ...lockerTextH2Sx,+ "&&&": { p: 0 },+ minHeight: 38,+ display: "flex",+ alignItems: "center",+ mb: 2.5,+ ...lockerColorSx(theme, { color: "textBase" }),})}>{t("addEmail")}</DialogTitle>- <DialogContent>- <Stack sx={{ gap: 2, pt: 0.25, pb: 1 }}>- <TextField+ <DialogContent sx={{ "&&&": { p: 0 } }}>+ <Stack sx={{ gap: 3 }}>+ <FormFieldtype="email"label={t("enterEmail")}value={viewerEmail}@@ -459,42 +486,12 @@ export const LockerCollectionShareDrawer: React.FC<autoFocusfullWidtherror={!!viewerEmailError}- helperText={viewerEmailError ?? " "}+ helperText={viewerEmailError ?? undefined}onKeyDown={(event) => {if (event.key === "Enter") {void handleAddViewer();}}}- sx={(theme) => ({- "& .MuiInputLabel-root": {- color: "rgba(255, 255, 255, 0.72)",- },- "& .MuiInputLabel-root.Mui-focused": {- color: "#FFFFFF",- },- "& .MuiInputBase-input": { color: "#FFFFFF" },- "& .MuiFormHelperText-root": {- color: viewerEmailError- ? theme.vars.palette.critical.main- : "rgba(255, 255, 255, 0.64)",- },- ...theme.applyStyles("light", {- "& .MuiInputLabel-root": {- color: theme.vars.palette.text.muted,- },- "& .MuiInputLabel-root.Mui-focused": {- color: theme.vars.palette.text.base,- },- "& .MuiInputBase-input": {- color: theme.vars.palette.text.base,- },- "& .MuiFormHelperText-root": {- color: viewerEmailError- ? theme.vars.palette.critical.main- : theme.vars.palette.text.muted,- },- }),- })}/><Stack direction="row" sx={{ gap: 1 }}><Button@@ -503,9 +500,12 @@ export const LockerCollectionShareDrawer: React.FC<onClick={handleCloseAddViewer}disabled={isSubmittingViewer}sx={(theme) => ({- color: "#FFFFFF",- ...theme.applyStyles("light", {- color: theme.vars.palette.text.base,+ ...lockerTextBodyBoldSx,+ minHeight: 52,+ borderRadius: "20px",+ ...lockerColorSx(theme, {+ backgroundColor: "fillDark",+ color: "textBase",}),})}>@@ -516,7 +516,22 @@ export const LockerCollectionShareDrawer: React.FC<variant="contained"onClick={() => void handleAddViewer()}disabled={isSubmittingViewer}- sx={{ color: "#FFFFFF" }}+ sx={(theme) => ({+ ...lockerTextBodyBoldSx,+ minHeight: 52,+ borderRadius: "20px",+ ...lockerColorSx(theme, {+ backgroundColor: "primary",+ color: "specialWhite",+ }),+ "&:hover": lockerColorSx(theme, {+ backgroundColor: "primaryDark",+ }),+ "&.Mui-disabled": lockerColorSx(theme, {+ backgroundColor: "fillDarkest",+ color: "textLighter",+ }),+ })}>{isSubmittingViewer? t("sharing")diff --git a/web/apps/locker/src/components/LockerConfirmDialog.tsx b/web/apps/locker/src/components/LockerConfirmDialog.tsxnew file mode 100644index 0000000000..32ced7ed44--- /dev/null+++ b/web/apps/locker/src/components/LockerConfirmDialog.tsx@@ -0,0 +1,208 @@+import {+ lockerSheetContainerSx,+ lockerSheetPaperSx,+} from "@/components/locker-dialog-styles";+import {+ lockerColorSx,+ lockerTextBodyBoldSx,+ lockerTextBodySx,+ lockerTextH2Sx,+ lockerTextMiniSx,+} from "@/components/locker-tokens";+import { Cancel01Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import {+ Box,+ Checkbox,+ Dialog,+ FormControlLabel,+ IconButton,+ Stack,+ Typography,+} from "@mui/material";+import { LoadingButton } from "ente-base/components/mui/LoadingButton";+import { t } from "i18next";+import type React from "react";++interface LockerConfirmDialogProps {+ open: boolean;+ illustration: string;+ title: string;+ body: React.ReactNode;+ confirmLabel: string;+ tone?: "critical" | "primary";+ loading?: boolean;+ error?: string;+ checkbox?: {+ label: string;+ checked: boolean;+ onChange: (v: boolean) => void;+ };+ onClose: () => void;+ onConfirm: () => void | Promise<void>;+}++export function LockerConfirmDialog({+ open,+ illustration,+ title,+ body,+ confirmLabel,+ tone = "critical",+ loading,+ error,+ checkbox,+ onClose,+ onConfirm,+}: LockerConfirmDialogProps) {+ const handleClose = () => {+ if (!loading) {+ onClose();+ }+ };++ return (+ <Dialog+ open={open}+ onClose={handleClose}+ fullWidth+ maxWidth="xs"+ slotProps={{+ paper: { sx: lockerSheetPaperSx },+ container: { sx: lockerSheetContainerSx },+ }}+ >+ <Stack>+ <Box sx={{ display: "flex", justifyContent: "flex-end" }}>+ <IconButton+ aria-label={t("cancel")}+ onClick={handleClose}+ disabled={loading}+ sx={(theme) => ({+ width: 36,+ height: 36,+ borderRadius: "50%",+ padding: 0,+ ...lockerColorSx(theme, {+ backgroundColor: "fillLight",+ color: "iconColor",+ }),+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor: "fillDark",+ }),+ },+ })}+ >+ <HugeiconsIcon+ icon={Cancel01Icon}+ size={18}+ strokeWidth={1.5}+ />+ </IconButton>+ </Box>+ <img+ src={illustration}+ alt=""+ style={{+ width: 120,+ height: 120,+ objectFit: "contain",+ display: "block",+ margin: "4px auto 0",+ }}+ />+ <Typography+ sx={{ ...lockerTextH2Sx, textAlign: "center", mt: 2.5 }}+ >+ {title}+ </Typography>+ <Typography+ sx={(theme) => ({+ ...lockerTextBodySx,+ textAlign: "center",+ mt: 1.5,+ ...lockerColorSx(theme, { color: "textLight" }),+ })}+ >+ {body}+ </Typography>+ {checkbox && (+ <Box+ sx={{+ display: "flex",+ mt: 2.5,+ justifyContent: "center",+ }}+ >+ <FormControlLabel+ control={+ <Checkbox+ checked={checkbox.checked}+ disabled={loading}+ onChange={(event) =>+ checkbox.onChange(event.target.checked)+ }+ />+ }+ label={checkbox.label}+ sx={{+ alignItems: "center",+ m: 0,+ "& .MuiFormControlLabel-label":+ lockerTextBodySx,+ }}+ />+ </Box>+ )}+ {error && (+ <Typography+ sx={(theme) => ({+ ...lockerTextMiniSx,+ textAlign: "center",+ mt: 1.5,+ ...lockerColorSx(theme, { color: "warning" }),+ })}+ >+ {error}+ </Typography>+ )}+ <LoadingButton+ fullWidth+ color={tone}+ loading={loading}+ onClick={onConfirm}+ sx={(theme) => ({+ ...lockerTextBodyBoldSx,+ mt: 3,+ minHeight: 52,+ borderRadius: "20px",+ textTransform: "none",+ ...lockerColorSx(theme, {+ backgroundColor:+ tone === "critical" ? "warning" : "primary",+ color: "specialWhite",+ }),+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor:+ tone === "critical"+ ? "warningDark"+ : "primaryDark",+ }),+ },+ "&.Mui-disabled": {+ ...lockerColorSx(theme, {+ backgroundColor:+ tone === "critical" ? "warning" : "primary",+ color: "specialWhite",+ }),+ },+ })}+ >+ {confirmLabel}+ </LoadingButton>+ </Stack>+ </Dialog>+ );+}diff --git a/web/apps/locker/src/components/LockerFileLinkDialog.tsx b/web/apps/locker/src/components/LockerFileLinkDialog.tsxindex 1bdd5f0cb3..0cea0317c6 100644--- a/web/apps/locker/src/components/LockerFileLinkDialog.tsx+++ b/web/apps/locker/src/components/LockerFileLinkDialog.tsx@@ -1,17 +1,27 @@-import { lockerDialogPaperSx } from "@/components/locker-dialog-styles";-import CloseIcon from "@mui/icons-material/Close";+import {+ lockerSheetContainerSx,+ lockerSheetPaperSx,+} from "@/components/locker-dialog-styles";+import {+ lockerColorSx,+ lockerShadowFloating,+ lockerTextBodyBoldSx,+ lockerTextBodySx,+ lockerTextH2Sx,+} from "@/components/locker-tokens";+import { Cancel01Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";import ContentCopyIcon from "@mui/icons-material/ContentCopy";import {Box,Button,CircularProgress,Dialog,- DialogContent,- DialogTitle,IconButton,Stack,Typography,} from "@mui/material";+import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { t } from "i18next";import React from "react";@@ -43,102 +53,187 @@ export const LockerFileLinkDialog: React.FC<LockerFileLinkDialogProps> = ({<Dialogopen={open}onClose={loading || deleting ? undefined : onClose}- fullWidth- maxWidth="xs"+ fullWidth={!loading}+ maxWidth={loading ? false : "xs"}slotProps={{paper: {- sx: { ...lockerDialogPaperSx, width: "min(100%, 420px)" },+ sx: loading+ ? (theme) => ({+ display: "flex",+ flexDirection: "row",+ alignItems: "center",+ gap: 2,+ padding: "20px 24px",+ borderRadius: "20px",+ ...lockerColorSx(theme, {+ backgroundColor: "backgroundBase",+ }),+ boxShadow: lockerShadowFloating,+ width: "auto",+ })+ : lockerSheetPaperSx,+ },+ container: {+ sx: loading ? { alignItems: "center" } : lockerSheetContainerSx,},}}>- <DialogTitle sx={{ pr: 6 }}>- {itemTitle}- <IconButton- onClick={onClose}- size="small"- sx={{ position: "absolute", right: 12, top: 12 }}- disabled={loading || deleting}- >- <CloseIcon fontSize="small" />- </IconButton>- </DialogTitle>- <DialogContent sx={{ pb: 3 }}>- {loading ? (+ {loading ? (+ <>+ <CircularProgress+ size={24}+ thickness={4}+ sx={(theme) => lockerColorSx(theme, { color: "primary" })}+ />+ <Typography sx={lockerTextBodySx}>+ {t("creatingShareLink")}+ </Typography>+ </>+ ) : (+ <Stack><Stack- sx={{- minHeight: 180,- alignItems: "center",- justifyContent: "center",- gap: 1.5,- }}+ direction="row"+ sx={{ alignItems: "center", gap: 1.5, minHeight: 38 }}>- <CircularProgress size={28} />- <Typography variant="body" sx={{ color: "text.muted" }}>- {t("creatingShareLink")}+ <Typography+ noWrap+ sx={{ ...lockerTextH2Sx, flex: 1, minWidth: 0 }}+ >+ {itemTitle}</Typography>+ <IconButton+ aria-label={t("cancel")}+ onClick={onClose}+ disabled={deleting}+ sx={(theme) => ({+ width: 36,+ height: 36,+ borderRadius: "50%",+ p: 0,+ flexShrink: 0,+ ...lockerColorSx(theme, {+ backgroundColor: "fillLight",+ color: "iconColor",+ }),+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor: "fillDark",+ }),+ },+ })}+ >+ <HugeiconsIcon+ icon={Cancel01Icon}+ size={18}+ strokeWidth={1.5}+ />+ </IconButton></Stack>- ) : (- <Stack sx={{ gap: 2 }}>- <Typography variant="body" sx={{ color: "text.muted" }}>- {t("shareThisLink")}+ <Typography+ sx={(theme) => ({+ ...lockerTextBodySx,+ mt: 2,+ ...lockerColorSx(theme, { color: "textLight" }),+ })}+ >+ {t("shareThisLink")}+ </Typography>+ <Box+ sx={(theme) => ({+ position: "relative",+ mt: 3,+ borderRadius: "12px",+ padding: "16px 48px 16px 12px",+ ...lockerColorSx(theme, {+ backgroundColor: "fillLight",+ }),+ })}+ >+ <Typography+ component="div"+ sx={{+ wordBreak: "break-all",+ fontSize: 13,+ lineHeight: 1.5,+ fontFamily:+ 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',+ }}+ >+ {url}</Typography>-- <Box+ <IconButton+ aria-label={t("copyLink")}+ onClick={onCopy}+ disabled={!url || deleting}sx={(theme) => ({- p: 1.5,- borderRadius: "12px",- bgcolor: theme.vars.palette.fill.faint,+ position: "absolute",+ right: 6,+ top: 6,+ width: 36,+ height: 36,+ borderRadius: "50%",+ ...lockerColorSx(theme, { color: "iconColor" }),+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor: "fillDark",+ }),+ },})}>- <Typography- component="div"- sx={{- wordBreak: "break-all",- fontSize: 13,- lineHeight: 1.5,- fontFamily:- 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',- }}- >- {url}- </Typography>- </Box>-- <Stack- direction={{ xs: "column", sm: "row" }}- sx={{ gap: 1 }}- >- <Button- variant="contained"- startIcon={<ContentCopyIcon />}- onClick={onCopy}- disabled={!url || deleting}- fullWidth- >- {t("copyLink")}- </Button>- {showShareAction && (- <Button- variant="outlined"- onClick={onShare}- disabled={!url || deleting}- fullWidth- >- {t("shareLink")}- </Button>- )}- </Stack>-+ <ContentCopyIcon sx={{ fontSize: 18 }} />+ </IconButton>+ </Box>+ <Stack sx={{ gap: 1.5, mt: 2 }}><Button+ fullWidth+ onClick={showShareAction ? onShare : onCopy}+ disabled={!url || deleting}+ sx={(theme) => ({+ ...lockerTextBodyBoldSx,+ minHeight: 52,+ borderRadius: "20px",+ textTransform: "none",+ ...lockerColorSx(theme, {+ backgroundColor: "primary",+ color: "specialWhite",+ }),+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor: "primaryDark",+ }),+ },+ })}+ >+ {showShareAction ? t("shareLink") : t("copyLink")}+ </Button>+ <LoadingButton+ fullWidthvariant="text"color="critical"+ loading={deleting}onClick={onDelete}- disabled={deleting}+ sx={(theme) => ({+ ...lockerTextBodyBoldSx,+ minHeight: 52,+ borderRadius: "20px",+ textTransform: "none",+ backgroundColor: "transparent",+ ...lockerColorSx(theme, { color: "warning" }),+ "&.Mui-disabled": {+ backgroundColor: "transparent",+ ...lockerColorSx(theme, { color: "warning" }),+ },+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor: "warningLight",+ }),+ },+ })}>{deleting ? t("deletingShareLink") : t("deleteLink")}- </Button>+ </LoadingButton></Stack>- )}- </DialogContent>+ </Stack>+ )}</Dialog>);diff --git a/web/apps/locker/src/components/LockerMenu.tsx b/web/apps/locker/src/components/LockerMenu.tsxnew file mode 100644index 0000000000..557ec13f79--- /dev/null+++ b/web/apps/locker/src/components/LockerMenu.tsx@@ -0,0 +1,181 @@+import CheckRoundedIcon from "@mui/icons-material/CheckRounded";+import MoreHorizIcon from "@mui/icons-material/MoreHoriz";+import {+ Box,+ IconButton,+ MenuItem,+ Typography,+ type IconButtonProps,+} from "@mui/material";+import Menu, { type MenuProps } from "@mui/material/Menu";+import React, { createContext, useContext, useMemo, useState } from "react";+import { lockerMenuPaperSx } from "./locker-dialog-styles";+import { lockerColorSx, lockerTextMiniSx } from "./locker-tokens";++const LockerMenuContext = createContext<{ close: () => void } | undefined>(+ undefined,+);++export const LockerOverflowMenu: React.FC<+ React.PropsWithChildren<{+ ariaID: string;+ triggerButtonIcon?: React.ReactNode;+ triggerButtonSxProps?: IconButtonProps["sx"];+ }>+> = ({ ariaID, triggerButtonIcon, triggerButtonSxProps, children }) => {+ const [anchorEl, setAnchorEl] = useState<MenuProps["anchorEl"]>();+ const context = useMemo(+ () => ({ close: () => setAnchorEl(undefined) }),+ [],+ );+ return (+ <LockerMenuContext value={context}>+ <IconButton+ onClick={(event) => setAnchorEl(event.currentTarget)}+ aria-controls={anchorEl ? ariaID : undefined}+ aria-haspopup="true"+ aria-expanded={anchorEl ? "true" : undefined}+ sx={triggerButtonSxProps}+ >+ {triggerButtonIcon ?? <MoreHorizIcon />}+ </IconButton>+ <Menu+ id={ariaID}+ {...(anchorEl && { anchorEl })}+ open={!!anchorEl}+ onClose={() => setAnchorEl(undefined)}+ slotProps={{+ paper: { sx: lockerMenuPaperSx },+ list: { disablePadding: true, "aria-labelledby": ariaID },+ }}+ anchorOrigin={{ vertical: "bottom", horizontal: "right" }}+ transformOrigin={{ vertical: "top", horizontal: "right" }}+ >+ {children}+ </Menu>+ </LockerMenuContext>+ );+};++export const LockerMenuOption: React.FC<+ React.PropsWithChildren<{+ onClick: () => void;+ critical?: boolean;+ disabled?: boolean;+ selected?: boolean;+ startIcon?: React.ReactNode;+ secondary?: string;+ }>+> = ({+ onClick,+ critical,+ disabled,+ selected,+ startIcon,+ secondary,+ children,+ ...rest+}) => {+ const menuContext = useContext(LockerMenuContext);+ return (+ <MenuItem+ {...rest}+ onClick={() => {+ onClick();+ menuContext?.close();+ }}+ disabled={disabled}+ selected={selected}+ sx={(theme) => ({+ height: 52,+ minHeight: 52,+ px: "16px",+ gap: "6px",+ alignItems: "center",+ borderBottom: "1px solid",+ ...lockerColorSx(theme, { borderColor: "strokeFaint" }),+ "&.Mui-disabled": { opacity: 0.5 },+ "&.Mui-selected": lockerColorSx(theme, {+ backgroundColor: "primaryLight",+ }),+ "&:hover, &.Mui-selected:hover": lockerColorSx(theme, {+ backgroundColor: "fillDark",+ }),+ })}+ >+ {startIcon && (+ <Box+ sx={(theme) => ({+ width: 24,+ height: 24,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ flexShrink: 0,+ ...lockerColorSx(theme, {+ color: critical ? "warning" : "textBase",+ }),+ "& .MuiSvgIcon-root": { fontSize: 18 },+ })}+ >+ {startIcon}+ </Box>+ )}+ <Typography+ noWrap+ sx={(theme) => ({+ ...lockerTextMiniSx,+ flex: 1,+ minWidth: 0,+ ...lockerColorSx(theme, {+ color: critical ? "warning" : "textBase",+ }),+ })}+ >+ {children}+ </Typography>+ {secondary !== undefined && (+ <Typography+ sx={(theme) => ({+ ...lockerTextMiniSx,+ flexShrink: 0,+ ...lockerColorSx(theme, { color: "textLight" }),+ })}+ >+ Β· {secondary}+ </Typography>+ )}+ {selected && (+ <CheckRoundedIcon+ sx={(theme) => ({+ fontSize: 18,+ ...lockerColorSx(theme, { color: "primary" }),+ })}+ />+ )}+ </MenuItem>+ );+};++export const LockerMenuFooter: React.FC<+ React.PropsWithChildren<{ onClick: () => void }>+> = ({ onClick, children, ...rest }) => (+ <MenuItem+ {...rest}+ onClick={onClick}+ sx={(theme) => ({+ ...lockerTextMiniSx,+ height: 44,+ minHeight: 44,+ width: "100%",+ justifyContent: "center",+ textDecoration: "underline",+ textUnderlineOffset: "3px",+ textTransform: "none",+ ...lockerColorSx(theme, { color: "textLight" }),+ "&:hover": lockerColorSx(theme, { backgroundColor: "fillDark" }),+ })}+ >+ {children}+ </MenuItem>+);diff --git a/web/apps/locker/src/components/itemList/ItemListDialogs.tsx b/web/apps/locker/src/components/itemList/ItemListDialogs.tsxindex 0c9b07abbd..d456372661 100644--- a/web/apps/locker/src/components/itemList/ItemListDialogs.tsx+++ b/web/apps/locker/src/components/itemList/ItemListDialogs.tsx@@ -3,26 +3,25 @@ import {lockerPrimaryButtonSx,} from "@/components/createItemDialog/create-item-dialog-styles";import { FormField } from "@/components/createItemDialog/ItemFormFields";+import { lockerMenuPaperSx } from "@/components/locker-dialog-styles";import {lockerColorSx,lockerTextBodyBoldSx,+ lockerTextBodySx,lockerTextH2Sx,lockerTextMiniSx,} from "@/components/locker-tokens";+import { LockerMenuFooter, LockerMenuOption } from "@/components/LockerMenu";import type { LockerCollection } from "@/types";import { Cancel01Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";-import CheckCircleRoundedIcon from "@mui/icons-material/CheckCircleRounded";+import CheckRoundedIcon from "@mui/icons-material/CheckRounded";import {Box,- Button,Chip,Dialog,- DialogContent,- DialogTitle,IconButton,Menu,- MenuItem,Snackbar,Stack,Typography,@@ -30,7 +29,11 @@ import {import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { t } from "i18next";import React from "react";-import { lockerDialogPaperSx } from "../locker-dialog-styles";+import {+ lockerSheetContainerSx,+ lockerSheetPaperSx,+} from "../locker-dialog-styles";+import { LockerConfirmDialog } from "../LockerConfirmDialog";import { LockerFileLinkDialog } from "../LockerFileLinkDialog";interface ItemListDialogsProps {@@ -138,49 +141,26 @@ export const ItemListDialogs: React.FC<ItemListDialogsProps> = ({onDelete={onRequestDeleteFileLink}/>- <Dialog- slotProps={{ paper: { sx: lockerDialogPaperSx } }}+ <LockerConfirmDialogopen={isDeleteFileLinkConfirmOpen}+ illustration="/images/file_delete_icon.png"+ title={t("deleteShareLinkDialogTitle")}+ body={t("deleteShareLinkConfirmation")}+ confirmLabel={t("delete")}+ loading={isDeletingFileLink}onClose={() => {if (!isDeletingFileLink) {setDeleteFileLinkConfirmOpen(false);}}}- fullWidth- maxWidth="xs"- >- <DialogTitle>{t("deleteShareLinkDialogTitle")}</DialogTitle>- <DialogContent>- <Stack sx={{ gap: 2.25 }}>- <Typography sx={{ color: "text.muted" }}>- {t("deleteShareLinkConfirmation")}- </Typography>- <Stack direction="row" sx={{ gap: 1 }}>- <Button- fullWidth- color="secondary"- disabled={isDeletingFileLink}- onClick={() => setDeleteFileLinkConfirmOpen(false)}- sx={{ minHeight: 44 }}- >- {t("cancel")}- </Button>- <LoadingButton- fullWidth- color="critical"- loading={isDeletingFileLink}- onClick={deleteFileLink}- sx={{ minHeight: 44 }}- >- {t("deleteLink")}- </LoadingButton>- </Stack>- </Stack>- </DialogContent>- </Dialog>+ onConfirm={deleteFileLink}+ /><Dialog- slotProps={{ paper: { sx: lockerDialogPaperSx } }}+ slotProps={{+ paper: { sx: lockerSheetPaperSx },+ container: { sx: lockerSheetContainerSx },+ }}open={restoreDialogOpen}onClose={() => {if (!restoringItem) {@@ -190,69 +170,177 @@ export const ItemListDialogs: React.FC<ItemListDialogsProps> = ({fullWidthmaxWidth="xs">- <DialogTitle>{t("restoreToCollection")}</DialogTitle>- <DialogContent>- <Stack sx={{ gap: 1, pt: 0.25, pb: 1 }}>+ <Stack>+ <Stack+ direction="row"+ sx={{ alignItems: "center", gap: 1.5, minHeight: 38 }}+ >+ <Typography+ noWrap+ sx={{ ...lockerTextH2Sx, flex: 1, minWidth: 0 }}+ >+ {t("restoreToCollection")}+ </Typography>+ <IconButton+ aria-label={t("cancel")}+ disabled={restoringItem}+ onClick={() => {+ if (!restoringItem) {+ onCloseRestoreDialog();+ }+ }}+ sx={(theme) => ({+ width: 36,+ height: 36,+ borderRadius: "50%",+ p: 0,+ flexShrink: 0,+ ...lockerColorSx(theme, {+ backgroundColor: "fillLight",+ color: "iconColor",+ }),+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor: "fillDark",+ }),+ },+ })}+ >+ <HugeiconsIcon+ icon={Cancel01Icon}+ size={18}+ strokeWidth={1.5}+ />+ </IconButton>+ </Stack>+ <Typography+ sx={(theme) => ({+ ...lockerTextMiniSx,+ mt: 2.5,+ mb: 1,+ ...lockerColorSx(theme, { color: "textLight" }),+ })}+ >+ {t("collections")}+ </Typography>+ <Box sx={{ display: "flex", flexWrap: "wrap", gap: 1 }}>{restoreCollections.length > 0 ? (restoreCollections.map((collection) => (<Chipkey={collection.id}label={collection.name}- variant={- restoreCollectionID === collection.id- ? "filled"- : "outlined"- }- color={- restoreCollectionID === collection.id- ? "primary"- : "default"+ icon={+ restoreCollectionID === collection.id ? (+ <CheckRoundedIcon+ sx={{ fontSize: 14 }}+ />+ ) : undefined}disabled={restoringItem}onClick={() =>setRestoreCollectionID(collection.id)}+ sx={(theme) => ({+ height: 36,+ borderRadius: "9999px",+ px: "14px",+ border: "1px solid",+ ...lockerColorSx(theme, {+ backgroundColor:+ restoreCollectionID ===+ collection.id+ ? "primaryLight"+ : "fillLight",+ color:+ restoreCollectionID ===+ collection.id+ ? "primary"+ : "textBase",+ ...(restoreCollectionID ===+ collection.id+ ? {+ borderColor:+ "primaryStroke" as const,+ }+ : {}),+ }),+ ...(restoreCollectionID === collection.id+ ? {}+ : { borderColor: "transparent" }),+ "& .MuiChip-label": {+ ...lockerTextBodySx,+ px: 0,+ },+ "& .MuiChip-icon": {+ ml: 0,+ mr: 0.75,+ ...lockerColorSx(theme, {+ color: "primary",+ }),+ },+ })}/>))) : (- <Typography variant="body" sx={{ color: "text.muted" }}>- {t("noCollectionsAvailableForSelection")}- </Typography>- )}- {restoreError && (<Typography- variant="small"- sx={{ color: "critical.main" }}+ sx={(theme) => ({+ ...lockerTextBodySx,+ ...lockerColorSx(theme, { color: "textLight" }),+ })}>- {restoreError}+ {t("noCollectionsAvailableForSelection")}</Typography>)}- <LoadingButton- variant="contained"- loading={restoringItem}- disabled={restoreCollectionID === null}- onClick={onConfirmRestore}- sx={{ mt: 1 }}+ </Box>+ {restoreError && (+ <Typography+ sx={(theme) => ({+ ...lockerTextMiniSx,+ mt: 1.5,+ ...lockerColorSx(theme, { color: "warning" }),+ })}>- {t("restore")}- </LoadingButton>- </Stack>- </DialogContent>+ {restoreError}+ </Typography>+ )}+ <LoadingButton+ fullWidth+ variant="contained"+ loading={restoringItem}+ disabled={restoreCollectionID === null}+ onClick={onConfirmRestore}+ sx={(theme) => ({+ ...lockerTextBodyBoldSx,+ mt: 3,+ minHeight: 52,+ borderRadius: "20px",+ textTransform: "none",+ ...lockerColorSx(theme, {+ backgroundColor: "primary",+ color: "specialWhite",+ }),+ "&:hover": {+ ...lockerColorSx(theme, {+ backgroundColor: "primaryDark",+ }),+ },+ "&.Mui-disabled": {+ ...lockerColorSx(theme, {+ backgroundColor: "fillDarkest",+ color: "textLighter",+ }),+ },+ })}+ >+ {t("restore")}+ </LoadingButton>+ </Stack></Dialog><DialogslotProps={{- paper: {- sx: (theme) => ({- ...lockerDialogPaperSx,- borderRadius: "24px",- width: "min(100%, 440px)",- padding: "20px",- ...lockerColorSx(theme, {- backgroundColor: "backgroundBase",- }),- }),- },+ paper: { sx: lockerSheetPaperSx },+ container: { sx: lockerSheetContainerSx },}}open={renameCollectionOpen}onClose={() => {@@ -344,17 +432,8 @@ export const ItemListDialogs: React.FC<ItemListDialogsProps> = ({<DialogslotProps={{- paper: {- sx: (theme) => ({- ...lockerDialogPaperSx,- borderRadius: "24px",- width: "min(100%, 440px)",- padding: "20px",- ...lockerColorSx(theme, {- backgroundColor: "backgroundBase",- }),- }),- },+ paper: { sx: lockerSheetPaperSx },+ container: { sx: lockerSheetContainerSx },}}open={createCollectionOpen}onClose={() => {@@ -451,147 +530,37 @@ export const ItemListDialogs: React.FC<ItemListDialogsProps> = ({open={!!collectionFilterAnchorEl}onClose={closeCollectionFilterMenu}slotProps={{- paper: {- sx: {- mt: 1,- width: "fit-content",- minWidth: 0,- maxWidth: "calc(100vw - 32px)",- borderRadius: "18px",- overflow: "hidden",- },- },+ paper: { sx: [lockerMenuPaperSx, { mt: 1 }] },+ list: { disablePadding: true },}}>- <Box sx={{ px: 1, pt: 0, pb: 0, width: "fit-content" }}>- {dropdownHomeCollections.map((collection) => {- const isSelected = homeSelectedCollectionIDs.includes(- collection.id,- );-- return (- <MenuItem- key={collection.id}- onClick={() =>- onToggleHomeCollection(collection.id)- }- sx={(theme) => ({- gap: 1.25,- px: 1,- py: 1,- my: "6px",- borderRadius: "14px",- alignItems: "center",- width: "auto",- color: isSelected- ? "primary.main"- : "text.base",- backgroundColor: isSelected- ? "rgba(16, 113, 255, 0.10)"- : "transparent",- "&:hover": {- backgroundColor: isSelected- ? "rgba(16, 113, 255, 0.14)"- : theme.vars.palette.fill.faint,- },- })}- >- <CheckCircleRoundedIcon- sx={{- fontSize: 20,- color: isSelected- ? "primary.main"- : "text.faint",- opacity: isSelected ? 1 : 0.22,- flexShrink: 0,- }}- />- <Box sx={{ minWidth: 0, flex: 1 }}>- <Typography- variant="body"- sx={{- fontWeight: isSelected ? 700 : 500,- display: "flex",- alignItems: "center",- gap: 0.75,- minWidth: 0,- whiteSpace: "nowrap",- }}- >- <Box- component="span"- sx={{- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- minWidth: 0,- }}- >- {collection.name}- </Box>- <Box- component="span"- sx={{- color: "text.muted",- flexShrink: 0,- }}- >- {"Β·"}- </Box>- <Box- component="span"- sx={{- color: "text.muted",- fontWeight: 500,- flexShrink: 0,- whiteSpace: "nowrap",- }}- >- {new Intl.NumberFormat().format(- collection.items.length,- )}- </Box>- </Typography>- </Box>- </MenuItem>- );- })}- {homeSelectedCollectionIDs.length > 0 && (- <Box- sx={{- display: "flex",- justifyContent: "center",- pt: "12px",- pb: 0,- }}+ {dropdownHomeCollections.map((collection) => {+ const isSelected = homeSelectedCollectionIDs.includes(+ collection.id,+ );+ return (+ <LockerMenuOption+ key={collection.id}+ onClick={() => onToggleHomeCollection(collection.id)}+ selected={isSelected}+ secondary={new Intl.NumberFormat().format(+ collection.items.length,+ )}>- <Button- color="secondary"- onClick={() => {- clearHomeCollectionSelection();- closeCollectionFilterMenu();- }}- sx={{- minWidth: "auto",- px: 1,- py: 0.5,- backgroundColor: "transparent",- color: "text.muted",- fontSize: "0.8125rem",- fontWeight: 500,- textDecoration: "underline",- textUnderlineOffset: "3px",- "&:hover": {- backgroundColor: "transparent",- color: "text.secondary",- },- }}- >- {t("clearSelection")}- </Button>- </Box>- )}- </Box>+ {collection.name}+ </LockerMenuOption>+ );+ })}+ {homeSelectedCollectionIDs.length > 0 && (+ <LockerMenuFooter+ onClick={() => {+ clearHomeCollectionSelection();+ closeCollectionFilterMenu();+ }}+ >+ {t("clearSelection")}+ </LockerMenuFooter>+ )}</Menu><Snackbardiff --git a/web/apps/locker/src/components/locker-dialog-styles.ts b/web/apps/locker/src/components/locker-dialog-styles.tsindex 8f1d1d0163..765ce8634d 100644--- a/web/apps/locker/src/components/locker-dialog-styles.ts+++ b/web/apps/locker/src/components/locker-dialog-styles.ts@@ -1 +1,33 @@-export const lockerDialogPaperSx = { borderRadius: "20px" };+import type { Theme } from "@mui/material";+import { lockerColorSx, lockerShadowFloating } from "./locker-tokens";++export const lockerMenuPaperSx = (theme: Theme) => ({+ "& .MuiMenuItem-root:last-of-type": { borderBottomColor: "transparent" },+ width: 196,+ borderRadius: "20px",+ overflow: "hidden",+ boxShadow: lockerShadowFloating,+ border: "1px solid",+ ...lockerColorSx(theme, {+ backgroundColor: "fillLight",+ borderColor: "strokeFaint",+ }),+});++export const lockerSheetPaperSx = (theme: Theme) => ({+ borderRadius: "24px",+ width: "min(100%, 440px)",+ padding: "20px",+ ...lockerColorSx(theme, { backgroundColor: "backgroundBase" }),+ [theme.breakpoints.down("sm")]: {+ margin: 0,+ width: "100%",+ maxWidth: "100%",+ borderRadius: "20px 20px 0 0",+ paddingBottom: "34px",+ },+});++export const lockerSheetContainerSx = {+ alignItems: { xs: "flex-end", sm: "center" },+};diff --git a/web/apps/locker/src/components/locker-tokens.ts b/web/apps/locker/src/components/locker-tokens.tsindex 11e078ece5..10c4060bf7 100644--- a/web/apps/locker/src/components/locker-tokens.ts+++ b/web/apps/locker/src/components/locker-tokens.ts@@ -5,18 +5,25 @@ export const lockerColors = {backgroundBase: { light: "#f4f4f4", dark: "#161616" },fillLight: { light: "#ffffff", dark: "#212121" },fillDark: { light: "#eaeaea", dark: "#0a0a0a" },+ fillDarkest: { light: "#d2d2d2", dark: "#292929" },strokeFaint: { light: "#ebebeb", dark: "#2a2a2a" },+ strokeDark: { light: "#e0e0e0", dark: "#3e3e3e" },textBase: { light: "#000000", dark: "#ffffff" },textLight: { light: "#666666", dark: "#999999" },textLighter: { light: "#969696", dark: "#969696" },iconColor: { light: "rgba(0, 0, 0, 0.75)", dark: "#ffffff" },primary: { light: "#1071ff", dark: "#1071ff" },+ primaryLight: { light: "#e7effa", dark: "#292929" },primaryDark: { light: "#0e5fd9", dark: "#0e5fd9" },+ primaryStroke: { light: "#1071ff", dark: "#1071ff" },warning: { light: "#f63a3a", dark: "#f63a3a" },+ warningLight: { light: "#faebeb", dark: "#292929" },warningDark: { light: "#dd3434", dark: "#dd3434" },specialWhite: { light: "#ffffff", dark: "#ffffff" },} as const;+export const lockerShadowFloating = "0px 12px 24px rgba(0, 0, 0, 0.14)";+export const lockerColorSx = (theme: Theme,colors: Partial<diff --git a/web/apps/locker/src/components/lockerPage/DeleteCollectionDialog.tsx b/web/apps/locker/src/components/lockerPage/DeleteCollectionDialog.tsxindex ba106a619d..2df9359bf9 100644--- a/web/apps/locker/src/components/lockerPage/DeleteCollectionDialog.tsx+++ b/web/apps/locker/src/components/lockerPage/DeleteCollectionDialog.tsx@@ -1,23 +1,4 @@-import { lockerDialogPaperSx } from "@/components/locker-dialog-styles";-import {- lockerColorSx,- lockerTextBodyBoldSx,- lockerTextBodySx,- lockerTextH2Sx,- lockerTextMiniSx,-} from "@/components/locker-tokens";-import { Cancel01Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import {- Box,- Checkbox,- Dialog,- FormControlLabel,- IconButton,- Stack,- Typography,-} from "@mui/material";-import { LoadingButton } from "ente-base/components/mui/LoadingButton";+import { LockerConfirmDialog } from "@/components/LockerConfirmDialog";import { t } from "i18next";import React from "react";import type { DeleteCollectionDialogState } from "./use-locker-actions";@@ -37,155 +18,26 @@ export const DeleteCollectionDialog: React.FC<DeleteCollectionDialogProps> = ({onConfirm,onToggleDeleteFromEverywhere,}) => (- <Dialog+ <LockerConfirmDialogopen={dialogState !== null}- onClose={() => {- if (!dialogState?.loading) {- onClose();- }- }}- fullWidth- maxWidth="xs"- slotProps={{- paper: {- sx: (theme) => ({- ...lockerDialogPaperSx,- borderRadius: "24px",- width: "min(100%, 440px)",- padding: "20px",- ...lockerColorSx(theme, {- backgroundColor: "backgroundBase",- }),- }),- },- }}- >- <Stack>- <Box sx={{ display: "flex", justifyContent: "flex-end" }}>- <IconButton- aria-label={t("cancel")}- onClick={onClose}- disabled={visibleDialogState?.loading}- sx={(theme) => ({- width: 36,- height: 36,- borderRadius: "50%",- padding: 0,- ...lockerColorSx(theme, {- backgroundColor: "fillLight",- color: "iconColor",- }),- "&:hover": {- ...lockerColorSx(theme, {- backgroundColor: "fillDark",- }),- },- })}- >- <HugeiconsIcon- icon={Cancel01Icon}- size={18}- strokeWidth={1.5}- />- </IconButton>- </Box>- <img- src="/images/collection_delete_icon.png"- alt=""- style={{- width: 120,- height: 120,- objectFit: "contain",- display: "block",- margin: "4px auto 0",- }}- />- <Typography- sx={{ ...lockerTextH2Sx, textAlign: "center", mt: 2.5 }}- >- {t("deleteCollectionTitle")}- </Typography>- <Typography- sx={(theme) => ({- ...lockerTextBodySx,- textAlign: "center",- mt: 1.5,- ...lockerColorSx(theme, { color: "textLight" }),- })}- >- {t("deleteCollectionDialogBody", {- collectionName: visibleDialogState?.collectionName ?? "",- })}- </Typography>- {visibleDialogState?.hasItems && (- <Box- sx={{ display: "flex", mt: 2.5, justifyContent: "center" }}- >- <FormControlLabel- control={- <Checkbox- checked={- visibleDialogState.deleteFromEverywhere- }- disabled={visibleDialogState.loading}- onChange={(event) =>- onToggleDeleteFromEverywhere(- event.target.checked,- )- }- />- }- label={t("deleteCollectionFromEverywhere")}- sx={{- alignItems: "center",- m: 0,- "& .MuiFormControlLabel-label": lockerTextBodySx,- }}- />- </Box>- )}- {visibleDialogState?.error && (- <Typography- sx={(theme) => ({- ...lockerTextMiniSx,- textAlign: "center",- mt: 1.5,- ...lockerColorSx(theme, { color: "warning" }),- })}- >- {visibleDialogState.error}- </Typography>- )}- <LoadingButton- fullWidth- color="critical"- loading={visibleDialogState?.loading}- onClick={onConfirm}- sx={(theme) => ({- ...lockerTextBodyBoldSx,- mt: 3,- minHeight: 52,- borderRadius: "20px",- textTransform: "none",- ...lockerColorSx(theme, {- backgroundColor: "warning",- color: "specialWhite",- }),- "&:hover": {- ...lockerColorSx(theme, {- backgroundColor: "warningDark",- }),- },- "&.Mui-disabled": {- ...lockerColorSx(theme, {- backgroundColor: "warning",- color: "specialWhite",- }),- },- })}- >- {t("delete")}- </LoadingButton>- </Stack>- </Dialog>+ illustration="/images/collection_delete_icon.png"+ title={t("deleteCollectionTitle")}+ body={t("deleteCollectionDialogBody", {+ collectionName: visibleDialogState?.collectionName ?? "",+ })}+ confirmLabel={t("delete")}+ checkbox={+ visibleDialogState?.hasItems+ ? {+ label: t("deleteCollectionFromEverywhere"),+ checked: visibleDialogState.deleteFromEverywhere,+ onChange: onToggleDeleteFromEverywhere,+ }+ : undefined+ }+ loading={visibleDialogState?.loading}+ error={visibleDialogState?.error ?? undefined}+ onClose={onClose}+ onConfirm={onConfirm}+ />);diff --git a/web/apps/locker/src/components/lockerPage/EmptyTrashDialog.tsx b/web/apps/locker/src/components/lockerPage/EmptyTrashDialog.tsxindex 83081f4dac..ac6a8fce64 100644--- a/web/apps/locker/src/components/lockerPage/EmptyTrashDialog.tsx+++ b/web/apps/locker/src/components/lockerPage/EmptyTrashDialog.tsx@@ -1,15 +1,4 @@-import { lockerDialogPaperSx } from "@/components/locker-dialog-styles";-import {- lockerColorSx,- lockerTextBodyBoldSx,- lockerTextBodySx,- lockerTextH2Sx,- lockerTextMiniSx,-} from "@/components/locker-tokens";-import { Cancel01Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import { Box, Dialog, IconButton, Stack, Typography } from "@mui/material";-import { LoadingButton } from "ente-base/components/mui/LoadingButton";+import { LockerConfirmDialog } from "@/components/LockerConfirmDialog";import { t } from "i18next";export interface EmptyTrashDialogState {@@ -30,130 +19,17 @@ export function EmptyTrashDialog({onClose,onConfirm,}: EmptyTrashDialogProps) {- const handleClose = () => {- if (!dialogState?.loading) {- onClose();- }- };-return (- <Dialog+ <LockerConfirmDialogopen={dialogState !== null}- onClose={handleClose}- fullWidth- maxWidth="xs"- slotProps={{- paper: {- sx: (theme) => ({- ...lockerDialogPaperSx,- borderRadius: "24px",- width: "min(100%, 440px)",- padding: "20px",- ...lockerColorSx(theme, {- backgroundColor: "backgroundBase",- }),- }),- },- }}- >- <Stack>- <Box sx={{ display: "flex", justifyContent: "flex-end" }}>- <IconButton- aria-label={t("cancel")}- onClick={handleClose}- disabled={visibleDialogState?.loading}- sx={(theme) => ({- width: 36,- height: 36,- borderRadius: "50%",- padding: 0,- ...lockerColorSx(theme, {- backgroundColor: "fillLight",- color: "iconColor",- }),- "&:hover": {- ...lockerColorSx(theme, {- backgroundColor: "fillDark",- }),- },- })}- >- <HugeiconsIcon- icon={Cancel01Icon}- size={18}- strokeWidth={1.5}- />- </IconButton>- </Box>- <img- src="/images/collection_delete_icon.png"- alt=""- style={{- width: 120,- height: 120,- objectFit: "contain",- display: "block",- margin: "4px auto 0",- }}- />- <Typography- sx={{ ...lockerTextH2Sx, textAlign: "center", mt: 2.5 }}- >- {t("empty_trash_title")}- </Typography>- <Typography- sx={(theme) => ({- ...lockerTextBodySx,- textAlign: "center",- mt: 1.5,- ...lockerColorSx(theme, { color: "textLight" }),- })}- >- {t("empty_trash_message")}- </Typography>- {visibleDialogState?.error && (- <Typography- sx={(theme) => ({- ...lockerTextMiniSx,- textAlign: "center",- mt: 1.5,- ...lockerColorSx(theme, { color: "warning" }),- })}- >- {visibleDialogState.error}- </Typography>- )}- <LoadingButton- fullWidth- color="critical"- loading={visibleDialogState?.loading}- onClick={onConfirm}- sx={(theme) => ({- ...lockerTextBodyBoldSx,- mt: 3,- minHeight: 52,- borderRadius: "20px",- textTransform: "none",- ...lockerColorSx(theme, {- backgroundColor: "warning",- color: "specialWhite",- }),- "&:hover": {- ...lockerColorSx(theme, {- backgroundColor: "warningDark",- }),- },- "&.Mui-disabled": {- ...lockerColorSx(theme, {- backgroundColor: "warning",- color: "specialWhite",- }),- },- })}- >- {t("empty_trash")}- </LoadingButton>- </Stack>- </Dialog>+ illustration="/images/collection_delete_icon.png"+ title={t("empty_trash_title")}+ body={t("empty_trash_message")}+ confirmLabel={t("empty_trash")}+ loading={visibleDialogState?.loading}+ error={visibleDialogState?.error}+ onClose={onClose}+ onConfirm={onConfirm}+ />);}diff --git a/web/apps/locker/src/components/lockerPage/use-locker-actions.tsx b/web/apps/locker/src/components/lockerPage/use-locker-actions.tsxindex 1581472de5..e7b8def471 100644--- a/web/apps/locker/src/components/lockerPage/use-locker-actions.tsx+++ b/web/apps/locker/src/components/lockerPage/use-locker-actions.tsx@@ -33,14 +33,11 @@ import type {LockerUploadCandidate,} from "@/types";import { getItemTitle, isCollectionOwner } from "@/types";-import { Box } from "@mui/material";import { savedLocalUser } from "ente-accounts/services/accounts-db";-import type { MiniDialogAttributes } from "ente-base/components/MiniDialog";import log from "ente-base/log";import { t } from "i18next";import type { DragEvent } from "react";import { useCallback, useEffect, useRef, useState } from "react";-import { Trans } from "react-i18next";import { filterNonEmptyUploadItems } from "../createItemDialog/file-upload-helpers";import type { CreateItemDialogEditItem } from "../createItemDialog/use-create-item-dialog-state";import type { EmptyTrashDialogState } from "./EmptyTrashDialog";@@ -67,6 +64,17 @@ type FileSystemDirectoryEntry = FileSystemEntry & {createReader: () => FileSystemDirectoryReader;};+export interface ConfirmDialogState {+ illustration: string;+ title: string;+ body: React.ReactNode;+ confirmLabel: string;+ tone: "critical" | "primary";+ action: () => Promise<void>;+ loading: boolean;+ error?: string;+}+export interface DeleteCollectionDialogState {collectionID: number;collectionName: string;@@ -301,7 +309,6 @@ interface UseLockerActionsProps {refreshData: (masterKey?: string) => Promise<void>;navigateHome: () => void;removeCollectionFromState: (collectionID: number) => void;- showMiniDialog: (attributes: MiniDialogAttributes) => void;trashLastUpdatedAt: number;}@@ -314,7 +321,6 @@ export const useLockerActions = ({refreshData,navigateHome,removeCollectionFromState,- showMiniDialog,trashLastUpdatedAt,}: UseLockerActionsProps) => {const currentUserID = savedLocalUser()?.id;@@ -332,6 +338,9 @@ export const useLockerActions = ({const [emptyTrashDialog, setEmptyTrashDialog] =useState<EmptyTrashDialogState | null>(null);const emptyTrashDialogRef = useRef<EmptyTrashDialogState | null>(null);+ const [confirmDialog, setConfirmDialog] =+ useState<ConfirmDialogState | null>(null);+ const confirmDialogRef = useRef<ConfirmDialogState | null>(null);const [toast, setToast] = useState<string | null>(null);const [shareCollectionID, setShareCollectionID] = useState<number | null>(null,@@ -355,6 +364,12 @@ export const useLockerActions = ({}}, [emptyTrashDialog]);+ useEffect(() => {+ if (confirmDialog) {+ confirmDialogRef.current = confirmDialog;+ }+ }, [confirmDialog]);+useEffect(() => {shareCollectionIDRef.current = shareCollectionID;}, [shareCollectionID]);@@ -413,6 +428,12 @@ export const useLockerActions = ({const visibleEmptyTrashDialog =emptyTrashDialog ?? emptyTrashDialogRef.current;+ const visibleConfirmDialog = confirmDialog ?? confirmDialogRef.current;++ const closeConfirmDialog = useCallback(() => {+ if (!confirmDialog?.loading) setConfirmDialog(null);+ }, [confirmDialog]);+const uploadPreflightFailureMessage = useCallback((failure: LockerUploadPreflightFailure,@@ -562,37 +583,23 @@ export const useLockerActions = ({selectedCollectionID,);- showMiniDialog({- title: t("delete"),- message: (- <Trans- i18nKey="deleteFileConfirmation"- components={{- fileName: (- <Box- component="span"- sx={{ fontWeight: 700, color: "text.base" }}- >- {getItemTitle(item)}- </Box>- ),- }}- />- ),- continue: {- text: t("delete"),- color: "critical",- action: async () => {- for (const collectionID of collectionIDs) {- await trashFiles([item.id], collectionID);- }- await refreshData();- setToast(t("fileDeletedSuccessfully"));- },+ setConfirmDialog({+ illustration: "/images/file_delete_icon.png",+ title: t("areYouSure"),+ body: t("deleteMultipleFilesDialogBody", { count: 1 }),+ confirmLabel: t("yesDeleteFiles", { count: 1 }),+ tone: "critical",+ action: async () => {+ for (const collectionID of collectionIDs) {+ await trashFiles([item.id], collectionID);+ }+ await refreshData();+ setToast(t("fileDeletedSuccessfully"));},+ loading: false,});},- [refreshData, selectedCollectionID, showMiniDialog],+ [refreshData, selectedCollectionID],);const handleDeleteItems = useCallback(@@ -601,51 +608,46 @@ export const useLockerActions = ({return;}- showMiniDialog({- title: t("delete"),- message: t("deleteMultipleFilesDialogBody", {+ setConfirmDialog({+ illustration: "/images/file_delete_icon.png",+ title: t("areYouSure"),+ body: t("deleteMultipleFilesDialogBody", {count: items.length,}),- continue: {- text: t("yesDeleteFiles", { count: items.length }),- color: "critical",- action: async () => {- const fileIDsByCollection = new Map<- number,- Set<number>- >();- for (const item of items) {- const collectionIDs = collectionIDsForItemMutation(- item,- selectedCollectionID,- );- for (const collectionID of collectionIDs) {- const existing =- fileIDsByCollection.get(collectionID) ??- new Set<number>();- existing.add(item.id);- fileIDsByCollection.set(collectionID, existing);- }+ confirmLabel: t("yesDeleteFiles", { count: items.length }),+ tone: "critical",+ action: async () => {+ const fileIDsByCollection = new Map<number, Set<number>>();+ for (const item of items) {+ const collectionIDs = collectionIDsForItemMutation(+ item,+ selectedCollectionID,+ );+ for (const collectionID of collectionIDs) {+ const existing =+ fileIDsByCollection.get(collectionID) ??+ new Set<number>();+ existing.add(item.id);+ fileIDsByCollection.set(collectionID, existing);}+ }- for (const [- collectionID,- fileIDs,- ] of fileIDsByCollection.entries()) {- await trashFiles([...fileIDs], collectionID);- }+ for (const [+ collectionID,+ fileIDs,+ ] of fileIDsByCollection.entries()) {+ await trashFiles([...fileIDs], collectionID);+ }- await refreshData();- setToast(- t("filesDeletedSuccessfully", {- count: items.length,- }),- );- },+ await refreshData();+ setToast(+ t("filesDeletedSuccessfully", { count: items.length }),+ );},+ loading: false,});},- [refreshData, selectedCollectionID, showMiniDialog],+ [refreshData, selectedCollectionID],);const handleEditItem = useCallback(@@ -680,29 +682,25 @@ export const useLockerActions = ({const handlePermanentlyDelete = useCallback((items: LockerItem[]) => {- showMiniDialog({+ setConfirmDialog({+ illustration: "/images/warning-red.png",title: t("permanentlyDelete"),- message: t("permanentlyDeleteFilesBody", {- count: items.length,- }),- continue: {- text: t("permanentlyDelete"),- color: "critical",- action: async () => {- await permanentlyDeleteFromTrash(- items.map((item) => item.id),- );- await refreshData();- setToast(- t("filesDeletedPermanently", {- count: items.length,- }),- );- },+ body: t("permanentlyDeleteFilesBody", { count: items.length }),+ confirmLabel: t("permanentlyDelete"),+ tone: "critical",+ action: async () => {+ await permanentlyDeleteFromTrash(+ items.map((item) => item.id),+ );+ await refreshData();+ setToast(+ t("filesDeletedPermanently", { count: items.length }),+ );},+ loading: false,});},- [refreshData, showMiniDialog],+ [refreshData],);const handleRestoreItem = useCallback(@@ -752,6 +750,35 @@ export const useLockerActions = ({}}, [emptyTrashDialog, refreshData, trashLastUpdatedAt]);+ const handleConfirmDialogConfirm = useCallback(async () => {+ if (!confirmDialog || confirmDialog.loading) {+ return;+ }++ setConfirmDialog({ ...confirmDialog, loading: true, error: undefined });+ try {+ await confirmDialog.action();+ setConfirmDialog(null);+ } catch (error) {+ log.error("Failed to confirm Locker action", error);+ setConfirmDialog((current) =>+ current+ ? {+ ...current,+ error:+ error instanceof Error+ ? error.message+ : t("generic_error"),+ }+ : current,+ );+ } finally {+ setConfirmDialog((current) =>+ current ? { ...current, loading: false } : current,+ );+ }+ }, [confirmDialog]);+const handleCreateCollection = useCallback(async (name: string): Promise<number> => {if (!masterKey) {@@ -1045,32 +1072,31 @@ export const useLockerActions = ({const handleLeaveCollection = useCallback((collection: LockerCollection) => {- showMiniDialog({+ setConfirmDialog({+ illustration: "/images/warning-grey.png",title: t("leaveCollection"),- message: t("filesAddedByYouWillBeRemovedFromTheCollection"),- continue: {- text: t("leaveCollection"),- color: "critical",- action: async () => {- await leaveCollectionAPI(collection.id);- if (shareCollectionIDRef.current === collection.id) {- setShareCollectionID(null);- }- if (selectedCollectionIDRef.current === collection.id) {- navigateHome();- }- removeCollectionFromState(collection.id);- setToast(t("leaveCollectionSuccessfully"));- void refreshCollectionsAfterMutation();- },+ body: t("filesAddedByYouWillBeRemovedFromTheCollection"),+ confirmLabel: t("leaveCollection"),+ tone: "primary",+ action: async () => {+ await leaveCollectionAPI(collection.id);+ if (shareCollectionIDRef.current === collection.id) {+ setShareCollectionID(null);+ }+ if (selectedCollectionIDRef.current === collection.id) {+ navigateHome();+ }+ removeCollectionFromState(collection.id);+ setToast(t("leaveCollectionSuccessfully"));+ void refreshCollectionsAfterMutation();},+ loading: false,});},[navigateHome,refreshCollectionsAfterMutation,removeCollectionFromState,- showMiniDialog,],);@@ -1136,6 +1162,10 @@ export const useLockerActions = ({);return {+ confirmDialog,+ visibleConfirmDialog,+ closeConfirmDialog,+ handleConfirmDialogConfirm,createDialogOpen,deleteCollectionDialog,editItem,diff --git a/web/apps/locker/src/pages/locker.tsx b/web/apps/locker/src/pages/locker.tsxindex dea14be91d..2d92ba4cde 100644--- a/web/apps/locker/src/pages/locker.tsx+++ b/web/apps/locker/src/pages/locker.tsx@@ -1,6 +1,7 @@import { CreateItemDialog } from "@/components/CreateItemDialog";import { ItemList } from "@/components/ItemList";import { LockerCollectionShareDrawer } from "@/components/LockerCollectionShareDrawer";+import { LockerConfirmDialog } from "@/components/LockerConfirmDialog";import { LockerNavbar } from "@/components/LockerNavbar";import { LockerSidebar } from "@/components/LockerSidebar";import { lockerColorSx } from "@/components/locker-tokens";@@ -59,6 +60,10 @@ export const LockerPage: React.FC = () => {} = useLockerData({ router, logout, showMiniDialog });const {+ confirmDialog,+ visibleConfirmDialog,+ closeConfirmDialog,+ handleConfirmDialogConfirm,createDialogOpen,deleteCollectionDialog,editItem,@@ -110,7 +115,6 @@ export const LockerPage: React.FC = () => {refreshData,navigateHome,removeCollectionFromState,- showMiniDialog,trashLastUpdatedAt,});@@ -235,6 +239,18 @@ export const LockerPage: React.FC = () => {onRefreshSharees={fetchCollectionSharees}warmContacts={warmContacts}/>+ <LockerConfirmDialog+ open={confirmDialog !== null}+ illustration={visibleConfirmDialog?.illustration ?? ""}+ title={visibleConfirmDialog?.title ?? ""}+ body={visibleConfirmDialog?.body}+ confirmLabel={visibleConfirmDialog?.confirmLabel ?? ""}+ tone={visibleConfirmDialog?.tone}+ loading={visibleConfirmDialog?.loading}+ error={visibleConfirmDialog?.error}+ onClose={closeConfirmDialog}+ onConfirm={handleConfirmDialogConfirm}+ /><EmptyTrashDialogdialogState={emptyTrashDialog}visibleDialogState={visibleEmptyTrashDialog}