Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add notifications button and sidebar to album collection header

Anand Baburajanc4ea9e739890
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 8169bb778f..52a0b9da3d 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -73,6 +73,7 @@ export interface CollectionHeaderProps {
onRemotePull: (opts?: RemotePullOpts) => Promise<void>;
onCollectionShare: () => void;
onCollectionCast: () => void;
+ onCollectionNotifications: () => void;
/**
* A function that can be used to create a UI notification to track the
* progress of user-initiated download, and to cancel it if needed.
@@ -124,6 +125,7 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
onRemotePull,
onCollectionShare,
onCollectionCast,
+ onCollectionNotifications,
onAddSaveGroup,
isActiveCollectionDownloadInProgress,
}) => {
@@ -550,6 +552,7 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
isDownloadInProgress={isActiveCollectionDownloadInProgress}
onEmptyTrashClick={confirmEmptyTrash}
onDownloadClick={downloadCollection}
+ onNotificationsClick={onCollectionNotifications}
onShareClick={onCollectionShare}
/>
{validMenuOptions.length > 0 && (
@@ -593,12 +596,14 @@ interface QuickOptionsProps {
isDownloadInProgress: () => boolean;
onEmptyTrashClick: () => void;
onDownloadClick: () => void;
+ onNotificationsClick: () => void;
onShareClick: () => void;
}
const QuickOptions: React.FC<QuickOptionsProps> = ({
onEmptyTrashClick,
onDownloadClick,
+ onNotificationsClick,
onShareClick,
collectionSummary,
isDownloadInProgress,
@@ -617,6 +622,9 @@ const QuickOptions: React.FC<QuickOptionsProps> = ({
onClick={onDownloadClick}
/>
))}
+ {showNotificationsQuickOption(collectionSummary) && (
+ <NotificationsQuickOption onClick={onNotificationsClick} />
+ )}
{showShareQuickOption(collectionSummary) && (
<ShareQuickOption
collectionSummary={collectionSummary}
@@ -670,6 +678,45 @@ const DownloadQuickOption: React.FC<DownloadQuickOptionProps> = ({
</Tooltip>
);
+const showNotificationsQuickOption = ({ type }: CollectionSummary) =>
+ type == "album" || type == "folder";
+
+const NotificationsIcon: React.FC = () => (
+ <svg
+ width="18"
+ height="19"
+ viewBox="0 0 20 21"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M13.5 16.5C13.5 18.433 11.933 20 10 20C8.067 20 6.5 18.433 6.5 16.5M17.2311 16.5H2.76887C1.79195 16.5 1 15.708 1 14.7311C1 14.262 1.18636 13.8121 1.51809 13.4803L2.12132 12.8771C2.68393 12.3145 3 11.5514 3 10.7558V8C3 4.13401 6.13401 1 10 1C13.866 1 17 4.134 17 8V10.7558C17 11.5514 17.3161 12.3145 17.8787 12.8771L18.4819 13.4803C18.8136 13.8121 19 14.262 19 14.7311C19 15.708 18.208 16.5 17.2311 16.5Z"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+);
+
+const NotificationsQuickOption: React.FC<OptionProps> = ({ onClick }) => (
+ <Tooltip title={t("notifications")}>
+ <IconButton onClick={onClick}>
+ <Box
+ sx={{
+ width: 24,
+ height: 24,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
+ <NotificationsIcon />
+ </Box>
+ </IconButton>
+ </Tooltip>
+);
+
const showShareQuickOption = ({ type, attributes }: CollectionSummary) =>
type == "album" ||
type == "folder" ||
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 71ce9b68a5..7f6465b3a3 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -11,6 +11,7 @@ import {
isSaveComplete,
type SaveGroup,
} from "ente-gallery/components/utils/save-groups";
+import { NotificationsSidebar } from "ente-gallery/components/viewer/NotificationsSidebar";
import { sortFiles } from "ente-gallery/utils/file";
import type { Collection } from "ente-media/collection";
import type { EnteFile } from "ente-media/file";
@@ -104,6 +105,10 @@ export const GalleryBarAndListHeader: React.FC<
useModalVisibility();
const { show: showCollectionCast, props: collectionCastVisibilityProps } =
useModalVisibility();
+ const {
+ show: showCollectionNotifications,
+ props: collectionNotificationsVisibilityProps,
+ } = useModalVisibility();
const [collectionsSortBy, setCollectionsSortBy] =
useCollectionsSortByLocalState("updation-time-desc");
@@ -151,6 +156,7 @@ export const GalleryBarAndListHeader: React.FC<
}
onCollectionShare={showCollectionShare}
onCollectionCast={showCollectionCast}
+ onCollectionNotifications={showCollectionNotifications}
/>
) : activePerson ? (
<PeopleHeader
@@ -172,6 +178,7 @@ export const GalleryBarAndListHeader: React.FC<
activePerson,
showCollectionShare,
showCollectionCast,
+ showCollectionNotifications,
// TODO: Cluster
// This causes a loop since it is an array dep
// people,
@@ -230,6 +237,10 @@ export const GalleryBarAndListHeader: React.FC<
{...collectionCastVisibilityProps}
collection={activeCollection}
/>
+ <NotificationsSidebar
+ {...collectionNotificationsVisibilityProps}
+ albumName={activeCollection?.name ?? ""}
+ />
</>
);
};
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index 7e1c3ce740..be31e9e5ce 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -243,6 +243,7 @@
"delete_photos": "Delete photos",
"keep_photos": "Keep photos",
"share_album": "Share album",
+ "notifications": "Notifications",
"sharing_with_self": "You cannot share with yourself",
"sharing_already_shared": "You're already sharing this with {{email}}",
"sharing_album_not_allowed": "Sharing album not allowed",
diff --git a/web/packages/gallery/components/viewer/NotificationsSidebar.tsx b/web/packages/gallery/components/viewer/NotificationsSidebar.tsx
new file mode 100644
index 0000000000..c3cbeb8fd5
--- /dev/null
+++ b/web/packages/gallery/components/viewer/NotificationsSidebar.tsx
@@ -0,0 +1,137 @@
+import CloseIcon from "@mui/icons-material/Close";
+import { Box, Drawer, IconButton, Stack, styled, Typography } from "@mui/material";
+import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
+import React from "react";
+
+// =============================================================================
+// Types
+// =============================================================================
+
+export interface NotificationsSidebarProps extends ModalVisibilityProps {
+ /**
+ * The name of the album to display in the header.
+ */
+ albumName: string;
+}
+
+// =============================================================================
+// Main Component
+// =============================================================================
+
+/**
+ * A sidebar panel for displaying notifications for an album.
+ */
+export const NotificationsSidebar: React.FC<NotificationsSidebarProps> = ({
+ open,
+ onClose,
+ albumName,
+}) => {
+ return (
+ <SidebarDrawer open={open} onClose={onClose} anchor="right">
+ <DrawerContentWrapper>
+ <Header>
+ <Typography
+ sx={(theme) => ({
+ color: "#000",
+ fontWeight: 600,
+ ...theme.applyStyles("dark", { color: "#fff" }),
+ })}
+ >
+ {albumName}
+ </Typography>
+ <CloseButton onClick={onClose}>
+ <CloseIcon sx={{ fontSize: 22 }} />
+ </CloseButton>
+ </Header>
+
+ <ContentContainer>
+ {/* Main content will be added later */}
+ </ContentContainer>
+ </DrawerContentWrapper>
+ </SidebarDrawer>
+ );
+};
+
+// =============================================================================
+// Styled Components
+// =============================================================================
+
+// Drawer & Layout
+const SidebarDrawer = styled(Drawer)(({ theme }) => ({
+ "& .MuiDrawer-paper": {
+ width: "23vw",
+ minWidth: "520px",
+ maxWidth: "calc(100% - 32px)",
+ height: "calc(100% - 32px)",
+ margin: "16px",
+ borderRadius: "36px",
+ backgroundColor: "#fff",
+ padding: "24px 24px 32px 24px",
+ boxShadow: "none",
+ border: "1px solid #E0E0E0",
+ display: "flex",
+ flexDirection: "column",
+ overflow: "visible",
+ "@media (max-width: 450px)": {
+ width: "100%",
+ minWidth: "unset",
+ maxWidth: "100%",
+ height: "100%",
+ margin: 0,
+ borderRadius: 0,
+ },
+ ...theme.applyStyles("dark", {
+ backgroundColor: "#1b1b1b",
+ border: "1px solid rgba(255, 255, 255, 0.18)",
+ }),
+ },
+ "& .MuiBackdrop-root": { backgroundColor: "transparent" },
+}));
+
+const DrawerContentWrapper = styled(Box)(() => ({
+ position: "relative",
+ display: "flex",
+ flexDirection: "column",
+ flex: 1,
+ minHeight: 0,
+}));
+
+const Header = styled(Stack)(() => ({
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between",
+ marginBottom: 48,
+}));
+
+const CloseButton = styled(IconButton)(({ theme }) => ({
+ backgroundColor: "#F5F5F7",
+ color: "#000",
+ padding: "8px",
+ "&:hover": { backgroundColor: "#E5E5E7" },
+ ...theme.applyStyles("dark", {
+ backgroundColor: "rgba(255, 255, 255, 0.12)",
+ color: "#fff",
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },
+ }),
+}));
+
+const ContentContainer = styled(Box)(({ theme }) => ({
+ flex: 1,
+ overflow: "auto",
+ marginRight: -24,
+ paddingRight: 24,
+ "&::-webkit-scrollbar": { width: "6px" },
+ "&::-webkit-scrollbar-track": { background: "transparent" },
+ "&::-webkit-scrollbar-thumb": {
+ background: "rgba(0, 0, 0, 0.2)",
+ borderRadius: "3px",
+ },
+ scrollbarWidth: "thin",
+ scrollbarColor: "rgba(0, 0, 0, 0.2) transparent",
+ ...theme.applyStyles("dark", {
+ "&::-webkit-scrollbar-thumb": {
+ background: "rgba(255, 255, 255, 0.2)",
+ },
+ scrollbarColor: "rgba(255, 255, 255, 0.2) transparent",
+ }),
+}));