Skip to content

Commit

Permalink
fix: image context path (#7262)
Browse files Browse the repository at this point in the history
* fix: image context path

* feat: update code

* feat: optimize code style

---------

Co-authored-by: 杨国璇 <[email protected]>
  • Loading branch information
YangGuoXuan-0503 and 杨国璇 authored Dec 26, 2024
1 parent 69541fa commit c807d09
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
7 changes: 6 additions & 1 deletion frontend/src/metadata/components/context-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import PropTypes from 'prop-types';

import './index.css';

const ContextMenu = ({ options, boundaryCoordinates, onOptionClick, ignoredTriggerElements }) => {
const ContextMenu = ({
options,
boundaryCoordinates = { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0 },
onOptionClick,
ignoredTriggerElements
}) => {
const menuRef = useRef(null);
const [visible, setVisible] = useState(false);
const [position, setPosition] = useState({ top: 0, left: 0 });
Expand Down
12 changes: 5 additions & 7 deletions frontend/src/metadata/views/gallery/context-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CONTEXT_MENU_KEY = {
REMOVE: 'remove',
};

const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onDelete, onDuplicate, addFolder, onRemoveImage }) => {
const GalleryContextMenu = ({ metadata, selectedImages, onDelete, onDuplicate, addFolder, onRemoveImage }) => {
const [isZipDialogOpen, setIsZipDialogOpen] = useState(false);
const [isCopyDialogOpen, setIsCopyDialogOpen] = useState(false);

Expand Down Expand Up @@ -68,7 +68,7 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
return;
}
const dirents = selectedImages.map(image => {
const value = image.path === '/' ? image.name : `${image.path}/${image.name}`;
const value = image.parentDir === '/' ? image.name : `${image.parentDir}/${image.name}`;
return value;
});
metadataAPI.zipDownload(repoID, '/', dirents).then((res) => {
Expand Down Expand Up @@ -100,13 +100,12 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
}, [handleDownload, onDelete, selectedImages, toggleCopyDialog, onRemoveImage]);

const dirent = new Dirent({ name: selectedImages[0]?.name });
const path = selectedImages[0]?.path;
const parentDir = selectedImages[0]?.parentDir;

return (
<>
<ContextMenu
options={options}
boundaryCoordinates={boundaryCoordinates}
ignoredTriggerElements={['.metadata-gallery-image-item', '.metadata-gallery-grid-image']}
onOptionClick={handleOptionClick}
/>
Expand All @@ -115,15 +114,15 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
<ZipDownloadDialog
repoID={repoID}
path="/"
target={selectedImages.map(image => image.path === '/' ? image.name : `${image.path}/${image.name}`)}
target={selectedImages.map(image => image.parentDir === '/' ? image.name : `${image.parentDir}/${image.name}`)}
toggleDialog={closeZipDialog}
/>
</ModalPortal>
)}
{isCopyDialogOpen && (
<ModalPortal>
<CopyDirent
path={path}
path={parentDir}
repoID={repoID}
dirent={dirent}
isMultipleOperation={false}
Expand All @@ -141,7 +140,6 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
GalleryContextMenu.propTypes = {
metadata: PropTypes.object,
selectedImages: PropTypes.array,
boundaryCoordinates: PropTypes.object,
onDelete: PropTypes.func,
onDuplicate: PropTypes.func,
addFolder: PropTypes.func,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/metadata/views/gallery/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore, duplicateRecord,
<GalleryContextmenu
metadata={metadata}
selectedImages={selectedImages}
boundaryCoordinates={containerRef?.current?.getBoundingClientRect() || {}}
onDelete={handleDeleteSelectedImages}
onDuplicate={duplicateRecord}
addFolder={onAddFolder}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/metadata/views/kanban/boards/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ const Boards = ({ modifyRecord, deleteRecords, modifyColumnData, onCloseSettings
</div>
</div>
<ContextMenu
boundaryCoordinates={{ top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0 }}
selectedCard={selectedCard}
onDelete={onDeleteRecords}
onRename={onRename}
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/metadata/views/kanban/context-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const CONTEXT_MENU_KEY = {
RENAME: 'rename',
};

const KanbanContextMenu = ({ boundaryCoordinates, selectedCard, onDelete, onRename }) => {
const KanbanContextMenu = ({ selectedCard, onDelete, onRename }) => {
const [isRenameDialogShow, setIsRenameDialogShow] = useState(false);
const [isZipDialogOpen, setIsZipDialogOpen] = useState(false);

Expand Down Expand Up @@ -130,7 +130,6 @@ const KanbanContextMenu = ({ boundaryCoordinates, selectedCard, onDelete, onRena
<>
<ContextMenu
options={options}
boundaryCoordinates={boundaryCoordinates}
onOptionClick={handleOptionClick}
ignoredTriggerElements={['.sf-metadata-kanban-card']}
/>
Expand All @@ -154,7 +153,6 @@ const KanbanContextMenu = ({ boundaryCoordinates, selectedCard, onDelete, onRena
};

KanbanContextMenu.propTypes = {
boundaryCoordinates: PropTypes.object,
selectedCard: PropTypes.string,
onDelete: PropTypes.func,
onRename: PropTypes.func,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/metadata/views/kanban/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Kanban = () => {
}, [isShowSettings]);

return (
<div className="sf-metadata-container sf-metadata-view-kanban-container">
<div className="sf-metadata-container">
<div className="sf-metadata-view-kanban">
<Boards
modifyRecord={modifyRecord}
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/metadata/views/table/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@
height: 100%;
width: 100%;
overflow: hidden;
}

.sf-metadata-wrapper .sf-metadata-main .sf-metadata-container-transform {
transform: translateZ(10px);
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/metadata/views/table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const Table = () => {
}, [containerRef]);

return (
<div className="sf-metadata-container" ref={containerRef}>
<div className="sf-metadata-container sf-metadata-container-transform" ref={containerRef}>
<TableMain
isGroupView={isGroupView}
isLoadingMore={isLoadingMore}
Expand Down

0 comments on commit c807d09

Please sign in to comment.