Skip to content

armgit / ente

Public Imported from GitHub
0

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

Tie into the flow

Manav Rathia13f3020ca59
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 53646284a5..ed7ae74945 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -4,7 +4,6 @@ import {
type GalleryBarImplProps,
} from "@/new/photos/components/Gallery/BarImpl";
import { PeopleHeader } from "@/new/photos/components/Gallery/PeopleHeader";
-import { PeopleSelector } from "@/new/photos/components/PeopleSelector";
import {
areOnlySystemCollections,
collectionsSortBy,
@@ -108,7 +107,6 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
const [openCollectionShareView, setOpenCollectionShareView] =
useState(false);
const [openAlbumCastDialog, setOpenAlbumCastDialog] = useState(false);
- const [openPeopleSelector, setOpenPeopleSelector] = useState(false);
const [collectionsSortBy, setCollectionsSortBy] =
useCollectionsSortByLocalState("updation-time-desc");
@@ -174,7 +172,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
) : activePerson ? (
<PeopleHeader
person={activePerson}
- {...{ onSelectPerson, appContext }}
+ {...{ onSelectPerson, people, appContext }}
/>
) : (
<></>
@@ -189,15 +187,9 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
activeCollectionID,
isActiveCollectionDownloadInProgress,
activePerson,
+ people,
]);
- // TODO-Cluster
- useEffect(() => {
- if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) {
- setOpenPeopleSelector(true);
- }
- }, []);
-
if (shouldBeHidden) {
return <></>;
}
@@ -247,10 +239,6 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
onClose={() => setOpenAlbumCastDialog(false)}
collection={activeCollection}
/>
- <PeopleSelector
- open={openPeopleSelector}
- onClose={() => setOpenPeopleSelector(false)}
- />
</>
);
};
diff --git a/web/packages/new/photos/components/PeopleSelector.tsx b/web/packages/new/photos/components/AddPersonDialog.tsx
similarity index 79%
rename from web/packages/new/photos/components/PeopleSelector.tsx
rename to web/packages/new/photos/components/AddPersonDialog.tsx
index 52fa8382fe..776ad2d549 100644
--- a/web/packages/new/photos/components/PeopleSelector.tsx
+++ b/web/packages/new/photos/components/AddPersonDialog.tsx
@@ -9,6 +9,7 @@ import {
} from "@mui/material";
import { t } from "i18next";
import React, { useState } from "react";
+import type { FaceCluster } from "../services/ml/cluster";
import type { Person } from "../services/ml/people";
import { SpaceBetweenFlex, type ButtonishProps } from "./mui";
import {
@@ -23,24 +24,42 @@ import {
LargeTileTextOverlay,
} from "./Tiles";
-type PeopleSelectorProps = DialogVisibilityProps;
+type AddPersonDialogProps = DialogVisibilityProps & {
+ /**
+ * The list of people from show the existing named people.
+ */
+ people: Person[];
+ /**
+ * The cluster to add to the selected person (existing or new).
+ */
+ cluster: FaceCluster;
+};
-export const PeopleSelector: React.FC<PeopleSelectorProps> = ({
+/**
+ * A dialog allowing the user to select one of the existing named persons they
+ * have, or create a new one, and then associate the provided cluster to it,
+ * creating or updating a remote "person".
+ */
+export const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
open,
onClose,
+ people,
+ cluster,
}) => {
const isFullScreen = useMediaQuery("(max-width: 490px)");
const [openNameInput, setOpenNameInput] = useState(false);
- const people: Person[] = [];
+ const cgroupPeople: Exclude<Person, { type: "cluster" }>[] = people.filter(
+ (p) => p.type != "cluster",
+ );
const handleAddPerson = () => {
setOpenNameInput(true);
};
const handleSelectPerson = (id: string) => {
- console.log("handleSelectPerson", id);
+ console.log("handleSelectPerson", id, cluster);
};
const handleAddPersonWithName = (name: string) => {
@@ -62,7 +81,7 @@ export const PeopleSelector: React.FC<PeopleSelectorProps> = ({
// directly to the add person dialog.
//
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
- if (open && !openNameInput && !people.length) {
+ if (open && !openNameInput && !cgroupPeople.length) {
onClose();
setOpenNameInput(true);
return <></>;
@@ -84,7 +103,7 @@ export const PeopleSelector: React.FC<PeopleSelectorProps> = ({
</SpaceBetweenFlex>
<DialogContent_>
<AddPerson onClick={handleAddPerson} />
- {people.map((person) => (
+ {cgroupPeople.map((person) => (
<PersonButton
key={person.id}
person={person}
@@ -128,7 +147,7 @@ const PersonButton: React.FC<PersonButtonProps> = ({
onClick={() => onPersonClick(person.id)}
>
<LargeTileTextOverlay>
- <Typography>{person.name}</Typography>
+ <Typography>{person.name ?? ""}</Typography>
</LargeTileTextOverlay>
</ItemCard>
);
diff --git a/web/packages/new/photos/components/Gallery/PeopleHeader.tsx b/web/packages/new/photos/components/Gallery/PeopleHeader.tsx
index 9c5b5d3c74..472e205b3b 100644
--- a/web/packages/new/photos/components/Gallery/PeopleHeader.tsx
+++ b/web/packages/new/photos/components/Gallery/PeopleHeader.tsx
@@ -26,6 +26,7 @@ import React, { useState } from "react";
import type { FaceCluster } from "../../services/ml/cluster";
import type { CGroup } from "../../services/user-entity";
import type { NewAppContextPhotos } from "../../types/context";
+import { AddPersonDialog } from "../AddPersonDialog";
import { SpaceBetweenFlex } from "../mui";
import { NameInputDialog } from "../NameInputDialog";
import type { GalleryBarImplProps } from "./BarImpl";
@@ -52,15 +53,19 @@ export interface GalleryPeopleState {
people: Person[];
}
-type PeopleHeaderProps = Pick<GalleryBarImplProps, "onSelectPerson"> & {
+type PeopleHeaderProps = Pick<
+ GalleryBarImplProps,
+ "people" | "onSelectPerson"
+> & {
person: Person;
appContext: NewAppContextPhotos;
};
export const PeopleHeader: React.FC<PeopleHeaderProps> = ({
+ people,
+ onSelectPerson,
person,
appContext,
- onSelectPerson,
}) => {
return (
<GalleryItemsHeaderAdapter>
@@ -80,7 +85,7 @@ export const PeopleHeader: React.FC<PeopleHeaderProps> = ({
) : (
<ClusterPersonOptions
cluster={person.cluster}
- appContext={appContext}
+ {...{ people, appContext }}
/>
)}
</SpaceBetweenFlex>
@@ -182,20 +187,25 @@ const CGroupPersonOptions: React.FC<CGroupPersonOptionsProps> = ({
);
};
-type ClusterPersonOptionsProps = Pick<PeopleHeaderProps, "appContext"> & {
+type ClusterPersonOptionsProps = Pick<
+ PeopleHeaderProps,
+ "people" | "appContext"
+> & {
cluster: FaceCluster;
};
const ClusterPersonOptions: React.FC<ClusterPersonOptionsProps> = ({
+ people,
cluster,
appContext,
}) => {
const { startLoading, finishLoading } = appContext;
- const [openNameInput, setOpenNameInput] = useState(false);
+ const [openAddPersonDialog, setOpenAddPersonDialog] = useState(false);
- const handleAddPerson = () => setOpenNameInput(true);
+ const handleAddPerson = () => setOpenAddPersonDialog(true);
+ // TODO-Cluster
const addPersonWithName = async (name: string) => {
startLoading();
try {
@@ -205,6 +215,8 @@ const ClusterPersonOptions: React.FC<ClusterPersonOptionsProps> = ({
}
};
+ if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) console.log(addPersonWithName);
+
return (
<>
<Stack direction="row" sx={{ alignItems: "center", gap: 2 }}>
@@ -228,14 +240,10 @@ const ClusterPersonOptions: React.FC<ClusterPersonOptionsProps> = ({
</OverflowMenu>
</Stack>
- <NameInputDialog
- open={openNameInput}
- onClose={() => setOpenNameInput(false)}
- title={pt("Add person") /* TODO-Cluster */}
- placeholder={t("enter_name")}
- initialValue={""}
- submitButtonTitle={t("add")}
- onSubmit={addPersonWithName}
+ <AddPersonDialog
+ open={openAddPersonDialog}
+ onClose={() => setOpenAddPersonDialog(false)}
+ {...{ people, cluster }}
/>
</>
);
diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsx
index cb78f649a7..0c733e92fc 100644
--- a/web/packages/new/photos/components/SearchBar.tsx
+++ b/web/packages/new/photos/components/SearchBar.tsx
@@ -43,6 +43,7 @@ import {
import AsyncSelect from "react-select/async";
import { SearchPeopleList } from "./PeopleList";
import { UnstyledButton } from "./UnstyledButton";
+import type { ButtonishProps } from "./mui";
export interface SearchBarProps {
/**
@@ -414,7 +415,9 @@ const EmptyState: React.FC<Pick<SearchBarProps, "onSelectPerson">> = ({
<Box sx={{ textAlign: "left" }}>
{people && people.length > 0 && (
<>
- <PeopleHeader onClick={() => onSelectPerson(undefined)} />
+ <SearchPeopleHeader
+ onClick={() => onSelectPerson(undefined)}
+ />
<SearchPeopleList {...{ people, onSelectPerson }} />
</>
)}
@@ -425,22 +428,18 @@ const EmptyState: React.FC<Pick<SearchBarProps, "onSelectPerson">> = ({
);
};
-interface PeopleHeaderProps {
- onClick: () => void;
-}
-
-const PeopleHeader: React.FC<PeopleHeaderProps> = ({ onClick }) => (
- <PeopleHeaderButton {...{ onClick }}>
+const SearchPeopleHeader: React.FC<ButtonishProps> = ({ onClick }) => (
+ <SearchPeopleHeaderButton {...{ onClick }}>
<Stack direction="row" color="text.muted">
<Typography color="text.base" variant="large">
{t("people")}
</Typography>
<ChevronRightIcon />
</Stack>
- </PeopleHeaderButton>
+ </SearchPeopleHeaderButton>
);
-const PeopleHeaderButton = styled(UnstyledButton)(
+const SearchPeopleHeaderButton = styled(UnstyledButton)(
({ theme }) => `
/* The color for the chevron */
color: ${theme.colors.stroke.muted};