mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
improve code
This commit is contained in:
@@ -6,7 +6,7 @@ import { gettext, siteRoot, mediaUrl } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import URLDecorator from '../../utils/url-decorator';
|
||||
import ItemDropDownMenu from '../dropdown-menu/item-dropdown-menu';
|
||||
import ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu';
|
||||
import Rename from '../rename';
|
||||
import ModalPortal from '../modal-portal';
|
||||
import MoveDirentDialog from '../dialog/move-dirent-dialog';
|
||||
@@ -429,8 +429,8 @@ class DirentListItem extends React.Component {
|
||||
<i className="op-icon sf2-icon-delete" title={gettext('Delete')} onClick={this.onItemDelete}></i>
|
||||
</li>
|
||||
<li className="operation-group-item">
|
||||
<ItemDropDownMenu
|
||||
opItem={this.props.dirent}
|
||||
<ItemDropdownMenu
|
||||
item={this.props.dirent}
|
||||
menuClass={'sf2-icon-caret-down'}
|
||||
isHandleContextMenuEvent={true}
|
||||
getMenuList={this.props.getDirentItemMenuList}
|
||||
@@ -459,8 +459,8 @@ class DirentListItem extends React.Component {
|
||||
<i className="op-icon sf2-icon-delete" title={gettext('Delete')} onClick={this.onItemDelete}></i>
|
||||
</li>
|
||||
<li className="operation-group-item">
|
||||
<ItemDropDownMenu
|
||||
opItem={this.props.dirent}
|
||||
<ItemDropdownMenu
|
||||
item={this.props.dirent}
|
||||
menuClass={'sf2-icon-caret-down'}
|
||||
isHandleContextMenuEvent={true}
|
||||
getMenuList={this.props.getDirentItemMenuList}
|
||||
|
@@ -6,7 +6,7 @@ import { gettext } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
tagName: PropTypes.string,
|
||||
opItem: PropTypes.object.isRequired,
|
||||
item: PropTypes.object.isRequired,
|
||||
menuClass: PropTypes.string,
|
||||
isHandleContextMenuEvent: PropTypes.bool,
|
||||
getMenuList: PropTypes.func.isRequired,
|
||||
@@ -15,7 +15,7 @@ const propTypes = {
|
||||
unfreezeItem: PropTypes.func,
|
||||
};
|
||||
|
||||
class ItemDropDownMenu extends React.Component {
|
||||
class ItemDropdownMenu extends React.Component {
|
||||
|
||||
static defaultProps = {
|
||||
isHandleContextMenuEvent: true,
|
||||
@@ -34,15 +34,15 @@ class ItemDropDownMenu extends React.Component {
|
||||
if (this.props.isHandleContextMenuEvent) {
|
||||
this.listenerId = listener.register(this.onShowMenu, this.onHideMenu);
|
||||
}
|
||||
let { opItem } = this.props;
|
||||
let menuList = this.props.getMenuList(opItem);
|
||||
let { item } = this.props;
|
||||
let menuList = this.props.getMenuList(item);
|
||||
this.setState({menuList: menuList});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) { // for toolbar opItem operation
|
||||
let { opItem } = nextProps;
|
||||
if (opItem.name !== this.props.opItem.name) {
|
||||
let menuList = this.props.getMenuList(opItem);
|
||||
componentWillReceiveProps(nextProps) { // for toolbar item operation
|
||||
let { item } = nextProps;
|
||||
if (item.name !== this.props.item.name) {
|
||||
let menuList = this.props.getMenuList(item);
|
||||
this.setState({menuList: menuList});
|
||||
}
|
||||
}
|
||||
@@ -88,8 +88,8 @@ class ItemDropDownMenu extends React.Component {
|
||||
|
||||
onMenuItemClick = (event) => {
|
||||
let operation = event.target.dataset.toggle;
|
||||
let opItem = this.props.opItem;
|
||||
this.props.onMenuItemClick(operation, event, opItem);
|
||||
let item = this.props.item;
|
||||
this.props.onMenuItemClick(operation, event, item);
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -153,6 +153,6 @@ class ItemDropDownMenu extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
ItemDropDownMenu.propTypes = propTypes;
|
||||
ItemDropdownMenu.propTypes = propTypes;
|
||||
|
||||
export default ItemDropDownMenu;
|
||||
export default ItemDropdownMenu;
|
||||
|
@@ -13,7 +13,7 @@ import RelatedFileDialogs from '../dialog/related-file-dialogs';
|
||||
import EditFileTagDialog from '../dialog/edit-filetag-dialog';
|
||||
import ZipDownloadDialog from '../dialog/zip-download-dialog';
|
||||
import ModalPortal from '../modal-portal';
|
||||
import ItemDropDownMenu from '../dropdown-menu/item-dropdown-menu';
|
||||
import ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu';
|
||||
|
||||
import '../../css/dirents-menu.css';
|
||||
|
||||
@@ -282,9 +282,9 @@ class MutipleDirOperationToolbar extends React.Component {
|
||||
<Button className="secondary group-op-item action-icon sf2-icon-delete" title={gettext('Delete')} onClick={this.onItemsDelete}></Button>
|
||||
<Button className="secondary group-op-item action-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemsDownload}></Button>
|
||||
{this.props.selectedDirentList.length === 1 &&
|
||||
<ItemDropDownMenu
|
||||
<ItemDropdownMenu
|
||||
tagName={'button'}
|
||||
opItem={this.props.selectedDirentList[0]}
|
||||
item={this.props.selectedDirentList[0]}
|
||||
menuClass={'fas fa-ellipsis-v dirents-more-menu'}
|
||||
onMenuItemClick={this.onMenuItemClick}
|
||||
getMenuList={this.getDirentMenuList}
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { permission } from '../../utils/constants';
|
||||
import TextTranslation from '../../utils/text-translation';
|
||||
import ItemDropDownMenu from '../dropdown-menu/item-dropdown-menu';
|
||||
import ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu';
|
||||
|
||||
const propTypes = {
|
||||
repoPermission: PropTypes.bool,
|
||||
@@ -253,8 +253,8 @@ class TreeNodeView extends React.Component {
|
||||
{isNodeMenuShow && (
|
||||
<div className="right-icon">
|
||||
{((this.props.repoPermission || permission) && this.state.isShowOperationMenu) && (
|
||||
<ItemDropDownMenu
|
||||
opItem={this.props.node}
|
||||
<ItemDropdownMenu
|
||||
item={this.props.node}
|
||||
menuClass={'fas fa-ellipsis-v'}
|
||||
getMenuList={this.caculateMenuList}
|
||||
onMenuItemClick={this.onMenuItemClick}
|
||||
|
Reference in New Issue
Block a user