1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 10:26:17 +00:00

update image dialog, add download, delete and view original image button (#6670)

* update image dialog, add download, delete and view original image button

* update react-image-lightbox

* add-image-rotate-api

* support restore in image previewer

* support image rotate

* upgrade react-image-lightbox

* fix bug - first image auto previewed in list layout, improve delete and restore action

* remove raise

* fix last line

---------

Co-authored-by: r350178982 <32759763+r350178982@users.noreply.github.com>
Co-authored-by: Michael An <2331806369@qq.com>
This commit is contained in:
Aries
2024-09-03 10:31:42 +08:00
committed by GitHub
parent 670ee89f24
commit 89b4e92fa6
17 changed files with 384 additions and 17 deletions

View File

@@ -17,6 +17,7 @@ import DirentListItem from './dirent-list-item';
import ContextMenu from '../context-menu/context-menu';
import { hideMenu, showMenu } from '../context-menu/actions';
import DirentsDraggedPreview from '../draggable/dirents-dragged-preview';
import { EVENT_BUS_TYPE } from '../common/event-bus-type';
const propTypes = {
path: PropTypes.string.isRequired,
@@ -55,6 +56,7 @@ const propTypes = {
posX: PropTypes.string,
posY: PropTypes.string,
getMenuContainerSize: PropTypes.func,
eventBus: PropTypes.object,
};
class DirentListView extends React.Component {
@@ -99,6 +101,26 @@ class DirentListView extends React.Component {
}
}
componentDidMount() {
this.unsubscribeEvent = this.props.eventBus.subscribe(EVENT_BUS_TYPE.RESTORE_IMAGE, this.recalculateImageItems);
}
recalculateImageItems = () => {
if (!this.state.isImagePopupOpen) return;
let imageItems = this.props.direntList
.filter((item) => Utils.imageCheck(item.name))
.map((item) => this.prepareImageItem(item));
this.setState({
imageItems: imageItems,
imageIndex: this.state.imageIndex % imageItems.length,
});
};
componentWillUnmount() {
this.unsubscribeEvent();
}
freezeItem = () => {
this.setState({ isItemFreezed: true });
};
@@ -199,6 +221,21 @@ class DirentListView extends React.Component {
}));
};
deleteImage = (name) => {
const item = this.props.fullDirentList.find((item) => item.name === name);
this.props.onItemDelete(item);
const newImageItems = this.props.fullDirentList
.filter((item) => item.name !== name && Utils.imageCheck(item.name))
.map((item) => this.prepareImageItem(item));
this.setState((prevState) => ({
isImagePopupOpen: newImageItems.length > 0,
imageItems: newImageItems,
imageIndex: prevState.imageIndex % newImageItems.length,
}));
};
closeImagePopup = () => {
this.setState({ isImagePopupOpen: false });
};
@@ -727,6 +764,7 @@ class DirentListView extends React.Component {
closeImagePopup={this.closeImagePopup}
moveToPrevImage={this.moveToPrevImage}
moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage}
/>
</ModalPortal>
)}