Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move to new

Manav Rathi395d8a8ab8d5
diff --git a/web/apps/photos/src/components/Upload/CollectionMappingChoiceModal.tsx b/web/apps/photos/src/components/Upload/CollectionMappingChoiceModal.tsx
deleted file mode 100644
index 6b2ca678cb..0000000000
--- a/web/apps/photos/src/components/Upload/CollectionMappingChoiceModal.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import type { CollectionMapping } from "@/base/types/ipc";
-import { FocusVisibleButton } from "@/new/photos/components/FocusVisibleButton";
-import CloseIcon from "@mui/icons-material/Close";
-import FolderIcon from "@mui/icons-material/Folder";
-import FolderCopyIcon from "@mui/icons-material/FolderCopy";
-import {
- Dialog,
- DialogContent,
- DialogTitle,
- IconButton,
- Stack,
- Typography,
-} from "@mui/material";
-import { t } from "i18next";
-
-interface CollectionMappingChoiceModalProps {
- open: boolean;
- onClose: () => void;
- didSelect: (mapping: CollectionMapping) => void;
-}
-
-export const CollectionMappingChoiceModal: React.FC<
- CollectionMappingChoiceModalProps
-> = ({ open, onClose, didSelect }) => {
- return (
- <Dialog
- open={open}
- onClose={onClose}
- fullWidth
- PaperProps={{ sx: { maxWidth: "360px", padding: "12px" } }}
- >
- <DialogTitle
- variant="large"
- fontWeight={"bold"}
- sx={{
- "&&&": { padding: 0 },
- marginBlockStart: "4px",
- marginInlineStart: 2,
- display: "flex",
- justifyContent: "space-between",
- alignItems: "center",
- }}
- >
- {t("multi_folder_upload")}
- <IconButton
- aria-label={t("close")}
- color="secondary"
- onClick={onClose}
- >
- <CloseIcon />
- </IconButton>
- </DialogTitle>
- <DialogContent sx={{ "&&&": { padding: 2 } }}>
- <Stack sx={{ gap: "16px" }}>
- <Typography color="text.muted">
- {t("upload_to_choice")}
- </Typography>
- <Stack sx={{ mt: "4px", gap: "12px" }}>
- <FocusVisibleButton
- size="medium"
- color="accent"
- startIcon={<FolderIcon />}
- onClick={() => {
- onClose();
- didSelect("root");
- }}
- >
- {t("upload_to_single_album")}
- </FocusVisibleButton>
-
- <FocusVisibleButton
- size="medium"
- color="accent"
- startIcon={<FolderCopyIcon />}
- onClick={() => {
- onClose();
- didSelect("parent");
- }}
- >
- {t("upload_to_album_per_folder")}
- </FocusVisibleButton>
- </Stack>
- </Stack>
- </DialogContent>
- </Dialog>
- );
-};
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx
index 4a9a124233..90012baafc 100644
--- a/web/apps/photos/src/components/Upload/Uploader.tsx
+++ b/web/apps/photos/src/components/Upload/Uploader.tsx
@@ -2,6 +2,7 @@ import { basename } from "@/base/file";
import log from "@/base/log";
import type { CollectionMapping, Electron, ZipItem } from "@/base/types/ipc";
import type { Collection } from "@/media/collection";
+import { CollectionMappingChoiceDialog } from "@/new/photos/components/CollectionMappingChoiceDialog";
import { exportMetadataDirectoryName } from "@/new/photos/services/export";
import type {
FileAndPath,
@@ -49,7 +50,6 @@ import {
getRootLevelFileWithFolderNotAllowMessage,
} from "utils/ui";
import { SetCollectionNamerAttributes } from "../Collections/CollectionNamer";
-import { CollectionMappingChoiceModal } from "./CollectionMappingChoiceModal";
import UploadProgress from "./UploadProgress";
import {
UploadTypeSelector,
@@ -765,7 +765,7 @@ export default function Uploader({
return (
<>
- <CollectionMappingChoiceModal
+ <CollectionMappingChoiceDialog
open={choiceModalView}
onClose={handleChoiceModalClose}
didSelect={didSelectCollectionMapping}
diff --git a/web/apps/photos/src/components/WatchFolder.tsx b/web/apps/photos/src/components/WatchFolder.tsx
index 66688266c6..9283d27297 100644
--- a/web/apps/photos/src/components/WatchFolder.tsx
+++ b/web/apps/photos/src/components/WatchFolder.tsx
@@ -2,6 +2,7 @@ import { EllipsizedTypography } from "@/base/components/Typography";
import { ensureElectron } from "@/base/electron";
import { basename, dirname } from "@/base/file";
import type { CollectionMapping, FolderWatch } from "@/base/types/ipc";
+import { CollectionMappingChoiceDialog } from "@/new/photos/components/CollectionMappingChoiceDialog";
import { ensure } from "@/utils/ensure";
import {
FlexWrapper,
@@ -28,7 +29,6 @@ import {
Typography,
styled,
} from "@mui/material";
-import { CollectionMappingChoiceModal } from "components/Upload/CollectionMappingChoiceModal";
import { t } from "i18next";
import { AppContext } from "pages/_app";
import React, { useContext, useEffect, useState } from "react";
@@ -141,7 +141,7 @@ export const WatchFolder: React.FC<WatchFolderProps> = ({ open, onClose }) => {
</Stack>
</DialogContent>
</Dialog>
- <CollectionMappingChoiceModal
+ <CollectionMappingChoiceDialog
open={choiceModalOpen}
onClose={closeChoiceModal}
didSelect={addWatchWithMapping}
diff --git a/web/packages/new/photos/components/CollectionMappingChoiceDialog.tsx b/web/packages/new/photos/components/CollectionMappingChoiceDialog.tsx
new file mode 100644
index 0000000000..cb6c28ca77
--- /dev/null
+++ b/web/packages/new/photos/components/CollectionMappingChoiceDialog.tsx
@@ -0,0 +1,90 @@
+import type { CollectionMapping } from "@/base/types/ipc";
+import { FocusVisibleButton } from "@/new/photos/components/FocusVisibleButton";
+import CloseIcon from "@mui/icons-material/Close";
+import FolderIcon from "@mui/icons-material/Folder";
+import FolderCopyIcon from "@mui/icons-material/FolderCopy";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ IconButton,
+ Stack,
+ Typography,
+} from "@mui/material";
+import { t } from "i18next";
+import React from "react";
+import type { DialogVisiblityProps } from "./mui";
+
+type CollectionMappingChoiceModalProps = DialogVisiblityProps & {
+ didSelect: (mapping: CollectionMapping) => void;
+};
+
+/**
+ * A {@link Dialog} that allow the user to choose a collection mapping.
+ * @param param0
+ * @returns
+ */
+export const CollectionMappingChoiceDialog: React.FC<
+ CollectionMappingChoiceModalProps
+> = ({ open, onClose, didSelect }) => (
+ <Dialog
+ open={open}
+ onClose={onClose}
+ fullWidth
+ PaperProps={{ sx: { maxWidth: "360px", padding: "12px" } }}
+ >
+ <DialogTitle
+ variant="large"
+ fontWeight={"bold"}
+ sx={{
+ "&&&": { padding: 0 },
+ marginBlockStart: "4px",
+ marginInlineStart: 2,
+ display: "flex",
+ justifyContent: "space-between",
+ alignItems: "center",
+ }}
+ >
+ {t("multi_folder_upload")}
+ <IconButton
+ aria-label={t("close")}
+ color="secondary"
+ onClick={onClose}
+ >
+ <CloseIcon />
+ </IconButton>
+ </DialogTitle>
+ <DialogContent sx={{ "&&&": { padding: 2 } }}>
+ <Stack sx={{ gap: "16px" }}>
+ <Typography color="text.muted">
+ {t("upload_to_choice")}
+ </Typography>
+ <Stack sx={{ mt: "4px", gap: "12px" }}>
+ <FocusVisibleButton
+ size="medium"
+ color="accent"
+ startIcon={<FolderIcon />}
+ onClick={() => {
+ onClose();
+ didSelect("root");
+ }}
+ >
+ {t("upload_to_single_album")}
+ </FocusVisibleButton>
+
+ <FocusVisibleButton
+ size="medium"
+ color="accent"
+ startIcon={<FolderCopyIcon />}
+ onClick={() => {
+ onClose();
+ didSelect("parent");
+ }}
+ >
+ {t("upload_to_album_per_folder")}
+ </FocusVisibleButton>
+ </Stack>
+ </Stack>
+ </DialogContent>
+ </Dialog>
+);