mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-17 15:53:28 +00:00
add repo-toolbar and repo-dialog
This commit is contained in:
96
frontend/src/components/dialog/create-repo-dialog.js
Normal file
96
frontend/src/components/dialog/create-repo-dialog.js
Normal file
@@ -0,0 +1,96 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Check } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
|
||||
};
|
||||
|
||||
class CreateRepoDialog extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
repoName: '',
|
||||
password: '',
|
||||
password2: '',
|
||||
};
|
||||
this.newInput = React.createRef();
|
||||
}
|
||||
|
||||
handleChange = (e) => {
|
||||
this.setState({
|
||||
childName: e.target.value,
|
||||
});
|
||||
}
|
||||
|
||||
handleSubmit = () => {
|
||||
let path = this.state.parentPath + this.state.childName;
|
||||
this.props.onAddFolder(path);
|
||||
}
|
||||
|
||||
handleKeyPress = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.handleSubmit();
|
||||
}
|
||||
}
|
||||
|
||||
toggle = () => {
|
||||
this.props.addFolderCancel();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.newInput.focus();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<ModalHeader toggle={this.toggle}>{gettext('New Folder')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<Form>
|
||||
<FormGroup>
|
||||
<Label for="fileName">{gettext('Name')}: </Label>
|
||||
<Input
|
||||
onKeyPress={this.handleKeyPress}
|
||||
innerRef={input => {this.newInput = input;}}
|
||||
id="fileName" placeholder={gettext('newName')}
|
||||
value={this.state.childName}
|
||||
onChange={this.handleNameChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Input type="checkbox" id="encrypt"/>{gettext('Encrypt')}
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Label for="fileName">{gettext('Password(at least 8 characters)')}</Label>
|
||||
<Input
|
||||
id="fileName"
|
||||
placeholder={gettext('password')}
|
||||
value={this.state.childName}
|
||||
onChange={this.handlePasswordChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Label for="fileName">{gettext('Password again')}: </Label>
|
||||
<Input
|
||||
id="fileName"
|
||||
placeholder={gettext('password2')}
|
||||
value={this.state.childName}
|
||||
onChange={this.handlePassword2Change}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Form>
|
||||
<div className="err-message"></div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.handleSubmit}>{gettext('Submit')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
CreateRepoDialog.propTypes = propTypes;
|
||||
|
||||
export default CreateRepoDialog;
|
27
frontend/src/components/toolbar/repo-view-toobar.js
Normal file
27
frontend/src/components/toolbar/repo-view-toobar.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { gettext } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
isOwnLibrary: PropTypes.bool.isRequired,
|
||||
libraryType: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
class RepoViewToolbar extends React.Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<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.onCreateClick}>{gettext('New Library')}</button>
|
||||
<button className="btn btn-secondary operation-item" title={gettext('More')} onClick={this.onShareClick}>{gettext('More')}</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RepoViewToolbar.propTypes = propTypes;
|
||||
|
||||
export default RepoViewToolbar;
|
Reference in New Issue
Block a user