mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 18:03:48 +00:00
transfer repo to department
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||||
import { gettext } from '../../utils/constants';
|
import Select from 'react-select';
|
||||||
|
import makeAnimated from 'react-select/lib/animated';
|
||||||
|
import { seafileAPI } from '../../utils/seafile-api.js';
|
||||||
|
import { gettext, isPro } from '../../utils/constants';
|
||||||
import UserSelect from '../user-select';
|
import UserSelect from '../user-select';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@@ -16,14 +19,13 @@ class TransferDialog extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
selectedOption: null,
|
selectedOption: null,
|
||||||
errorMsg: [],
|
errorMsg: [],
|
||||||
sharedItems: []
|
transferToUser: true,
|
||||||
};
|
};
|
||||||
this.options = [];
|
this.options = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSelectChange = (option) => {
|
handleSelectChange = (option) => {
|
||||||
this.setState({selectedOption: option});
|
this.setState({selectedOption: option});
|
||||||
this.options = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit = () => {
|
submit = () => {
|
||||||
@@ -31,24 +33,59 @@ class TransferDialog extends React.Component {
|
|||||||
this.props.submit(user);
|
this.props.submit(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
seafileAPI.shareableGroups().then((res) => {
|
||||||
|
for (let i = 0 ; i < res.data.length; i++) {
|
||||||
|
let obj = {};
|
||||||
|
obj.value = res.data[i].name;
|
||||||
|
obj.email = `${res.data[i].id}@seafile_group`;
|
||||||
|
obj.label = res.data[i].name;
|
||||||
|
this.options.push(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onClick = () => {
|
||||||
|
this.setState({
|
||||||
|
transferToUser: !this.state.transferToUser,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const itemName = this.props.itemName;
|
const itemName = this.props.itemName;
|
||||||
const innerSpan = '<span class="op-target" title=' + itemName + '>' + itemName +'</span>';
|
const innerSpan = '<span class="op-target" title=' + itemName + '>' + itemName +'</span>';
|
||||||
let msg = gettext('Transfer Library {library_name} To');
|
let msg = gettext('Transfer Library {library_name}');
|
||||||
let message = msg.replace('{library_name}', innerSpan);
|
let message = msg.replace('{library_name}', innerSpan);
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={true} centered={true}>
|
<Modal isOpen={true}>
|
||||||
<ModalHeader toggle={this.props.toggleDialog}>
|
<ModalHeader toggle={this.props.toggleDialog}>
|
||||||
<div dangerouslySetInnerHTML={{__html:message}} />
|
<div dangerouslySetInnerHTML={{__html:message}} />
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<UserSelect
|
{this.state.transferToUser ?
|
||||||
ref="userSelect"
|
<UserSelect
|
||||||
isMulti={false}
|
ref="userSelect"
|
||||||
className="reviewer-select"
|
isMulti={false}
|
||||||
placeholder={gettext('Please enter 1 or more character')}
|
className="reviewer-select"
|
||||||
onSelectChange={this.handleSelectChange}
|
placeholder={gettext('Search users')}
|
||||||
/>
|
onSelectChange={this.handleSelectChange}
|
||||||
|
/> :
|
||||||
|
<Select
|
||||||
|
isClearable
|
||||||
|
isMulti={false}
|
||||||
|
maxMenuHeight={200}
|
||||||
|
hideSelectedOptions={true}
|
||||||
|
components={makeAnimated()}
|
||||||
|
placeholder={gettext('Select a Department')}
|
||||||
|
options={this.options}
|
||||||
|
onChange={this.handleSelectChange}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
{isPro &&
|
||||||
|
<a href="#" onClick={this.onClick}>{this.state.transferToUser ?
|
||||||
|
gettext('Transfer Library to Department'): gettext('Transfer Library to User')}
|
||||||
|
</a>
|
||||||
|
}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button color="secondary" onClick={this.props.toggleDialog}>{gettext('Cancel')}</Button>
|
<Button color="secondary" onClick={this.props.toggleDialog}>{gettext('Cancel')}</Button>
|
||||||
|
Reference in New Issue
Block a user