1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 17:33:18 +00:00

Merge pull request #2659 from haiwen/bug-repair

Bug repair
This commit is contained in:
Daniel Pan
2018-12-18 11:07:32 +08:00
committed by GitHub
9 changed files with 150 additions and 52 deletions

View File

@@ -9964,7 +9964,7 @@
}, },
"react-popper": { "react-popper": {
"version": "0.8.3", "version": "0.8.3",
"resolved": "http://registry.npmjs.org/react-popper/-/react-popper-0.8.3.tgz", "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-0.8.3.tgz",
"integrity": "sha1-D3MzMTfJ+wr27EB00tBYWgoEYeE=", "integrity": "sha1-D3MzMTfJ+wr27EB00tBYWgoEYeE=",
"requires": { "requires": {
"popper.js": "^1.12.9", "popper.js": "^1.12.9",

View File

@@ -7,6 +7,63 @@ import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import { seafileAPI } from '../../utils/seafile-api.js'; import { seafileAPI } from '../../utils/seafile-api.js';
class GroupItem extends React.Component {
constructor(props) {
super(props);
this.state = {
isOperationShow: false
};
}
onMouseEnter = () => {
this.setState({isOperationShow: true});
}
onMouseLeave = () => {
this.setState({isOperationShow: false});
}
deleteShareItem = () => {
let item = this.props.item;
this.props.deleteShareItem(item.group_info.id);
}
render() {
let item = this.props.item;
return (
<tr onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
<td>{item.group_info.name}</td>
<td>{Utils.sharePerms[item.permission]}</td>
<td>
<span
className={`sf2-icon-x3 sf2-x op-icon a-simulate ${this.state.isOperationShow ? '' : 'hide'}`}
onClick={this.deleteShareItem}
title={gettext('Delete')}
>
</span>
</td>
</tr>
);
}
}
class GroupList extends React.Component {
render() {
let items = this.props.items;
return (
<tbody>
{items.map((item, index) => {
return (
<GroupItem key={index} item={item} deleteShareItem={this.props.deleteShareItem}/>
);
})}
</tbody>
);
}
}
const propTypes = { const propTypes = {
isGroupOwnedRepo: PropTypes.bool, isGroupOwnedRepo: PropTypes.bool,
itemPath: PropTypes.string.isRequired, itemPath: PropTypes.string.isRequired,
@@ -85,7 +142,7 @@ class ShareToGroup extends React.Component {
let path = this.props.itemPath; let path = this.props.itemPath;
let repoID = this.props.repoID; let repoID = this.props.repoID;
let isGroupOwnedRepo = this.props.isGroupOwnedRepo; let isGroupOwnedRepo = this.props.isGroupOwnedRepo;
if (this.state.selectedOption.length > 0 ) { if (this.state.selectedOption && this.state.selectedOption.length > 0 ) {
for (let i = 0; i < this.state.selectedOption.length; i ++) { for (let i = 0; i < this.state.selectedOption.length; i ++) {
groups[i] = this.state.selectedOption[i].id; groups[i] = this.state.selectedOption[i].id;
} }
@@ -137,8 +194,7 @@ class ShareToGroup extends React.Component {
} }
} }
deleteShareItem = (e, groupID) => { deleteShareItem = (groupID) => {
e.preventDefault();
let path = this.props.itemPath; let path = this.props.itemPath;
let repoID = this.props.repoID; let repoID = this.props.repoID;
if (this.props.isGroupOwnedRepo) { if (this.props.isGroupOwnedRepo) {
@@ -207,20 +263,6 @@ class ShareToGroup extends React.Component {
} }
} }
function GroupList(props) {
return (
<tbody>
{props.items.map((item, index) => (
<tr key={index}>
<td>{item.group_info.name}</td>
<td>{Utils.sharePerms[item.permission]}</td>
<td><a href="#" onClick={(e) => {props.deleteShareItem(e, item.group_info.id);}} className="sf2-icon-x3 sf2-x op-icon" title={gettext('Delete')}></a></td>
</tr>
))}
</tbody>
);
}
ShareToGroup.propTypes = propTypes; ShareToGroup.propTypes = propTypes;
export default ShareToGroup; export default ShareToGroup;

View File

@@ -6,6 +6,63 @@ import PropTypes from 'prop-types';
import { Button, Input } from 'reactstrap'; import { Button, Input } from 'reactstrap';
import { seafileAPI } from '../../utils/seafile-api.js'; import { seafileAPI } from '../../utils/seafile-api.js';
class UserItem extends React.Component {
constructor(props) {
super(props);
this.state = {
isOperationShow: false
};
}
onMouseEnter = () => {
this.setState({isOperationShow: true});
}
onMouseLeave = () => {
this.setState({isOperationShow: false});
}
deleteShareItem = () => {
let item = this.props.item;
this.props.deleteShareItem(item.name);
}
render() {
let item = this.props.item;
return (
<tr onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
<td>{item.user_info.nickname}</td>
<td>{Utils.sharePerms[item.permission]}</td>
<td>
<span
className={`sf2-icon-x3 sf2-x op-icon a-simulate ${this.state.isOperationShow ? '' : 'hide'}`}
onClick={this.deleteShareItem}
title={gettext('Delete')}
>
</span>
</td>
</tr>
);
}
}
class UserList extends React.Component {
render() {
let items = this.props.items;
return (
<tbody>
{items.map((item, index) => {
return (
<UserItem key={index} item={item} deleteShareItem={this.props.deleteShareItem}/>
);
})}
</tbody>
);
}
}
const propTypes = { const propTypes = {
isGroupOwnedRepo: PropTypes.bool, isGroupOwnedRepo: PropTypes.bool,
itemPath: PropTypes.string.isRequired, itemPath: PropTypes.string.isRequired,
@@ -88,7 +145,7 @@ class ShareToUser extends React.Component {
let users = []; let users = [];
let path = this.props.itemPath; let path = this.props.itemPath;
let repoID = this.props.repoID; let repoID = this.props.repoID;
if (this.state.selectedOption.length > 0 ) { if (this.state.selectedOption && this.state.selectedOption.length > 0 ) {
for (let i = 0; i < this.state.selectedOption.length; i ++) { for (let i = 0; i < this.state.selectedOption.length; i ++) {
users[i] = this.state.selectedOption[i].email; users[i] = this.state.selectedOption[i].email;
} }
@@ -134,8 +191,7 @@ class ShareToUser extends React.Component {
} }
} }
deleteShareItem = (e, username) => { deleteShareItem = (username) => {
e.preventDefault();
let path = this.props.itemPath; let path = this.props.itemPath;
let repoID = this.props.repoID; let repoID = this.props.repoID;
if (this.props.isGroupOwnedRepo) { if (this.props.isGroupOwnedRepo) {
@@ -210,20 +266,6 @@ class ShareToUser extends React.Component {
} }
} }
function UserList(props) {
return (
<tbody>
{props.items.map((item, index) => (
<tr key={index}>
<td>{item.user_info.nickname}</td>
<td>{Utils.sharePerms[item.permission]}</td>
<td><a href="#" onClick={(e) => {props.deleteShareItem(e, item.user_info.name);}} className="sf2-icon-x3 sf2-x op-icon" title={gettext('Delete')}></a></td>
</tr>
))}
</tbody>
);
}
ShareToUser.propTypes = propTypes; ShareToUser.propTypes = propTypes;
export default ShareToUser; export default ShareToUser;

View File

@@ -126,6 +126,7 @@ class DirPanel extends React.Component {
onItemsDelete={this.props.onItemsDelete} onItemsDelete={this.props.onItemsDelete}
/> : /> :
<DirOperationToolBar <DirOperationToolBar
isViewFile={false}
path={this.props.path} path={this.props.path}
repoID={this.props.repoID} repoID={this.props.repoID}
onAddFile={this.props.onAddFile} onAddFile={this.props.onAddFile}
@@ -152,6 +153,7 @@ class DirPanel extends React.Component {
<div className="cur-view-container"> <div className="cur-view-container">
<div className="cur-view-path"> <div className="cur-view-path">
<CurDirPath <CurDirPath
isViewFile={false}
repoID={this.props.repoID} repoID={this.props.repoID}
repoName={this.props.repoName} repoName={this.props.repoName}
pathPrefix={this.props.pathPrefix} pathPrefix={this.props.pathPrefix}
@@ -209,9 +211,10 @@ class DirPanel extends React.Component {
)} )}
{this.props.libNeedDecrypt && ( {this.props.libNeedDecrypt && (
<ModalPortal> <ModalPortal>
<LibDecryptDialog repoID={this.props.repoID} <LibDecryptDialog
onLibDecryptDialog={this.props.onLibDecryptDialog} repoID={this.props.repoID}
/> onLibDecryptDialog={this.props.onLibDecryptDialog}
/>
</ModalPortal> </ModalPortal>
)} )}
</div> </div>

View File

@@ -46,14 +46,14 @@ class RepoListItem extends React.Component {
<span className="icon far fa-folder"></span> <span className="icon far fa-folder"></span>
<span className="name">{this.props.repo.repo_name}</span> <span className="name">{this.props.repo.repo_name}</span>
</span> </span>
{ {this.state.isShowChildren && (
<DirentListView <DirentListView
repo={this.props.repo} repo={this.props.repo}
isShowChildren={this.state.isShowChildren} isShowChildren={this.state.isShowChildren}
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
selectedPath={this.props.selectedPath} selectedPath={this.props.selectedPath}
/> />
} )}
</li> </li>
); );
} }

View File

@@ -135,14 +135,9 @@ class DirOperationToolbar extends React.Component {
} }
render() { render() {
let isFile = this.props.isViewFile; let { path, isViewFile } = this.props;
let itemName; let itemType = isViewFile ? 'file' : 'dir';
if (this.props.isViewFile) { let itemName = isViewFile ? Utils.getFileName(path) : Utils.getFolderName(path);
itemName = Utils.getFileName(this.props.path)
} else {
itemName = this.props.path.replace('\/','');
}
return ( return (
<Fragment> <Fragment>
<div className="operation"> <div className="operation">
@@ -203,7 +198,7 @@ class DirOperationToolbar extends React.Component {
{this.state.isShareDialogShow && {this.state.isShareDialogShow &&
<ModalPortal> <ModalPortal>
<ShareDialog <ShareDialog
isDir={!isFile} itemType={itemType}
itemName={itemName} itemName={itemName}
itemPath={this.props.path} itemPath={this.props.path}
repoID={this.props.repoID} repoID={this.props.repoID}

View File

@@ -26,8 +26,6 @@
background-color: #fff; background-color: #fff;
line-height: 29px; line-height: 29px;
font-weight: normal; font-weight: normal;
font-size: 13px;
color: #333;
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 2px; border-radius: 2px;
} }

View File

@@ -175,7 +175,7 @@ class Item extends Component {
'is_admin': data.is_admin, 'is_admin': data.is_admin,
'permission': permission 'permission': permission
}); });
data.url = `${siteRoot}library/${data.repo_id}/${Utils.encodePath(data.repo_name)}`; data.url = `${siteRoot}library/${data.repo_id}/${Utils.encodePath(data.repo_name)}/`;
let iconVisibility = this.state.showOpIcon ? '' : ' invisible'; let iconVisibility = this.state.showOpIcon ? '' : ' invisible';
let shareIconClassName = 'sf2-icon-share sf2-x op-icon' + iconVisibility; let shareIconClassName = 'sf2-icon-share sf2-x op-icon' + iconVisibility;

View File

@@ -170,6 +170,24 @@ export const Utils = {
return filePath.slice(lastIndex+1); return filePath.slice(lastIndex+1);
}, },
/**
* input:
* eg: /
* ../abc/abc/
* ../abc/bc
* output(return):
* eg: /
* abc
* bc
*/
getFolderName: function(path) {
if (path === '/') {
return path;
}
path = path[path.length - 1] !== '/' ? path : path.slice(0, path.length -2);
return path.slice(path.lastIndexOf('/') + 1);
},
/* /*
return dirname of a path. return dirname of a path.
if path is '/', return '/'. if path is '/', return '/'.