mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
sysadmin reconstruct institutions pages (#4213)
* sysadmin reconstruct institutions pages * optimize code * optimize seafile js api name sysAdminAddInstitutionUserBatch * update seafile-js
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Form, FormGroup, Input } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
toggle: PropTypes.func.isRequired,
|
||||
addInstitution: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class SysAdminAddInstitutionDialog extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
value: '',
|
||||
isSubmitBtnActive: false
|
||||
};
|
||||
}
|
||||
|
||||
handleChange = (e) => {
|
||||
const value = e.target.value;
|
||||
if (!value.trim()) {
|
||||
this.setState({isSubmitBtnActive: false});
|
||||
} else {
|
||||
this.setState({isSubmitBtnActive: true});
|
||||
}
|
||||
|
||||
this.setState({value: value});
|
||||
}
|
||||
|
||||
handleSubmit = () => {
|
||||
this.toggle();
|
||||
this.props.addInstitution(this.state.value.trim());
|
||||
}
|
||||
|
||||
toggle = () => {
|
||||
this.props.toggle();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<ModalHeader toggle={this.toggle}>{gettext('Add institution')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<Form>
|
||||
<p>{gettext('Name')}</p>
|
||||
<FormGroup>
|
||||
<Input
|
||||
value={this.state.value}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Form>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.handleSubmit} disabled={!this.state.isSubmitBtnActive}>{gettext('Submit')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SysAdminAddInstitutionDialog.propTypes = propTypes;
|
||||
|
||||
export default SysAdminAddInstitutionDialog;
|
@@ -0,0 +1,54 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import UserSelect from '../../user-select.js';
|
||||
|
||||
const propTypes = {
|
||||
toggle: PropTypes.func.isRequired,
|
||||
addUser: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class AddMemberDialog extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
selectedOption: [],
|
||||
};
|
||||
}
|
||||
|
||||
handleSelectChange = (option) => {
|
||||
this.setState({ selectedOption: option });
|
||||
}
|
||||
|
||||
handleSubmit = () => {
|
||||
if (!this.state.selectedOption) return;
|
||||
const emails = this.state.selectedOption.map(item => item.email);
|
||||
this.props.addUser(emails)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.props.toggle}>
|
||||
<ModalHeader toggle={this.props.toggle}>{gettext('Add Member')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<UserSelect
|
||||
placeholder={gettext('Select users...')}
|
||||
onSelectChange={this.handleSelectChange}
|
||||
isMulti={true}
|
||||
className='org-add-member-select'
|
||||
/>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.handleSubmit}>{gettext('Submit')}</Button>
|
||||
<Button color="secondary" onClick={this.props.toggle}>{gettext('Cancel')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AddMemberDialog.propTypes = propTypes;
|
||||
|
||||
export default AddMemberDialog;
|
Reference in New Issue
Block a user