1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 02:48:51 +00:00

fix: image context path (#7262)

* fix: image context path

* feat: update code

* feat: optimize code style

---------

Co-authored-by: 杨国璇 <ygx@Hello-word.local>
This commit is contained in:
杨国璇
2024-12-26 17:25:46 +08:00
committed by GitHub
parent 69541fae7e
commit c807d09819
8 changed files with 17 additions and 15 deletions

View File

@@ -3,7 +3,12 @@ import PropTypes from 'prop-types';
import './index.css'; 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 menuRef = useRef(null);
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [position, setPosition] = useState({ top: 0, left: 0 }); const [position, setPosition] = useState({ top: 0, left: 0 });

View File

@@ -19,7 +19,7 @@ const CONTEXT_MENU_KEY = {
REMOVE: 'remove', 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 [isZipDialogOpen, setIsZipDialogOpen] = useState(false);
const [isCopyDialogOpen, setIsCopyDialogOpen] = useState(false); const [isCopyDialogOpen, setIsCopyDialogOpen] = useState(false);
@@ -68,7 +68,7 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
return; return;
} }
const dirents = selectedImages.map(image => { 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; return value;
}); });
metadataAPI.zipDownload(repoID, '/', dirents).then((res) => { metadataAPI.zipDownload(repoID, '/', dirents).then((res) => {
@@ -100,13 +100,12 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
}, [handleDownload, onDelete, selectedImages, toggleCopyDialog, onRemoveImage]); }, [handleDownload, onDelete, selectedImages, toggleCopyDialog, onRemoveImage]);
const dirent = new Dirent({ name: selectedImages[0]?.name }); const dirent = new Dirent({ name: selectedImages[0]?.name });
const path = selectedImages[0]?.path; const parentDir = selectedImages[0]?.parentDir;
return ( return (
<> <>
<ContextMenu <ContextMenu
options={options} options={options}
boundaryCoordinates={boundaryCoordinates}
ignoredTriggerElements={['.metadata-gallery-image-item', '.metadata-gallery-grid-image']} ignoredTriggerElements={['.metadata-gallery-image-item', '.metadata-gallery-grid-image']}
onOptionClick={handleOptionClick} onOptionClick={handleOptionClick}
/> />
@@ -115,7 +114,7 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
<ZipDownloadDialog <ZipDownloadDialog
repoID={repoID} repoID={repoID}
path="/" 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} toggleDialog={closeZipDialog}
/> />
</ModalPortal> </ModalPortal>
@@ -123,7 +122,7 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
{isCopyDialogOpen && ( {isCopyDialogOpen && (
<ModalPortal> <ModalPortal>
<CopyDirent <CopyDirent
path={path} path={parentDir}
repoID={repoID} repoID={repoID}
dirent={dirent} dirent={dirent}
isMultipleOperation={false} isMultipleOperation={false}
@@ -141,7 +140,6 @@ const GalleryContextMenu = ({ metadata, selectedImages, boundaryCoordinates, onD
GalleryContextMenu.propTypes = { GalleryContextMenu.propTypes = {
metadata: PropTypes.object, metadata: PropTypes.object,
selectedImages: PropTypes.array, selectedImages: PropTypes.array,
boundaryCoordinates: PropTypes.object,
onDelete: PropTypes.func, onDelete: PropTypes.func,
onDuplicate: PropTypes.func, onDuplicate: PropTypes.func,
addFolder: PropTypes.func, addFolder: PropTypes.func,

View File

@@ -374,7 +374,6 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore, duplicateRecord,
<GalleryContextmenu <GalleryContextmenu
metadata={metadata} metadata={metadata}
selectedImages={selectedImages} selectedImages={selectedImages}
boundaryCoordinates={containerRef?.current?.getBoundingClientRect() || {}}
onDelete={handleDeleteSelectedImages} onDelete={handleDeleteSelectedImages}
onDuplicate={duplicateRecord} onDuplicate={duplicateRecord}
addFolder={onAddFolder} addFolder={onAddFolder}

View File

@@ -307,7 +307,6 @@ const Boards = ({ modifyRecord, deleteRecords, modifyColumnData, onCloseSettings
</div> </div>
</div> </div>
<ContextMenu <ContextMenu
boundaryCoordinates={{ top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0 }}
selectedCard={selectedCard} selectedCard={selectedCard}
onDelete={onDeleteRecords} onDelete={onDeleteRecords}
onRename={onRename} onRename={onRename}

View File

@@ -23,7 +23,7 @@ const CONTEXT_MENU_KEY = {
RENAME: 'rename', RENAME: 'rename',
}; };
const KanbanContextMenu = ({ boundaryCoordinates, selectedCard, onDelete, onRename }) => { const KanbanContextMenu = ({ selectedCard, onDelete, onRename }) => {
const [isRenameDialogShow, setIsRenameDialogShow] = useState(false); const [isRenameDialogShow, setIsRenameDialogShow] = useState(false);
const [isZipDialogOpen, setIsZipDialogOpen] = useState(false); const [isZipDialogOpen, setIsZipDialogOpen] = useState(false);
@@ -130,7 +130,6 @@ const KanbanContextMenu = ({ boundaryCoordinates, selectedCard, onDelete, onRena
<> <>
<ContextMenu <ContextMenu
options={options} options={options}
boundaryCoordinates={boundaryCoordinates}
onOptionClick={handleOptionClick} onOptionClick={handleOptionClick}
ignoredTriggerElements={['.sf-metadata-kanban-card']} ignoredTriggerElements={['.sf-metadata-kanban-card']}
/> />
@@ -154,7 +153,6 @@ const KanbanContextMenu = ({ boundaryCoordinates, selectedCard, onDelete, onRena
}; };
KanbanContextMenu.propTypes = { KanbanContextMenu.propTypes = {
boundaryCoordinates: PropTypes.object,
selectedCard: PropTypes.string, selectedCard: PropTypes.string,
onDelete: PropTypes.func, onDelete: PropTypes.func,
onRename: PropTypes.func, onRename: PropTypes.func,

View File

@@ -42,7 +42,7 @@ const Kanban = () => {
}, [isShowSettings]); }, [isShowSettings]);
return ( return (
<div className="sf-metadata-container sf-metadata-view-kanban-container"> <div className="sf-metadata-container">
<div className="sf-metadata-view-kanban"> <div className="sf-metadata-view-kanban">
<Boards <Boards
modifyRecord={modifyRecord} modifyRecord={modifyRecord}

View File

@@ -424,6 +424,9 @@
height: 100%; height: 100%;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
}
.sf-metadata-wrapper .sf-metadata-main .sf-metadata-container-transform {
transform: translateZ(10px); transform: translateZ(10px);
} }

View File

@@ -151,7 +151,7 @@ const Table = () => {
}, [containerRef]); }, [containerRef]);
return ( return (
<div className="sf-metadata-container" ref={containerRef}> <div className="sf-metadata-container sf-metadata-container-transform" ref={containerRef}>
<TableMain <TableMain
isGroupView={isGroupView} isGroupView={isGroupView}
isLoadingMore={isLoadingMore} isLoadingMore={isLoadingMore}