2019-10-15 05:41:41 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
|
|
|
import { Utils } from '../../../utils/utils';
|
|
|
|
import { gettext } from '../../../utils/constants';
|
|
|
|
import UserSelect from '../../user-select';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
groupName: PropTypes.string.isRequired,
|
|
|
|
transferGroup: PropTypes.func.isRequired,
|
|
|
|
toggleDialog: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
class SysAdminTransferGroupDialog extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
selectedOption: null,
|
|
|
|
submitBtnDisabled: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleSelectChange = (option) => {
|
|
|
|
this.setState({
|
|
|
|
selectedOption: option,
|
2020-11-02 05:56:35 +00:00
|
|
|
submitBtnDisabled: option == null
|
2019-10-15 05:41:41 +00:00
|
|
|
});
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-10-15 05:41:41 +00:00
|
|
|
|
|
|
|
submit = () => {
|
|
|
|
const receiver = this.state.selectedOption.email;
|
|
|
|
this.props.transferGroup(receiver);
|
|
|
|
this.props.toggleDialog();
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-10-15 05:41:41 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { submitBtnDisabled } = this.state;
|
2024-07-18 03:58:42 +00:00
|
|
|
const groupName = '<span class="op-target">' + Utils.HTMLescape(this.props.groupName) + '</span>';
|
2019-11-29 07:17:00 +00:00
|
|
|
const msg = gettext('Transfer Group {placeholder} to').replace('{placeholder}', groupName);
|
2019-10-15 05:41:41 +00:00
|
|
|
return (
|
2023-11-30 05:58:06 +00:00
|
|
|
<Modal isOpen={true} toggle={this.props.toggleDialog}>
|
2019-10-15 05:41:41 +00:00
|
|
|
<ModalHeader toggle={this.props.toggleDialog}>
|
2024-07-18 03:58:42 +00:00
|
|
|
<span dangerouslySetInnerHTML={{ __html: msg }}></span>
|
2019-10-15 05:41:41 +00:00
|
|
|
</ModalHeader>
|
|
|
|
<ModalBody>
|
|
|
|
<UserSelect
|
|
|
|
ref="userSelect"
|
|
|
|
isMulti={false}
|
|
|
|
placeholder={gettext('Select a user')}
|
|
|
|
onSelectChange={this.handleSelectChange}
|
2020-11-02 05:56:35 +00:00
|
|
|
/>
|
2019-10-15 05:41:41 +00:00
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
<Button color="secondary" onClick={this.props.toggleDialog}>{gettext('Cancel')}</Button>
|
|
|
|
<Button color="primary" onClick={this.submit} disabled={submitBtnDisabled}>{gettext('Submit')}</Button>
|
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SysAdminTransferGroupDialog.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default SysAdminTransferGroupDialog;
|