mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 15:26:19 +00:00
Contextmenu improve (#3238)
* add a commen contextmenu component * optimized translate for menu * repair contextmenu bug * optimized share btn show code * repair showShareBtn bug * optimized contextmenu * optimized contextmenu code * complete dirent-item-menu logic * optimized contextmenu code * complete dirent-container-menu logic * complete tree-node-contextmenu logic * delete unnecessary code * optimized contextmenu func * repair bug * optimized code style * optimized code style * add a dirent-none-view for dir-list-view mode * optimized dirent-container-menu&dirent-item-menu * add select-item contextmenu * repair rebase bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import listener from '../context-menu/globalEventListener';
|
||||
import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap';
|
||||
import { gettext, isPro, enableFileComment, fileAuditEnabled, folderPermEnabled } from '../../utils/constants';
|
||||
|
||||
@@ -10,7 +11,6 @@ const propTypes = {
|
||||
onMenuItemClick: PropTypes.func.isRequired,
|
||||
onFreezedItem: PropTypes.func.isRequired,
|
||||
onUnfreezedItem: PropTypes.func.isRequired,
|
||||
appMenuType: PropTypes.oneOf(['list_view_contextmenu', 'item_contextmenu', 'tree_contextmenu', 'item_op_menu']),
|
||||
};
|
||||
|
||||
class DirentMenu extends React.Component {
|
||||
@@ -25,11 +25,23 @@ class DirentMenu extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
this.menuList = this.calculateMenuList();
|
||||
this.listenerId = listener.register(this.onShowMenu, this.onHideMenu);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProp) {
|
||||
if (nextProp.appMenuType === 'list_view_contextmenu' || nextProp.appMenuType === 'item_contextmenu') {
|
||||
this.setState({isItemMenuShow: false});
|
||||
componentWillUnmount () {
|
||||
if (this.listenerId) {
|
||||
listener.unregister(this.listenerId);
|
||||
}
|
||||
}
|
||||
|
||||
onShowMenu = () => {
|
||||
// nothing todo
|
||||
}
|
||||
|
||||
onHideMenu = () => {
|
||||
if (this.state.isItemMenuShow) {
|
||||
this.setState({isItemMenuShow: false});
|
||||
this.props.onUnfreezedItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user