2018-12-03 16:21:09 +08:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { gettext } from '../../utils/constants';
|
2018-12-07 10:36:59 +08:00
|
|
|
import ModalPortal from '../modal-portal';
|
|
|
|
import CreateRepoDialog from '../dialog/create-repo-dialog';
|
2018-12-03 16:21:09 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
2018-12-07 10:36:59 +08:00
|
|
|
// isOwnLibrary: PropTypes.bool.isRequired,
|
2018-12-07 13:21:43 +08:00
|
|
|
libraryType: PropTypes.string.isRequired,
|
2018-12-07 10:36:59 +08:00
|
|
|
onCreateRepo: PropTypes.func.isRequired,
|
2018-12-03 16:21:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class RepoViewToolbar extends React.Component {
|
2018-12-07 10:36:59 +08:00
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isCreateRepoDialogShow: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
onCreateRepo = (repo) => {
|
|
|
|
this.props.onCreateRepo(repo);
|
|
|
|
this.onCreateToggle();
|
|
|
|
}
|
|
|
|
|
|
|
|
onCreateToggle = () => {
|
|
|
|
this.setState({isCreateRepoDialogShow: !this.state.isCreateRepoDialogShow});
|
|
|
|
}
|
2018-12-03 16:21:09 +08:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2018-12-07 10:36:59 +08:00
|
|
|
<Fragment>
|
|
|
|
<div className="cur-view-toolbar border-left-show">
|
|
|
|
<span className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none" title="Side Nav Menu" onClick={this.props.onShowSidePanel}></span>
|
|
|
|
<div className="operation">
|
|
|
|
<button className="btn btn-secondary operation-item" title={gettext('New Library')} onClick={this.onCreateToggle}>
|
|
|
|
<i className="fas fa-plus-square op-icon"></i>
|
|
|
|
{gettext('New Library')}
|
|
|
|
</button>
|
2018-12-07 13:21:43 +08:00
|
|
|
{this.props.libraryType !== 'group' && (
|
|
|
|
<button className="btn btn-secondary operation-item" title={gettext('More')} onClick={this.onShareClick}>{gettext('More')}</button>
|
|
|
|
)}
|
2018-12-07 10:36:59 +08:00
|
|
|
</div>
|
2018-12-03 16:21:09 +08:00
|
|
|
</div>
|
2018-12-07 10:36:59 +08:00
|
|
|
{this.state.isCreateRepoDialogShow && (
|
|
|
|
<ModalPortal>
|
|
|
|
<CreateRepoDialog
|
2018-12-07 13:21:43 +08:00
|
|
|
libraryType={this.props.libraryType}
|
2018-12-07 10:36:59 +08:00
|
|
|
onCreateRepo={this.onCreateRepo}
|
|
|
|
onCreateToggle={this.onCreateToggle}
|
|
|
|
/>
|
|
|
|
</ModalPortal>
|
|
|
|
)}
|
|
|
|
</Fragment>
|
2018-12-03 16:21:09 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RepoViewToolbar.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default RepoViewToolbar;
|