Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Add back button for albums opened from overview

AswinAsok4d99317f86a3
diff --git a/web/apps/photos/src/components/collections/CollectionHeader.tsx b/web/apps/photos/src/components/collections/CollectionHeader.tsx
index 4963825a20..0c6f00b766 100644
--- a/web/apps/photos/src/components/collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/collections/CollectionHeader.tsx
@@ -21,6 +21,7 @@ import {
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import ArchiveOutlinedIcon from "@mui/icons-material/ArchiveOutlined";
+import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import CheckIcon from "@mui/icons-material/Check";
import LinkIcon from "@mui/icons-material/Link";
import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
@@ -98,12 +99,18 @@ export interface CollectionHeaderProps {
onAddSaveGroup: AddSaveGroup;
onShowMap: () => void;
onBackToAlbums: () => void;
+ showBackToAlbums: boolean;
onDescriptionHeightChange?: (height: number) => void;
}
export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {
- const { activeCollection, collectionSummary, onDescriptionHeightChange } =
- props;
+ const {
+ activeCollection,
+ collectionSummary,
+ onBackToAlbums,
+ showBackToAlbums,
+ onDescriptionHeightChange,
+ } = props;
const showCover = useMediaQuery(useTheme().breakpoints.up("sm"));
const { name, type, attributes, fileCount } = collectionSummary;
@@ -157,6 +164,17 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {
...(isAlbum && { gridArea: "summary" }),
}}
>
+ {isAlbum && showBackToAlbums && (
+ <Tooltip title={t("go_back")}>
+ <IconButton
+ aria-label={t("go_back")}
+ onClick={onBackToAlbums}
+ sx={{ width: 32, height: 32, flexShrink: 0 }}
+ >
+ <ArrowBackIcon sx={{ fontSize: 20 }} />
+ </IconButton>
+ </Tooltip>
+ )}
{isAlbum && showCover && (
<Box
aria-hidden
diff --git a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx
index 5f37cb4838..0404caf94f 100644
--- a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx
@@ -53,6 +53,7 @@ type GalleryBarAndListHeaderProps = {
| "onShowMap"
| "onCollectionSlideshow"
| "onBackToAlbums"
+ | "showBackToAlbums"
> &
Pick<
CollectionShareProps,
@@ -84,6 +85,7 @@ export const GalleryBarAndListHeader: React.FC<
onCollectionSlideshow,
setFileListHeader,
onBackToAlbums,
+ showBackToAlbums,
onBackToPeople,
}) => {
const { show: showCollectionShare, props: collectionShareVisibilityProps } =
@@ -151,6 +153,7 @@ export const GalleryBarAndListHeader: React.FC<
onShowMap,
onCollectionSlideshow,
onBackToAlbums,
+ showBackToAlbums,
}}
collectionSummary={collectionSummary}
onCollectionShare={openCollectionShare}
@@ -202,6 +205,7 @@ export const GalleryBarAndListHeader: React.FC<
onShowMap,
onCollectionSlideshow,
onBackToAlbums,
+ showBackToAlbums,
onBackToPeople,
onEditAlbumDetails,
albumDescription,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 7c840d98f7..8142cacfce 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -219,6 +219,8 @@ const Page: React.FC = () => {
});
const [albumFilter, setAlbumFilter] = useState<AlbumFilter>("ente");
const [albumSearchQuery, setAlbumSearchQuery] = useState("");
+ const [albumOpenedFromOverview, setAlbumOpenedFromOverview] =
+ useState<number>();
const [blockingLoad, setBlockingLoad] = useState(false);
const [peopleSortBy, setPeopleSortBy] =
useState<PeopleSortBy>("count-desc");
@@ -1560,6 +1562,7 @@ const Page: React.FC = () => {
const handleShowCollectionSummaryWithID = useCallback(
(collectionSummaryID: number | undefined) => {
+ setAlbumOpenedFromOverview(undefined);
setIsMapView(false);
setCleanupView(undefined);
// Museum deletes collection contents asynchronously; pull on entry.
@@ -2362,6 +2365,11 @@ const Page: React.FC = () => {
onAddSaveGroup,
}}
onBackToAlbums={handleBackToAlbums}
+ showBackToAlbums={
+ albumOpenedFromOverview !== undefined &&
+ albumOpenedFromOverview ===
+ collectionSummary?.id
+ }
onBackToPeople={handleBackToPeople}
mode={barMode}
shouldHide={isInSearchMode}
@@ -2431,7 +2439,10 @@ const Page: React.FC = () => {
filter={overviewFilter!}
searchQuery={albumSearchQuery}
sortBy={collectionsSortBy}
- onSelectAlbum={handleShowCollectionSummaryWithID}
+ onSelectAlbum={(collectionID) => {
+ handleShowCollectionSummaryWithID(collectionID);
+ setAlbumOpenedFromOverview(collectionID);
+ }}
onCreateAlbum={() => {
setPostCreateAlbumOp(undefined);
postCreateAlbumHidden.current = false;