mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 21:30:39 +00:00
Add comment and participant (#3882)
* update handle error * comment and add participant * update nextProps
This commit is contained in:
@@ -3,15 +3,13 @@ import PropTypes from 'prop-types';
|
||||
import moment from 'moment';
|
||||
import { processor } from '@seafile/seafile-editor/dist/utils/seafile-markdown2html';
|
||||
import { Button, Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { gettext, username } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
import ParticipantsList from '../file-view/participants-list';
|
||||
import '../../css/comments-list.css';
|
||||
|
||||
const { username } = window.app.pageOptions;
|
||||
|
||||
const DetailCommentListPropTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
filePath: PropTypes.string.isRequired,
|
||||
@@ -26,10 +24,12 @@ class DetailCommentList extends React.Component {
|
||||
this.state = {
|
||||
commentsList: [],
|
||||
};
|
||||
this.isParticipant = false;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.listComments();
|
||||
this.checkParticipant();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
@@ -38,6 +38,17 @@ class DetailCommentList extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
checkParticipant = () => {
|
||||
const fileParticipantList = this.props.fileParticipantList;
|
||||
if (fileParticipantList.length === 0) {
|
||||
this.isParticipant = false;
|
||||
} else {
|
||||
this.isParticipant = fileParticipantList.some((participant) => {
|
||||
return participant.email === username;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
listComments = (filePath) => {
|
||||
seafileAPI.listComments(this.props.repoID, (filePath || this.props.filePath)).then((res) => {
|
||||
this.setState({ commentsList: res.data.comments });
|
||||
@@ -61,10 +72,23 @@ class DetailCommentList extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
this.addParticipant();
|
||||
}
|
||||
this.refs.commentTextarea.value = '';
|
||||
}
|
||||
|
||||
addParticipant = () => {
|
||||
const { repoID, filePath } = this.props;
|
||||
if (this.isParticipant) return;
|
||||
seafileAPI.addFileParticipant(repoID, filePath, username).then((res) => {
|
||||
this.isParticipant = true;
|
||||
this.props.onParticipantsChange(repoID, filePath);
|
||||
}).catch((err) => {
|
||||
let errMessage = Utils.getErrorMsg(err);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
|
||||
resolveComment = (event) => {
|
||||
const { repoID } = this.props;
|
||||
seafileAPI.updateComment(repoID, event.target.id, 'true').then(() => {
|
||||
|
Reference in New Issue
Block a user