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

[file view] redesigned the comment panel

This commit is contained in:
llj
2022-04-09 14:55:40 +08:00
parent 1c303bf2f7
commit cc9dbd346c
4 changed files with 64 additions and 71 deletions

View File

@@ -10,6 +10,7 @@ import { Utils } from '../../utils/utils';
import toaster from '../toast';
import { MentionsInput, Mention } from 'react-mentions';
import { defaultStyle, defaultMentionStyle } from '../../css/react-mentions-default-style';
import '../../css/comments-list.css';
const { username, repoID, filePath } = window.app.pageOptions;
@@ -35,10 +36,6 @@ class CommentPanel extends React.Component {
this.toBeAddedParticipant = [];
}
toggleResolvedComment = () => {
this.setState({ showResolvedComment: !this.state.showResolvedComment });
}
listComments = () => {
seafileAPI.listComments(repoID, filePath).then((res) => {
this.setState({
@@ -165,27 +162,16 @@ class CommentPanel extends React.Component {
const { participants, commentsList } = this.state;
return (
<div className="seafile-comment">
<div className="seafile-comment-title">
<div className="seafile-comment-title flex-shrink-0">
<div onClick={this.props.toggleCommentPanel} className="seafile-comment-title-close">
<i className="fa fa-times-circle"/>
<i className="fa fa-times-circle"></i>
</div>
<div className="seafile-comment-title-text">{gettext('Comments')}</div>
</div>
<div className="seafile-comment-toggle-resolved">
<div className="seafile-comment-title-text">{gettext('Show resolved comments')}</div>
<div className="seafile-comment-title-toggle d-flex">
<label className="custom-switch" id="toggle-resolved-comments">
<input type="checkbox" name="option" className="custom-switch-input"
onChange={this.toggleResolvedComment}
checked={this.state.showResolvedComment && 'checked'}
/>
<span className="custom-switch-indicator"></span>
</label>
</div>
</div>
<div className="flex-fill o-auto">
{commentsList.length > 0 ? (
<ul className="seafile-comment-list">
{commentsList.length > 0 &&
commentsList.map((item, index = 0, arr) => {
{commentsList.map((item, index = 0, arr) => {
let oldTime = (new Date(item.created_at)).getTime();
let time = moment(oldTime).format('YYYY-MM-DD HH:mm');
return (
@@ -199,12 +185,12 @@ class CommentPanel extends React.Component {
/>
</React.Fragment>
);
})
})}
</ul>) :
<p className="text-center my-4">{gettext('No comment yet.')}</p>
}
{commentsList.length == 0 &&
<li className="comment-vacant">{gettext('No comment yet.')}</li>}
</ul>
<div className="seafile-comment-footer">
</div>
<div className="seafile-comment-footer flex-shrink-0">
{participants &&
<ParticipantsList
onParticipantsChange={this.onParticipantsChange}
@@ -230,10 +216,12 @@ class CommentPanel extends React.Component {
appendSpaceOnAdd={true}
/>
</MentionsInput>
<div className="comment-submit-container">
<Button className="submit-comment" color="primary" size="sm" onClick={this.onSubmit}>
{gettext('Submit')}</Button>
</div>
</div>
</div>
);
}
}

View File

@@ -1,4 +1,5 @@
.seafile-comment {
background-color: #f5f5f5;
border-left: 1px solid #e6e6dd;
display: flex;
flex-direction: column;
@@ -11,7 +12,7 @@
line-height: 3em;
padding: 0 1em;
display: flex;
background-color: #fafaf9;
background-color: #fff;
}
.seafile-comment-title .seafile-comment-title-text,
.seafile-history-title .seafile-history-title-text {
@@ -27,26 +28,8 @@
.seafile-history-title .seafile-history-title-close:hover {
color: #888;
}
.seafile-comment-toggle-resolved {
margin-top: 45px;
border-bottom: 1px solid #e5e5e5;
padding: 5px 10px;
display: flex;
position: absolute;
background-color: #fff;
justify-content: space-between;
width: 29%;
}
.seafile-comment-list {
height: calc(100% - 40px);
margin-top: 30px;
overflow-y: auto;
margin-bottom: 0;
}
.seafile-comment-list .comment-vacant {
padding: 1em;
text-align: center;
list-style: none;
}
.seafile-comment-item {
padding: 15px 10px;
@@ -89,6 +72,13 @@
}
.seafile-comment-item .seafile-comment-content {
margin-left: 42px;
padding: 5px 10px;
border-radius: 4px;
background: #fff;
}
.seafile-comment-item .seafile-comment-content p {
word-break: break-all;
margin: 0;
}
.seafile-comment-item .seafile-comment-content ol,
.seafile-comment-item .seafile-comment-content ul,
@@ -104,7 +94,6 @@
background-color: #e6ffed;
}
.seafile-comment-footer {
background-color: #fafaf9;
padding: 10px;
border-top: 1px solid #e5e5e5;
min-height: 182px;
@@ -117,18 +106,30 @@
border-radius: 5px;
background-color: #fff;
}
.seafile-comment-footer .comment-submit-container {
border: 1px solid #e6e6dd;
border-top: none;
border-radius: 0 0 5px 5px;
padding: 5px;
background: #fff;
text-align: right;
position: relative;
}
.seafile-comment-footer .comment-submit-container::before {
border-top: 1px solid #e6e6dd;
content: '';
position: absolute;
left: 5px;
right: 5px;
top: 0;
}
.seafile-comment-footer .submit-comment {
margin-top: 5px;
padding: 0.35rem 0.5rem;
height: 28px;
}
.seafile-edit-comment .comment-btn {
height: 28px;
}
@media (max-width: 768px) {
.seafile-comment-toggle-resolved {
width: 100%;
}
}
.detail-comments {
border-left: 0;
}

View File

@@ -67,6 +67,6 @@ body {
}
@media (min-width: 768px) {
.file-view-body .seafile-comment {
width: 29%;
width: 300px;
}
}

View File

@@ -35,14 +35,18 @@ const defaultStyle = {
minHeight: 90,
height: 90,
border: '1px solid #e6e6dd',
borderRadius: '5px',
borderBottom: 'none',
borderRadius: '5px 5px 0 0',
overfflowY: 'auto',
outline: 'none',
'&focused': {
/*
backgroundColor: '#cee4e5',
outlineOffset: '-2px',
outlineColor: '-webkit-focus-ring-color',
outlineStyle: 'auto',
outlineWidth: '5px',
*/
},
},
},