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 (