mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 02:07:33 +00:00
copy 1
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
|||||||
ImageEditorOverlay,
|
ImageEditorOverlay,
|
||||||
type ImageEditorOverlayProps,
|
type ImageEditorOverlayProps,
|
||||||
} from "@/new/photos/components/ImageEditorOverlay";
|
} from "@/new/photos/components/ImageEditorOverlay";
|
||||||
|
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
||||||
import DeleteIcon from "@mui/icons-material/Delete";
|
import DeleteIcon from "@mui/icons-material/Delete";
|
||||||
import EditIcon from "@mui/icons-material/Edit";
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
|
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
|
||||||
@@ -338,8 +339,7 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
: undefined;
|
: undefined;
|
||||||
}, [onDelete, showConfirmDelete, handleMoreMenuClose]);
|
}, [onDelete, showConfirmDelete, handleMoreMenuClose]);
|
||||||
|
|
||||||
// Not memoized since it depends on the frequently changing
|
// Not memoized since it uses the frequently changing `activeAnnotatedFile`.
|
||||||
// `activeAnnotatedFile`.
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
const file = activeAnnotatedFile!.file;
|
const file = activeAnnotatedFile!.file;
|
||||||
await onDelete(file);
|
await onDelete(file);
|
||||||
@@ -364,6 +364,11 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Not memoized since it uses the frequently changing `activeAnnotatedFile`.
|
||||||
|
const handleCopyImage = () => {
|
||||||
|
console.log("TODO copy", activeAnnotatedFile!);
|
||||||
|
};
|
||||||
|
|
||||||
const handleEditImage = useMemo(() => {
|
const handleEditImage = useMemo(() => {
|
||||||
return onSaveEditedImageCopy
|
return onSaveEditedImageCopy
|
||||||
? () => {
|
? () => {
|
||||||
@@ -388,10 +393,9 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
|
|
||||||
const handleAnnotate = useCallback(
|
const handleAnnotate = useCallback(
|
||||||
(file: EnteFile): FileViewerFileAnnotation => {
|
(file: EnteFile): FileViewerFileAnnotation => {
|
||||||
log.debug(() => ["viewer", { action: "annotate", file }]);
|
|
||||||
|
|
||||||
const fileID = file.id;
|
const fileID = file.id;
|
||||||
const isOwnFile = file.ownerID == user?.id;
|
const isOwnFile = file.ownerID == user?.id;
|
||||||
|
|
||||||
const canModify =
|
const canModify =
|
||||||
isOwnFile && !isInTrashSection && !isInHiddenSection;
|
isOwnFile && !isInTrashSection && !isInHiddenSection;
|
||||||
const showFavorite = canModify;
|
const showFavorite = canModify;
|
||||||
@@ -413,16 +417,30 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
const showCopyImage = (() => {
|
||||||
|
switch (file.metadata.fileType) {
|
||||||
|
case FileType.image:
|
||||||
|
case FileType.livePhoto:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
const showMore =
|
const showMore =
|
||||||
showDelete || showEditImage || showDownload == "menu";
|
showDownload == "menu" ||
|
||||||
|
showDelete ||
|
||||||
|
showCopyImage ||
|
||||||
|
showEditImage;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fileID,
|
fileID,
|
||||||
isOwnFile,
|
isOwnFile,
|
||||||
showFavorite,
|
showFavorite,
|
||||||
|
showDownload,
|
||||||
showMore,
|
showMore,
|
||||||
showDelete,
|
showDelete,
|
||||||
showDownload,
|
showCopyImage,
|
||||||
showEditImage,
|
showEditImage,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -602,6 +620,14 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
</MoreMenuItem>
|
</MoreMenuItem>
|
||||||
)}
|
)}
|
||||||
|
{activeAnnotatedFile?.annotation.showCopyImage && (
|
||||||
|
<MoreMenuItem onClick={handleCopyImage}>
|
||||||
|
<Typography sx={{ fontWeight: "medium" }}>
|
||||||
|
{/*TODO */ pt("Copy image")}
|
||||||
|
</Typography>
|
||||||
|
<ContentCopyIcon />
|
||||||
|
</MoreMenuItem>
|
||||||
|
)}
|
||||||
{activeAnnotatedFile?.annotation.showEditImage && (
|
{activeAnnotatedFile?.annotation.showEditImage && (
|
||||||
<MoreMenuItem onClick={handleEditImage}>
|
<MoreMenuItem onClick={handleEditImage}>
|
||||||
<Typography sx={{ fontWeight: "medium" }}>
|
<Typography sx={{ fontWeight: "medium" }}>
|
||||||
|
@@ -53,14 +53,6 @@ export interface FileViewerFileAnnotation {
|
|||||||
* `true` if the toggle favorite action should be shown for this file.
|
* `true` if the toggle favorite action should be shown for this file.
|
||||||
*/
|
*/
|
||||||
showFavorite: boolean;
|
showFavorite: boolean;
|
||||||
/**
|
|
||||||
* `true` if the more menu action should be shown for this file.
|
|
||||||
*/
|
|
||||||
showMore: boolean;
|
|
||||||
/**
|
|
||||||
* `true` if the delete action should be shown for this file.
|
|
||||||
*/
|
|
||||||
showDelete: boolean;
|
|
||||||
/**
|
/**
|
||||||
* Set if the download action should be shown for this file.
|
* Set if the download action should be shown for this file.
|
||||||
*
|
*
|
||||||
@@ -71,6 +63,18 @@ export interface FileViewerFileAnnotation {
|
|||||||
* Note: "bar" should only be set if {@link haveUser} is also true.
|
* Note: "bar" should only be set if {@link haveUser} is also true.
|
||||||
*/
|
*/
|
||||||
showDownload: "bar" | "menu" | undefined;
|
showDownload: "bar" | "menu" | undefined;
|
||||||
|
/**
|
||||||
|
* `true` if the more menu action should be shown for this file.
|
||||||
|
*/
|
||||||
|
showMore: boolean;
|
||||||
|
/**
|
||||||
|
* `true` if the delete action should be shown for this file.
|
||||||
|
*/
|
||||||
|
showDelete: boolean;
|
||||||
|
/**
|
||||||
|
* `true` if the copy image action should be shown for this file.
|
||||||
|
*/
|
||||||
|
showCopyImage: boolean;
|
||||||
/**
|
/**
|
||||||
* `true` if this is an image which can be edited, _and_ editing is
|
* `true` if this is an image which can be edited, _and_ editing is
|
||||||
* possible, and the edit action should therefore be shown for this file.
|
* possible, and the edit action should therefore be shown for this file.
|
||||||
|
Reference in New Issue
Block a user