Skip to content

armgit / ente

Public Imported from GitHub
0

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

[photos][web] Remove All People dialog

AswinAsok9d047a970f3f
diff --git a/web/apps/photos/src/components/Collections/AllPeople.tsx b/web/apps/photos/src/components/Collections/AllPeople.tsx
deleted file mode 100644
index 11e48b9b4e..0000000000
--- a/web/apps/photos/src/components/Collections/AllPeople.tsx
+++ /dev/null
@@ -1,1066 +0,0 @@
-import {
- CollectionTileButton,
- CollectionTileTextOverlay,
- CollectionDialogSearchField as SearchField,
-} from "@/components/CollectionDialog/Primitives";
-import {
- collectionDialogBodyMutedSx,
- collectionDialogDividerSx,
- collectionDialogFullScreenQuery,
- collectionDialogHeaderActionsSx,
- collectionDialogHeaderRowSx,
- collectionDialogHeaderSx,
- collectionDialogIconButtonSx,
- collectionDialogNoResultsSx,
- collectionDialogPaperSx,
- collectionDialogTitleSx,
-} from "@/components/CollectionDialog/styles";
-import { PeopleSortOptions } from "@/components/PeopleSortOptions";
-import { useWrapAsyncOperation } from "@/components/utils/use-wrap-async";
-import { sortPeople, type PeopleSortBy } from "@/utils/people-sort";
-import {
- ArrowDownDoubleIcon,
- ArrowUpDoubleIcon,
-} from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
-import AddIcon from "@mui/icons-material/Add";
-import CloseIcon from "@mui/icons-material/Close";
-import EditIcon from "@mui/icons-material/Edit";
-import HideImageOutlinedIcon from "@mui/icons-material/HideImageOutlined";
-import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
-import PushPinIcon from "@mui/icons-material/PushPin";
-import PushPinOutlinedIcon from "@mui/icons-material/PushPinOutlined";
-import {
- Box,
- Button,
- Dialog,
- IconButton,
- Stack,
- Tooltip,
- Typography,
- styled,
- useMediaQuery,
-} from "@mui/material";
-import {
- OverflowMenu,
- OverflowMenuOption,
-} from "ente-base/components/OverflowMenu";
-import { SingleInputDialog } from "ente-base/components/SingleInputDialog";
-import { useBaseContext } from "ente-base/context";
-import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
-import { ItemCard } from "ente-new/photos/components/Tiles";
-import {
- addCGroup,
- addClusterToCGroup,
- ignoreCluster,
- pinCGroup,
- renameCGroup,
- unpinCGroup,
-} from "ente-new/photos/services/ml";
-import type { FaceCluster } from "ente-new/photos/services/ml/cluster";
-import type {
- CGroupPerson,
- ClusterPerson,
- Person,
-} from "ente-new/photos/services/ml/people";
-import { t } from "i18next";
-import memoize from "memoize-one";
-import React, {
- useCallback,
- useEffect,
- useId,
- useMemo,
- useRef,
- useState,
-} from "react";
-import AutoSizer from "react-virtualized-auto-sizer";
-import {
- VariableSizeList,
- areEqual,
- type ListChildComponentProps,
-} from "react-window";
-
-interface AllPeopleProps {
- open: boolean;
- onClose: () => void;
- people: Person[];
- allPeople: Person[];
- onSelectPerson: (id: string) => void;
- peopleSortBy: PeopleSortBy;
- onChangePeopleSortBy: (by: PeopleSortBy) => void;
-}
-
-export const AllPeople: React.FC<AllPeopleProps> = ({
- open,
- onClose,
- people,
- allPeople,
- onSelectPerson,
- peopleSortBy,
- onChangePeopleSortBy,
-}) => {
- const fullScreen = useMediaQuery(collectionDialogFullScreenQuery);
- const titleID = useId();
- const { showMiniDialog } = useBaseContext();
- const [searchTerm, setSearchTerm] = useState("");
- const [showingAllPeople, setShowingAllPeople] = useState(false);
- const [personToRename, setPersonToRename] = useState<CGroupPerson>();
- const [clusterToName, setClusterToName] = useState<ClusterPerson>();
-
- const handleExited = () => {
- setSearchTerm("");
- setShowingAllPeople(false);
- };
-
- const handleSelectPerson = (personID: string) => {
- onSelectPerson(personID);
- onClose();
- };
-
- const handleRenamePerson = async (name: string) => {
- if (!personToRename) return;
- await renameCGroup(personToRename.cgroup, name);
- setPersonToRename(undefined);
- };
-
- const handlePinPerson = useWrapAsyncOperation(
- async (person: CGroupPerson) =>
- person.isPinned
- ? unpinCGroup(person.cgroup)
- : pinCGroup(person.cgroup),
- );
-
- const handleIgnorePerson = (person: ClusterPerson) => {
- showMiniDialog({
- title: t("ignore_person_confirm"),
- message: t("ignore_person_confirm_message"),
- continue: {
- text: t("ignore"),
- color: "primary",
- action: () => ignoreCluster(person.cluster),
- },
- });
- };
-
- const hasSearchQuery = !!searchTerm.trim();
-
- const extraPeople = useMemo(() => {
- const visiblePersonIDs = new Set(people.map(({ id }) => id));
- const extra = allPeople.filter(
- (person) =>
- !visiblePersonIDs.has(person.id) &&
- !(person.type == "cgroup" && person.isHidden),
- );
- return sortPeople(extra, peopleSortBy);
- }, [allPeople, people, peopleSortBy]);
-
- const handleToggleShowingAllPeople = () => {
- setShowingAllPeople((value) => !value);
- };
-
- const searchablePeople = useMemo(
- () =>
- showingAllPeople || people.length == 0
- ? sortPeople(people.concat(extraPeople), peopleSortBy)
- : people,
- [extraPeople, people, peopleSortBy, showingAllPeople],
- );
-
- const filteredSearchPeople = useMemo(() => {
- if (!searchTerm.trim()) {
- return searchablePeople;
- }
-
- const searchLower = searchTerm.toLowerCase();
- return searchablePeople.filter((person) =>
- person.name?.toLowerCase().includes(searchLower),
- );
- }, [searchTerm, searchablePeople]);
-
- const primaryPeople = hasSearchQuery
- ? filteredSearchPeople
- : people.length == 0
- ? extraPeople
- : people;
- const expandedPeople =
- !hasSearchQuery && showingAllPeople && people.length > 0
- ? extraPeople
- : [];
-
- const visiblePeopleCount = primaryPeople.length + expandedPeople.length;
- const totalPeopleCount = hasSearchQuery
- ? searchablePeople.length
- : visiblePeopleCount;
-
- return (
- <>
- <Dialog
- {...{ open, onClose, fullScreen }}
- aria-labelledby={titleID}
- maxWidth={false}
- sx={{
- "& .MuiDialog-container": { justifyContent: "flex-end" },
- "& .MuiDialog-paper": {
- borderRadius: "32px",
- [`@media ${collectionDialogFullScreenQuery}`]: {
- borderRadius: 0,
- },
- },
- }}
- slots={{ transition: SlideUpTransition }}
- slotProps={{
- paper: { sx: collectionDialogPaperSx },
- transition: { onExited: handleExited },
- }}
- >
- <Title
- titleID={titleID}
- onClose={onClose}
- peopleCount={visiblePeopleCount}
- totalCount={totalPeopleCount}
- searchTerm={searchTerm}
- onSearchChange={setSearchTerm}
- peopleSortBy={peopleSortBy}
- onChangePeopleSortBy={onChangePeopleSortBy}
- />
- <Box sx={collectionDialogDividerSx} />
- <AllPeopleContent
- primaryPeople={primaryPeople}
- expandedPeople={expandedPeople}
- hasSearchQuery={hasSearchQuery}
- showMoreFacesButton={
- people.length > 0 && extraPeople.length > 0
- }
- showingAllPeople={showingAllPeople}
- onToggleShowingAllPeople={handleToggleShowingAllPeople}
- onSelectPerson={handleSelectPerson}
- onRenamePerson={setPersonToRename}
- onPinPerson={handlePinPerson}
- onAddName={setClusterToName}
- onIgnorePerson={handleIgnorePerson}
- />
- </Dialog>
- <SingleInputDialog
- open={!!personToRename}
- onClose={() => setPersonToRename(undefined)}
- title={t("rename_person")}
- label={t("name")}
- placeholder={t("enter_name")}
- autoComplete="name"
- initialValue={personToRename?.name ?? ""}
- submitButtonColor="primary"
- submitButtonTitle={t("rename")}
- onSubmit={handleRenamePerson}
- />
- <AddPersonDialog
- open={!!clusterToName}
- onClose={() => setClusterToName(undefined)}
- people={people}
- cluster={clusterToName?.cluster}
- />
- </>
- );
-};
-
-const GridColumns = 3;
-const GridGap = 8;
-const GridPaddingInline = 20;
-const ShowMoreFacesButtonHeight = 56;
-const ShowMoreFacesButtonVerticalGap = 16;
-const ShowMoreFacesRowItemSize =
- ShowMoreFacesButtonHeight + 2 * ShowMoreFacesButtonVerticalGap;
-const ExpandedPeopleTopSpacing = 4;
-const personCardShellClassName = "all-people-person-card";
-
-type TitleProps = {
- titleID: string;
- peopleCount: number;
- totalCount: number;
- searchTerm: string;
- onSearchChange: (value: string) => void;
- peopleSortBy: PeopleSortBy;
- onChangePeopleSortBy: (by: PeopleSortBy) => void;
-} & Pick<AllPeopleProps, "onClose">;
-
-const Title: React.FC<TitleProps> = ({
- titleID,
- onClose,
- peopleCount,
- totalCount,
- searchTerm,
- onSearchChange,
- peopleSortBy,
- onChangePeopleSortBy,
-}) => (
- <Stack sx={collectionDialogHeaderSx}>
- <Stack direction="row" sx={collectionDialogHeaderRowSx}>
- <Stack sx={{ minWidth: 0, gap: "2px" }}>
- <Typography
- id={titleID}
- component="h2"
- sx={collectionDialogTitleSx}
- >
- {t("people")}
- </Typography>
- <Typography sx={collectionDialogBodyMutedSx}>
- {searchTerm
- ? `${peopleCount} / ${totalCount} ${t("people")}`
- : `${peopleCount} ${t("people")}`}
- </Typography>
- </Stack>
- <Stack direction="row" sx={collectionDialogHeaderActionsSx}>
- <PeopleSortOptions
- activeSortBy={peopleSortBy}
- onChangeSortBy={onChangePeopleSortBy}
- nestedInDialog
- variant="v2"
- />
- <IconButton
- aria-label={t("close")}
- onClick={onClose}
- sx={collectionDialogIconButtonSx}
- >
- <CloseIcon sx={{ fontSize: 18 }} />
- </IconButton>
- </Stack>
- </Stack>
- <SearchField
- value={searchTerm}
- onChange={onSearchChange}
- placeholder={t("people_search_hint")}
- />
- </Stack>
-);
-
-interface AllPeopleContentProps {
- primaryPeople: Person[];
- expandedPeople: Person[];
- hasSearchQuery: boolean;
- showMoreFacesButton: boolean;
- showingAllPeople: boolean;
- onToggleShowingAllPeople: () => void;
- onSelectPerson: (id: string) => void;
- onRenamePerson: (person: CGroupPerson) => void;
- onPinPerson: (person: CGroupPerson) => void | Promise<void>;
- onAddName: (person: ClusterPerson) => void;
- onIgnorePerson: (person: ClusterPerson) => void;
-}
-
-type PeopleListItem =
- | { type: "people"; people: Person[]; topSpacing?: boolean }
- | { type: "showMoreButton" };
-
-interface ItemData extends Pick<
- AllPeopleContentProps,
- | "showingAllPeople"
- | "onToggleShowingAllPeople"
- | "onSelectPerson"
- | "onRenamePerson"
- | "onPinPerson"
- | "onAddName"
- | "onIgnorePerson"
-> {
- tileSize: number;
- items: PeopleListItem[];
-}
-
-const createItemData = memoize(
- (
- tileSize: number,
- items: PeopleListItem[],
- showingAllPeople: boolean,
- onToggleShowingAllPeople: () => void,
- onSelectPerson: (id: string) => void,
- onRenamePerson: (person: CGroupPerson) => void,
- onPinPerson: (person: CGroupPerson) => void | Promise<void>,
- onAddName: (person: ClusterPerson) => void,
- onIgnorePerson: (person: ClusterPerson) => void,
- ) => ({
- tileSize,
- items,
- showingAllPeople,
- onToggleShowingAllPeople,
- onSelectPerson,
- onRenamePerson,
- onPinPerson,
- onAddName,
- onIgnorePerson,
- }),
-);
-
-const peopleListItems = (
- people: Person[],
- columns: number,
- firstRowTopSpacing = false,
-): PeopleListItem[] => {
- const items: PeopleListItem[] = [];
- for (let index = 0; index < people.length; index += columns) {
- items.push({
- type: "people",
- people: people.slice(index, index + columns),
- topSpacing: firstRowTopSpacing && index == 0,
- });
- }
- return items;
-};
-
-const peopleListItemSize = (
- item: PeopleListItem | undefined,
- tileSize: number,
-) => {
- switch (item?.type) {
- case "showMoreButton":
- return ShowMoreFacesRowItemSize;
- default:
- return (
- tileSize +
- GridGap +
- (item?.topSpacing ? ExpandedPeopleTopSpacing : 0)
- );
- }
-};
-
-const PeopleRow = React.memo(
- ({ data, index, style }: ListChildComponentProps<ItemData>) => {
- const {
- items,
- tileSize,
- showingAllPeople,
- onToggleShowingAllPeople,
- onSelectPerson,
- onRenamePerson,
- onPinPerson,
- onAddName,
- onIgnorePerson,
- } = data;
- const item = items[index]!;
-
- if (item.type == "showMoreButton") {
- return (
- <div style={style}>
- <ShowMoreFacesButton
- showingAllPeople={showingAllPeople}
- onClick={onToggleShowingAllPeople}
- />
- </div>
- );
- }
-
- return (
- <div style={style}>
- <Stack
- direction="row"
- sx={{
- boxSizing: "border-box",
- height: "100%",
- "--tile-size": `${tileSize}px`,
- px: `${GridPaddingInline}px`,
- pt: item.topSpacing
- ? `${ExpandedPeopleTopSpacing}px`
- : 0,
- pb: `${GridGap}px`,
- gap: `${GridGap}px`,
- }}
- >
- {item.people.map((person) => (
- <PersonCard
- key={person.id}
- person={person}
- onSelectPerson={onSelectPerson}
- onRenamePerson={onRenamePerson}
- onPinPerson={onPinPerson}
- onAddName={onAddName}
- onIgnorePerson={onIgnorePerson}
- />
- ))}
- </Stack>
- </div>
- );
- },
- areEqual,
-);
-
-const AllPeopleContent: React.FC<AllPeopleContentProps> = ({
- primaryPeople,
- expandedPeople,
- hasSearchQuery,
- showMoreFacesButton,
- showingAllPeople,
- onToggleShowingAllPeople,
- onSelectPerson,
- onRenamePerson,
- onPinPerson,
- onAddName,
- onIgnorePerson,
-}) => {
- const columns = GridColumns;
- const listOuterRef = useRef<HTMLDivElement>(null);
- const [scrollbarWidth, setScrollbarWidth] = useState(0);
- const handleListOuterRef = useCallback((element: HTMLDivElement | null) => {
- listOuterRef.current = element;
- if (element) {
- setScrollbarWidth(element.offsetWidth - element.clientWidth);
- }
- }, []);
-
- const shouldShowMoreFacesButton = showMoreFacesButton && !hasSearchQuery;
- const shouldShowExpandedPeople =
- showingAllPeople && expandedPeople.length > 0;
-
- const items = useMemo(() => {
- const items = peopleListItems(primaryPeople, columns);
-
- if (shouldShowMoreFacesButton) {
- items.push({ type: "showMoreButton" });
- }
-
- if (shouldShowMoreFacesButton && shouldShowExpandedPeople) {
- items.push(...peopleListItems(expandedPeople, columns, true));
- }
-
- return items;
- }, [
- columns,
- expandedPeople,
- primaryPeople,
- shouldShowExpandedPeople,
- shouldShowMoreFacesButton,
- ]);
-
- const handleToggleShowingAllPeople = () => {
- onToggleShowingAllPeople();
- if (!showingAllPeople && shouldShowMoreFacesButton) {
- window.requestAnimationFrame(() => {
- listOuterRef.current?.scrollBy({
- top: ShowMoreFacesRowItemSize,
- behavior: "smooth",
- });
- });
- }
- };
-
- if (hasSearchQuery && primaryPeople.length === 0) {
- return (
- <Box sx={collectionDialogNoResultsSx}>
- <Typography sx={collectionDialogBodyMutedSx}>
- {t("no_results")}
- </Typography>
- </Box>
- );
- }
-
- const primaryRowCount = Math.ceil(primaryPeople.length / columns);
- const listKey = `${shouldShowMoreFacesButton}-${primaryRowCount}`;
-
- return (
- <Box sx={{ flex: 1, minHeight: 0, pt: "16px", pb: "20px" }}>
- <AutoSizer>
- {({ width, height }) => {
- const tileSize = Math.max(
- 0,
- Math.floor(
- (width -
- scrollbarWidth -
- 2 * GridPaddingInline -
- (GridColumns - 1) * GridGap) /
- GridColumns,
- ),
- );
- return (
- <VariableSizeList
- {...{ width, height }}
- outerRef={handleListOuterRef}
- // Keep the measured gutter stable as rows are added
- // or removed, including when searching for people.
- style={{ scrollbarGutter: "stable" }}
- key={`${listKey}-${tileSize}`}
- itemCount={items.length}
- itemSize={(index) =>
- peopleListItemSize(items[index], tileSize)
- }
- itemData={createItemData(
- tileSize,
- items,
- showingAllPeople,
- handleToggleShowingAllPeople,
- onSelectPerson,
- onRenamePerson,
- onPinPerson,
- onAddName,
- onIgnorePerson,
- )}
- >
- {PeopleRow}
- </VariableSizeList>
- );
- }}
- </AutoSizer>
- </Box>
- );
-};
-
-interface ShowMoreFacesButtonProps {
- showingAllPeople: boolean;
- onClick: () => void;
-}
-
-const ShowMoreFacesButton: React.FC<ShowMoreFacesButtonProps> = ({
- showingAllPeople,
- onClick,
-}) => (
- <Box
- sx={{
- px: `${GridPaddingInline}px`,
- py: `${ShowMoreFacesButtonVerticalGap}px`,
- }}
- >
- <Button
- fullWidth
- variant="text"
- onClick={onClick}
- startIcon={
- <HugeiconsIcon
- icon={
- showingAllPeople
- ? ArrowUpDoubleIcon
- : ArrowDownDoubleIcon
- }
- size={20}
- strokeWidth={1.5}
- />
- }
- sx={{
- color: "text.base",
- backgroundColor: "fill.faint",
- border: 0,
- borderRadius: "16px",
- height: `${ShowMoreFacesButtonHeight}px`,
- minHeight: `${ShowMoreFacesButtonHeight}px`,
- "&:hover": { backgroundColor: "fill.muted" },
- }}
- >
- {showingAllPeople ? t("show_less_faces") : t("show_more_faces")}
- </Button>
- </Box>
-);
-
-interface PersonCardProps {
- person: Person;
- onSelectPerson: (id: string) => void;
- onRenamePerson: (person: CGroupPerson) => void;
- onPinPerson: (person: CGroupPerson) => void | Promise<void>;
- onAddName: (person: ClusterPerson) => void;
- onIgnorePerson: (person: ClusterPerson) => void;
-}
-
-const PersonCard: React.FC<PersonCardProps> = ({
- person,
- onSelectPerson,
- onRenamePerson,
- onPinPerson,
- onAddName,
- onIgnorePerson,
-}) => (
- <PersonCardShell className={personCardShellClassName}>
- <ItemCard
- TileComponent={CollectionTileButton}
- coverFile={person.displayFaceFile}
- coverFaceID={person.displayFaceID}
- onClick={() => onSelectPerson(person.id)}
- >
- <CollectionTileTextOverlay>
- {person.name && (
- <Tooltip title={person.name} arrow>
- <Typography
- sx={{
- fontSize: 14,
- lineHeight: "20px",
- fontWeight: 500,
- paddingRight: "18px",
- overflow: "hidden",
- textOverflow: "ellipsis",
- display: "-webkit-box",
- WebkitLineClamp: 3,
- WebkitBoxOrient: "vertical",
- }}
- >
- {person.name}
- </Typography>
- </Tooltip>
- )}
- <Typography
- sx={{
- fontSize: 12,
- lineHeight: "16px",
- fontWeight: 500,
- opacity: 0.7,
- }}
- >
- {t("photos_count", { count: person.fileIDs.length })}
- </Typography>
- </CollectionTileTextOverlay>
- {person.isPinned && (
- <PinnedIconContainer>
- <PushPinIcon sx={{ fontSize: 20, color: "white" }} />
- </PinnedIconContainer>
- )}
- </ItemCard>
- <PersonActionMenu
- person={person}
- onRenamePerson={onRenamePerson}
- onPinPerson={onPinPerson}
- onAddName={onAddName}
- onIgnorePerson={onIgnorePerson}
- />
- </PersonCardShell>
-);
-
-const PersonCardShell = styled("div")`
- position: relative;
- flex: none;
- width: var(--tile-size);
- height: var(--tile-size);
-`;
-
-const PinnedIconContainer = styled(Box)`
- position: absolute;
- inset-inline-end: 8px;
- inset-block-end: 8px;
- display: flex;
-`;
-
-interface PersonActionMenuProps {
- person: Person;
- onRenamePerson: (person: CGroupPerson) => void;
- onPinPerson: (person: CGroupPerson) => void | Promise<void>;
- onAddName: (person: ClusterPerson) => void;
- onIgnorePerson: (person: ClusterPerson) => void;
-}
-
-const PersonActionMenu: React.FC<PersonActionMenuProps> = ({
- person,
- onRenamePerson,
- onPinPerson,
- onAddName,
- onIgnorePerson,
-}) => {
- const menuOptions =
- person.type === "cgroup"
- ? [
- <OverflowMenuOption
- key="rename"
- compact
- startIcon={<EditIcon />}
- onClick={() => onRenamePerson(person)}
- >
- {t("rename")}
- </OverflowMenuOption>,
- person.isPinned ? (
- <OverflowMenuOption
- key="unpin"
- compact
- startIcon={<PushPinOutlinedIcon />}
- onClick={() => void onPinPerson(person)}
- >
- {t("unpin_person")}
- </OverflowMenuOption>
- ) : (
- <OverflowMenuOption
- key="pin"
- compact
- startIcon={<PushPinIcon />}
- onClick={() => void onPinPerson(person)}
- >
- {t("pin_person")}
- </OverflowMenuOption>
- ),
- ]
- : [
- <OverflowMenuOption
- key="add-name"
- compact
- startIcon={<AddIcon />}
- onClick={() => onAddName(person)}
- >
- {t("add_a_name")}
- </OverflowMenuOption>,
- <OverflowMenuOption
- key="ignore"
- compact
- startIcon={<HideImageOutlinedIcon />}
- onClick={() => onIgnorePerson(person)}
- >
- {t("ignore")}
- </OverflowMenuOption>,
- ];
-
- return (
- <ActionMenuContainer>
- <OverflowMenu
- ariaID={`person-modal-options-${person.id}`}
- triggerButtonIcon={<MoreHorizIcon sx={{ fontSize: 18 }} />}
- triggerButtonSxProps={{
- color: "white",
- minWidth: 24,
- minHeight: 24,
- padding: "2px",
- opacity: 0.9,
- "&:hover": { backgroundColor: "transparent", opacity: 1 },
- }}
- menuPaperSxProps={(theme) => ({
- minWidth: 238,
- width: 238,
- mt: "6px",
- border: "1px solid #ececec",
- borderRadius: "16px",
- backgroundColor: "background.paper",
- boxShadow: "0 4px 4px rgba(0 0 0 / 0.16)",
- overflow: "hidden",
- "& .MuiList-root": { p: 0.75 },
- "& .MuiMenuItem-root": {
- minHeight: 40,
- height: 40,
- boxSizing: "border-box",
- py: "10px",
- px: "12px",
- borderRadius: "8px",
- color: "text.base",
- "&:hover": { backgroundColor: "fill.faintHover" },
- },
- "& .MuiTypography-root": {
- fontSize: 14,
- lineHeight: "20px",
- fontWeight: 500,
- },
- ...theme.applyStyles("dark", {
- borderColor: "rgba(255 255 255 / 0.12)",
- backgroundColor: "#282828",
- boxShadow: "0 4px 4px rgba(0 0 0 / 0.40)",
- }),
- })}
- >
- {menuOptions}
- </OverflowMenu>
- </ActionMenuContainer>
- );
-};
-
-const ActionMenuContainer = styled(Box)`
- position: absolute;
- inset-block-start: 8px;
- inset-inline-end: 8px;
- z-index: 1;
- opacity: 0;
- pointer-events: none;
- transition: opacity 120ms ease;
-
- .${personCardShellClassName}:hover &,
- .${personCardShellClassName}:focus-within & {
- opacity: 1;
- pointer-events: auto;
- }
-
- @media (hover: none) {
- opacity: 1;
- pointer-events: auto;
- }
-`;
-
-interface AddPersonDialogProps {
- open: boolean;
- onClose: () => void;
- people: Person[];
- cluster: FaceCluster | undefined;
-}
-
-const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
- open,
- onClose,
- people,
- cluster,
-}) => {
- const isFullScreen = useMediaQuery(collectionDialogFullScreenQuery);
- const titleID = useId();
- const [openNameInput, setOpenNameInput] = useState(false);
-
- const cgroupPeople: CGroupPerson[] = people.filter(
- (person): person is CGroupPerson => person.type != "cluster",
- );
-
- useEffect(() => {
- if (!open) {
- setOpenNameInput(false);
- return;
- }
- if (!cgroupPeople.length) {
- setOpenNameInput(true);
- }
- }, [open, cgroupPeople.length]);
-
- const handleAddPerson = () => setOpenNameInput(true);
-
- const handleAddPersonBySelect = useWrapAsyncOperation(
- async (personID: string) => {
- if (!cluster) return;
- const person = cgroupPeople.find((p) => p.id == personID);
- if (!person) return;
-
- await addClusterToCGroup(person.cgroup, cluster);
- setOpenNameInput(false);
- onClose();
- },
- );
-
- const handleAddPersonWithName = async (name: string) => {
- if (!cluster) return;
- await addCGroup(name, cluster);
- setOpenNameInput(false);
- onClose();
- };
-
- return (
- <>
- <Dialog
- open={open && cgroupPeople.length > 0}
- onClose={onClose}
- fullScreen={isFullScreen}
- aria-labelledby={titleID}
- maxWidth={false}
- sx={{
- "& .MuiDialog-paper": {
- borderRadius: "32px",
- [`@media ${collectionDialogFullScreenQuery}`]: {
- borderRadius: 0,
- },
- },
- }}
- slots={{ transition: SlideUpTransition }}
- slotProps={{ paper: { sx: collectionDialogPaperSx } }}
- >
- <Stack sx={collectionDialogHeaderSx}>
- <Stack direction="row" sx={collectionDialogHeaderRowSx}>
- <Typography id={titleID} sx={collectionDialogTitleSx}>
- {t("add_name")}
- </Typography>
- <IconButton
- aria-label={t("close")}
- onClick={onClose}
- sx={collectionDialogIconButtonSx}
- >
- <CloseIcon sx={{ fontSize: 20 }} />
- </IconButton>
- </Stack>
- </Stack>
- <Box sx={collectionDialogDividerSx} />
- <DialogContent_>
- <CollectionTileButton
- onClick={handleAddPerson}
- aria-label={t("new_person")}
- sx={(theme) => ({
- boxSizing: "border-box",
- border: "1px dashed",
- borderColor: "stroke.muted",
- color: "text.muted",
- "&:hover": { borderColor: "rgba(0 0 0 / 0.45)" },
- ...theme.applyStyles("dark", {
- "&:hover": {
- borderColor: "rgba(255 255 255 / 0.45)",
- },
- }),
- })}
- >
- <AddIcon
- sx={{
- position: "absolute",
- top: "50%",
- left: "50%",
- transform: "translate(-50%, -50%)",
- fontSize: 20,
- }}
- />
- </CollectionTileButton>
- {cgroupPeople.map((person) => (
- <PersonPickerCard
- key={person.id}
- person={person}
- onPersonClick={handleAddPersonBySelect}
- />
- ))}
- </DialogContent_>
- </Dialog>
-
- <SingleInputDialog
- open={openNameInput}
- variant="people"
- sx={{ "& .MuiDialog-paper": { borderRadius: "32px" } }}
- onClose={() => {
- setOpenNameInput(false);
- if (!cgroupPeople.length) {
- onClose();
- }
- }}
- title={t("new_person")}
- label={t("add_name")}
- placeholder={t("enter_name")}
- autoComplete="name"
- submitButtonColor="primary"
- submitButtonTitle={t("add")}
- onSubmit={handleAddPersonWithName}
- />
- </>
- );
-};
-
-const DialogContent_ = styled(Box)({
- flex: 1,
- minHeight: 0,
- overflowY: "auto",
- display: "grid",
- gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
- gridAutoRows: "max-content",
- alignContent: "start",
- alignItems: "start",
- gap: `${GridGap}px`,
- // Keep the scroll track clear of the dialog's rounded bottom corners.
- marginBlock: "16px 32px",
- marginInlineEnd: "8px",
- paddingInline: `${GridPaddingInline}px ${GridPaddingInline - 8}px`,
- scrollbarGutter: "stable",
-});
-
-interface PersonPickerCardProps {
- person: Person;
- onPersonClick: (personID: string) => void;
-}
-
-const PersonPickerCard: React.FC<PersonPickerCardProps> = ({
- person,
- onPersonClick,
-}) => (
- <ItemCard
- TileComponent={CollectionTileButton}
- coverFile={person.displayFaceFile}
- coverFaceID={person.displayFaceID}
- onClick={() => onPersonClick(person.id)}
- >
- <CollectionTileTextOverlay>
- <Tooltip title={person.name ?? ""} arrow>
- <Typography
- sx={{
- fontSize: 14,
- lineHeight: "20px",
- fontWeight: 500,
- overflow: "hidden",
- textOverflow: "ellipsis",
- display: "-webkit-box",
- WebkitLineClamp: 3,
- WebkitBoxOrient: "vertical",
- overflowWrap: "anywhere",
- }}
- >
- {person.name ?? ""}
- </Typography>
- </Tooltip>
- </CollectionTileTextOverlay>
- </ItemCard>
-);
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 6738c001f8..0db9cee011 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -1,5 +1,4 @@
// TODO: Audit this file
-import { AllPeople } from "@/components/Collections/AllPeople";
import {
CollectionShare,
type CollectionShareIntent,
@@ -35,7 +34,6 @@ import {
type CollectionSummaries,
type CollectionSummary,
} from "ente-new/photos/services/collection-summary";
-import type { Person } from "ente-new/photos/services/ml/people";
import { includes } from "ente-utils/type-guards";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { AlbumCastDialog } from "./AlbumCastDialog";
@@ -53,7 +51,6 @@ export type GalleryBarAndListHeaderProps = Omit<
| "collectionsSortBy"
| "onChangeCollectionsSortBy"
| "onCreateAlbum"
- | "onShowAllPeople"
> & {
onAlbumSummariesChange: (
albums: CollectionSummary[],
@@ -61,7 +58,6 @@ export type GalleryBarAndListHeaderProps = Omit<
) => void;
shouldHide: boolean;
barCollectionSummaries: CollectionSummaries;
- allPeople: Person[];
activeCollection: Collection | undefined;
setActiveCollectionID: (collectionID: number) => void;
setFileListHeader: (header: FileListHeaderOrFooter) => void;
@@ -104,7 +100,6 @@ export const GalleryBarAndListHeader: React.FC<
onAlbumSearchQueryChange,
onShowAlbumOverview,
onSelectPerson,
- allPeople,
saveGroups,
hasActiveFileSelection,
activePerson,
@@ -127,8 +122,6 @@ export const GalleryBarAndListHeader: React.FC<
showAlbumNameInput();
};
- const { show: showAllPeople, props: allPeopleVisibilityProps } =
- useModalVisibility();
const { show: showCollectionShare, props: collectionShareVisibilityProps } =
useModalVisibility();
const { show: showCollectionCast, props: collectionCastVisibilityProps } =
@@ -347,7 +340,6 @@ export const GalleryBarAndListHeader: React.FC<
onChangeCollectionsSortBy={setCollectionsSortBy}
onChangePeopleSortBy={onChangePeopleSortBy}
onCreateAlbum={openAlbumCreation}
- onShowAllPeople={showAllPeople}
collectionSummaries={visibleCollectionSummaries}
visibleAlbumFilters={visibleAlbumFilters}
/>
@@ -358,14 +350,6 @@ export const GalleryBarAndListHeader: React.FC<
onRemotePull={onRemotePull}
onSelectCollectionID={selectCollection}
/>
- <AllPeople
- {...allPeopleVisibilityProps}
- people={sortedPeople}
- allPeople={allPeople}
- onSelectPerson={selectPerson}
- peopleSortBy={peopleSortBy}
- onChangePeopleSortBy={onChangePeopleSortBy}
- />
{activeCollection && (
<>
<CollectionShare
diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsx
index 537a09f5ef..d18a97c10b 100644
--- a/web/apps/photos/src/components/gallery/BarImpl.tsx
+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx
@@ -83,7 +83,6 @@ export interface GalleryBarImplProps extends GalleryBarPresentationProps {
activeCollectionID: number | undefined;
onSelectCollectionID: (collectionID: number) => void;
onCreateAlbum: () => void;
- onShowAllPeople: () => void;
collectionsSortBy: CollectionsSortBy;
onChangeCollectionsSortBy: (by: CollectionsSortBy) => void;
peopleSortBy: PeopleSortBy;
@@ -107,7 +106,6 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
activeCollectionID,
onSelectCollectionID,
onCreateAlbum,
- onShowAllPeople,
collectionsSortBy,
onChangeCollectionsSortBy,
peopleSortBy,
@@ -374,20 +372,6 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
onChangeSortBy={onChangePeopleSortBy}
/>
)}
- {mode == "people" && (
- <Tooltip title={t("people")}>
- <IconButton
- aria-label={t("people")}
- aria-haspopup="dialog"
- onClick={() => {
- mobileDrawerProps.onClose();
- onShowAllPeople();
- }}
- >
- <ExpandMoreIcon sx={{ fontSize: 20 }} />
- </IconButton>
- </Tooltip>
- )}
{(mode == "albums" || mode == "hidden-albums") && (
<Tooltip title={t("new_album")}>
<IconButton
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index dfd7ddd7b7..9f7c14a265 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -2136,10 +2136,6 @@ const Page: React.FC = () => {
(state.view?.type == "people"
? state.view.visiblePeople
: undefined) ?? [],
- allPeople:
- (state.view?.type == "people"
- ? state.view.people
- : undefined) ?? [],
setBlockingLoad,
setActiveCollectionID:
handleShowCollectionSummaryWithID,
diff --git a/web/apps/photos/tests/sidebar-quick-links.test.tsx b/web/apps/photos/tests/sidebar-quick-links.test.tsx
index 43003370fe..85446f6ed0 100644
--- a/web/apps/photos/tests/sidebar-quick-links.test.tsx
+++ b/web/apps/photos/tests/sidebar-quick-links.test.tsx
@@ -13,9 +13,6 @@ const { renderBar } = vi.hoisted(() => ({
}));
vi.mock("@/components/gallery/BarImpl", () => ({ GalleryBarImpl: renderBar }));
-vi.mock("@/components/Collections/AllPeople", () => ({
- AllPeople: () => null,
-}));
vi.mock("@/components/Collections/CollectionShare", () => ({
CollectionShare: () => null,
}));
@@ -70,7 +67,6 @@ const renderSidebar = (
barCollectionSummaries: new Map(summaries.map((cs) => [cs.id, cs])),
uncategorizedCollectionSummaryID: 99,
people: [],
- allPeople: [],
peopleSortBy: "name-asc",
saveGroups: [],
setActiveCollectionID: vi.fn(),