1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 07:27:04 +00:00

Show draft review info at repo info bar (#2832)

This commit is contained in:
C_Q
2019-01-18 14:50:42 +08:00
committed by Daniel Pan
parent f0e9c7a1b1
commit d1f55247ff
14 changed files with 450 additions and 30 deletions

View File

@@ -3,7 +3,9 @@ import PropTypes from 'prop-types';
import ModalPortal from './modal-portal';
import { Modal } from 'reactstrap';
import ListTaggedFilesDialog from './dialog/list-taggedfiles-dialog';
import { siteRoot } from '../utils/constants';
import ListRepoDraftsDialog from './dialog/list-repo-drafts-dialog';
import ListRepoReviewsDialog from './dialog/list-repo-reviews-dialog';
import { siteRoot, gettext } from '../utils/constants';
import { Utils } from '../utils/utils';
import '../css/repo-info-bar.css';
@@ -13,6 +15,8 @@ const propTypes = {
currentPath: PropTypes.string.isRequired,
usedRepoTags: PropTypes.array.isRequired,
readmeMarkdown: PropTypes.object,
draftCounts: PropTypes.number,
reviewCounts: PropTypes.number,
};
class RepoInfoBar extends React.Component {
@@ -22,6 +26,8 @@ class RepoInfoBar extends React.Component {
this.state = {
currentTag: null,
isListTaggedFileShow: false,
showRepoDrafts: false,
showRepoReviews: false,
};
}
@@ -38,6 +44,18 @@ class RepoInfoBar extends React.Component {
});
}
toggleDrafts = () => {
this.setState({
showRepoDrafts: !this.state.showRepoDrafts
});
}
toggleReviews = () => {
this.setState({
showRepoReviews: !this.state.showRepoReviews
});
}
render() {
let {repoID, currentPath, usedRepoTags, readmeMarkdown} = this.props;
let href = readmeMarkdown !== null ? siteRoot + 'lib/' + repoID + '/file' + Utils.joinPath(currentPath, readmeMarkdown.name) : '';
@@ -59,24 +77,61 @@ class RepoInfoBar extends React.Component {
})}
</ul>
)}
{readmeMarkdown !== null && (
<div className="readme-file">
<i className="readme-flag fa fa-flag"></i>
<a className="readme-name" href={href} target='_blank'>{readmeMarkdown.name}</a>
</div>
)}
<div className="readme-files">
{readmeMarkdown !== null && (
<span className="readme-file">
<i className="readme-flag fa fa-flag"></i>
<a className="readme-name" href={href} target='_blank'>{readmeMarkdown.name}</a>
</span>
)}
{this.props.draftCounts > 0 &&
<span className="readme-file">
<i className="readme-flag fa fa-pen"></i>
<span className="used-tag-name">{gettext('draft')}</span>
<span className="used-tag-files" onClick={this.toggleDrafts}>
{this.props.draftCounts > 1 ? this.props.draftCounts + ' files' : this.props.draftCounts + ' file'}
</span>
</span>
}
{this.props.reviewCounts > 0 &&
<span className="readme-file">
<i className="readme-flag fa fa-clipboard"></i>
<span className="used-tag-name">{gettext('review')}</span>
<span className="used-tag-files" onClick={this.toggleReviews}>
{this.props.reviewCounts > 1 ? this.props.reviewCounts + ' files' : this.props.reviewCounts + ' file'}
</span>
</span>
}
</div>
{this.state.isListTaggedFileShow && (
<ModalPortal>
<Modal isOpen={true}>
<ListTaggedFilesDialog
repoID={repoID}
currentTag={this.state.currentTag}
onClose={this.onCloseDialog}
toggleCancel={this.onListTaggedFiles}
/>
</Modal>
<ListTaggedFilesDialog
repoID={repoID}
currentTag={this.state.currentTag}
onClose={this.onCloseDialog}
toggleCancel={this.onListTaggedFiles}
/>
</ModalPortal>
)}
{this.state.showRepoDrafts && (
<ModalPortal>
<ListRepoDraftsDialog
toggle={this.toggleDrafts}
repoID={this.props.repoID}
/>
</ModalPortal>
)}
{this.state.showRepoReviews && (
<ModalPortal>
<ListRepoReviewsDialog
toggle={this.toggleReviews}
repoID={this.props.repoID}
/>
</ModalPortal>
)}
</div>
);
}