1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

optimized code

This commit is contained in:
shanshuirenjia
2018-12-17 22:34:54 +08:00
parent 5836e40712
commit 93b619899f
2 changed files with 19 additions and 11 deletions

View File

@@ -134,20 +134,10 @@ class DirOperationToolbar extends React.Component {
this.props.goDraftPage();
}
getFolderName = (path) => {
// eg: /
if (path === '/') {
return path;
}
// eg: /abc/bcd/; /abc/bcd
path = path[path.length - 1] !== '/' ? path : path.slice(0, path.length -2);
return path.slice(path.lastIndexOf('/') + 1);
}
render() {
let { path, isViewFile } = this.props;
let itemType = isViewFile ? 'file' : 'dir';
let itemName = isViewFile ? Utils.getFileName(path) : this.getFolderName(path);
let itemName = isViewFile ? Utils.getFileName(path) : Utils.getFolderName(path);
return (
<Fragment>
<div className="operation">