π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
style(photos):match-inline-link-settings-to-sidebar
Aswin Asokd35dd6135437
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsxindex 534b96b426..4673d91e80 100644--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx@@ -3,6 +3,7 @@import Avatar from "@/components/Avatar";import type { RemotePullOpts } from "@/components/gallery";import { PublicLinkCreated } from "@/components/share/PublicLinkCreated";+import { sidebarStyles, sidebarTheme } from "@/components/sidebar/theme";import { usePublicLinkURL } from "@/components/utils/use-public-link-url";import { avatarTextColor } from "@/services/avatar";import AddIcon from "@mui/icons-material/Add";@@ -20,10 +21,19 @@ import Photo, { default as PhotoIcon } from "@mui/icons-material/Photo";import PublicIcon from "@mui/icons-material/Public";import RemoveCircleOutlinedIcon from "@mui/icons-material/RemoveCircleOutlined";import WorkspacesIcon from "@mui/icons-material/Workspaces";-import { Box, Dialog, Stack, styled, Typography } from "@mui/material";+import {+ Box,+ Dialog,+ Stack,+ styled,+ ThemeProvider,+ Typography,+} from "@mui/material";import NumberAvatar from "@mui/material/Avatar";import TextField from "@mui/material/TextField";import type { LocalUser } from "ente-accounts/services/user";+import { EnteSwitch } from "ente-base/components/EnteSwitch";+import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import {SidebarDrawer,@@ -53,6 +63,7 @@ import {useModalVisibility,type ModalVisibilityProps,} from "ente-base/components/utils/modal";+import { RowCard } from "ente-base/components/v2/RowCard";import { useBaseContext } from "ente-base/context";import { deriveInteractiveKey } from "ente-base/crypto";import { isHTTPErrorWithStatus, isMuseumHTTPError } from "ente-base/http";@@ -1872,25 +1883,121 @@ export const ManagePublicShareOptions: React.FC<if (props.variant == "inline") {return (- <Box- ref={panelRef}- aria-label={t("manage_link")}- sx={{- position: "relative",- minWidth: 0,- borderRadius: 3,- overflow: "hidden",- }}- >- <SidebarPanelContext.Provider value={() => panelRef.current}>- <SidebarDrawerDepthContext.Provider value={1}>- <Typography component="h2" variant="h3" sx={{ px: 1 }}>- {t("manage_link")}+ <ThemeProvider theme={sidebarTheme}>+ <Stack+ ref={panelRef}+ component="section"+ aria-label={t("manage_link")}+ sx={[+ sidebarStyles,+ {+ gap: 2,+ position: "relative",+ minWidth: 0,+ borderRadius: 3,+ overflow: "hidden",+ },+ ]}+ >+ <Box sx={{ minWidth: 0, p: 1 }}>+ <SidebarPanelContext.Provider+ value={() => panelRef.current}+ >+ <SidebarDrawerDepthContext.Provider value={1}>+ <Stack sx={{ gap: 1 }}>+ <ManageLayout+ variant="inline"+ {...{+ collection,+ onRootClose,+ onRemotePull,+ }}+ />+ <ManagePublicCollect+ variant="inline"+ publicURL={publicURL}+ onUpdate={handlePublicURLUpdate}+ />+ <ManageLinkExpiry+ variant="inline"+ {...{ onRootClose, publicURL }}+ onUpdate={handlePublicURLUpdate}+ />+ <ManageDeviceLimit+ variant="inline"+ {...{ onRootClose, publicURL }}+ onUpdate={handlePublicURLUpdate}+ />+ <ManageDownloadAccess+ variant="inline"+ publicURL={publicURL}+ onUpdate={handlePublicURLUpdate}+ />+ <ManageJoinAlbum+ variant="inline"+ publicURL={publicURL}+ onUpdate={handlePublicURLUpdate}+ />+ <ManageLinkPassword+ variant="inline"+ publicURL={publicURL}+ onUpdate={handlePublicURLUpdate}+ />+ </Stack>+ <Stack sx={{ mt: 2, gap: 1 }}>+ <RowCard+ title={t("copy_link")}+ onClick={handleCopyLink}+ endIcon={+ copied ? (+ <DoneIcon />+ ) : (+ <ContentCopyIcon />+ )+ }+ />+ <RowCard+ title={t("copy_embed_html")}+ onClick={handleCopyEmbedLink}+ endIcon={+ embedCopied ? (+ <DoneIcon />+ ) : (+ <CodeIcon />+ )+ }+ />+ </Stack>+ </SidebarDrawerDepthContext.Provider>+ </SidebarPanelContext.Provider>+ </Box>+ <FocusVisibleButton+ color="critical"+ onClick={handleRemovePublicLink}+ sx={{+ alignSelf: "flex-start",+ ml: 1,+ px: 1,+ py: 1,+ bgcolor: "transparent",+ color: "critical.main",+ fontSize: 14,+ fontWeight: 600,+ "&:hover": { bgcolor: "fill.faintHover" },+ }}+ >+ {t("remove_link")}+ </FocusVisibleButton>+ {errorMessage && (+ <Typography+ variant="small"+ sx={{ px: 2, color: "critical.main" }}+ >+ {errorMessage}</Typography>- {content}- </SidebarDrawerDepthContext.Provider>- </SidebarPanelContext.Provider>- </Box>+ )}+ </Stack>+ </ThemeProvider>);}@@ -1908,6 +2015,7 @@ export const ManagePublicShareOptions: React.FC<};interface ManagePublicLinkSettingProps {+ variant?: "inline";publicURL: PublicURL;onUpdate: (req: UpdatePublicURLAttributes) => Promise<void>;}@@ -1917,6 +2025,7 @@ type ManagePublicLinkSettingDrawerProps = ManagePublicLinkSettingProps & {};const ManagePublicCollect: React.FC<ManagePublicLinkSettingProps> = ({+ variant,publicURL,onUpdate,}) => {@@ -1928,6 +2037,25 @@ const ManagePublicCollect: React.FC<ManagePublicLinkSettingProps> = ({void onUpdate({ enableComment: !publicURL.enableComment });};+ if (variant == "inline") {+ return (+ <Stack sx={{ gap: 1 }}>+ <PublicLinkSwitch+ variant={variant}+ label={t("allow_adding_photos")}+ checked={publicURL.enableCollect}+ onClick={handleCollectSetting}+ />+ <PublicLinkSwitch+ variant={variant}+ label={t("enable_comments")}+ checked={publicURL.enableComment}+ onClick={handleCommentSetting}+ />+ </Stack>+ );+ }+return (<Stack><RowButtonGroup>@@ -1948,6 +2076,7 @@ const ManagePublicCollect: React.FC<ManagePublicLinkSettingProps> = ({};const ManageLinkExpiry: React.FC<ManagePublicLinkSettingDrawerProps> = ({+ variant,onRootClose,publicURL,onUpdate,@@ -1964,17 +2093,21 @@ const ManageLinkExpiry: React.FC<ManagePublicLinkSettingDrawerProps> = ({return (<>- <RowButtonGroup>- <RowButton- onClick={showExpiryOptions}- endIcon={<ChevronRightIcon />}- label={t("link_expiry")}- color={- isLinkExpired(publicURL.validTill)- ? "critical"- : "primary"+ {variant == "inline" ? (+ <RowCard+ title={+ <Box+ component="span"+ sx={{+ color: isLinkExpired(publicURL.validTill)+ ? "critical.main"+ : "text.base",+ }}+ >+ {t("link_expiry")}+ </Box>}- caption={+ subtitle={isLinkExpired(publicURL.validTill)? t("link_expired"): publicURL.validTill@@ -1983,8 +2116,31 @@ const ManageLinkExpiry: React.FC<ManagePublicLinkSettingDrawerProps> = ({}): t("never")}+ onClick={showExpiryOptions}/>- </RowButtonGroup>+ ) : (+ <RowButtonGroup>+ <RowButton+ onClick={showExpiryOptions}+ endIcon={<ChevronRightIcon />}+ label={t("link_expiry")}+ color={+ isLinkExpired(publicURL.validTill)+ ? "critical"+ : "primary"+ }+ caption={+ isLinkExpired(publicURL.validTill)+ ? t("link_expired")+ : publicURL.validTill+ ? formattedDateTime(publicURL.validTill, {+ omitWeekdayWhenYearIncluded: true,+ })+ : t("never")+ }+ />+ </RowButtonGroup>+ )}<TitledNestedSidebarDraweranchor="right"{...expiryOptionsVisibilityProps}@@ -2044,6 +2200,7 @@ const microsecsAfter = (after: "hour" | "day" | "week" | "month" | "year") => {};const ManageDeviceLimit: React.FC<ManagePublicLinkSettingDrawerProps> = ({+ variant,onRootClose,publicURL,onUpdate,@@ -2060,16 +2217,28 @@ const ManageDeviceLimit: React.FC<ManagePublicLinkSettingDrawerProps> = ({return (<>- <RowButton- label={t("device_limit")}- caption={- publicURL.deviceLimit == 0- ? t("none")- : publicURL.deviceLimit.toString()- }- onClick={showDeviceOptions}- endIcon={<ChevronRightIcon />}- />+ {variant == "inline" ? (+ <RowCard+ title={t("device_limit")}+ subtitle={+ publicURL.deviceLimit == 0+ ? t("none")+ : publicURL.deviceLimit.toString()+ }+ onClick={showDeviceOptions}+ />+ ) : (+ <RowButton+ label={t("device_limit")}+ caption={+ publicURL.deviceLimit == 0+ ? t("none")+ : publicURL.deviceLimit.toString()+ }+ onClick={showDeviceOptions}+ endIcon={<ChevronRightIcon />}+ />+ )}<TitledNestedSidebarDraweranchor="right"{...deviceOptionsVisibilityProps}@@ -2104,6 +2273,7 @@ const deviceLimitOptions = () =>}));const ManageDownloadAccess: React.FC<ManagePublicLinkSettingProps> = ({+ variant,publicURL,onUpdate,}) => {@@ -2128,7 +2298,8 @@ const ManageDownloadAccess: React.FC<ManagePublicLinkSettingProps> = ({};return (- <RowSwitch+ <PublicLinkSwitch+ variant={variant}label={t("allow_downloads")}checked={publicURL.enableDownload}onClick={handleFileDownloadSetting}@@ -2137,6 +2308,7 @@ const ManageDownloadAccess: React.FC<ManagePublicLinkSettingProps> = ({};const ManageJoinAlbum: React.FC<ManagePublicLinkSettingProps> = ({+ variant,publicURL,onUpdate,}) => {@@ -2145,7 +2317,8 @@ const ManageJoinAlbum: React.FC<ManagePublicLinkSettingProps> = ({};return (- <RowSwitch+ <PublicLinkSwitch+ variant={variant}label={t("allow_joining_album")}checked={publicURL.enableJoin}onClick={handleJoinSetting}@@ -2154,6 +2327,7 @@ const ManageJoinAlbum: React.FC<ManagePublicLinkSettingProps> = ({};const ManageLinkPassword: React.FC<ManagePublicLinkSettingProps> = ({+ variant,publicURL,onUpdate,}) => {@@ -2179,7 +2353,8 @@ const ManageLinkPassword: React.FC<ManagePublicLinkSettingProps> = ({return (<>- <RowSwitch+ <PublicLinkSwitch+ variant={variant}label={t("password_lock")}checked={publicURL.passwordEnabled}onClick={handlePasswordChangeSetting}@@ -2192,6 +2367,24 @@ const ManageLinkPassword: React.FC<ManagePublicLinkSettingProps> = ({);};+const PublicLinkSwitch: React.FC<+ React.ComponentProps<typeof RowSwitch> & { variant?: "inline" }+> = ({ variant, label, checked, onClick }) =>+ variant == "inline" ? (+ <RowCard+ title={label}+ endIcon={+ <EnteSwitch+ checked={checked}+ onChange={onClick}+ slotProps={{ input: { "aria-label": label } }}+ />+ }+ />+ ) : (+ <RowSwitch {...{ label, checked, onClick }} />+ );+type SetPublicLinkPasswordProps = ModalVisibilityProps &ManagePublicLinkSettingProps;@@ -2269,12 +2462,14 @@ const SetPublicLinkPassword: React.FC<SetPublicLinkPasswordProps> = ({};interface ManageLayoutProps {+ variant?: "inline";onRootClose: () => void;collection: Collection;onRemotePull: (opts?: RemotePullOpts) => Promise<void>;}const ManageLayout: React.FC<ManageLayoutProps> = ({+ variant,onRootClose,collection,onRemotePull,@@ -2311,14 +2506,22 @@ const ManageLayout: React.FC<ManageLayoutProps> = ({return (<>- <RowButtonGroup>- <RowButton- label={t("album_layout")}- caption={layoutLabel(currentLayout)}+ {variant == "inline" ? (+ <RowCard+ title={t("album_layout")}+ subtitle={layoutLabel(currentLayout)}onClick={showLayoutOptions}- endIcon={<ChevronRightIcon />}/>- </RowButtonGroup>+ ) : (+ <RowButtonGroup>+ <RowButton+ label={t("album_layout")}+ caption={layoutLabel(currentLayout)}+ onClick={showLayoutOptions}+ endIcon={<ChevronRightIcon />}+ />+ </RowButtonGroup>+ )}<TitledNestedSidebarDraweranchor="right"{...layoutOptionsVisibilityProps}diff --git a/web/apps/photos/src/components/sidebar/theme.ts b/web/apps/photos/src/components/sidebar/theme.tsindex 4722273ba7..426ad52dbc 100644--- a/web/apps/photos/src/components/sidebar/theme.ts+++ b/web/apps/photos/src/components/sidebar/theme.ts@@ -6,8 +6,8 @@ const inter =const sidebarHeadingFont = '"Outfit Variable", Outfit, sans-serif';// Keep the settings palette local, including drawers and portalled menus.-export const sidebarTheme = (theme: Theme): Theme => {- const colors: CSSObject = {+export const sidebarStyles = (theme: Theme): CSSObject => {+ return {"--mui-palette-background-default": "#F4F4F4","--mui-palette-background-paper": "#FFFFFF","--mui-palette-background-paper2": "#FFFFFF",@@ -98,6 +98,10 @@ export const sidebarTheme = (theme: Theme): Theme => {color: "#969696",},};+};++export const sidebarTheme = (theme: Theme): Theme => {+ const colors = sidebarStyles(theme);return {...theme,