Skip to content

armgit / ente

Public Imported from GitHub
0

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

Ref

Manav Rathi6b85687f7222
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx
index 2b0619b695..de9934c1e9 100644
--- a/web/apps/photos/src/components/Upload/Uploader.tsx
+++ b/web/apps/photos/src/components/Upload/Uploader.tsx
@@ -1,9 +1,10 @@
+import { useModalVisibility } from "@/base/components/utils/modal";
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 type { EnteFile } from "@/media/file";
-import UserNameInputDialog from "@/new/albums/components/UploaderNameInput";
+import { UploaderNameInput } from "@/new/albums/components/UploaderNameInput";
import { CollectionMappingChoiceDialog } from "@/new/photos/components/CollectionMappingChoiceDialog";
import type { CollectionSelectorAttributes } from "@/new/photos/components/CollectionSelector";
import { downloadAppDialogAttributes } from "@/new/photos/components/utils/download";
@@ -137,11 +138,13 @@ export default function Uploader({
const [hasLivePhotos, setHasLivePhotos] = useState(false);
const [openChoiceDialog, setOpenChoiceDialog] = useState(false);
- const [userNameInputDialogView, setUserNameInputDialogView] =
- useState(false);
const [importSuggestion, setImportSuggestion] = useState<ImportSuggestion>(
DEFAULT_IMPORT_SUGGESTION,
);
+ const {
+ show: showUploaderNameInput,
+ props: uploaderNameInputVisibilityProps,
+ } = useModalVisibility();
/**
* {@link File}s that the user drag-dropped or selected for uploads (web).
@@ -220,7 +223,6 @@ export default function Uploader({
const electron = globalThis.electron;
const closeUploadProgress = () => setUploadProgressView(false);
- const showUserNameInputDialog = () => setUserNameInputDialogView(true);
const handleChoiceModalClose = () => {
setOpenChoiceDialog(false);
@@ -231,8 +233,8 @@ export default function Uploader({
uploadRunning.current = false;
};
- const handleUserNameInputDialogClose = () => {
- setUserNameInputDialogView(false);
+ const handleUploaderNameInputClose = () => {
+ uploaderNameInputVisibilityProps.onClose();
uploadRunning.current = false;
};
@@ -424,7 +426,7 @@ export default function Uploader({
),
);
uploaderNameRef.current = uploaderName;
- showUserNameInputDialog();
+ showUploaderNameInput();
return;
}
@@ -807,12 +809,12 @@ export default function Uploader({
finishedUploads={finishedUploads}
cancelUploads={cancelUploads}
/>
- <UserNameInputDialog
- open={userNameInputDialogView}
- onClose={handleUserNameInputDialogClose}
- onNameSubmit={handlePublicUpload}
- toUploadFilesCount={uploadItemsAndPaths.current?.length}
+ <UploaderNameInput
+ open={uploaderNameInputVisibilityProps.open}
+ onClose={handleUploaderNameInputClose}
uploaderName={uploaderNameRef.current}
+ uploadFileCount={uploadItemsAndPaths.current?.length ?? 0}
+ onSubmit={handlePublicUpload}
/>
</>
);
diff --git a/web/packages/new/albums/components/UploaderNameInput.tsx b/web/packages/new/albums/components/UploaderNameInput.tsx
index b7a6d41db7..c0b0fb00ea 100644
--- a/web/packages/new/albums/components/UploaderNameInput.tsx
+++ b/web/packages/new/albums/components/UploaderNameInput.tsx
@@ -1,3 +1,4 @@
+import type { ModalVisibilityProps } from "@/base/components/utils/modal";
import SingleInputForm from "@ente/shared/components/SingleInputForm";
import AutoAwesomeOutlinedIcon from "@mui/icons-material/AutoAwesomeOutlined";
import {
@@ -9,16 +10,35 @@ import {
} from "@mui/material";
import { t } from "i18next";
-export default function UploaderNameInputDialog({
+type UploaderNameInput = ModalVisibilityProps & {
+ /**
+ * The existing uploader name to prefill.
+ */
+ uploaderName: string;
+ /**
+ * Count of the number of files that the uploader is trying to upload.
+ */
+ uploadFileCount: number;
+ /**
+ * Callback invoked when the user presses submit after entering a name.
+ */
+ onSubmit: (name: string) => Promise<void>;
+};
+
+/**
+ * A dialog asking the uploader to a public album to provide their name so that
+ * other folks can know who uploaded a given photo in the shared album.
+ */
+export const UploaderNameInput: React.FC<UploaderNameInput> = ({
open,
onClose,
- onNameSubmit,
- toUploadFilesCount,
uploaderName,
-}) {
+ uploadFileCount,
+ onSubmit,
+}) => {
const handleSubmit = async (inputValue: string) => {
onClose();
- await onNameSubmit(inputValue);
+ await onSubmit(inputValue);
};
return (
@@ -52,7 +72,7 @@ export default function UploaderNameInputDialog({
callback={handleSubmit}
placeholder={t("NAME_PLACEHOLDER")}
buttonText={t("add_photos_count", {
- count: toUploadFilesCount ?? 0,
+ count: uploadFileCount,
})}
fieldType="text"
blockButton
@@ -61,4 +81,4 @@ export default function UploaderNameInputDialog({
</DialogContent>
</Dialog>
);
-}
+};