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