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

repair bug (#3272)

This commit is contained in:
杨顺强
2019-04-13 16:56:06 +08:00
committed by Daniel Pan
parent fe36faa44c
commit 19a2fc7355
5 changed files with 25 additions and 10 deletions

View File

@@ -68,6 +68,10 @@ class DirentListItem extends React.Component {
this.setState({
highlight: false,
isOperationShow: false,
}, () => {
if (nextProps.activeDirent && nextProps.activeDirent.name === nextProps.dirent.name) {
this.setState({isOperationShow: true});
}
});
}
}
@@ -494,7 +498,7 @@ class DirentListItem extends React.Component {
}
</Fragment> :
<Fragment>
{(this.state.isOperationShow || (activeDirent && dirent.name === activeDirent.name)) &&
{this.state.isOperationShow &&
<div className="operations">
<ul className="operation-group">
<li className="operation-group-item">

View File

@@ -18,14 +18,23 @@ class DirentMenu extends React.Component {
constructor(props) {
super(props);
this.state = {
isItemMenuShow: false
isItemMenuShow: false,
menuList: [],
};
this.menuList = [];
}
componentDidMount() {
this.menuList = this.calculateMenuList();
this.listenerId = listener.register(this.onShowMenu, this.onHideMenu);
let { currentRepoInfo, dirent, isRepoOwner } = this.props;
let menuList = this.calculateMenuList(currentRepoInfo, dirent, isRepoOwner);
this.setState({menuList: menuList});
}
componentWillReceiveProps(nextProps) {
let { currentRepoInfo, dirent, isRepoOwner } = nextProps;
let menuList = this.calculateMenuList(currentRepoInfo, dirent, isRepoOwner);
this.setState({menuList: menuList});
}
componentWillUnmount () {
@@ -45,8 +54,7 @@ class DirentMenu extends React.Component {
}
}
calculateMenuList() {
let { currentRepoInfo, dirent, isRepoOwner } = this.props;
calculateMenuList(currentRepoInfo, dirent, isRepoOwner) {
let type = dirent.type;
let permission = dirent.permission;
@@ -172,7 +180,7 @@ class DirentMenu extends React.Component {
}
render() {
if (!this.menuList.length) {
if (!this.state.menuList.length) {
return '';
}
return (
@@ -186,7 +194,7 @@ class DirentMenu extends React.Component {
onClick={this.onDropdownToggleClick}
/>
<DropdownMenu>
{this.menuList.map((menuItem, index) => {
{this.state.menuList.map((menuItem, index) => {
if (menuItem === 'Divider') {
return <DropdownItem key={index} divider/>;
} else {