Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use

Manav Rathiff4239731603
diff --git a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
index be0a499555..8e1bac65f8 100644
--- a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
+++ b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
@@ -1,14 +1,16 @@
import { MenuItemGroup, MenuSectionTitle } from "@/base/components/Menu";
-import { SidebarDrawer } from "@/base/components/mui/SidebarDrawer";
+import {
+ NestedSidebarDrawer,
+ type NestedSidebarDrawerVisibilityProps,
+} from "@/base/components/mui/SidebarDrawer";
import { Titlebar } from "@/base/components/Titlebar";
-import type { NestedDrawerVisibilityProps } from "@/base/components/utils/modal";
import { AppContext } from "@/new/photos/types/context";
import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";
-import { Box, DialogProps, Stack } from "@mui/material";
+import { Box, Stack } from "@mui/material";
import { t } from "i18next";
import React, { useContext } from "react";
-export const AdvancedSettings: React.FC<NestedDrawerVisibilityProps> = ({
+export const AdvancedSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({
open,
onClose,
onRootClose,
@@ -20,26 +22,14 @@ export const AdvancedSettings: React.FC<NestedDrawerVisibilityProps> = ({
onRootClose();
};
- const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {
- if (reason === "backdropClick") {
- handleRootClose();
- } else {
- onClose();
- }
- };
-
const toggleCFProxy = () => {
appContext.setIsCFProxyDisabled(!appContext.isCFProxyDisabled);
};
return (
- <SidebarDrawer
- transitionDuration={0}
- open={open}
- onClose={handleDrawerClose}
- BackdropProps={{
- sx: { "&&&": { backgroundColor: "transparent" } },
- }}
+ <NestedSidebarDrawer
+ {...{ open, onClose }}
+ onRootClose={handleRootClose}
>
<Stack spacing={"4px"} py={"12px"}>
<Titlebar
@@ -66,6 +56,6 @@ export const AdvancedSettings: React.FC<NestedDrawerVisibilityProps> = ({
</Stack>
</Box>
</Stack>
- </SidebarDrawer>
+ </NestedSidebarDrawer>
);
};
diff --git a/web/apps/photos/src/components/Sidebar/MapSetting.tsx b/web/apps/photos/src/components/Sidebar/MapSetting.tsx
index f33b1f04a7..9b535d9eae 100644
--- a/web/apps/photos/src/components/Sidebar/MapSetting.tsx
+++ b/web/apps/photos/src/components/Sidebar/MapSetting.tsx
@@ -1,24 +1,19 @@
import { MenuItemGroup } from "@/base/components/Menu";
-import { SidebarDrawer } from "@/base/components/mui/SidebarDrawer";
+import {
+ NestedSidebarDrawer,
+ type NestedSidebarDrawerVisibilityProps,
+} from "@/base/components/mui/SidebarDrawer";
import { Titlebar } from "@/base/components/Titlebar";
-import type { NestedDrawerVisibilityProps } from "@/base/components/utils/modal";
import log from "@/base/log";
import { AppContext } from "@/new/photos/types/context";
import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";
-import {
- Box,
- Button,
- DialogProps,
- Link,
- Stack,
- Typography,
-} from "@mui/material";
+import { Box, Button, Link, Stack, Typography } from "@mui/material";
import { t } from "i18next";
import React, { useContext, useEffect, useState } from "react";
import { Trans } from "react-i18next";
import { getMapEnabledStatus } from "services/userService";
-export const MapSettings: React.FC<NestedDrawerVisibilityProps> = ({
+export const MapSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({
open,
onClose,
onRootClose,
@@ -45,22 +40,10 @@ export const MapSettings: React.FC<NestedDrawerVisibilityProps> = ({
onRootClose();
};
- const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {
- if (reason === "backdropClick") {
- handleRootClose();
- } else {
- onClose();
- }
- };
-
return (
- <SidebarDrawer
- transitionDuration={0}
- open={open}
- onClose={handleDrawerClose}
- BackdropProps={{
- sx: { "&&&": { backgroundColor: "transparent" } },
- }}
+ <NestedSidebarDrawer
+ {...{ open, onClose }}
+ onRootClose={handleRootClose}
>
<Stack spacing={"4px"} py={"12px"}>
<Titlebar
@@ -90,7 +73,7 @@ export const MapSettings: React.FC<NestedDrawerVisibilityProps> = ({
onClose={closeModifyMapEnabled}
onRootClose={handleRootClose}
/>
- </SidebarDrawer>
+ </NestedSidebarDrawer>
);
};
@@ -122,21 +105,11 @@ const ModifyMapEnabled = ({ open, onClose, onRootClose, mapEnabled }) => {
onRootClose();
};
- const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {
- if (reason === "backdropClick") {
- handleRootClose();
- } else {
- onClose();
- }
- };
-
return (
<Box>
- <SidebarDrawer
- anchor="left"
- transitionDuration={0}
- open={open}
- onClose={handleDrawerClose}
+ <NestedSidebarDrawer
+ {...{ open, onClose }}
+ onRootClose={handleRootClose}
slotProps={{
backdrop: {
sx: { "&&&": { backgroundColor: "transparent" } },
@@ -156,7 +129,7 @@ const ModifyMapEnabled = ({ open, onClose, onRootClose, mapEnabled }) => {
onRootClose={handleRootClose}
/>
)}
- </SidebarDrawer>
+ </NestedSidebarDrawer>
</Box>
);
};
diff --git a/web/apps/photos/src/components/Sidebar/TwoFactorModal.tsx b/web/apps/photos/src/components/Sidebar/TwoFactorModal.tsx
index 437d746ea9..9520bd3727 100644
--- a/web/apps/photos/src/components/Sidebar/TwoFactorModal.tsx
+++ b/web/apps/photos/src/components/Sidebar/TwoFactorModal.tsx
@@ -1,40 +1,33 @@
import { disableTwoFactor } from "@/accounts/api/user";
-import { SidebarDrawer } from "@/base/components/mui/SidebarDrawer";
-import type { ModalVisibilityProps, NestedDrawerVisibilityProps } from "@/base/components/utils/modal";
+import {
+ NestedSidebarDrawer,
+ type NestedSidebarDrawerVisibilityProps,
+} from "@/base/components/mui/SidebarDrawer";
import { AppContext } from "@/new/photos/types/context";
import { VerticallyCentered } from "@ente/shared/components/Container";
import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton";
import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
import { LS_KEYS, getData, setLSUser } from "@ente/shared/storage/localStorage";
import LockIcon from "@mui/icons-material/Lock";
-import {
- Button,
- Dialog,
- DialogContent,
- Grid,
- Typography,
- styled,
-} from "@mui/material";
+import { Button, DialogContent, Grid, Typography } from "@mui/material";
import { t } from "i18next";
import router, { useRouter } from "next/router";
import { useContext, useEffect, useState } from "react";
import { getTwoFactorStatus } from "services/userService";
-const TwoFactorDialog = styled(Dialog)(({ theme }) => ({
- "& .MuiDialogContent-root": {
- padding: theme.spacing(2, 4),
- },
-}));
+// const TwoFactorDialog = styled(Dialog)(({ theme }) => ({
+// "& .MuiDialogContent-root": {
+// padding: theme.spacing(2, 4),
+// },
+// }));
// type TwoFactorModalProps = ModalVisibilityProps & {
// closeSidebar: () => void;
// };
-export const TwoFactorSettings: React.FC<NestedDrawerVisibilityProps> = ({
- open,
- onClose,
- onRootClose: closeSidebar,
-}) => {
+export const TwoFactorSettings: React.FC<
+ NestedSidebarDrawerVisibilityProps
+> = ({ open, onClose, onRootClose }) => {
const [isTwoFactorEnabled, setTwoFactorStatus] = useState(false);
useEffect(() => {
@@ -58,38 +51,31 @@ export const TwoFactorSettings: React.FC<NestedDrawerVisibilityProps> = ({
main();
}, [open]);
- const closeDialog = () => {
+ const handleRootClose = () => {
onClose();
- closeSidebar();
+ onRootClose();
};
return (
- <SidebarDrawer
- // <TwoFactorDialog
- // maxWidth="xs"
- // transitionDuration={0}
- // open={open}
- // onClose={onClose}
- transitionDuration={0}
- open={open}
- onClose={onClose}
- BackdropProps={{
- sx: { "&&&": { backgroundColor: "transparent" } },
- }}
+ <NestedSidebarDrawer
+ {...{ open, onClose }}
+ onRootClose={handleRootClose}
>
<DialogTitleWithCloseButton onClose={onClose}>
{t("TWO_FACTOR_AUTHENTICATION")}
</DialogTitleWithCloseButton>
<DialogContent sx={{ px: 4 }}>
{isTwoFactorEnabled ? (
- <TwoFactorModalManageSection closeDialog={closeDialog} />
+ <TwoFactorModalManageSection
+ closeDialog={handleRootClose}
+ />
) : (
- <TwoFactorModalSetupSection closeDialog={closeDialog} />
+ <TwoFactorModalSetupSection closeDialog={handleRootClose} />
)}
</DialogContent>
- </SidebarDrawer>
+ </NestedSidebarDrawer>
);
-}
+};
export default TwoFactorSettings;
diff --git a/web/apps/photos/src/components/Sidebar/index.tsx b/web/apps/photos/src/components/Sidebar/index.tsx
index ce9f2a6e6e..c0eacee9b2 100644
--- a/web/apps/photos/src/components/Sidebar/index.tsx
+++ b/web/apps/photos/src/components/Sidebar/index.tsx
@@ -532,7 +532,7 @@ const UtilitySection: React.FC<UtilitySectionProps> = ({ closeSidebar }) => {
/>
<TwoFactorModal
{...twoFactorVisibilityProps}
- closeSidebar={closeSidebar}
+ onRootClose={closeSidebar}
/>
{isElectron() && (
<WatchFolder
diff --git a/web/packages/new/photos/components/MLSettings.tsx b/web/packages/new/photos/components/MLSettings.tsx
index 3b2c43f44d..3a053793a9 100644
--- a/web/packages/new/photos/components/MLSettings.tsx
+++ b/web/packages/new/photos/components/MLSettings.tsx
@@ -1,8 +1,10 @@
import { MenuItemGroup } from "@/base/components/Menu";
import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";
-import { SidebarDrawer } from "@/base/components/mui/SidebarDrawer";
+import {
+ NestedSidebarDrawer,
+ type NestedSidebarDrawerVisibilityProps,
+} from "@/base/components/mui/SidebarDrawer";
import { Titlebar } from "@/base/components/Titlebar";
-import type { NestedDrawerVisibilityProps } from "@/base/components/utils/modal";
import { disableML, enableML, type MLStatus } from "@/new/photos/services/ml";
import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";
import {
@@ -16,7 +18,6 @@ import {
Paper,
Stack,
Typography,
- type DialogProps,
} from "@mui/material";
import { t } from "i18next";
import React, { useEffect, useState } from "react";
@@ -26,7 +27,7 @@ import { openURL } from "../utils/web";
import { useMLStatusSnapshot } from "./utils/ml";
import { useWrapAsyncOperation } from "./utils/use-wrap-async";
-export const MLSettings: React.FC<NestedDrawerVisibilityProps> = ({
+export const MLSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({
open,
onClose,
onRootClose,
@@ -39,11 +40,6 @@ export const MLSettings: React.FC<NestedDrawerVisibilityProps> = ({
onRootClose();
};
- const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {
- if (reason == "backdropClick") handleRootClose();
- else onClose();
- };
-
const handleEnableML = () => setOpenFaceConsent(true);
const handleConsent = useWrapAsyncOperation(async () => {
@@ -67,24 +63,19 @@ export const MLSettings: React.FC<NestedDrawerVisibilityProps> = ({
return (
<Box>
- <SidebarDrawer
- anchor="left"
- transitionDuration={0}
- open={open}
- onClose={handleDrawerClose}
- BackdropProps={{
- sx: { "&&&": { backgroundColor: "transparent" } },
- }}
+ <NestedSidebarDrawer
+ {...{ open, onClose }}
+ onRootClose={handleRootClose}
>
<Stack spacing={"4px"} py={"12px"}>
<Titlebar
onClose={onClose}
title={t("ml_search")}
- onRootClose={onRootClose}
+ onRootClose={handleRootClose}
/>
{component}
</Stack>
- </SidebarDrawer>
+ </NestedSidebarDrawer>
<FaceConsent
open={openFaceConsent}
@@ -134,7 +125,7 @@ const EnableML: React.FC<EnableMLProps> = ({ onEnable }) => {
);
};
-type FaceConsentProps = NestedDrawerVisibilityProps & {
+type FaceConsentProps = NestedSidebarDrawerVisibilityProps & {
/** Called when the user provides their consent. */
onConsent: () => void;
};
@@ -156,11 +147,6 @@ const FaceConsent: React.FC<FaceConsentProps> = ({
onRootClose();
};
- const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {
- if (reason == "backdropClick") handleRootClose();
- else onClose();
- };
-
const privacyPolicyLink = (
<Link
target="_blank"
@@ -174,13 +160,9 @@ const FaceConsent: React.FC<FaceConsentProps> = ({
);
return (
- <SidebarDrawer
- transitionDuration={0}
- open={open}
- onClose={handleDrawerClose}
- BackdropProps={{
- sx: { "&&&": { backgroundColor: "transparent" } },
- }}
+ <NestedSidebarDrawer
+ {...{ open, onClose }}
+ onRootClose={handleRootClose}
>
<Stack spacing={"4px"} py={"12px"}>
<Titlebar
@@ -233,7 +215,7 @@ const FaceConsent: React.FC<FaceConsentProps> = ({
</Stack>
</Stack>
</Stack>
- </SidebarDrawer>
+ </NestedSidebarDrawer>
);
};