Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat(fileViewer):enabled-menu

Aswin Asok3d2f5bd99e34
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 86362bcebe..93f48f04cc 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -36,6 +36,7 @@ import {
GalleryItemsSummary,
} from "ente-new/photos/components/gallery/ListHeader";
import { useSettingsSnapshot } from "ente-new/photos/components/utils/use-snapshot";
+import type { FileListWithViewerProps } from "../FileListWithViewer";
import {
defaultHiddenCollectionUserFacingName,
deleteCollection,
@@ -64,7 +65,18 @@ import React, { useCallback, useRef } from "react";
import { Trans } from "react-i18next";
import { CollectionMapDialog } from "./CollectionMapDialog";
-export interface CollectionHeaderProps {
+export interface CollectionHeaderProps
+ extends Pick<
+ FileListWithViewerProps,
+ | "onMarkTempDeleted"
+ | "onAddFileToCollection"
+ | "onRemoteFilesPull"
+ | "onVisualFeedback"
+ | "fileNormalCollectionIDs"
+ | "collectionNameByID"
+ | "onSelectCollection"
+ | "onSelectPerson"
+ > {
collectionSummary: CollectionSummary;
// TODO: This can be undefined
activeCollection: Collection;
@@ -129,6 +141,14 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
onCollectionCast,
onAddSaveGroup,
isActiveCollectionDownloadInProgress,
+ onMarkTempDeleted,
+ onAddFileToCollection,
+ onRemoteFilesPull,
+ onVisualFeedback,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection,
+ onSelectPerson,
}) => {
const { showMiniDialog, onGenericError } = useBaseContext();
const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();
@@ -599,6 +619,16 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
{...mapDialogVisibilityProps}
collectionSummary={collectionSummary}
activeCollection={activeCollection}
+ onRemotePull={onRemotePull}
+ onAddSaveGroup={onAddSaveGroup}
+ onMarkTempDeleted={onMarkTempDeleted}
+ onAddFileToCollection={onAddFileToCollection}
+ onRemoteFilesPull={onRemoteFilesPull}
+ onVisualFeedback={onVisualFeedback}
+ fileNormalCollectionIDs={fileNormalCollectionIDs}
+ collectionNameByID={collectionNameByID}
+ onSelectCollection={onSelectCollection}
+ onSelectPerson={onSelectPerson}
/>
<SingleInputDialog
{...albumNameInputVisibilityProps}
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
index 71e11d846f..7c161cebbc 100644
--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
@@ -11,6 +11,7 @@ import {
Stack,
styled,
Typography,
+ useTheme,
type IconButtonProps,
} from "@mui/material";
import { ensureLocalUser } from "ente-accounts/services/user";
@@ -27,6 +28,7 @@ import {
fileLocation,
ItemVisibility,
} from "ente-media/file-metadata";
+import type { RemotePullOpts } from "ente-new/photos/components/gallery";
import {
addToFavoritesCollection,
removeFromFavoritesCollection,
@@ -48,6 +50,7 @@ import React, {
useRef,
useState,
} from "react";
+import type { FileListWithViewerProps } from "../FileListWithViewer";
import { FileListWithViewer } from "../FileListWithViewer";
import { calculateOptimalZoom, getMapCenter } from "../TripLayout/mapHelpers";
import type { JourneyPoint } from "../TripLayout/types";
@@ -57,9 +60,23 @@ import { generateNeededThumbnails } from "../TripLayout/utils/dataProcessing";
// Types
// ============================================================================
-interface CollectionMapDialogProps extends ModalVisibilityProps {
+interface CollectionMapDialogProps
+ extends ModalVisibilityProps,
+ Pick<
+ FileListWithViewerProps,
+ | "onAddSaveGroup"
+ | "onMarkTempDeleted"
+ | "onAddFileToCollection"
+ | "onRemoteFilesPull"
+ | "onVisualFeedback"
+ | "fileNormalCollectionIDs"
+ | "collectionNameByID"
+ | "onSelectCollection"
+ | "onSelectPerson"
+ > {
collectionSummary: CollectionSummary;
activeCollection: Collection;
+ onRemotePull?: (opts?: RemotePullOpts) => Promise<void>;
}
interface MapDataState {
@@ -77,6 +94,11 @@ interface FavoritesState {
pendingVisibilityUpdates: Set<number>;
}
+interface MapDataResult extends MapDataState {
+ removeFiles: (fileIDs: number[]) => void;
+ updateFileVisibility: (file: EnteFile, visibility: ItemVisibility) => void;
+}
+
/**
* Dynamically loaded map components to avoid SSR issues with Leaflet
*/
@@ -148,7 +170,7 @@ function useMapData(
open: boolean,
activeCollection: Collection,
onGenericError: (e: unknown) => void,
-): MapDataState {
+): MapDataResult {
const [state, setState] = useState<MapDataState>({
mapCenter: null,
mapPhotos: [],
@@ -241,7 +263,53 @@ function useMapData(
void loadMapData();
}, [open, activeCollection, onGenericError, loadAllThumbs]);
- return state;
+ const removeFiles = useCallback((fileIDs: number[]) => {
+ if (!fileIDs.length) return;
+ setState((prev) => {
+ const ids = new Set(fileIDs);
+ const filesByID = new Map(prev.filesByID);
+ const thumbByFileID = new Map(prev.thumbByFileID);
+ ids.forEach((id) => {
+ filesByID.delete(id);
+ thumbByFileID.delete(id);
+ });
+ const mapPhotos = prev.mapPhotos.filter(
+ (photo) => !ids.has(photo.fileId),
+ );
+ return {
+ ...prev,
+ filesByID,
+ thumbByFileID,
+ mapPhotos,
+ mapCenter: mapPhotos.length ? prev.mapCenter : null,
+ };
+ });
+ }, []);
+
+ const updateFileVisibility = useCallback(
+ (file: EnteFile, visibility: ItemVisibility) => {
+ setState((prev) => {
+ if (!prev.filesByID.has(file.id)) return prev;
+ if (!file.magicMetadata) return prev;
+
+ const updatedMagicMetadata = {
+ ...file.magicMetadata,
+ data: { ...file.magicMetadata.data, visibility },
+ };
+
+ const updatedFile: EnteFile = {
+ ...file,
+ magicMetadata: updatedMagicMetadata,
+ };
+ const filesByID = new Map(prev.filesByID);
+ filesByID.set(file.id, updatedFile);
+ return { ...prev, filesByID };
+ });
+ },
+ [],
+ );
+
+ return { ...state, removeFiles, updateFileVisibility };
}
/**
@@ -650,14 +718,37 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
onClose,
collectionSummary,
activeCollection,
+ onRemotePull,
+ onAddSaveGroup,
+ onMarkTempDeleted,
+ onAddFileToCollection,
+ onRemoteFilesPull,
+ onVisualFeedback,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection,
+ onSelectPerson,
}) => {
const { onGenericError } = useBaseContext();
const mapComponents = useMapComponents();
const user = useCurrentUser();
+ const theme = useTheme();
+ const fileViewerZIndex = useMemo(
+ () => theme.zIndex.modal + 3,
+ [theme.zIndex.modal],
+ );
const optimalZoom = calculateOptimalZoom();
- const { mapCenter, mapPhotos, filesByID, thumbByFileID, isLoading, error } =
- useMapData(open, activeCollection, onGenericError);
+ const {
+ mapCenter,
+ mapPhotos,
+ filesByID,
+ thumbByFileID,
+ isLoading,
+ error,
+ removeFiles: removeFilesFromMap,
+ updateFileVisibility,
+ } = useMapData(open, activeCollection, onGenericError);
const { visiblePhotos, setVisiblePhotos } = useVisiblePhotos();
@@ -678,11 +769,12 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
.filter((f): f is EnteFile => f !== undefined);
}, [visiblePhotos, filesByID]);
- // No-op handlers for FileListWithViewer
- const handleRemotePull = useCallback(() => Promise.resolve(), []);
- const handleVisualFeedback = useCallback(() => {
- /* no-op */
- }, []);
+ const handleRemotePull = useCallback(
+ () =>
+ onRemotePull ? onRemotePull({ silent: true }) : Promise.resolve(),
+ [onRemotePull],
+ );
+ const visualFeedback = useMemo(() => onVisualFeedback, [onVisualFeedback]);
// Empty selection state since we don't support selection in map view
const emptySelected = useMemo(
@@ -698,6 +790,36 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
/* no-op */
}, []);
+ const handleMarkTempDeleted = useCallback(
+ (files: EnteFile[]) => {
+ onMarkTempDeleted?.(files);
+ const idsToRemove = new Set(files.map((file) => file.id));
+ setVisiblePhotos((prev) =>
+ prev.filter((photo) => !idsToRemove.has(photo.fileId)),
+ );
+ removeFilesFromMap([...idsToRemove]);
+ },
+ [onMarkTempDeleted, removeFilesFromMap, setVisiblePhotos],
+ );
+
+ const handleFileVisibilityUpdateWithLocalState = useCallback(
+ async (file: EnteFile, visibility: ItemVisibility) => {
+ await handleFileVisibilityUpdate(file, visibility);
+ const updatedMagicMetadata = file.magicMetadata
+ ? {
+ ...file.magicMetadata,
+ data: { ...file.magicMetadata.data, visibility },
+ }
+ : undefined;
+ const updatedFile =
+ updatedMagicMetadata !== undefined
+ ? { ...file, magicMetadata: updatedMagicMetadata }
+ : file;
+ updateFileVisibility(updatedFile, visibility);
+ },
+ [handleFileVisibilityUpdate, updateFileVisibility],
+ );
+
const body = useMemo(() => {
if (isLoading) {
return (
@@ -757,9 +879,20 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
pendingFavoriteUpdates={pendingFavoriteUpdates}
pendingVisibilityUpdates={pendingVisibilityUpdates}
onToggleFavorite={handleToggleFavorite}
- onFileVisibilityUpdate={handleFileVisibilityUpdate}
+ onFileVisibilityUpdate={
+ handleFileVisibilityUpdateWithLocalState
+ }
onRemotePull={handleRemotePull}
- onVisualFeedback={handleVisualFeedback}
+ onVisualFeedback={visualFeedback}
+ onAddSaveGroup={onAddSaveGroup}
+ onMarkTempDeleted={handleMarkTempDeleted}
+ onAddFileToCollection={onAddFileToCollection}
+ onRemoteFilesPull={onRemoteFilesPull}
+ fileNormalCollectionIDs={fileNormalCollectionIDs}
+ collectionNameByID={collectionNameByID}
+ onSelectCollection={onSelectCollection}
+ onSelectPerson={onSelectPerson}
+ fileViewerZIndex={fileViewerZIndex}
selected={emptySelected}
setSelected={noOpSetSelected}
/>
@@ -770,10 +903,10 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
emptySelected,
error,
favoriteFileIDs,
- handleFileVisibilityUpdate,
+ handleFileVisibilityUpdateWithLocalState,
handleRemotePull,
handleToggleFavorite,
- handleVisualFeedback,
+ visualFeedback,
isLoading,
mapCenter,
mapComponents,
@@ -781,9 +914,18 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
noOpSetSelected,
onClose,
optimalZoom,
+ onAddFileToCollection,
+ onAddSaveGroup,
+ onRemoteFilesPull,
pendingFavoriteUpdates,
pendingVisibilityUpdates,
setVisiblePhotos,
+ collectionNameByID,
+ fileNormalCollectionIDs,
+ handleMarkTempDeleted,
+ onSelectCollection,
+ onSelectPerson,
+ fileViewerZIndex,
thumbByFileID,
user,
visibleFiles,
@@ -839,6 +981,15 @@ interface MapLayoutProps {
) => Promise<void>;
onRemotePull: () => Promise<void>;
onVisualFeedback: () => void;
+ onAddSaveGroup: FileListWithViewerProps["onAddSaveGroup"];
+ onMarkTempDeleted?: FileListWithViewerProps["onMarkTempDeleted"];
+ onAddFileToCollection?: FileListWithViewerProps["onAddFileToCollection"];
+ onRemoteFilesPull?: FileListWithViewerProps["onRemoteFilesPull"];
+ fileNormalCollectionIDs?: FileListWithViewerProps["fileNormalCollectionIDs"];
+ collectionNameByID?: FileListWithViewerProps["collectionNameByID"];
+ onSelectCollection?: FileListWithViewerProps["onSelectCollection"];
+ onSelectPerson?: FileListWithViewerProps["onSelectPerson"];
+ fileViewerZIndex: number;
selected: {
ownCount: number;
count: number;
@@ -868,6 +1019,15 @@ function MapLayout({
onFileVisibilityUpdate,
onRemotePull,
onVisualFeedback,
+ onAddSaveGroup,
+ onMarkTempDeleted,
+ onAddFileToCollection,
+ onRemoteFilesPull,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection,
+ onSelectPerson,
+ fileViewerZIndex,
selected,
setSelected,
}: MapLayoutProps) {
@@ -888,8 +1048,17 @@ function MapLayout({
onFileVisibilityUpdate={onFileVisibilityUpdate}
onRemotePull={onRemotePull}
onVisualFeedback={onVisualFeedback}
+ onAddSaveGroup={onAddSaveGroup}
+ onMarkTempDeleted={onMarkTempDeleted}
+ onAddFileToCollection={onAddFileToCollection}
+ onRemoteFilesPull={onRemoteFilesPull}
+ fileNormalCollectionIDs={fileNormalCollectionIDs}
+ collectionNameByID={collectionNameByID}
+ onSelectCollection={onSelectCollection}
+ onSelectPerson={onSelectPerson}
selected={selected}
setSelected={setSelected}
+ fileViewerZIndex={fileViewerZIndex}
/>
<Box sx={{ width: "100%", height: "100%" }}>
<MapCanvas
@@ -932,6 +1101,15 @@ interface CollectionSidebarProps {
) => Promise<void>;
onRemotePull: () => Promise<void>;
onVisualFeedback: () => void;
+ onAddSaveGroup: FileListWithViewerProps["onAddSaveGroup"];
+ onMarkTempDeleted?: FileListWithViewerProps["onMarkTempDeleted"];
+ onAddFileToCollection?: FileListWithViewerProps["onAddFileToCollection"];
+ onRemoteFilesPull?: FileListWithViewerProps["onRemoteFilesPull"];
+ fileNormalCollectionIDs?: FileListWithViewerProps["fileNormalCollectionIDs"];
+ collectionNameByID?: FileListWithViewerProps["collectionNameByID"];
+ onSelectCollection?: FileListWithViewerProps["onSelectCollection"];
+ onSelectPerson?: FileListWithViewerProps["onSelectPerson"];
+ fileViewerZIndex: number;
selected: {
ownCount: number;
count: number;
@@ -956,6 +1134,15 @@ function CollectionSidebar({
onFileVisibilityUpdate,
onRemotePull,
onVisualFeedback,
+ onAddSaveGroup,
+ onMarkTempDeleted,
+ onAddFileToCollection,
+ onRemoteFilesPull,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection,
+ onSelectPerson,
+ fileViewerZIndex,
selected,
setSelected,
}: CollectionSidebarProps) {
@@ -971,14 +1158,6 @@ function CollectionSidebar({
: undefined;
}, [coverFile, mapPhotos, thumbByFileID]);
- // No-op for onAddSaveGroup since we don't support download in map view
- const handleAddSaveGroup = useCallback(
- () => () => {
- /* no-op */
- },
- [],
- );
-
return (
<SidebarWrapper>
<SidebarContainer>
@@ -1000,12 +1179,20 @@ function CollectionSidebar({
onFileVisibilityUpdate={onFileVisibilityUpdate}
onRemotePull={onRemotePull}
onVisualFeedback={onVisualFeedback}
- onAddSaveGroup={handleAddSaveGroup}
- enableDownload={false}
+ onAddSaveGroup={onAddSaveGroup}
+ onMarkTempDeleted={onMarkTempDeleted}
+ onAddFileToCollection={onAddFileToCollection}
+ onRemoteFilesPull={onRemoteFilesPull}
+ enableEditImage={false}
+ fileNormalCollectionIDs={fileNormalCollectionIDs}
+ collectionNameByID={collectionNameByID}
+ onSelectCollection={onSelectCollection}
+ onSelectPerson={onSelectPerson}
+ enableDownload={true}
activeCollectionID={collectionSummary.id}
selected={selected}
setSelected={setSelected}
- fileViewerZIndex={1301}
+ fileViewerZIndex={fileViewerZIndex}
/>
) : (
<EmptyState>
@@ -1525,7 +1712,7 @@ const SidebarGradient = styled(Box)(({ theme }) => ({
right: 0,
height: "80px",
background:
- "linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0.65) 40%, rgba(0,0,0,0) 100%)",
+ "linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0.65) 4%, rgba(0,0,0,0) 100%)",
pointerEvents: "none",
borderRadius: "0",
[theme.breakpoints.up("md")]: {
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 71ce9b68a5..41111983bd 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -52,7 +52,19 @@ type GalleryBarAndListHeaderProps = Omit<
setActiveCollectionID: (collectionID: number) => void;
setFileListHeader: (header: FileListHeaderOrFooter) => void;
saveGroups: SaveGroup[];
-} & Pick<CollectionHeaderProps, "onRemotePull" | "onAddSaveGroup"> &
+} & Pick<
+ CollectionHeaderProps,
+ | "onRemotePull"
+ | "onAddSaveGroup"
+ | "onMarkTempDeleted"
+ | "onAddFileToCollection"
+ | "onRemoteFilesPull"
+ | "onVisualFeedback"
+ | "fileNormalCollectionIDs"
+ | "collectionNameByID"
+ | "onSelectCollection"
+ | "onSelectPerson"
+ > &
Pick<
CollectionShareProps,
"user" | "emailByUserID" | "shareSuggestionEmails" | "setBlockingLoad"
@@ -95,6 +107,13 @@ export const GalleryBarAndListHeader: React.FC<
shareSuggestionEmails,
onRemotePull,
onAddSaveGroup,
+ onMarkTempDeleted,
+ onAddFileToCollection,
+ onRemoteFilesPull,
+ onVisualFeedback,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection,
onSelectPerson,
setFileListHeader,
}) => {
@@ -145,6 +164,14 @@ export const GalleryBarAndListHeader: React.FC<
isActiveCollectionDownloadInProgress,
onRemotePull,
onAddSaveGroup,
+ onMarkTempDeleted,
+ onAddFileToCollection,
+ onRemoteFilesPull,
+ onVisualFeedback,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection,
+ onSelectPerson,
}}
collectionSummary={
toShowCollectionSummaries.get(activeCollectionID!)!
@@ -172,6 +199,16 @@ export const GalleryBarAndListHeader: React.FC<
activePerson,
showCollectionShare,
showCollectionCast,
+ onRemotePull,
+ onAddSaveGroup,
+ onMarkTempDeleted,
+ onAddFileToCollection,
+ onRemoteFilesPull,
+ onVisualFeedback,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection,
+ onSelectPerson,
// TODO: Cluster
// This causes a loop since it is an array dep
// people,
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index f20f5fae24..3a10a9609d 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -15,6 +15,7 @@ import { PseudoCollectionID } from "ente-new/photos/services/collection-summary"
import { t } from "i18next";
import { useCallback, useMemo, useState } from "react";
import AutoSizer from "react-virtualized-auto-sizer";
+import { useTheme } from "@mui/material/styles";
import { uploadManager } from "services/upload-manager";
import {
FileList,
@@ -28,6 +29,10 @@ export type FileListWithViewerProps = {
*/
files: EnteFile[];
enableDownload?: boolean;
+ /**
+ * Whether the edit image action should be available in the viewer.
+ */
+ enableEditImage?: boolean;
/**
* Called when the component wants to mark the given files as deleted in the
* the in-memory, unsynced, state maintained by the top level gallery.
@@ -108,6 +113,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
user,
files,
enableDownload,
+ enableEditImage = true,
disableGrouping,
enableSelect,
selected,
@@ -137,6 +143,11 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
}) => {
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[] =>
@@ -221,7 +232,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
isInTrashSection={
activeCollectionID == PseudoCollectionID.trash
}
- zIndex={fileViewerZIndex}
+ zIndex={viewerZIndex}
{...{
user,
files,
@@ -242,7 +253,9 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
onTriggerRemotePull={handleTriggerRemotePull}
onDownload={handleDownload}
onDelete={handleDelete}
- onSaveEditedImageCopy={handleSaveEditedImageCopy}
+ onSaveEditedImageCopy={
+ enableEditImage ? handleSaveEditedImageCopy : undefined
+ }
onAddFileToCollection={onAddFileToCollection}
activeCollectionID={activeCollectionID}
/>
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index fd64f4075a..8e350fc7ff 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -1303,6 +1303,13 @@ const Page: React.FC = () => {
setFileListHeader,
saveGroups,
onAddSaveGroup,
+ onMarkTempDeleted: handleMarkTempDeleted,
+ onAddFileToCollection: handleAddSingleFileToCollection,
+ onRemoteFilesPull: remoteFilesPull,
+ onVisualFeedback: handleVisualFeedback,
+ fileNormalCollectionIDs,
+ collectionNameByID,
+ onSelectCollection: handleSelectCollection,
}}
mode={barMode}
shouldHide={isInSearchMode}
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 61a12d2388..b7447949bf 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -1063,7 +1063,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
onClose={handleImageEditorClose}
file={activeAnnotatedFile.file}
onSaveEditedCopy={handleSaveEditedCopy}
- zIndex={zIndex !== undefined ? zIndex + 1 : undefined}
+ zIndex={zIndex !== undefined ? zIndex + 2 : undefined}
/>
)}
<Shortcuts
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index 73eb310867..a054ae72ca 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -12,6 +12,7 @@ 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";
@@ -104,6 +105,10 @@ type CollectionSelectorProps = ModalVisibilityProps & {
collectionForCollectionSummaryID: (
collectionID: number,
) => Promise<Collection>;
+ /**
+ * Optional z-index to ensure the selector appears above other dialogs.
+ */
+ zIndex?: number;
};
/**
@@ -116,9 +121,12 @@ 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("");
@@ -210,6 +218,7 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
onClose={handleClose}
fullWidth
fullScreen={isFullScreen}
+ sx={{ zIndex: dialogZIndex }}
slotProps={{
paper: {
sx: {
diff --git a/web/packages/new/photos/components/ImageEditorOverlay.tsx b/web/packages/new/photos/components/ImageEditorOverlay.tsx
index 0886878727..6ddc473788 100644
--- a/web/packages/new/photos/components/ImageEditorOverlay.tsx
+++ b/web/packages/new/photos/components/ImageEditorOverlay.tsx
@@ -31,6 +31,7 @@ import {
Tab,
Tabs,
Typography,
+ useTheme,
} from "@mui/material";
import type { MiniDialogAttributes } from "ente-base/components/MiniDialog";
import { SidebarDrawer } from "ente-base/components/mui/SidebarDrawer";
@@ -114,6 +115,9 @@ export const ImageEditorOverlay: React.FC<ImageEditorOverlayProps> = ({
onSaveEditedCopy,
zIndex,
}) => {
+ const theme = useTheme();
+ const overlayZIndex = zIndex ?? theme.zIndex.modal + 2;
+
const { showMiniDialog } = useBaseContext();
const canvasRef = useRef<HTMLCanvasElement | null>(null);
@@ -534,7 +538,7 @@ export const ImageEditorOverlay: React.FC<ImageEditorOverlayProps> = ({
sx={{
backgroundColor: "background.default" /* Opaque */,
width: "100%",
- zIndex: zIndex ?? "var(--mui-zIndex-modal)",
+ zIndex: overlayZIndex,
}}
open
>