Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(contextMenu):add-edit-location

Aswin Asok8ae56eee7043
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsx
index 6bc74a1867..f3f595c7e2 100644
--- a/web/apps/photos/src/components/FileList.tsx
+++ b/web/apps/photos/src/components/FileList.tsx
@@ -272,6 +272,10 @@ export interface FileListProps {
* Whether to show the "Add Person" action in the context menu.
*/
showAddPersonAction?: boolean;
+ /**
+ * Whether to show the "Edit Location" action in the context menu.
+ */
+ showEditLocationAction?: boolean;
}
/**
@@ -301,6 +305,7 @@ export const FileList: React.FC<FileListProps> = ({
collectionSummary,
onContextMenuAction,
showAddPersonAction,
+ showEditLocationAction,
}) => {
const [_items, setItems] = useState<FileListItem[]>([]);
const items = useDeferredValue(_items);
@@ -643,6 +648,8 @@ export const FileList: React.FC<FileListProps> = ({
isInSearchMode: modePlus === "search",
collectionSummary,
showAddPerson: !!showAddPersonAction,
+ showEditLocation:
+ !!showEditLocationAction && selected.ownCount > 0,
});
}, [
onContextMenuAction,
@@ -650,6 +657,8 @@ export const FileList: React.FC<FileListProps> = ({
modePlus,
collectionSummary,
showAddPersonAction,
+ showEditLocationAction,
+ selected.ownCount,
]);
// Handle context menu open
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index d363fd641c..4bf45fe022 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -110,6 +110,7 @@ export type FileListWithViewerProps = {
| "listBorderRadius"
| "onContextMenuAction"
| "showAddPersonAction"
+ | "showEditLocationAction"
> &
Pick<
FileViewerProps,
@@ -161,6 +162,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
listBorderRadius,
onContextMenuAction,
showAddPersonAction,
+ showEditLocationAction,
isInIncomingSharedCollection,
isInHiddenSection,
fileNormalCollectionIDs,
@@ -357,6 +359,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
collectionSummary: activeCollectionSummary,
onContextMenuAction,
showAddPersonAction,
+ showEditLocationAction,
}}
onItemClick={handleThumbnailClick}
/>
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index f125aadecd..f0fea86e25 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -106,14 +106,14 @@ import {
PseudoCollectionID,
} from "ente-new/photos/services/collection-summary";
import exportService from "ente-new/photos/services/export";
-import {
- addManualFileAssignmentsToPerson,
- isMLEnabled,
-} from "ente-new/photos/services/ml";
import {
updateFilesLocation,
updateFilesVisibility,
} from "ente-new/photos/services/file";
+import {
+ addManualFileAssignmentsToPerson,
+ isMLEnabled,
+} from "ente-new/photos/services/ml";
import {
savedCollectionFiles,
@@ -1359,6 +1359,9 @@ const Page: React.FC = () => {
case "addPerson":
showContextMenuAssignPerson();
break;
+ case "editLocation":
+ showEditLocation();
+ break;
}
},
[
@@ -1369,6 +1372,7 @@ const Page: React.FC = () => {
handleRemoveFilesFromCollection,
showMiniDialog,
showContextMenuAssignPerson,
+ showEditLocation,
activeCollectionSummary,
activeCollection,
],
@@ -1678,6 +1682,7 @@ const Page: React.FC = () => {
isInHiddenSection={barMode == "hidden-albums"}
onContextMenuAction={handleContextMenuAction}
showAddPersonAction={showAddPersonAction}
+ showEditLocationAction={selected.ownCount > 0}
{...{
favoriteFileIDs,
collectionNameByID,
diff --git a/web/packages/new/photos/components/FileContextMenu.tsx b/web/packages/new/photos/components/FileContextMenu.tsx
index fcad23e79f..94ef7977af 100644
--- a/web/packages/new/photos/components/FileContextMenu.tsx
+++ b/web/packages/new/photos/components/FileContextMenu.tsx
@@ -4,6 +4,7 @@ import ArchiveIcon from "@mui/icons-material/ArchiveOutlined";
import MoveIcon from "@mui/icons-material/ArrowForward";
import DeleteIcon from "@mui/icons-material/Delete";
import DownloadIcon from "@mui/icons-material/Download";
+import EditLocationAltIcon from "@mui/icons-material/EditLocationAlt";
import PersonAddIcon from "@mui/icons-material/PersonAdd";
import RemoveIcon from "@mui/icons-material/RemoveCircleOutline";
import RestoreIcon from "@mui/icons-material/Restore";
@@ -58,6 +59,7 @@ interface ActionConfig {
const actionConfigs: Record<FileContextAction, ActionConfig> = {
download: { label: "download", Icon: DownloadIcon },
fixTime: { label: "fix_creation_time", Icon: ClockIcon },
+ editLocation: { label: "edit_location", Icon: EditLocationAltIcon },
favorite: { label: "favorite", Icon: StarBorderIcon },
archive: { label: "archive", Icon: ArchiveIcon },
unarchive: { label: "unarchive", Icon: UnArchiveIcon },
@@ -138,6 +140,7 @@ export const FileContextMenu: React.FC<FileContextMenuProps> = memo(
{destructiveActions.length > 0 && primaryActions.length > 0 && (
<Divider />
)}
+
{destructiveActions.map((action) => {
const { label, Icon } = actionConfigs[action];
return (
diff --git a/web/packages/new/photos/components/SelectedFileOptions.tsx b/web/packages/new/photos/components/SelectedFileOptions.tsx
index 21576e5685..40ccc69309 100644
--- a/web/packages/new/photos/components/SelectedFileOptions.tsx
+++ b/web/packages/new/photos/components/SelectedFileOptions.tsx
@@ -148,7 +148,6 @@ interface SelectedFileOptionsProps {
*/
onShowAssignPersonDialog?: () => void;
- onAddPersonToSelectedFiles?: (personID: string) => Promise<void>;
/**
* Called when the user wants to edit the location of the selected files.
*
@@ -183,7 +182,6 @@ export const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({
createOnSelectForCollectionOp,
createFileOpHandler,
onShowAssignPersonDialog,
- onAddPersonToSelectedFiles,
onEditLocation,
onSelectAll,
isAllSelected,
@@ -510,7 +508,7 @@ const UnhideButton: React.FC<ButtonishProps> = ({ onClick }) => (
const DeleteButton: React.FC<ButtonishProps> = ({ onClick }) => (
<Tooltip title={t("delete")}>
- <IconButton {...{ onClick }}>
+ <IconButton {...{ onClick }} sx={{ color: "critical.main" }}>
<DeleteIcon />
</IconButton>
</Tooltip>
@@ -526,7 +524,7 @@ const RestoreButton: React.FC<ButtonishProps> = ({ onClick }) => (
const DeletePermanentlyButton: React.FC<ButtonishProps> = ({ onClick }) => (
<Tooltip title={t("delete_permanently")}>
- <IconButton {...{ onClick }}>
+ <IconButton {...{ onClick }} sx={{ color: "critical.main" }}>
<DeleteIcon />
</IconButton>
</Tooltip>
diff --git a/web/packages/new/photos/utils/file-actions.ts b/web/packages/new/photos/utils/file-actions.ts
index 857c81e2fd..12c20c0212 100644
--- a/web/packages/new/photos/utils/file-actions.ts
+++ b/web/packages/new/photos/utils/file-actions.ts
@@ -12,6 +12,7 @@ import {
export type FileContextAction =
| "download"
| "fixTime"
+ | "editLocation"
| "favorite"
| "archive"
| "unarchive"
@@ -45,6 +46,12 @@ export interface FileActionContext {
* This depends on ML being enabled and having named people.
*/
showAddPerson: boolean;
+ /**
+ * Whether to show the "Edit Location" action.
+ *
+ * This depends on the selection containing owned files.
+ */
+ showEditLocation: boolean;
}
/**
@@ -56,10 +63,20 @@ export interface FileActionContext {
export function getAvailableFileActions(
context: FileActionContext,
): FileContextAction[] {
- const { barMode, isInSearchMode, collectionSummary, showAddPerson } =
- context;
-
- const actions = getBaseActions(barMode, isInSearchMode, collectionSummary);
+ const {
+ barMode,
+ isInSearchMode,
+ collectionSummary,
+ showAddPerson,
+ showEditLocation,
+ } = context;
+
+ const actions = getBaseActions(
+ barMode,
+ isInSearchMode,
+ collectionSummary,
+ showEditLocation,
+ );
// Insert "addPerson" before modification actions if enabled
// (not applicable for trash since you can't add people to trashed files)
@@ -77,18 +94,16 @@ function getBaseActions(
barMode: GalleryBarMode | undefined,
isInSearchMode: boolean,
collectionSummary: CollectionSummary | undefined,
+ showEditLocation: boolean,
): FileContextAction[] {
// Search mode actions
if (isInSearchMode) {
- return [
- "favorite",
- "fixTime",
- "download",
- "addToAlbum",
- "archive",
- "hide",
- "trash",
- ];
+ const actions: FileContextAction[] = ["favorite", "fixTime"];
+ if (showEditLocation) {
+ actions.push("editLocation");
+ }
+ actions.push("download", "addToAlbum", "archive", "hide", "trash");
+ return actions;
}
// People mode actions
@@ -136,7 +151,11 @@ function getBaseActions(
actions.push("favorite");
}
- actions.push("fixTime", "download", "addToAlbum");
+ actions.push("fixTime");
+ if (showEditLocation) {
+ actions.push("editLocation");
+ }
+ actions.push("download", "addToAlbum");
if (collectionSummary?.id === PseudoCollectionID.all) {
actions.push("archive");
@@ -152,7 +171,7 @@ function getBaseActions(
}
/**
- * Actions that modify file visibility or location.
+ * Actions that modify file visibility or collection membership.
* "addPerson" is inserted before the first of these actions.
*/
const modificationActions: FileContextAction[] = [