mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-24 21:07:17 +00:00
org admin delete org (#8167)
* org admin delete org * code-optimize * add ORG_ENABLE_ADMIN_DELETE_ORG * Organization -> Team --------- Co-authored-by: r350178982 <32759763+r350178982@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, Input, ModalBody, ModalFooter, Label, Form, FormGroup } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import SeahubModalHeader from '@/components/common/seahub-modal-header';
|
||||
|
||||
const propTypes = {
|
||||
organizationName: PropTypes.string.isRequired,
|
||||
toggle: PropTypes.func.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
class OrgAdminDeleteOrgDialog extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
name: '',
|
||||
errMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
toggle = () => {
|
||||
this.props.toggle();
|
||||
};
|
||||
|
||||
inputName = (e) => {
|
||||
let name = e.target.value;
|
||||
this.setState({ name: name });
|
||||
};
|
||||
|
||||
validateInputParams() {
|
||||
let errMessage;
|
||||
let name = this.state.name.trim();
|
||||
if (!name.length) {
|
||||
errMessage = gettext('Name is required');
|
||||
this.setState({ errMessage: errMessage });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name !== this.props.organizationName) {
|
||||
errMessage = gettext('Names don\'t match');
|
||||
this.setState({ errMessage: errMessage });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
handleSubmit = () => {
|
||||
let isValid = this.validateInputParams();
|
||||
if (isValid) {
|
||||
this.props.handleSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<SeahubModalHeader toggle={this.toggle}>{gettext('Delete Team')}</SeahubModalHeader>
|
||||
<ModalBody>
|
||||
<Form>
|
||||
<FormGroup>
|
||||
<Label for="orgName">{gettext('To confirm, type "{placeholder}" in the box below').replace('{placeholder}', this.props.organizationName)}</Label>
|
||||
<Input id="orgName" value={this.state.name || ''} onChange={this.inputName} />
|
||||
</FormGroup>
|
||||
</Form>
|
||||
{this.state.errMessage && <Label className="err-message">{this.state.errMessage}</Label>}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.handleSubmit} >{gettext('Submit')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
OrgAdminDeleteOrgDialog.propTypes = propTypes;
|
||||
|
||||
export default OrgAdminDeleteOrgDialog;
|
@@ -2,7 +2,7 @@ import React, { Component, Fragment } from 'react';
|
||||
import { InputGroupText } from 'reactstrap';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import { orgAdminAPI } from '../../../utils/org-admin-api';
|
||||
import { gettext, mediaUrl, logoPath, orgID, orgEnableAdminCustomLogo, orgEnableAdminCustomName, enableMultiADFS } from '../../../utils/constants';
|
||||
import { gettext, mediaUrl, logoPath, orgID, orgEnableAdminCustomLogo, orgEnableAdminCustomName, orgEnableAdminDeleteOrg, enableMultiADFS } from '../../../utils/constants';
|
||||
import Loading from '../../../components/loading';
|
||||
import toaster from '../../../components/toast';
|
||||
import MainPanelTopbar from '../main-panel-topbar';
|
||||
@@ -10,6 +10,7 @@ import Section from '../../common-admin/web-settings/section';
|
||||
import CheckboxItem from '../../common-admin/web-settings/checkbox-item';
|
||||
import FileItem from '../../common-admin/web-settings/file-item';
|
||||
import InputItem from './input-item';
|
||||
import DeleteOrganizationDialog from '../../../components/dialog/org-admin-delete-org-dialog';
|
||||
|
||||
import '../../../css/system-admin-web-settings.css';
|
||||
|
||||
@@ -29,7 +30,8 @@ class OrgWebSettings extends Component {
|
||||
force_adfs_login: false,
|
||||
disable_org_encrypted_library: false,
|
||||
disable_org_user_clean_trash: false,
|
||||
user_default_quota: 0
|
||||
user_default_quota: 0,
|
||||
isDeleteOrganizationDialogShow: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -104,6 +106,19 @@ class OrgWebSettings extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
toggleDeleteOrganization = () => {
|
||||
this.setState({ isDeleteOrganizationDialogShow: !this.state.isDeleteOrganizationDialogShow });
|
||||
};
|
||||
|
||||
deleteOrganization = () => {
|
||||
orgAdminAPI.orgAdminDeleteOrg(orgID).then((res) => {
|
||||
window.location.href = '/';
|
||||
}).catch((error) => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { loading, errorMsg, config_dict, file_ext_white_list, force_adfs_login, disable_org_encrypted_library, disable_org_user_clean_trash, user_default_quota } = this.state;
|
||||
let logoPath = this.state.logoPath;
|
||||
@@ -206,11 +221,27 @@ class OrgWebSettings extends Component {
|
||||
/>
|
||||
</Fragment>
|
||||
</Section>
|
||||
{orgEnableAdminDeleteOrg &&
|
||||
<Section headingText={gettext('Delete')}>
|
||||
<Fragment>
|
||||
<button onClick={this.toggleDeleteOrganization.bind(this, null)} className="btn btn-outline-primary" >
|
||||
{gettext('Delete Team')}
|
||||
</button>
|
||||
</Fragment>
|
||||
</Section>
|
||||
}
|
||||
</Fragment>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{this.state.isDeleteOrganizationDialogShow &&
|
||||
<DeleteOrganizationDialog
|
||||
organizationName={config_dict['org_name']}
|
||||
toggle={this.toggleDeleteOrganization}
|
||||
handleSubmit={this.deleteOrganization}
|
||||
/>
|
||||
}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
@@ -176,6 +176,7 @@ export const orgMemberQuotaEnabled = window.org ? window.org.pageOptions.orgMemb
|
||||
export const orgEnableAdminCustomLogo = window.org ? window.org.pageOptions.orgEnableAdminCustomLogo === 'True' : false;
|
||||
export const orgEnableAdminCustomName = window.org ? window.org.pageOptions.orgEnableAdminCustomName === 'True' : false;
|
||||
export const orgEnableAdminInviteUser = window.org ? window.org.pageOptions.orgEnableAdminInviteUser === 'True' : false;
|
||||
export const orgEnableAdminDeleteOrg = window.org ? window.org.pageOptions.orgEnableAdminDeleteOrg === 'True' : false;
|
||||
export const enableMultiADFS = window.org ? window.org.pageOptions.enableMultiADFS === 'True' : false;
|
||||
export const enableSubscription = window.org ? window.org.pageOptions.enableSubscription : false;
|
||||
export const enableExternalBillingService = window.org ? window.org.pageOptions.enableExternalBillingService : false;
|
||||
|
@@ -566,6 +566,11 @@ class OrgAdminAPI {
|
||||
return this.req.put(url, form);
|
||||
}
|
||||
|
||||
orgAdminDeleteOrg(orgID) {
|
||||
const url = this.server + '/api/v2.1/org/' + orgID + '/admin/delete-org/';
|
||||
return this.req.delete(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let orgAdminAPI = new OrgAdminAPI();
|
||||
|
Reference in New Issue
Block a user