Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Use MenuComponent for active sessions

Aswin Asok926c1854b662
diff --git a/web/apps/photos/src/components/sidebar/account/SessionsSettings.tsx b/web/apps/photos/src/components/sidebar/account/SessionsSettings.tsx
index 5d4a9faba3..6cbe8cab01 100644
--- a/web/apps/photos/src/components/sidebar/account/SessionsSettings.tsx
+++ b/web/apps/photos/src/components/sidebar/account/SessionsSettings.tsx
@@ -1,10 +1,8 @@
-import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import DevicesIcon from "@mui/icons-material/Devices";
import RefreshIcon from "@mui/icons-material/Refresh";
import {
Box,
CircularProgress,
- Divider,
IconButton,
Stack,
Typography,
@@ -16,11 +14,12 @@ import {
terminateSession,
type Session,
} from "ente-accounts/services/sessions";
-import { RowButton, RowButtonGroup } from "ente-base/components/RowButton";
import {
TitledNestedSidebarDrawer,
type NestedSidebarDrawerVisibilityProps,
} from "ente-base/components/mui/SidebarDrawer";
+import { MenuComponent } from "ente-base/components/v2/MenuComponent";
+import { MenuGroupComponent } from "ente-base/components/v2/MenuGroupComponent";
import { useBaseContext } from "ente-base/context";
import { isHTTP401Error } from "ente-base/http";
import { formattedDateTime } from "ente-base/i18n-date";
@@ -208,8 +207,8 @@ const SessionsSettingsContents: React.FC<SessionsSettingsContentsProps> = ({
<Typography variant="small" sx={{ px: 0, color: "text.faint" }}>
{t("active_sessions_hint")}
</Typography>
- <RowButtonGroup>
- {sessions.map((session, index) => (
+ <MenuGroupComponent dividerInset={68}>
+ {sessions.map((session) => (
<SessionRow
key={session.token}
session={session}
@@ -218,10 +217,9 @@ const SessionsSettingsContents: React.FC<SessionsSettingsContentsProps> = ({
currentToken,
)}
onTerminate={() => handleTerminateSession(session)}
- showDivider={index < sessions.length - 1}
/>
))}
- </RowButtonGroup>
+ </MenuGroupComponent>
</Stack>
);
};
@@ -230,58 +228,38 @@ interface SessionRowProps {
session: Session;
isCurrentDevice: boolean;
onTerminate: () => void;
- showDivider: boolean;
}
const SessionRow: React.FC<SessionRowProps> = ({
session,
isCurrentDevice,
onTerminate,
- showDivider,
}) => {
const lastUsedFormatted = formattedDateTime(session.lastUsedTime);
return (
- <>
- <RowButton
- startIcon={<DevicesIcon />}
- label={
- <Stack sx={{ gap: 0.5, alignItems: "flex-start" }}>
- <Typography
- sx={{
- fontWeight: isCurrentDevice ? "bold" : "medium",
- color: isCurrentDevice
- ? "accent.main"
- : "text.base",
- textAlign: "left",
- }}
- >
- {isCurrentDevice
- ? t("this_device")
- : session.prettyUA}
- </Typography>
- {!isCurrentDevice && (
- <Typography
- variant="small"
- sx={{ color: "text.muted" }}
- >
- {session.ip.length > 28
- ? `${session.ip.slice(0, 28)}…`
- : session.ip}
- </Typography>
- )}
+ <MenuComponent
+ startIcon={<DevicesIcon />}
+ title={isCurrentDevice ? t("this_device") : session.prettyUA}
+ selected={isCurrentDevice}
+ description={
+ <Stack sx={{ gap: 0.5, mt: 0.5 }}>
+ {!isCurrentDevice && (
<Typography
variant="small"
- sx={{ color: "text.faint" }}
+ sx={{ color: "text.muted" }}
>
- {lastUsedFormatted}
+ {session.ip.length > 28
+ ? `${session.ip.slice(0, 28)}…`
+ : session.ip}
</Typography>
- </Stack>
- }
- endIcon={<ChevronRightIcon />}
- onClick={onTerminate}
- />
- {showDivider && <Divider sx={{ opacity: 0.4 }} />}
- </>
+ )}
+ <Typography variant="small" sx={{ color: "text.faint" }}>
+ {lastUsedFormatted}
+ </Typography>
+ </Stack>
+ }
+ onClick={onTerminate}
+ />
);
};
diff --git a/web/packages/base/components/v2/MenuComponent.tsx b/web/packages/base/components/v2/MenuComponent.tsx
index d60cdd55fa..52d46be2ce 100644
--- a/web/packages/base/components/v2/MenuComponent.tsx
+++ b/web/packages/base/components/v2/MenuComponent.tsx
@@ -5,6 +5,7 @@ import type { ReactNode } from "react";
interface MenuComponentProps {
title: string;
+ description?: ReactNode;
selected: boolean;
onClick: () => void;
startIcon?: ReactNode;
@@ -12,6 +13,7 @@ interface MenuComponentProps {
export function MenuComponent({
title,
+ description,
selected,
onClick,
startIcon,
@@ -58,21 +60,22 @@ export function MenuComponent({
{startIcon}
</Box>
)}
- <Typography
- sx={{
- flex: 1,
- minWidth: 0,
- fontSize: 14,
- lineHeight: "20px",
- fontWeight: 500,
- display: "-webkit-box",
- WebkitBoxOrient: "vertical",
- WebkitLineClamp: 2,
- overflow: "hidden",
- }}
- >
- {title}
- </Typography>
+ <Box sx={{ flex: 1, minWidth: 0 }}>
+ <Typography
+ sx={{
+ fontSize: 14,
+ lineHeight: "20px",
+ fontWeight: 500,
+ display: "-webkit-box",
+ WebkitBoxOrient: "vertical",
+ WebkitLineClamp: 2,
+ overflow: "hidden",
+ }}
+ >
+ {title}
+ </Typography>
+ {description}
+ </Box>
<Box
sx={{
width: 36,