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