Skip to content

armgit / ente

Public Imported from GitHub
0

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

Swap

Manav Rathi60774518b295
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx
index 6a9fe6d82a..6b3d900b2b 100644
--- a/web/apps/photos/src/components/Upload/Uploader.tsx
+++ b/web/apps/photos/src/components/Upload/Uploader.tsx
@@ -13,17 +13,19 @@ import type {
} from "@/new/photos/services/upload/types";
import { UPLOAD_STAGES } from "@/new/photos/services/upload/types";
import { redirectToCustomerPortal } from "@/new/photos/services/user-details";
-import { AppContext } from "@/new/photos/types/context";
+import { useAppContext } from "@/new/photos/types/context";
import { NotificationAttributes } from "@/new/photos/types/notification";
import { firstNonEmpty } from "@/utils/array";
import { ensure } from "@/utils/ensure";
import { CustomError } from "@ente/shared/error";
import DiscFullIcon from "@mui/icons-material/DiscFull";
+import InfoOutlined from "@mui/icons-material/InfoRounded";
import UserNameInputDialog from "components/UserNameInputDialog";
import { t } from "i18next";
import isElectron from "is-electron";
import { GalleryContext } from "pages/gallery";
import { useContext, useEffect, useRef, useState } from "react";
+import { Trans } from "react-i18next";
import { getLatestCollections } from "services/collectionService";
import {
getPublicCollectionUID,
@@ -42,7 +44,6 @@ import watcher from "services/watch";
import { SetLoading } from "types/gallery";
import { getOrCreateAlbum } from "utils/collection";
import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";
-import { getRootLevelFileWithFolderNotAllowMessage } from "utils/ui";
import { SetCollectionNamerAttributes } from "../Collections/CollectionNamer";
import UploadProgress from "./UploadProgress";
import {
@@ -107,7 +108,8 @@ export default function Uploader({
onUploadFile,
...props
}: Props) {
- const appContext = useContext(AppContext);
+ const appContext = useAppContext();
+ const { showMiniDialog } = appContext;
const galleryContext = useContext(GalleryContext);
const publicCollectionGalleryContext = useContext(
PublicCollectionGalleryContext,
@@ -708,7 +710,7 @@ export default function Uploader({
if (openZipFileSelector && electron) {
openZipFileSelector();
} else {
- appContext.showMiniDialog(downloadAppDialogAttributes());
+ showMiniDialog(downloadAppDialogAttributes());
}
}
};
@@ -760,9 +762,18 @@ export default function Uploader({
break;
case "parent":
if (importSuggestion.hasRootLevelFileWithFolder) {
- appContext.setDialogMessage(
- getRootLevelFileWithFolderNotAllowMessage(),
- );
+ showMiniDialog({
+ icon: <InfoOutlined />,
+ title: t("ROOT_LEVEL_FILE_WITH_FOLDER_NOT_ALLOWED"),
+ message: (
+ <Trans
+ i18nKey={
+ "ROOT_LEVEL_FILE_WITH_FOLDER_NOT_ALLOWED_MESSAGE"
+ }
+ />
+ ),
+ cancel: t("ok"),
+ });
} else {
uploadFilesToNewCollections("parent");
}
diff --git a/web/apps/photos/src/utils/ui/index.tsx b/web/apps/photos/src/utils/ui/index.tsx
index 2da29ebabe..11a1c08e77 100644
--- a/web/apps/photos/src/utils/ui/index.tsx
+++ b/web/apps/photos/src/utils/ui/index.tsx
@@ -1,7 +1,5 @@
import { DialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
-import InfoOutlined from "@mui/icons-material/InfoRounded";
import { t } from "i18next";
-import { Trans } from "react-i18next";
export const getTrashFilesMessage = (
deleteFileHelper,
@@ -27,15 +25,3 @@ export const getTrashFileMessage = (deleteFileHelper): DialogBoxAttributes => ({
},
close: { text: t("cancel") },
});
-
-export const getRootLevelFileWithFolderNotAllowMessage =
- (): DialogBoxAttributes => ({
- icon: <InfoOutlined />,
- title: t("ROOT_LEVEL_FILE_WITH_FOLDER_NOT_ALLOWED"),
- content: (
- <Trans
- i18nKey={"ROOT_LEVEL_FILE_WITH_FOLDER_NOT_ALLOWED_MESSAGE"}
- />
- ),
- close: {},
- });