Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Move all photos map to navigation rail

AswinAsokf852f84dd497
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index dd7885e7da..4a550f957b 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -2,8 +2,7 @@ import type { RemotePullOpts } from "@/components/gallery";
import { downloadAndSaveFiles } from "@/services/save";
import { uploadManager } from "@/services/upload-manager";
import { fileTimelineDateString } from "@/utils/file";
-import { IconButton, Tooltip, styled } from "@mui/material";
-import { useColorScheme, useTheme } from "@mui/material/styles";
+import { styled } from "@mui/material";
import type { AddSaveGroup } from "ente-gallery/components/utils/save-groups";
import {
FileViewer,
@@ -28,7 +27,6 @@ import {
export type FileListWithViewerProps = {
files: EnteFile[];
- onShowMap?: () => void;
enableDownload?: boolean;
enableImageEditing?: boolean;
onMarkTempDeleted?: (files: EnteFile[]) => void;
@@ -140,7 +138,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
pendingFileSidebar,
pendingHighlightCommentID,
onPendingNavigationConsumed,
- onShowMap,
}) => {
const [openFileViewer, setOpenFileViewer] = useState(false);
const [currentIndex, setCurrentIndex] = useState(0);
@@ -151,14 +148,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
string | undefined
>(undefined);
const { showNotification, setIsFileViewerOpen } = usePhotosAppContext();
- const { mode: colorSchemeMode, systemMode } = useColorScheme();
- const theme = useTheme();
- const resolvedMode =
- colorSchemeMode === "system"
- ? systemMode
- : (colorSchemeMode ?? theme.palette.mode);
- const isDarkMode = resolvedMode === "dark";
-
const updateOpenFileViewer = useCallback(
(open: boolean) => {
setOpenFileViewer(open);
@@ -249,39 +238,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
};
}, [enableImageEditing, showNotification]);
- const shouldShowMapButton =
- !!onShowMap &&
- modePlus !== "search" &&
- activeCollectionSummary?.type === "all" &&
- (activeCollectionSummary.fileCount > 0 || files.length > 0);
-
- const headerWithMap = useMemo(() => {
- if (!shouldShowMapButton || !header) return header;
- return {
- ...header,
- component: (
- <HeaderWithMap>
- <HeaderMain>{header.component}</HeaderMain>
- <Tooltip title={t("map")}>
- <IconButton
- className="map-button"
- size="small"
- aria-label={t("map")}
- onClick={onShowMap}
- >
- <MapIcon
- src="/images/gallery-globe/globe.svg"
- alt=""
- aria-hidden
- $isDarkMode={isDarkMode}
- />
- </IconButton>
- </Tooltip>
- </HeaderWithMap>
- ),
- };
- }, [header, isDarkMode, onShowMap, shouldShowMapButton]);
-
return (
<Container>
<AutoSizer>
@@ -291,7 +247,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
{...{
mode,
modePlus,
- header: headerWithMap,
+ header,
footer,
user,
disableGrouping,
@@ -363,30 +319,3 @@ const Container = styled("div")`
flex: 1;
width: 100%;
`;
-
-const HeaderWithMap = styled("div")`
- display: flex;
- align-items: center;
- justify-content: flex-start;
- gap: 12px;
- width: 100%;
- & > .map-button {
- flex-shrink: 0;
- margin-left: auto;
- }
-`;
-
-const HeaderMain = styled("div")`
- flex: 1;
- min-width: 0;
-`;
-
-const MapIcon = styled("img")<{ $isDarkMode: boolean }>(
- ({ theme, $isDarkMode }) => ({
- display: "block",
- width: 24,
- height: 24,
- filter:
- $isDarkMode || theme.palette.mode === "dark" ? "invert(1)" : "none",
- }),
-);
diff --git a/web/apps/photos/src/components/collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/collections/CollectionMapDialog.tsx
index cfa9335f85..1d70762323 100644
--- a/web/apps/photos/src/components/collections/CollectionMapDialog.tsx
+++ b/web/apps/photos/src/components/collections/CollectionMapDialog.tsx
@@ -80,6 +80,7 @@ interface CollectionMapDialogProps
| "onSelectPerson"
| "emailByUserID"
> {
+ embedded?: boolean;
collectionSummary: CollectionSummary;
files: EnteFile[];
mapFileSource: MapFileSource;
@@ -1002,6 +1003,7 @@ function createMarkerIcon(
export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
open,
onClose,
+ embedded = false,
collectionSummary,
files,
onRemotePull,
@@ -1149,7 +1151,10 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
);
} else if (!mapPoints.length || !mapCenter || !mapIndex) {
body = (
- <CenteredBox onClose={onClose} closeLabel={t("close")}>
+ <CenteredBox
+ onClose={embedded ? undefined : onClose}
+ closeLabel={t("close")}
+ >
<Typography variant="body" sx={{ color: "text.secondary" }}>
{t("no_geotagged_photos")}
</Typography>
@@ -1159,6 +1164,7 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
body = (
<Box sx={{ position: "relative", height: "100%", width: "100%" }}>
<CollectionSidebar
+ showCloseButton={!embedded}
collectionSummary={collectionSummary}
visibleFiles={visibleFiles}
isVisiblePhotosUpdating={isVisiblePhotosUpdating}
@@ -1203,6 +1209,21 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
);
}
+ if (embedded) {
+ return (
+ <Box
+ sx={{
+ position: "relative",
+ flex: 1,
+ minHeight: 0,
+ width: "100%",
+ }}
+ >
+ {body}
+ </Box>
+ );
+ }
+
return (
<Dialog
fullScreen
@@ -1234,6 +1255,7 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
};
interface CollectionSidebarProps {
+ showCloseButton: boolean;
collectionSummary: CollectionSummary;
visibleFiles: EnteFile[];
isVisiblePhotosUpdating: boolean;
@@ -1268,6 +1290,7 @@ const MOBILE_SIDEBAR_HEIGHT = "50%";
const COVER_HEADER_HEIGHT = COVER_IMAGE_HEIGHT + 34;
function CollectionSidebar({
+ showCloseButton,
collectionSummary,
visibleFiles,
isVisiblePhotosUpdating,
@@ -1381,17 +1404,19 @@ function CollectionSidebar({
{visibleDate && ` Β· ${visibleDate}`}
</Typography>
</Box>
- <IconButton
- onClick={onClose}
- size="small"
- sx={{
- color: "text.secondary",
- bgcolor: "fill.faint",
- "&:hover": { bgcolor: "fill.muted" },
- }}
- >
- <CloseIcon />
- </IconButton>
+ {showCloseButton && (
+ <IconButton
+ onClick={onClose}
+ size="small"
+ sx={{
+ color: "text.secondary",
+ bgcolor: "fill.faint",
+ "&:hover": { bgcolor: "fill.muted" },
+ }}
+ >
+ <CloseIcon />
+ </IconButton>
+ )}
</Box>
</StickyDateHeader>
<FileListContainer>
diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
index 1b776fec04..0441b0ebdb 100644
--- a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
+++ b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
@@ -6,6 +6,7 @@ import {
DashboardSquare01Icon,
Home01Icon,
Link04Icon,
+ Location01Icon,
Settings01Icon,
Upload01Icon,
User02Icon,
@@ -57,6 +58,8 @@ type PhotosNavigationShellProps = SearchBarProps & {
onSidebar: () => void;
onUpload: () => void;
onHome: () => void;
+ onShowMap: () => void;
+ isMapView: boolean;
mode: GalleryBarMode;
onChangeMode: (mode: GalleryBarMode) => boolean;
};
@@ -238,6 +241,7 @@ export const PhotosNavigationShell: React.FC<
<NormalNavigationRail
{...props}
isHome={
+ !props.isMapView &&
props.mode == "albums" &&
!props.isInSearchMode &&
galleryNavigation?.activeCollectionID ==
@@ -246,6 +250,7 @@ export const PhotosNavigationShell: React.FC<
onChangeMode={handleChangeMode}
opensDialog={mobile}
navigationOpen={
+ !props.isMapView &&
!!galleryNavigation &&
(mobile
? mobileDrawerProps.open
@@ -290,11 +295,13 @@ export const PhotosNavigationShell: React.FC<
flex: 1,
minWidth: 0,
minHeight: 0,
- pt: {
- xs: `${thumbnailGridPadding}px`,
- md: "36px",
- },
- px: { xs: 0, md: "12px" },
+ pt: props.isMapView
+ ? 0
+ : {
+ xs: `${thumbnailGridPadding}px`,
+ md: "36px",
+ },
+ px: props.isMapView ? 0 : { xs: 0, md: "12px" },
"--mui-palette-background-default": "#FFFFFF",
bgcolor: "background.default",
borderRadius: "20px",
@@ -392,6 +399,8 @@ const NormalNavigationRail: React.FC<
> = ({
onSidebar,
onHome,
+ onShowMap,
+ isMapView,
mode,
onChangeMode,
isHome,
@@ -460,6 +469,34 @@ const NormalNavigationRail: React.FC<
</Tooltip>
),
)}
+ <Tooltip title={t("map")}>
+ <FocusVisibleButton
+ color="secondary"
+ aria-label={t("map")}
+ aria-pressed={isMapView}
+ onClick={onShowMap}
+ sx={{
+ minWidth: 0,
+ width: 38,
+ height: 38,
+ flexShrink: 0,
+ p: 0,
+ borderRadius: "12px",
+ color: "text.base",
+ '&[aria-pressed="true"]': {
+ color: "#FFFFFF",
+ bgcolor: "accent.main",
+ "&:hover": { bgcolor: "accent.main" },
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={Location01Icon}
+ size={20}
+ strokeWidth={1.8}
+ />
+ </FocusVisibleButton>
+ </Tooltip>
<Box sx={{ flex: 1 }} />
<Tooltip title={t("settings")}>
<FocusVisibleButton
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 9861e54fbf..90897cc564 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -326,20 +326,25 @@ const Page: React.FC = () => {
const { show: showCollectionMap, props: collectionMapVisibilityProps } =
useModalVisibility();
const closeCollectionMap = collectionMapVisibilityProps.onClose;
+ const [isMapView, setIsMapView] = useState(false);
- const handleShowCollectionMap = useCallback(() => {
- void (async () => {
- if (!mapEnabled) {
- try {
- await updateMapEnabled(true);
- } catch (e) {
- onGenericError(e);
- return;
+ const handleShowCollectionMap = useCallback(
+ (embedded = false) => {
+ void (async () => {
+ if (!mapEnabled) {
+ try {
+ await updateMapEnabled(true);
+ } catch (e) {
+ onGenericError(e);
+ return;
+ }
}
- }
- showCollectionMap();
- })();
- }, [mapEnabled, onGenericError, showCollectionMap]);
+ if (embedded) setIsMapView(true);
+ else showCollectionMap();
+ })();
+ },
+ [mapEnabled, onGenericError, showCollectionMap],
+ );
const [albumAddedNotification, setAlbumAddedNotification] = useState<{
open: boolean;
@@ -1501,6 +1506,7 @@ const Page: React.FC = () => {
searchOption: SearchOption | undefined,
options?: { shouldExitSearchMode?: boolean },
) => {
+ setIsMapView(false);
if (searchOption) {
const type = searchOption.suggestion.type;
if (type == "sidebarAction") {
@@ -1557,6 +1563,7 @@ const Page: React.FC = () => {
const handleShowCollectionSummaryWithID = useCallback(
(collectionSummaryID: number | undefined) => {
+ setIsMapView(false);
setCleanupView(undefined);
// Museum deletes collection contents asynchronously; pull on entry.
if (collectionSummaryID == PseudoCollectionID.trash) {
@@ -1591,6 +1598,7 @@ const Page: React.FC = () => {
const handleShowCleanupView = useCallback(
(view: "large-files" | "duplicates") => {
+ setIsMapView(false);
setSelected({
ownCount: 0,
count: 0,
@@ -1634,6 +1642,7 @@ const Page: React.FC = () => {
return false;
}
onNavigate?.();
+ setIsMapView(false);
setCleanupView(undefined);
dispatch({ type: "showPeople" });
return true;
@@ -1771,6 +1780,7 @@ const Page: React.FC = () => {
const handleSelectCollection = useCallback(
(collectionID: number) => {
+ setIsMapView(false);
closeCollectionMap();
dispatch({
type: "showCollectionSummary",
@@ -1783,6 +1793,7 @@ const Page: React.FC = () => {
const handleSelectPerson = useCallback(
(personID: string) => {
setCleanupView(undefined);
+ setIsMapView(false);
closeCollectionMap();
dispatch({ type: "showPerson", personID });
},
@@ -2143,6 +2154,29 @@ const Page: React.FC = () => {
dispatch({ type: "selectLink", collectionID })
: handleShowCollectionSummaryWithID;
+ const collectionMap = activeCollectionSummary && (
+ <CollectionMapDialog
+ {...collectionMapVisibilityProps}
+ embedded={isMapView}
+ open={isMapView || collectionMapVisibilityProps.open}
+ onClose={isMapView ? () => setIsMapView(false) : closeCollectionMap}
+ collectionSummary={activeCollectionSummary}
+ files={activeCollection ? activeCollectionFiles : filteredFiles}
+ mapFileSource={mapFileSource}
+ onRemotePull={remotePull}
+ onAddSaveGroup={onAddSaveGroup}
+ onMarkTempDeleted={handleMarkTempDeleted}
+ onAddFileToCollection={handleAddSingleFileToCollection}
+ onRemoteFilesPull={remoteFilesPull}
+ onVisualFeedback={handleVisualFeedback}
+ fileNormalCollectionIDs={fileNormalCollectionIDs}
+ collectionNameByID={collectionNameByID}
+ emailByUserID={state.emailByUserID}
+ onSelectCollection={handleSelectCollection}
+ onSelectPerson={handleSelectPerson}
+ />
+ );
+
return (
<>
<FullScreenDropZone
@@ -2188,19 +2222,31 @@ const Page: React.FC = () => {
isInSearchMode={isInSearchMode}
isSettingsOpen={sidebarVisibilityProps.open}
mode={barMode}
- onChangeMode={handleChangeBarMode}
+ isMapView={isMapView}
+ onChangeMode={(mode) => {
+ const changed = handleChangeBarMode(mode);
+ if (changed) setIsMapView(false);
+ return changed;
+ }}
onSidebar={showSidebar}
onUpload={openUploader}
- onHome={() =>
+ onShowMap={() => {
handleShowCollectionSummaryWithID(
PseudoCollectionID.all,
- )
- }
+ );
+ handleShowCollectionMap(true);
+ }}
+ onHome={() => {
+ setIsMapView(false);
+ handleShowCollectionSummaryWithID(
+ PseudoCollectionID.all,
+ );
+ }}
onSelectSearchOption={handleSelectSearchOption}
onSelectPeople={handleShowPeople}
onSelectPerson={handleSelectPerson}
galleryNavigation={
- isCleanupViewOpen
+ isCleanupViewOpen || isMapView
? undefined
: {
activeCollectionID:
@@ -2271,7 +2317,7 @@ const Page: React.FC = () => {
) : null
}
>
- {!isCleanupViewOpen && (
+ {!isMapView && !isCleanupViewOpen && (
<>
<GalleryBarAndListHeader
hiddenAlbums={sidebarCollectionSummaries}
@@ -2293,7 +2339,7 @@ const Page: React.FC = () => {
setActiveCollectionID={selectGalleryCollection}
onSelectPerson={handleSelectPerson}
onEditAlbumDetails={showEditAlbumDetails}
- onShowMap={handleShowCollectionMap}
+ onShowMap={() => handleShowCollectionMap()}
onCollectionSlideshow={startSlideshow}
emailByUserID={state.emailByUserID}
shareSuggestionEmails={
@@ -2303,7 +2349,9 @@ const Page: React.FC = () => {
/>
</>
)}
- {cleanupView === "duplicates" ? (
+ {isMapView ? (
+ collectionMap
+ ) : cleanupView === "duplicates" ? (
<DuplicatesView onRemoteFilesPull={remoteFilesPull} />
) : cleanupView === "large-files" ? (
<LargeFilesView onRemoteFilesPull={remoteFilesPull} />
@@ -2379,7 +2427,6 @@ const Page: React.FC = () => {
footer={fileListFooter}
user={user}
files={filteredFiles}
- onShowMap={handleShowCollectionMap}
enableDownload={true}
disableGrouping={
state.searchSuggestion?.type == "clip" ||
@@ -2512,29 +2559,7 @@ const Page: React.FC = () => {
onClose={closeSlideshow}
/>
)}
- {activeCollectionSummary && (
- <CollectionMapDialog
- {...collectionMapVisibilityProps}
- collectionSummary={activeCollectionSummary}
- files={
- activeCollection
- ? activeCollectionFiles
- : filteredFiles
- }
- mapFileSource={mapFileSource}
- onRemotePull={remotePull}
- onAddSaveGroup={onAddSaveGroup}
- onMarkTempDeleted={handleMarkTempDeleted}
- onAddFileToCollection={handleAddSingleFileToCollection}
- onRemoteFilesPull={remoteFilesPull}
- onVisualFeedback={handleVisualFeedback}
- fileNormalCollectionIDs={fileNormalCollectionIDs}
- collectionNameByID={collectionNameByID}
- emailByUserID={state.emailByUserID}
- onSelectCollection={handleSelectCollection}
- onSelectPerson={handleSelectPerson}
- />
- )}
+ {!isMapView && collectionMap}
{activeCollection && editAlbumDetailsVisibilityProps.open && (
<EditAlbumDetailsDialog
key={activeCollection.id}