Skip to content

armgit / ente

Public Imported from GitHub
0

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

wip: checkpoint

Manav Rathi7ff5d4015237
diff --git a/web/apps/photos/src/components/Collections/AllCollections/header.tsx b/web/apps/photos/src/components/Collections/AllCollections/header.tsx
deleted file mode 100644
index 3d227367bf..0000000000
--- a/web/apps/photos/src/components/Collections/AllCollections/header.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import {
- FlexWrapper,
- FluidContainer,
- IconButtonWithBG,
-} from "@ente/shared/components/Container";
-import Close from "@mui/icons-material/Close";
-import { Box, DialogTitle, Stack, Typography } from "@mui/material";
-import { CollectionsSortOptions } from "components/Collections/CollectionListSortOptions";
-import { t } from "i18next";
-
-export default function AllCollectionsHeader({
- onClose,
- collectionCount,
- collectionSortBy,
- setCollectionSortBy,
- isInHiddenSection,
-}) {
- return (
- <DialogTitle>
- <FlexWrapper>
- <FluidContainer mr={1.5}>
- <Box>
- <Typography variant="h3">
- {isInHiddenSection
- ? t("all_hidden_albums")
- : t("all_albums")}
- </Typography>
- <Typography variant="small" color={"text.muted"}>
- {t("albums_count", { count: collectionCount })}
- </Typography>
- </Box>
- </FluidContainer>
- <Stack direction="row" spacing={1.5}>
- <CollectionsSortOptions
- activeSortBy={collectionSortBy}
- setSortBy={setCollectionSortBy}
- nestedInDialog
- />
- <IconButtonWithBG onClick={onClose}>
- <Close />
- </IconButtonWithBG>
- </Stack>
- </FlexWrapper>
- </DialogTitle>
- );
-}
diff --git a/web/apps/photos/src/components/Collections/AllCollections/index.tsx b/web/apps/photos/src/components/Collections/AllCollections/index.tsx
index 363960db03..24030a6e87 100644
--- a/web/apps/photos/src/components/Collections/AllCollections/index.tsx
+++ b/web/apps/photos/src/components/Collections/AllCollections/index.tsx
@@ -1,33 +1,47 @@
import type { CollectionSummary } from "@/new/photos/types/collection";
import { CollectionsSortBy } from "@/new/photos/types/collection";
-import { Divider, useMediaQuery } from "@mui/material";
+import {
+ FlexWrapper,
+ FluidContainer,
+ IconButtonWithBG,
+} from "@ente/shared/components/Container";
+import Close from "@mui/icons-material/Close";
+import {
+ Box,
+ DialogTitle,
+ Divider,
+ Stack,
+ Typography,
+ useMediaQuery,
+} from "@mui/material";
import {
AllCollectionDialog,
Transition,
} from "components/Collections/AllCollections/dialog";
+import { t } from "i18next";
+import { CollectionsSortOptions } from "../CollectionsSortOptions";
import AllCollectionContent from "./content";
-import AllCollectionsHeader from "./header";
-interface Iprops {
+interface AllCollectionsProps {
open: boolean;
onClose: () => void;
collectionSummaries: CollectionSummary[];
setActiveCollectionID: (id?: number) => void;
- collectionListSortBy: CollectionsSortBy;
- setCollectionListSortBy: (v: CollectionsSortBy) => void;
+ collectionsSortBy: CollectionsSortBy;
+ onChangeCollectionsSortBy: (by: CollectionsSortBy) => void;
isInHiddenSection: boolean;
}
const LeftSlideTransition = Transition("up");
-export default function AllCollections(props: Iprops) {
+export default function AllCollections(props: AllCollectionsProps) {
const {
collectionSummaries,
open,
onClose,
setActiveCollectionID,
- collectionListSortBy,
- setCollectionListSortBy,
+ collectionsSortBy,
+ onChangeCollectionsSortBy,
isInHiddenSection,
} = props;
const isMobile = useMediaQuery("(max-width: 428px)");
@@ -47,11 +61,13 @@ export default function AllCollections(props: Iprops) {
fullWidth={true}
>
<AllCollectionsHeader
- isInHiddenSection={isInHiddenSection}
- onClose={onClose}
+ {...{
+ isInHiddenSection,
+ onClose,
+ collectionsSortBy,
+ onChangeCollectionsSortBy,
+ }}
collectionCount={props.collectionSummaries.length}
- collectionSortBy={collectionListSortBy}
- setCollectionSortBy={setCollectionListSortBy}
/>
<Divider />
<AllCollectionContent
@@ -61,3 +77,38 @@ export default function AllCollections(props: Iprops) {
</AllCollectionDialog>
);
}
+
+const AllCollectionsHeader = ({
+ onClose,
+ collectionCount,
+ collectionsSortBy,
+ onChangeCollectionsSortBy,
+ isInHiddenSection,
+}) => (
+ <DialogTitle>
+ <FlexWrapper>
+ <FluidContainer mr={1.5}>
+ <Box>
+ <Typography variant="h3">
+ {isInHiddenSection
+ ? t("all_hidden_albums")
+ : t("all_albums")}
+ </Typography>
+ <Typography variant="small" color={"text.muted"}>
+ {t("albums_count", { count: collectionCount })}
+ </Typography>
+ </Box>
+ </FluidContainer>
+ <Stack direction="row" spacing={1.5}>
+ <CollectionsSortOptions
+ activeSortBy={collectionsSortBy}
+ onChangeSortBy={onChangeCollectionsSortBy}
+ nestedInDialog
+ />
+ <IconButtonWithBG onClick={onClose}>
+ <Close />
+ </IconButtonWithBG>
+ </Stack>
+ </FlexWrapper>
+ </DialogTitle>
+);
diff --git a/web/apps/photos/src/components/Collections/CollectionListBar.tsx b/web/apps/photos/src/components/Collections/CollectionListBar.tsx
index 52f4f184f4..3a17c83dd5 100644
--- a/web/apps/photos/src/components/Collections/CollectionListBar.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionListBar.tsx
@@ -33,7 +33,7 @@ import React, {
import AutoSizer from "react-virtualized-auto-sizer";
import { FixedSizeList, ListChildComponentProps, areEqual } from "react-window";
import type { GalleryBarMode } from ".";
-import { CollectionsSortOptions } from "./CollectionListSortOptions";
+import { CollectionsSortOptions } from "./CollectionsSortOptions";
export interface CollectionListBarProps {
/**
diff --git a/web/apps/photos/src/components/Collections/CollectionsSortOptions.tsx b/web/apps/photos/src/components/Collections/CollectionsSortOptions.tsx
index 49e1772714..7e93db6f92 100644
--- a/web/apps/photos/src/components/Collections/CollectionsSortOptions.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionsSortOptions.tsx
@@ -32,56 +32,60 @@ interface CollectionsSortOptionsProps {
* the {@link CollectionsSortBy} values that should be used for sorting the
* lists of collections.
*/
-export const CollectionsSortOptions: React.FC<CollectionsSortOptionsProps> = (
- props,
-) => {
- const SortByOption = SortByOptionCreator(props);
+export const CollectionsSortOptions: React.FC<CollectionsSortOptionsProps> = ({
+ nestedInDialog,
+ disableTriggerButtonBackground,
+ ...optProps
+}) => (
+ <OverflowMenu
+ ariaControls="collection-sort"
+ triggerButtonIcon={<SortIcon />}
+ menuPaperProps={{
+ sx: {
+ backgroundColor: (theme) =>
+ nestedInDialog && theme.colors.background.elevated2,
+ },
+ }}
+ triggerButtonProps={{
+ sx: {
+ background: (theme) =>
+ !disableTriggerButtonBackground && theme.colors.fill.faint,
+ },
+ }}
+ >
+ <SortByOption {...optProps} sortBy="name">
+ {t("sort_by_name")}
+ </SortByOption>
+ <SortByOption {...optProps} sortBy="creation-time-asc">
+ {t("sort_by_creation_time_ascending")}
+ </SortByOption>
+ <SortByOption {...optProps} sortBy="updation-time-desc">
+ {t("sort_by_updation_time_descending")}
+ </SortByOption>
+ </OverflowMenu>
+);
+
+type SortByOptionProps = Pick<
+ CollectionsSortOptionsProps,
+ "activeSortBy" | "onChangeSortBy"
+> & {
+ sortBy: CollectionsSortBy;
+};
+
+const SortByOption: React.FC<React.PropsWithChildren<SortByOptionProps>> = ({
+ sortBy,
+ activeSortBy,
+ onChangeSortBy,
+ children,
+}) => {
+ const handleClick = () => onChangeSortBy(sortBy);
return (
- <OverflowMenu
- ariaControls="collection-sort"
- triggerButtonIcon={<SortIcon />}
- menuPaperProps={{
- sx: {
- backgroundColor: (theme) =>
- props.nestedInDialog &&
- theme.colors.background.elevated2,
- },
- }}
- triggerButtonProps={{
- sx: {
- background: (theme) =>
- !props.disableTriggerButtonBackground &&
- theme.colors.fill.faint,
- },
- }}
+ <OverflowMenuOption
+ onClick={handleClick}
+ endIcon={activeSortBy == sortBy ? <TickIcon /> : <SvgIcon />}
>
- <SortByOption sortBy="name">{t("sort_by_name")}</SortByOption>
- <SortByOption sortBy="creation-time-asc">
- {t("sort_by_creation_time_ascending")}
- </SortByOption>
- <SortByOption sortBy="updation-time-desc">
- {t("sort_by_updation_time_descending")}
- </SortByOption>
- </OverflowMenu>
+ {children}
+ </OverflowMenuOption>
);
};
-
-const SortByOptionCreator =
- ({ onChangeSortBy, activeSortBy }: CollectionsSortOptionsProps) =>
- (props: { sortBy: CollectionsSortBy; children: any }) => {
- const handleClick = () => {
- onChangeSortBy(props.sortBy);
- };
-
- return (
- <OverflowMenuOption
- onClick={handleClick}
- endIcon={
- activeSortBy === props.sortBy ? <TickIcon /> : <SvgIcon />
- }
- >
- {props.children}
- </OverflowMenuOption>
- );
- };
diff --git a/web/apps/photos/src/components/Collections/index.tsx b/web/apps/photos/src/components/Collections/index.tsx
index 2709fad0a2..13f77e9f1b 100644
--- a/web/apps/photos/src/components/Collections/index.tsx
+++ b/web/apps/photos/src/components/Collections/index.tsx
@@ -188,8 +188,8 @@ export const Collections: React.FC<CollectionsProps> = ({
(x) => !isSystemCollection(x.type),
)}
setActiveCollectionID={setActiveCollectionID}
- setCollectionListSortBy={setCollectionsSortBy}
- collectionListSortBy={collectionsSortBy}
+ onChangeCollectionsSortBy={setCollectionsSortBy}
+ collectionsSortBy={collectionsSortBy}
isInHiddenSection={mode == "hidden-albums"}
/>
<CollectionShare