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

add participants in file comment and detail panel (#3880)

This commit is contained in:
Michael An
2019-07-20 09:51:19 +08:00
committed by Daniel Pan
parent 2ab3b45bf6
commit 2598cd433e
5 changed files with 39 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ class FileParticipantListItem extends Component {
const { participant } = this.props; const { participant } = this.props;
return ( return (
<div className="participant-select-info" onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}> <div className="participant-select-info" onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
<div className="d-flex"> <div className="d-flex" style={{maxWidth: '90%'}}>
<img className="avatar participant-select-avatar" src={participant.avatar_url} alt=""/> <img className="avatar participant-select-avatar" src={participant.avatar_url} alt=""/>
<span className="participant-select-name ellipsis">{participant.name}</span> <span className="participant-select-name ellipsis">{participant.name}</span>
</div> </div>

View File

@@ -7,6 +7,7 @@ import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import toaster from '../toast'; import toaster from '../toast';
import ParticipantsList from '../file-view/participants-list';
import '../../css/comments-list.css'; import '../../css/comments-list.css';
const { username } = window.app.pageOptions; const { username } = window.app.pageOptions;
@@ -14,6 +15,8 @@ const { username } = window.app.pageOptions;
const DetailCommentListPropTypes = { const DetailCommentListPropTypes = {
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
filePath: PropTypes.string.isRequired, filePath: PropTypes.string.isRequired,
onParticipantsChange: PropTypes.func.isRequired,
fileParticipantList: PropTypes.array.isRequired,
}; };
class DetailCommentList extends React.Component { class DetailCommentList extends React.Component {
@@ -93,6 +96,7 @@ class DetailCommentList extends React.Component {
} }
render() { render() {
const { repoID, filePath, fileParticipantList } = this.props;
return ( return (
<div className="seafile-comment detail-comments h-100 w-100"> <div className="seafile-comment detail-comments h-100 w-100">
<ul className="seafile-comment-list"> <ul className="seafile-comment-list">
@@ -114,6 +118,15 @@ class DetailCommentList extends React.Component {
<li className="comment-vacant">{gettext('No comment yet.')}</li>} <li className="comment-vacant">{gettext('No comment yet.')}</li>}
</ul> </ul>
<div className="seafile-comment-footer"> <div className="seafile-comment-footer">
{fileParticipantList &&
<ParticipantsList
onParticipantsChange={this.props.onParticipantsChange}
participants={fileParticipantList}
repoID={repoID}
filePath={filePath}
showIconTip={true}
/>
}
<textarea <textarea
className="add-comment-input" ref="commentTextarea" placeholder={gettext('Add a comment.')} className="add-comment-input" ref="commentTextarea" placeholder={gettext('Add a comment.')}
clos="100" rows="3" warp="virtual" clos="100" rows="3" warp="virtual"

View File

@@ -239,6 +239,8 @@ class DirentDetail extends React.Component {
<DetailCommentList <DetailCommentList
repoID={this.props.repoID} repoID={this.props.repoID}
filePath={(dirent && dirent.type === 'file') ? Utils.joinPath(path, dirent.name) : path} filePath={(dirent && dirent.type === 'file') ? Utils.joinPath(path, dirent.name) : path}
fileParticipantList={this.state.fileParticipantList}
onParticipantsChange={this.onParticipantsChange}
/> />
</TabPane> </TabPane>
</TabContent> </TabContent>

View File

@@ -26,6 +26,7 @@ class CommentPanel extends React.Component {
this.state = { this.state = {
commentsList: [], commentsList: [],
showResolvedComment: true, showResolvedComment: true,
participants: null,
}; };
} }
@@ -92,8 +93,27 @@ class CommentPanel extends React.Component {
}); });
} }
onParticipantsChange = () => {
if (this.props.onParticipantsChange) {
this.props.onParticipantsChange();
} else {
this.getParticipants();
}
}
getParticipants = () => {
if (this.props.participants) {
this.setState({ participants: this.props.participants });
} else {
seafileAPI.listFileParticipants(repoID, filePath).then((res) => {
this.setState({ participants: res.data.participant_list });
});
}
}
componentDidMount() { componentDidMount() {
this.listComments(); this.listComments();
this.getParticipants();
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@@ -103,7 +123,7 @@ class CommentPanel extends React.Component {
} }
render() { render() {
const { participants } = this.props; const { participants } = this.state;
return ( return (
<div className="seafile-comment"> <div className="seafile-comment">
<div className="seafile-comment-title"> <div className="seafile-comment-title">
@@ -148,7 +168,7 @@ class CommentPanel extends React.Component {
<div className="seafile-comment-footer"> <div className="seafile-comment-footer">
{participants && {participants &&
<ParticipantsList <ParticipantsList
onParticipantsChange={this.props.onParticipantsChange} onParticipantsChange={this.onParticipantsChange}
participants={participants} participants={participants}
repoID={repoID} repoID={repoID}
filePath={filePath} filePath={filePath}

View File

@@ -139,7 +139,7 @@
margin-top: 0; margin-top: 0;
} }
.detail-comments .seafile-comment-footer { .detail-comments .seafile-comment-footer {
min-height: 140px; min-height: 175px;
} }
.detail-comments .seafile-comment-footer .add-comment-input, .detail-comments .seafile-edit-comment .edit-comment-input { .detail-comments .seafile-comment-footer .add-comment-input, .detail-comments .seafile-edit-comment .edit-comment-input {
width: 100%; width: 100%;