import React from 'react'; import PropTypes from 'prop-types'; import ModalPortal from './modal-portal'; import ListTaggedFilesDialog from './dialog/list-taggedfiles-dialog'; import ListRepoDraftsDialog from './dialog/list-repo-drafts-dialog'; import ReadmeDialog from './dialog/readme-dialog'; import { siteRoot, gettext } from '../utils/constants'; import { Utils } from '../utils/utils'; import '../css/repo-info-bar.css'; const propTypes = { repoID: PropTypes.string.isRequired, currentPath: PropTypes.string.isRequired, usedRepoTags: PropTypes.array.isRequired, readmeMarkdown: PropTypes.object, draftCounts: PropTypes.number, updateUsedRepoTags: PropTypes.func.isRequired, onFileTagChanged: PropTypes.func.isRequired, }; class RepoInfoBar extends React.Component { constructor(props) { super(props); this.state = { currentTag: null, isListTaggedFileShow: false, showRepoDrafts: false, showReadmeDialog: false, }; } onListTaggedFiles = (currentTag) => { this.setState({ currentTag: currentTag, isListTaggedFileShow: !this.state.isListTaggedFileShow, }); } onCloseDialog = () => { this.setState({ isListTaggedFileShow: false }); } toggleDrafts = () => { this.setState({ showRepoDrafts: !this.state.showRepoDrafts }); } toggleReadme = () => { this.setState({ showReadmeDialog: !this.state.showReadmeDialog }); } render() { let {repoID, currentPath, usedRepoTags, readmeMarkdown} = this.props; let href = readmeMarkdown !== null ? siteRoot + 'lib/' + repoID + '/file' + Utils.joinPath(currentPath, readmeMarkdown.name) + '?mode=edit' : ''; let filePath = readmeMarkdown !== null ? currentPath + readmeMarkdown.name : ''; return (
{usedRepoTags.length > 0 && ( )}
0 && readmeMarkdown) ? 'file-info-list mt-1' : 'file-info-list'}> {(readmeMarkdown !== null && parseInt(readmeMarkdown.size) > 1) && {readmeMarkdown.name} } {(readmeMarkdown !== null && parseInt(readmeMarkdown.size) < 2) && {readmeMarkdown.name} } {this.props.draftCounts > 0 && {gettext('draft')} {this.props.draftCounts > 1 ? this.props.draftCounts + ' files' : this.props.draftCounts + ' file'} }
{this.state.isListTaggedFileShow && ( )} {this.state.showRepoDrafts && ( )} {this.state.showReadmeDialog && ( )}
); } } RepoInfoBar.propTypes = propTypes; export default RepoInfoBar;