π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refractor(CollectionMapDialog):modal-flow-updated
Aswin Asok3cb4e26385b7
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsxindex 9464118b18..9ac689c34c 100644--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx@@ -11,7 +11,6 @@ import {Stack,styled,Typography,- useTheme,type IconButtonProps,} from "@mui/material";import { ensureLocalUser } from "ente-accounts/services/user";@@ -744,11 +743,7 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({const { onGenericError } = useBaseContext();const mapComponents = useMapComponents();const user = useCurrentUser();- const theme = useTheme();- const fileViewerZIndex = useMemo(- () => theme.zIndex.modal + 3,- [theme.zIndex.modal],- );+ const [isFileViewerOpen, setIsFileViewerOpen] = useState(false);const optimalZoom = calculateOptimalZoom();const {@@ -903,9 +898,9 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({collectionNameByID={collectionNameByID}onSelectCollection={onSelectCollection}onSelectPerson={onSelectPerson}- fileViewerZIndex={fileViewerZIndex}selected={emptySelected}setSelected={noOpSetSelected}+ onSetOpenFileViewer={setIsFileViewerOpen}/>);}, [@@ -936,7 +931,7 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({handleMarkTempDeleted,onSelectCollection,onSelectPerson,- fileViewerZIndex,+ isFileViewerOpen,thumbByFileID,user,visibleFiles,@@ -944,7 +939,12 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({]);return (- <Dialog fullScreen open={open} onClose={onClose}>+ <Dialog+ fullScreen+ keepMounted+ open={open && !isFileViewerOpen}+ onClose={onClose}+ ><Boxsx={{position: "relative",@@ -1000,7 +1000,7 @@ interface MapLayoutProps {collectionNameByID?: FileListWithViewerProps["collectionNameByID"];onSelectCollection?: FileListWithViewerProps["onSelectCollection"];onSelectPerson?: FileListWithViewerProps["onSelectPerson"];- fileViewerZIndex: number;+ onSetOpenFileViewer?: (open: boolean) => void;selected: {ownCount: number;count: number;@@ -1038,7 +1038,7 @@ function MapLayout({collectionNameByID,onSelectCollection,onSelectPerson,- fileViewerZIndex,+ onSetOpenFileViewer,selected,setSelected,}: MapLayoutProps) {@@ -1069,7 +1069,7 @@ function MapLayout({onSelectPerson={onSelectPerson}selected={selected}setSelected={setSelected}- fileViewerZIndex={fileViewerZIndex}+ onSetOpenFileViewer={onSetOpenFileViewer}/><Box sx={{ width: "100%", height: "100%" }}><MapCanvas@@ -1120,7 +1120,7 @@ interface CollectionSidebarProps {collectionNameByID?: FileListWithViewerProps["collectionNameByID"];onSelectCollection?: FileListWithViewerProps["onSelectCollection"];onSelectPerson?: FileListWithViewerProps["onSelectPerson"];- fileViewerZIndex: number;+ onSetOpenFileViewer?: (open: boolean) => void;selected: {ownCount: number;count: number;@@ -1153,7 +1153,7 @@ function CollectionSidebar({collectionNameByID,onSelectCollection,onSelectPerson,- fileViewerZIndex,+ onSetOpenFileViewer,selected,setSelected,}: CollectionSidebarProps) {@@ -1202,7 +1202,7 @@ function CollectionSidebar({activeCollectionID={collectionSummary.id}selected={selected}setSelected={setSelected}- fileViewerZIndex={fileViewerZIndex}+ onSetOpenFileViewer={onSetOpenFileViewer}/>) : (<EmptyState>diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex e31f6484d2..945c9c6105 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -1,5 +1,4 @@import { styled } from "@mui/material";-import { useTheme } from "@mui/material/styles";import { isSameDay } from "ente-base/date";import { formattedDate } from "ente-base/i18n-date";import type { AddSaveGroup } from "ente-gallery/components/utils/save-groups";@@ -58,12 +57,6 @@ export type FileListWithViewerProps = {file: EnteFile,sourceCollectionSummaryID?: number,) => void;- /**- * Optional z-index for the FileViewer dialog.- *- * Use this when FileViewer needs to appear above other dialogs/modals.- */- fileViewerZIndex?: number;} & Pick<FileListProps,| "mode"@@ -134,15 +127,9 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({onSelectCollection,onSelectPerson,onAddFileToCollection,- fileViewerZIndex,}) => {const [openFileViewer, setOpenFileViewer] = useState(false);const [currentIndex, setCurrentIndex] = useState(0);- const theme = useTheme();- const viewerZIndex = useMemo(- () => fileViewerZIndex ?? theme.zIndex.modal + 2,- [fileViewerZIndex, theme.zIndex.modal],- );const annotatedFiles = useMemo((): FileListAnnotatedFile[] =>@@ -227,7 +214,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({isInTrashSection={activeCollectionID == PseudoCollectionID.trash}- zIndex={viewerZIndex}{...{user,files,diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsxindex 7c31b5649a..d9693080a0 100644--- a/web/packages/gallery/components/FileInfo.tsx+++ b/web/packages/gallery/components/FileInfo.tsx@@ -176,12 +176,6 @@ export type FileInfoProps = ModalVisibilityProps & {* Called when the user selects a person in the file info panel.*/onSelectPerson?: (personID: string) => void;- /**- * Optional z-index for the file info drawer.- *- * Use this when FileInfo needs to appear above other dialogs/modals.- */- zIndex?: number;};export const FileInfo: React.FC<FileInfoProps> = ({@@ -198,7 +192,6 @@ export const FileInfo: React.FC<FileInfoProps> = ({onUpdateCaption,onSelectCollection,onSelectPerson,- zIndex,}) => {const { mapEnabled } = useSettingsSnapshot();@@ -252,7 +245,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({const uploaderName = file.pubMagicMetadata?.data.uploaderName;return (- <FileInfoSidebar {...{ open, onClose, zIndex }}>+ <FileInfoSidebar {...{ open, onClose }}><SidebarDrawerTitlebaronClose={onClose}onRootClose={onClose}@@ -433,12 +426,7 @@ const annotateExif = (};const FileInfoSidebar = styled(- ({- zIndex,- ...props- }: Pick<DialogProps, "open" | "onClose" | "children"> & {- zIndex?: number;- }) => (+ (props: Pick<DialogProps, "open" | "onClose" | "children">) => (<SidebarDrawer{...props}anchor="right"@@ -448,7 +436,6 @@ const FileInfoSidebar = styled(// https://github.com/mui/material-ui/issues/43106#issuecomment-2514637251disableRestoreFocus={true}closeAfterTransition={true}- sx={zIndex !== undefined ? { zIndex } : undefined}/>),)(({ theme }) => ({diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex b7447949bf..d025413d53 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -137,12 +137,6 @@ export type FileViewerProps = ModalVisibilityProps & {* See: [Note: Gallery children can assume user]*/user?: LocalUser;- /**- * Optional z-index for the PhotoSwipe dialog.- *- * Use this when FileViewer needs to appear above other dialogs/modals.- */- zIndex?: number;/*** The list of files that are currently being displayed in the context in* which the file viewer was invoked.@@ -308,7 +302,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({open,onClose,user,- zIndex,files,initialIndex,disableDownload,@@ -881,7 +874,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({initialIndex,haveUser,showFullscreenButton,- zIndex,delegate: delegateRef.current!,onClose: () => {if (psRef.current) handleClose();@@ -910,7 +902,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({open,onClose,user,- zIndex,initialIndex,disableDownload,showFullscreenButton,@@ -962,7 +953,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({onUpdateCaption={handleUpdateCaption}onSelectCollection={handleSelectCollection}onSelectPerson={handleSelectPerson}- zIndex={zIndex !== undefined ? zIndex + 1 : undefined}{...{ collectionNameByID }}/><MoreMenu@@ -971,7 +961,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({anchorEl={moreMenuAnchorEl}id={moreMenuID}slotProps={{ list: { "aria-labelledby": moreButtonID } }}- sx={zIndex !== undefined ? { zIndex: zIndex + 1 } : undefined}>{activeAnnotatedFile.annotation.showDownload == "menu" && (<MoreMenuItem onClick={handleDownloadMenuAction}>@@ -1055,7 +1044,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({open={openConfirmDelete}onClose={handleConfirmDeleteClose}onConfirm={handleDelete}- zIndex={zIndex !== undefined ? zIndex + 1 : undefined}/>{handleSaveEditedCopy && (<ImageEditorOverlay@@ -1063,13 +1051,11 @@ export const FileViewer: React.FC<FileViewerProps> = ({onClose={handleImageEditorClose}file={activeAnnotatedFile.file}onSaveEditedCopy={handleSaveEditedCopy}- zIndex={zIndex !== undefined ? zIndex + 2 : undefined}/>)}<Shortcutsopen={openShortcuts}onClose={handleShortcutsClose}- zIndex={zIndex !== undefined ? zIndex + 1 : undefined}{...{ disableDownload, haveUser }}/></>@@ -1127,10 +1113,6 @@ type ConfirmDeleteFileDialogProps = ModalVisibilityProps & {* operation completes.*/onConfirm: () => Promise<void>;- /**- * Optional z-index for the dialog.- */- zIndex?: number;};/**@@ -1144,7 +1126,6 @@ const ConfirmDeleteFileDialog: React.FC<ConfirmDeleteFileDialogProps> = ({open,onClose,onConfirm,- zIndex,}) => {const [phase, setPhase] = useState<"loading" | "failed" | undefined>();@@ -1182,7 +1163,6 @@ const ConfirmDeleteFileDialog: React.FC<ConfirmDeleteFileDialogProps> = ({backgroundColor: theme.vars.palette.backdrop.faint,},}),- ...(zIndex !== undefined && { zIndex }),})}><Typography sx={{ color: "text.muted" }}>@@ -1218,10 +1198,6 @@ type ShortcutsProps = ModalVisibilityProps &* `true` if we're running in a context where there is a logged in user.*/haveUser: boolean;- /**- * Optional z-index for the dialog.- */- zIndex?: number;};const Shortcuts: React.FC<ShortcutsProps> = ({@@ -1229,14 +1205,12 @@ const Shortcuts: React.FC<ShortcutsProps> = ({onClose,disableDownload,haveUser,- zIndex,}) => (<Dialog{...{ open, onClose }}fullWidthfullScreen={useIsSmallWidth()}slotProps={{ backdrop: { sx: { backdropFilter: "blur(30px)" } } }}- sx={zIndex !== undefined ? { zIndex } : undefined}><SpacedRow sx={{ pt: 2, px: 2.5 }}><DialogTitle>{t("shortcuts")}</DialogTitle>diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 9565fb96d5..043d2a4de2 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -92,7 +92,7 @@ export interface FileViewerPhotoSwipeDelegate {type FileViewerPhotoSwipeOptions = Pick<FileViewerProps,- "initialIndex" | "showFullscreenButton" | "zIndex"+ "initialIndex" | "showFullscreenButton"> & {/*** `true` if we're running in the context of a logged in user, and so@@ -193,7 +193,6 @@ export class FileViewerPhotoSwipe {initialIndex,haveUser,showFullscreenButton,- zIndex,delegate,onClose,onAnnotate,@@ -1752,11 +1751,6 @@ export class FileViewerPhotoSwipe {// Initializing PhotoSwipe adds it to the DOM as a dialog-like div with// the class "pswp".pswp.init();-- // Apply custom z-index if provided.- if (zIndex !== undefined && pswp.element) {- pswp.element.style.zIndex = String(zIndex);- }}/**diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsxindex a054ae72ca..73eb310867 100644--- a/web/packages/new/photos/components/CollectionSelector.tsx+++ b/web/packages/new/photos/components/CollectionSelector.tsx@@ -12,7 +12,6 @@ import {TextField,Typography,useMediaQuery,- useTheme,} from "@mui/material";import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton";import type { ModalVisibilityProps } from "ente-base/components/utils/modal";@@ -105,10 +104,6 @@ type CollectionSelectorProps = ModalVisibilityProps & {collectionForCollectionSummaryID: (collectionID: number,) => Promise<Collection>;- /**- * Optional z-index to ensure the selector appears above other dialogs.- */- zIndex?: number;};/**@@ -121,12 +116,9 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({attributes,collectionSummaries,collectionForCollectionSummaryID,- zIndex,}) => {// Make the dialog fullscreen if the screen is <= the dialog's max width.const isFullScreen = useMediaQuery("(max-width: 490px)");- const theme = useTheme();- const dialogZIndex = zIndex ?? theme.zIndex.modal + 3;const [searchTerm, setSearchTerm] = useState("");@@ -218,7 +210,6 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({onClose={handleClose}fullWidthfullScreen={isFullScreen}- sx={{ zIndex: dialogZIndex }}slotProps={{paper: {sx: {diff --git a/web/packages/new/photos/components/ImageEditorOverlay.tsx b/web/packages/new/photos/components/ImageEditorOverlay.tsxindex 6ddc473788..26e5c96268 100644--- a/web/packages/new/photos/components/ImageEditorOverlay.tsx+++ b/web/packages/new/photos/components/ImageEditorOverlay.tsx@@ -31,7 +31,6 @@ import {Tab,Tabs,Typography,- useTheme,} from "@mui/material";import type { MiniDialogAttributes } from "ente-base/components/MiniDialog";import { SidebarDrawer } from "ente-base/components/mui/SidebarDrawer";@@ -82,13 +81,6 @@ export type ImageEditorOverlayProps = ModalVisibilityProps & {collection: Collection,enteFile: EnteFile,) => void;- /**- * Optional z-index for the overlay.- *- * Use this when ImageEditorOverlay needs to appear above other- * dialogs/modals.- */- zIndex?: number;};const filterDefaultValues = {@@ -113,11 +105,7 @@ export const ImageEditorOverlay: React.FC<ImageEditorOverlayProps> = ({onClose,file,onSaveEditedCopy,- zIndex,}) => {- const theme = useTheme();- const overlayZIndex = zIndex ?? theme.zIndex.modal + 2;-const { showMiniDialog } = useBaseContext();const canvasRef = useRef<HTMLCanvasElement | null>(null);@@ -538,7 +526,6 @@ export const ImageEditorOverlay: React.FC<ImageEditorOverlayProps> = ({sx={{backgroundColor: "background.default" /* Opaque */,width: "100%",- zIndex: overlayZIndex,}}open>