This commit is contained in:
Manav Rathi 2024-11-12 18:17:52 +05:30
parent 5461bd112f
commit df19e12ab8
No known key found for this signature in database
2 changed files with 19 additions and 48 deletions

View File

@ -2,6 +2,7 @@ import { EnteSwitch } from "@/base/components/EnteSwitch";
import { ensureElectron } from "@/base/electron"; import { ensureElectron } from "@/base/electron";
import log from "@/base/log"; import log from "@/base/log";
import { EnteFile } from "@/media/file"; import { EnteFile } from "@/media/file";
import { DialogCloseIconButton } from "@/new/photos/components/mui/Dialog";
import { useAppContext } from "@/new/photos/types/context"; import { useAppContext } from "@/new/photos/types/context";
import ChangeDirectoryOption from "@ente/shared/components/ChangeDirectoryOption"; import ChangeDirectoryOption from "@ente/shared/components/ChangeDirectoryOption";
import { import {
@ -9,13 +10,13 @@ import {
VerticallyCenteredFlex, VerticallyCenteredFlex,
} from "@ente/shared/components/Container"; } from "@ente/shared/components/Container";
import LinkButton from "@ente/shared/components/LinkButton"; import LinkButton from "@ente/shared/components/LinkButton";
import DialogTitleWithCloseButton from "@ente/shared/components/TitleWithCloseButton";
import { CustomError } from "@ente/shared/error"; import { CustomError } from "@ente/shared/error";
import { import {
Box, Box,
Button, Button,
Dialog, Dialog,
DialogContent, DialogContent,
DialogTitle,
Divider, Divider,
Tooltip, Tooltip,
Typography, Typography,
@ -41,7 +42,11 @@ interface ExportModalProps {
collectionNameMap: Map<number, string>; collectionNameMap: Map<number, string>;
} }
export default function ExportModal(props: ExportModalProps) { export default function ExportModal({
show,
onHide,
collectionNameMap,
}: ExportModalProps) {
const { showMiniDialog } = useAppContext(); const { showMiniDialog } = useAppContext();
const [exportStage, setExportStage] = useState(ExportStage.INIT); const [exportStage, setExportStage] = useState(ExportStage.INIT);
const [exportFolder, setExportFolder] = useState(""); const [exportFolder, setExportFolder] = useState("");
@ -79,11 +84,11 @@ export default function ExportModal(props: ExportModalProps) {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (!props.show) { if (!show) {
return; return;
} }
void syncExportRecord(exportFolder); void syncExportRecord(exportFolder);
}, [props.show]); }, [show]);
// ====================== // ======================
// HELPER FUNCTIONS // HELPER FUNCTIONS
@ -166,15 +171,14 @@ export default function ExportModal(props: ExportModalProps) {
}; };
return ( return (
<Dialog <Dialog open={show} onClose={onHide} maxWidth="xs" fullWidth>
open={props.show} <SpaceBetweenFlex sx={{ p: "12px 4px 0px 0px" }}>
onClose={props.onHide} <DialogTitle variant="h3" fontWeight={"bold"}>
maxWidth="xs" {t("export_data")}
fullWidth </DialogTitle>
> <DialogCloseIconButton {...{ onClose: onHide }} />
<DialogTitleWithCloseButton onClose={props.onHide}> </SpaceBetweenFlex>
{t("export_data")}
</DialogTitleWithCloseButton>
<DialogContent> <DialogContent>
<ExportDirectory <ExportDirectory
exportFolder={exportFolder} exportFolder={exportFolder}
@ -191,11 +195,11 @@ export default function ExportModal(props: ExportModalProps) {
exportStage={exportStage} exportStage={exportStage}
startExport={startExport} startExport={startExport}
stopExport={stopExport} stopExport={stopExport}
onHide={props.onHide} onHide={onHide}
lastExportTime={lastExportTime} lastExportTime={lastExportTime}
exportProgress={exportProgress} exportProgress={exportProgress}
pendingExports={pendingExports} pendingExports={pendingExports}
collectionNameMap={props.collectionNameMap} collectionNameMap={collectionNameMap}
/> />
</Dialog> </Dialog>
); );

View File

@ -1,33 +0,0 @@
import { SpaceBetweenFlex } from "@ente/shared/components/Container";
import CloseIcon from "@mui/icons-material/Close";
import { DialogTitle, IconButton, Typography } from "@mui/material";
import React from "react";
interface DialogTitleWithCloseButtonProps {
onClose: () => void;
}
const DialogTitleWithCloseButton: React.FC<
React.PropsWithChildren<DialogTitleWithCloseButtonProps>
> = ({ children, onClose }) => {
return (
<DialogTitle>
<SpaceBetweenFlex>
<Typography variant="h3" fontWeight={"bold"}>
{children}
</Typography>
{onClose && (
<IconButton
aria-label="close"
onClick={onClose}
sx={{ float: "right" }}
color="secondary"
>
<CloseIcon />
</IconButton>
)}
</SpaceBetweenFlex>
</DialogTitle>
);
};
export default DialogTitleWithCloseButton;