Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline consent contents

Manav Rathi07600c60185e
diff --git a/web/packages/new/photos/components/gallery/index.tsx b/web/packages/new/photos/components/gallery/index.tsx
index bcf9314789..b487dd512e 100644
--- a/web/packages/new/photos/components/gallery/index.tsx
+++ b/web/packages/new/photos/components/gallery/index.tsx
@@ -12,6 +12,7 @@ import type { SearchOption } from "@/new/photos/services/search/types";
import { Paper, Stack, Typography } from "@mui/material";
import { t } from "i18next";
import React, { useState } from "react";
+import { enableML } from "../../services/ml";
import { EnableML, FaceConsent } from "../sidebar/MLSettings";
import { useMLStatusSnapshot } from "../utils/use-snapshot";
import { useWrapAsyncOperation } from "../utils/use-wrap-async";
@@ -66,40 +67,6 @@ export const PeopleEmptyState: React.FC = () => {
}
};
-// import { FormPaper } from "@/base/components/FormPaper";
-
-export const PeopleEmptyStateDisabled: React.FC = () => {
- const [openFaceConsent, setOpenFaceConsent] = useState(false);
-
- const handleEnableML = () => setOpenFaceConsent(true);
-
- const handleConsent = useWrapAsyncOperation(async () => {
- await enableML();
- // Close the FaceConsent drawer, come back to ourselves.
- setOpenFaceConsent(false);
- });
-
- return (
- <Stack sx={{ alignItems: "center" }}>
- <Paper
- sx={{
- maxWidth: "360px",
- padding: "4px",
- }}
- >
- <EnableML onEnable={handleEnableML} />
- </Paper>
-
- <FaceConsent
- open={openFaceConsent}
- onClose={() => setOpenFaceConsent(false)}
- onRootClose={() => {}}
- onConsent={handleConsent}
- />
- </Stack>
- );
-};
-
export const PeopleEmptyStateMessage: React.FC<React.PropsWithChildren> = ({
children,
}) => (
@@ -118,3 +85,26 @@ export const PeopleEmptyStateMessage: React.FC<React.PropsWithChildren> = ({
</Typography>
</CenteredBox>
);
+
+export const PeopleEmptyStateDisabled: React.FC = () => {
+ const [showConsent, setShowConsent] = useState(false);
+
+ const handleConsent = useWrapAsyncOperation(async () => {
+ await enableML();
+ });
+
+ return (
+ <Stack sx={{ alignItems: "center" }}>
+ <Paper sx={{ maxWidth: "390px", padding: "4px", mb: "2rem" }}>
+ {!showConsent ? (
+ <EnableML onEnable={() => setShowConsent(true)} />
+ ) : (
+ <FaceConsent
+ onConsent={handleConsent}
+ onCancel={() => setShowConsent(false)}
+ />
+ )}
+ </Paper>
+ </Stack>
+ );
+};
diff --git a/web/packages/new/photos/components/sidebar/MLSettings.tsx b/web/packages/new/photos/components/sidebar/MLSettings.tsx
index 108eee09f5..315aa21774 100644
--- a/web/packages/new/photos/components/sidebar/MLSettings.tsx
+++ b/web/packages/new/photos/components/sidebar/MLSettings.tsx
@@ -77,7 +77,7 @@ export const MLSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({
</Stack>
</NestedSidebarDrawer>
- <FaceConsent
+ <FaceConsentDrawer
open={openFaceConsent}
onClose={() => setOpenFaceConsent(false)}
onRootClose={handleRootClose}
@@ -134,28 +134,54 @@ export const EnableML: React.FC<EnableMLProps> = ({
);
};
-type FaceConsentProps = NestedSidebarDrawerVisibilityProps & {
- /** Called when the user provides their consent. */
- onConsent: () => void;
-};
+type FaceConsentDrawerProps = NestedSidebarDrawerVisibilityProps &
+ Pick<FaceConsentProps, "onConsent">;
-export const FaceConsent: React.FC<FaceConsentProps> = ({
+const FaceConsentDrawer: React.FC<FaceConsentDrawerProps> = ({
open,
onClose,
onRootClose,
onConsent,
}) => {
- const [acceptTerms, setAcceptTerms] = useState(false);
-
- useEffect(() => {
- setAcceptTerms(false);
- }, [open]);
-
const handleRootClose = () => {
onClose();
onRootClose();
};
+ return (
+ <NestedSidebarDrawer
+ {...{ open, onClose }}
+ onRootClose={handleRootClose}
+ >
+ <Stack spacing={"4px"} py={"12px"}>
+ <SidebarDrawerTitlebar
+ onClose={onClose}
+ onRootClose={handleRootClose}
+ title={t("ml_consent_title")}
+ />
+ <FaceConsent onConsent={onConsent} onCancel={onClose} />
+ </Stack>
+ </NestedSidebarDrawer>
+ );
+};
+
+interface FaceConsentProps {
+ /** Called when the user provides their consent. */
+ onConsent: () => void;
+ /** Called when the user cancels out. */
+ onCancel: () => void;
+}
+
+export const FaceConsent: React.FC<FaceConsentProps> = ({
+ onConsent,
+ onCancel,
+}) => {
+ const [acceptTerms, setAcceptTerms] = useState(false);
+
+ useEffect(() => {
+ setAcceptTerms(false);
+ }, []);
+
const privacyPolicyLink = (
<Link
target="_blank"
@@ -169,62 +195,44 @@ export const FaceConsent: React.FC<FaceConsentProps> = ({
);
return (
- <NestedSidebarDrawer
- {...{ open, onClose }}
- onRootClose={handleRootClose}
- >
- <Stack spacing={"4px"} py={"12px"}>
- <SidebarDrawerTitlebar
- onClose={onClose}
- onRootClose={handleRootClose}
- title={t("ml_consent_title")}
+ <Stack py={"20px"} px={"8px"} spacing={"32px"}>
+ <Typography component="div" color="text.muted" px={"8px"}>
+ <Trans
+ i18nKey={"ml_consent_description"}
+ components={{ a: privacyPolicyLink }}
/>
- <Stack py={"20px"} px={"8px"} spacing={"32px"}>
- <Typography component="div" color="text.muted" px={"8px"}>
- <Trans
- i18nKey={"ml_consent_description"}
- components={{ a: privacyPolicyLink }}
- />
- </Typography>
- <FormGroup sx={{ width: "100%" }}>
- <FormControlLabel
- sx={{
- color: "text.muted",
- ml: 0,
- mt: 2,
- }}
- control={
- <Checkbox
- size="small"
- checked={acceptTerms}
- onChange={(e) =>
- setAcceptTerms(e.target.checked)
- }
- />
- }
- label={t("ml_consent_confirmation")}
+ </Typography>
+ <FormGroup sx={{ width: "100%" }}>
+ <FormControlLabel
+ sx={{
+ color: "text.muted",
+ ml: 0,
+ mt: 2,
+ }}
+ control={
+ <Checkbox
+ size="small"
+ checked={acceptTerms}
+ onChange={(e) => setAcceptTerms(e.target.checked)}
/>
- </FormGroup>
- <Stack px={"8px"} spacing={"8px"}>
- <Button
- color={"accent"}
- size="large"
- disabled={!acceptTerms}
- onClick={onConsent}
- >
- {t("ml_consent")}
- </Button>
- <Button
- color={"secondary"}
- size="large"
- onClick={onClose}
- >
- {t("cancel")}
- </Button>
- </Stack>
- </Stack>
+ }
+ label={t("ml_consent_confirmation")}
+ />
+ </FormGroup>
+ <Stack px={"8px"} spacing={"8px"}>
+ <Button
+ color={"accent"}
+ size="large"
+ disabled={!acceptTerms}
+ onClick={onConsent}
+ >
+ {t("ml_consent")}
+ </Button>
+ <Button color={"secondary"} size="large" onClick={onCancel}>
+ {t("cancel")}
+ </Button>
</Stack>
- </NestedSidebarDrawer>
+ </Stack>
);
};