1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-23 04:18:21 +00:00

move dialog

This commit is contained in:
Michael An
2019-05-05 15:18:54 +08:00
parent b183c7c3ab
commit 9574c5943f
13 changed files with 310 additions and 337 deletions

View File

@@ -1,19 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import { gettext, orgID } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import Toast from '../../components/toast';
import OrgUserInfo from '../../models/org-user';
import ModalPortal from '../../components/modal-portal';
import AddOrgAdminDialog from '../../components/dialog/org-add-admin-dialog';
import { gettext } from '../../utils/constants';
import UserItem from './org-user-item';
import '../../css/org-admin-paginator.css';
const propTypes = {
toggleAddOrgAdmin: PropTypes.func.isRequired,
currentTab: PropTypes.string.isRequired,
isShowAddOrgAdminDialog: PropTypes.bool.isRequired,
toggleDelete: PropTypes.func.isRequired,
toggleRevokeAdmin: PropTypes.func.isRequired,
orgAdminUsers: PropTypes.array.isRequired,
initOrgAdmin: PropTypes.func.isRequired,
};
class OrgAdminList extends React.Component {
@@ -21,18 +18,16 @@ class OrgAdminList extends React.Component {
constructor(props) {
super(props);
this.state = {
orgAdminUsers: [],
isItemFreezed: false,
};
}
componentDidMount() {
seafileAPI.listOrgUsers(orgID, true).then(res => {
let userList = res.data.user_list.map(item => {
return new OrgUserInfo(item);
});
this.setState({orgAdminUsers: userList});
});
this.props.initOrgAdmin();
}
componentWillReceiveProps(nextProps) {
this.props.initOrgAdmin();
}
onFreezedItem = () => {
@@ -43,44 +38,8 @@ class OrgAdminList extends React.Component {
this.setState({isItemFreezed: false});
}
toggleDelete = (email) => {
seafileAPI.deleteOrgUser(orgID, email).then(res => {
this.setState({
orgAdminUsers: this.state.orgAdminUsers.filter(item => item.email != email)
});
let msg = gettext('Successfully deleted %s');
msg = msg.replace('%s', email);
Toast.success(msg);
});
}
toggleRevokeAdmin = (email) => {
seafileAPI.setOrgAdmin(orgID, email, false).then(res => {
this.setState({
orgAdminUsers: this.state.orgAdminUsers.filter(item => item.email != email)
});
let msg = gettext('Successfully revoke the admin permission of %s');
msg = msg.replace('%s', email);
Toast.success(msg);
});
}
addOrgAdmin = (userEmail) => {
seafileAPI.setOrgAdmin(orgID, userEmail, true).then(res => {
let userInfo = new OrgUserInfo(res.data);
this.state.orgAdminUsers.unshift(userInfo);
this.setState({
orgAdminUsers: this.state.orgAdminUsers
});
this.props.toggleAddOrgAdmin();
let msg = gettext('Successfully set %s as admin.');
msg = msg.replace('%s', userInfo.email);
Toast.success(msg);
});
}
render() {
let orgAdminUsers = this.state.orgAdminUsers;
let orgAdminUsers = this.props.orgAdminUsers;
return (
<div className="cur-view-content">
@@ -102,8 +61,8 @@ class OrgAdminList extends React.Component {
user={item}
currentTab={this.props.currentTab}
isItemFreezed={this.state.isItemFreezed}
toggleDelete={this.toggleDelete}
toggleRevokeAdmin={this.toggleRevokeAdmin}
toggleDelete={this.props.toggleDelete}
toggleRevokeAdmin={this.props.toggleRevokeAdmin}
onFreezedItem={this.onFreezedItem}
onUnfreezedItem={this.onUnfreezedItem}
/>
@@ -111,11 +70,6 @@ class OrgAdminList extends React.Component {
})}
</tbody>
</table>
{this.props.isShowAddOrgAdminDialog && (
<ModalPortal>
<AddOrgAdminDialog toggle={this.props.toggleAddOrgAdmin} addOrgAdmin={this.addOrgAdmin} />
</ModalPortal>
)}
</div>
);
}