import React from 'react'; import PropTypes from 'prop-types'; import { ButtonGroup } from 'reactstrap'; import IconButton from '../icon-button'; import { gettext, siteRoot } from '../../utils/constants'; import { Utils } from '../../utils/utils'; const propTypes = { isLocked: PropTypes.bool.isRequired, lockedByMe: PropTypes.bool.isRequired, toggleLockFile: PropTypes.func.isRequired, toggleCommentPanel: PropTypes.func.isRequired }; const { canLockUnlockFile, repoID, repoName, parentDir, filePerm, filePath, canEditFile, err, encoding, // for 'edit', not undefined only for some kinds of files canDownloadFile, enableComment } = window.app.pageOptions; class FileToolbar extends React.Component { render() { const { isLocked, lockedByMe } = this.props; let showLockUnlockBtn = false; let lockUnlockText, lockUnlockIcon; if (canLockUnlockFile) { if (!isLocked) { showLockUnlockBtn = true; lockUnlockText = gettext('Lock'); lockUnlockIcon = 'fa fa-lock'; } else if (lockedByMe) { showLockUnlockBtn = true; lockUnlockText = gettext('Unlock'); lockUnlockIcon = 'fa fa-unlock'; } } return (