1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

Double name bug repair (#2879)

This commit is contained in:
杨顺强
2019-01-25 15:44:04 +08:00
committed by Daniel Pan
parent 9ddcf06225
commit 69b4db2afa
12 changed files with 222 additions and 91 deletions

View File

@@ -20,6 +20,7 @@ const propTypes = {
onUploadFolder: PropTypes.func.isRequired,
isDraft: PropTypes.bool,
hasDraft: PropTypes.bool,
direntList: PropTypes.array.isRequired,
};
class DirOperationToolbar extends React.Component {
@@ -167,6 +168,14 @@ class DirOperationToolbar extends React.Component {
this.props.goDraftPage();
}
checkDuplicatedName = (newName) => {
let direntList = this.props.direntList;
let isDuplicated = direntList.some(object => {
return object.name === newName;
});
return isDuplicated;
}
render() {
let { path, isViewFile } = this.props;
let itemType = isViewFile ? 'file' : 'dir';
@@ -220,8 +229,9 @@ class DirOperationToolbar extends React.Component {
parentPath={this.props.path}
fileType={this.state.fileType}
onAddFile={this.onAddFile}
checkDuplicatedName={this.checkDuplicatedName}
addFileCancel={this.onCreateFileToggle}
/>
/>
</ModalPortal>
)}
{this.state.isCreateFolderDialogShow && (
@@ -229,6 +239,7 @@ class DirOperationToolbar extends React.Component {
<CreateFolder
parentPath={this.props.path}
onAddFolder={this.onAddFolder}
checkDuplicatedName={this.checkDuplicatedName}
addFolderCancel={this.onCreateFolderToggle}
/>
</ModalPortal>