|
@@ -3,10 +3,8 @@ import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { format, formatDistanceStrict } from 'date-fns';
|
|
import { format, formatDistanceStrict } from 'date-fns';
|
|
|
|
|
|
|
|
-import Button from 'react-bootstrap/es/Button';
|
|
|
|
|
import Tooltip from 'react-bootstrap/es/Tooltip';
|
|
import Tooltip from 'react-bootstrap/es/Tooltip';
|
|
|
import OverlayTrigger from 'react-bootstrap/es/OverlayTrigger';
|
|
import OverlayTrigger from 'react-bootstrap/es/OverlayTrigger';
|
|
|
-import Collapse from 'react-bootstrap/es/Collapse';
|
|
|
|
|
|
|
|
|
|
import AppContainer from '../../services/AppContainer';
|
|
import AppContainer from '../../services/AppContainer';
|
|
|
import PageContainer from '../../services/PageContainer';
|
|
import PageContainer from '../../services/PageContainer';
|
|
@@ -33,7 +31,6 @@ class Comment extends React.PureComponent {
|
|
|
|
|
|
|
|
this.state = {
|
|
this.state = {
|
|
|
html: '',
|
|
html: '',
|
|
|
- isOlderRepliesShown: false,
|
|
|
|
|
isReEdit: false,
|
|
isReEdit: false,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -145,14 +142,6 @@ class Comment extends React.PureComponent {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- toggleOlderReplies() {
|
|
|
|
|
- this.setState((prevState) => {
|
|
|
|
|
- return {
|
|
|
|
|
- showOlderReplies: !prevState.showOlderReplies,
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
async renderHtml() {
|
|
async renderHtml() {
|
|
|
|
|
|
|
|
const { growiRenderer, appContainer } = this.props;
|
|
const { growiRenderer, appContainer } = this.props;
|
|
@@ -172,71 +161,6 @@ class Comment extends React.PureComponent {
|
|
|
await interceptorManager.process('postRenderCommentHtml', context);
|
|
await interceptorManager.process('postRenderCommentHtml', context);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- renderReply(reply) {
|
|
|
|
|
- return (
|
|
|
|
|
- <div key={reply._id} className="page-comment-reply">
|
|
|
|
|
- <CommentWrapper
|
|
|
|
|
- comment={reply}
|
|
|
|
|
- deleteBtnClicked={this.props.deleteBtnClicked}
|
|
|
|
|
- growiRenderer={this.props.growiRenderer}
|
|
|
|
|
- />
|
|
|
|
|
- </div>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- renderReplies() {
|
|
|
|
|
- const layoutType = this.props.appContainer.getConfig().layoutType;
|
|
|
|
|
- const isBaloonStyle = layoutType.match(/crowi-plus|growi|kibela/);
|
|
|
|
|
-
|
|
|
|
|
- let replyList = this.props.replyList;
|
|
|
|
|
- if (!isBaloonStyle) {
|
|
|
|
|
- replyList = replyList.slice().reverse();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const areThereHiddenReplies = replyList.length > 2;
|
|
|
|
|
-
|
|
|
|
|
- const { isOlderRepliesShown } = this.state;
|
|
|
|
|
- const toggleButtonIconName = isOlderRepliesShown ? 'icon-arrow-up' : 'icon-options-vertical';
|
|
|
|
|
- const toggleButtonIcon = <i className={`icon-fw ${toggleButtonIconName}`}></i>;
|
|
|
|
|
- const toggleButtonLabel = isOlderRepliesShown ? '' : 'more';
|
|
|
|
|
- const toggleButton = (
|
|
|
|
|
- <Button
|
|
|
|
|
- bsStyle="link"
|
|
|
|
|
- className="page-comments-list-toggle-older"
|
|
|
|
|
- onClick={() => { this.setState({ isOlderRepliesShown: !isOlderRepliesShown }) }}
|
|
|
|
|
- >
|
|
|
|
|
- {toggleButtonIcon} {toggleButtonLabel}
|
|
|
|
|
- </Button>
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- const shownReplies = replyList.slice(replyList.length - 2, replyList.length);
|
|
|
|
|
- const hiddenReplies = replyList.slice(0, replyList.length - 2);
|
|
|
|
|
-
|
|
|
|
|
- const hiddenElements = hiddenReplies.map((reply) => {
|
|
|
|
|
- return this.renderReply(reply);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- const shownElements = shownReplies.map((reply) => {
|
|
|
|
|
- return this.renderReply(reply);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return (
|
|
|
|
|
- <React.Fragment>
|
|
|
|
|
- {areThereHiddenReplies && (
|
|
|
|
|
- <div className="page-comments-hidden-replies">
|
|
|
|
|
- <Collapse in={this.state.isOlderRepliesShown}>
|
|
|
|
|
- <div>{hiddenElements}</div>
|
|
|
|
|
- </Collapse>
|
|
|
|
|
- <div className="text-center">{toggleButton}</div>
|
|
|
|
|
- </div>
|
|
|
|
|
- )}
|
|
|
|
|
-
|
|
|
|
|
- {shownElements}
|
|
|
|
|
- </React.Fragment>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
render() {
|
|
render() {
|
|
|
const comment = this.props.comment;
|
|
const comment = this.props.comment;
|
|
|
const commentId = comment._id;
|
|
const commentId = comment._id;
|
|
@@ -303,7 +227,6 @@ class Comment extends React.PureComponent {
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- {this.renderReplies()}
|
|
|
|
|
|
|
|
|
|
</React.Fragment>
|
|
</React.Fragment>
|
|
|
);
|
|
);
|
|
@@ -325,10 +248,6 @@ Comment.propTypes = {
|
|
|
comment: PropTypes.object.isRequired,
|
|
comment: PropTypes.object.isRequired,
|
|
|
growiRenderer: PropTypes.object.isRequired,
|
|
growiRenderer: PropTypes.object.isRequired,
|
|
|
deleteBtnClicked: PropTypes.func.isRequired,
|
|
deleteBtnClicked: PropTypes.func.isRequired,
|
|
|
- replyList: PropTypes.array,
|
|
|
|
|
-};
|
|
|
|
|
-Comment.defaultProps = {
|
|
|
|
|
- replyList: [],
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default CommentWrapper;
|
|
export default CommentWrapper;
|