Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove old one

Manav Rathi92adb3ad6f97
diff --git a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
index 8980c8ed5f..7240b47d17 100644
--- a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
+++ b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
@@ -1,27 +1,20 @@
-import { isDesktop } from "@/base/app";
import { EnteDrawer } from "@/base/components/EnteDrawer";
import { MenuItemGroup, MenuSectionTitle } from "@/base/components/Menu";
import { Titlebar } from "@/base/components/Titlebar";
-import { pt } from "@/base/i18n";
-import { MLSettingsBeta } from "@/new/photos/components/MLSettingsBeta";
-import { canEnableML } from "@/new/photos/services/ml";
import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";
-import ChevronRight from "@mui/icons-material/ChevronRight";
-import ScienceIcon from "@mui/icons-material/Science";
import { Box, DialogProps, Stack } from "@mui/material";
import { t } from "i18next";
import { AppContext } from "pages/_app";
-import { useContext, useEffect, useState } from "react";
+import React, { useContext } from "react";
+import type { SettingsDrawerProps } from "./types";
-export default function AdvancedSettings({ open, onClose, onRootClose }) {
+export const AdvancedSettings: React.FC<SettingsDrawerProps> = ({
+ open,
+ onClose,
+ onRootClose,
+}) => {
const appContext = useContext(AppContext);
- const [showMLSettings, setShowMLSettings] = useState(false);
- const [openMLSettings, setOpenMLSettings] = useState(false);
-
- useEffect(() => {
- if (isDesktop) void canEnableML().then(setShowMLSettings);
- }, []);
const handleRootClose = () => {
onClose();
onRootClose();
@@ -71,30 +64,8 @@ export default function AdvancedSettings({ open, onClose, onRootClose }) {
/>
</Box>
</Stack>
-
- {showMLSettings && (
- <Box>
- <MenuSectionTitle
- title={t("LABS")}
- icon={<ScienceIcon />}
- />
- <MenuItemGroup>
- <EnteMenuItem
- endIcon={<ChevronRight />}
- onClick={() => setOpenMLSettings(true)}
- label={pt("Face and magic search")}
- />
- </MenuItemGroup>
- </Box>
- )}
</Box>
</Stack>
-
- <MLSettingsBeta
- open={openMLSettings}
- onClose={() => setOpenMLSettings(false)}
- onRootClose={handleRootClose}
- />
</EnteDrawer>
);
-}
+};
diff --git a/web/apps/photos/src/components/Sidebar/MapSetting.tsx b/web/apps/photos/src/components/Sidebar/MapSetting.tsx
index 29acee238c..a64d64c9eb 100644
--- a/web/apps/photos/src/components/Sidebar/MapSetting.tsx
+++ b/web/apps/photos/src/components/Sidebar/MapSetting.tsx
@@ -13,11 +13,16 @@ import {
} from "@mui/material";
import { t } from "i18next";
import { AppContext } from "pages/_app";
-import { useContext, useEffect, useState } from "react";
+import React, { useContext, useEffect, useState } from "react";
import { Trans } from "react-i18next";
import { getMapEnabledStatus } from "services/userService";
+import type { SettingsDrawerProps } from "./types";
-export default function MapSettings({ open, onClose, onRootClose }) {
+export const MapSettings: React.FC<SettingsDrawerProps> = ({
+ open,
+ onClose,
+ onRootClose,
+}) => {
const { mapEnabled, updateMapEnabled } = useContext(AppContext);
const [modifyMapEnabledView, setModifyMapEnabledView] = useState(false);
@@ -87,7 +92,7 @@ export default function MapSettings({ open, onClose, onRootClose }) {
/>
</EnteDrawer>
);
-}
+};
const ModifyMapEnabled = ({ open, onClose, onRootClose, mapEnabled }) => {
const { somethingWentWrong, updateMapEnabled } = useContext(AppContext);
diff --git a/web/apps/photos/src/components/Sidebar/Preferences.tsx b/web/apps/photos/src/components/Sidebar/Preferences.tsx
index 000a1e44cc..05d72c92ae 100644
--- a/web/apps/photos/src/components/Sidebar/Preferences.tsx
+++ b/web/apps/photos/src/components/Sidebar/Preferences.tsx
@@ -1,3 +1,4 @@
+import { isDesktop } from "@/base/app";
import { EnteDrawer } from "@/base/components/EnteDrawer";
import { MenuItemGroup, MenuSectionTitle } from "@/base/components/Menu";
import { Titlebar } from "@/base/components/Titlebar";
@@ -9,7 +10,7 @@ import {
type SupportedLocale,
} from "@/base/i18n";
import { MLSettings } from "@/new/photos/components/MLSettings";
-import { isMLSupported } from "@/new/photos/services/ml";
+import { canEnableML } from "@/new/photos/services/ml";
import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";
import ChevronRight from "@mui/icons-material/ChevronRight";
import ScienceIcon from "@mui/icons-material/Science";
@@ -17,17 +18,27 @@ import { Box, DialogProps, Stack } from "@mui/material";
import DropdownInput from "components/DropdownInput";
import { t } from "i18next";
import { AppContext } from "pages/_app";
-import { useContext, useState } from "react";
-import AdvancedSettings from "./AdvancedSettings";
-import MapSettings from "./MapSetting";
+import React, { useContext, useEffect, useState } from "react";
+import { AdvancedSettings } from "./AdvancedSettings";
+import { MapSettings } from "./MapSetting";
+import type { SettingsDrawerProps } from "./types";
-export default function Preferences({ open, onClose, onRootClose }) {
+export const Preferences: React.FC<SettingsDrawerProps> = ({
+ open,
+ onClose,
+ onRootClose,
+}) => {
const appContext = useContext(AppContext);
const [advancedSettingsView, setAdvancedSettingsView] = useState(false);
const [mapSettingsView, setMapSettingsView] = useState(false);
+ const [showMLSettings, setShowMLSettings] = useState(false);
const [openMLSettings, setOpenMLSettings] = useState(false);
+ useEffect(() => {
+ if (isDesktop) void canEnableML().then(setShowMLSettings);
+ }, []);
+
const openAdvancedSettings = () => setAdvancedSettingsView(true);
const closeAdvancedSettings = () => setAdvancedSettingsView(false);
@@ -75,7 +86,7 @@ export default function Preferences({ open, onClose, onRootClose }) {
endIcon={<ChevronRight />}
label={t("ADVANCED")}
/>
- {isMLSupported && (
+ {showMLSettings && (
<Box>
<MenuSectionTitle
title={t("LABS")}
@@ -111,7 +122,7 @@ export default function Preferences({ open, onClose, onRootClose }) {
/>
</EnteDrawer>
);
-}
+};
const LanguageSelector = () => {
const locale = getLocaleInUse();
diff --git a/web/apps/photos/src/components/Sidebar/index.tsx b/web/apps/photos/src/components/Sidebar/index.tsx
index ccf921c854..9c3a19d8c7 100644
--- a/web/apps/photos/src/components/Sidebar/index.tsx
+++ b/web/apps/photos/src/components/Sidebar/index.tsx
@@ -50,7 +50,7 @@ import isElectron from "is-electron";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { GalleryContext } from "pages/gallery";
-import {
+import React, {
MouseEventHandler,
useContext,
useEffect,
@@ -78,7 +78,7 @@ import { getDownloadAppMessage } from "utils/ui";
import { isFamilyAdmin, isPartOfFamily } from "utils/user/family";
import { testUpload } from "../../../tests/upload.test";
import { MemberSubscriptionManage } from "../MemberSubscriptionManage";
-import Preferences from "./Preferences";
+import { Preferences } from "./Preferences";
import SubscriptionCard from "./SubscriptionCard";
interface Iprops {
diff --git a/web/apps/photos/src/components/Sidebar/types.ts b/web/apps/photos/src/components/Sidebar/types.ts
new file mode 100644
index 0000000000..e9eebadece
--- /dev/null
+++ b/web/apps/photos/src/components/Sidebar/types.ts
@@ -0,0 +1,8 @@
+export interface SettingsDrawerProps {
+ /** If `true`, then this drawer page is shown. */
+ open: boolean;
+ /** Called when the user wants to go back from this drawer page. */
+ onClose: () => void;
+ /** Called when the user wants to close the entire stack of drawers. */
+ onRootClose: () => void;
+}
diff --git a/web/packages/new/photos/components/MLSettingsBeta.tsx b/web/packages/new/photos/components/MLSettingsBeta.tsx
deleted file mode 100644
index 2f9bae19f4..0000000000
--- a/web/packages/new/photos/components/MLSettingsBeta.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import { EnteDrawer } from "@/base/components/EnteDrawer";
-import { Titlebar } from "@/base/components/Titlebar";
-import { pt, ut } from "@/base/i18n";
-import { Box, Stack, Typography, type DialogProps } from "@mui/material";
-import React from "react";
-
-interface MLSettingsBetaProps {
- /** If `true`, then this drawer page is shown. */
- open: boolean;
- /** Called when the user wants to go back from this drawer page. */
- onClose: () => void;
- /** Called when the user wants to close the entire stack of drawers. */
- onRootClose: () => void;
-}
-
-export const MLSettingsBeta: React.FC<MLSettingsBetaProps> = ({
- open,
- onClose,
- onRootClose,
-}) => {
- const handleRootClose = () => {
- onClose();
- onRootClose();
- };
-
- const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {
- if (reason == "backdropClick") handleRootClose();
- else onClose();
- };
-
- return (
- <Box>
- <EnteDrawer
- anchor="left"
- transitionDuration={0}
- open={open}
- onClose={handleDrawerClose}
- BackdropProps={{
- sx: { "&&&": { backgroundColor: "transparent" } },
- }}
- >
- <Stack spacing={"4px"} py={"12px"}>
- <Titlebar
- onClose={onClose}
- title={pt("Face and magic search")}
- onRootClose={onRootClose}
- />
-
- <Box px="8px">
- <Typography color="text.muted">
- {ut(
- "We're putting finishing touches, coming back soon!",
- )}
- </Typography>
- </Box>
- </Stack>
- </EnteDrawer>
- </Box>
- );
-};