mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-17 07:41:26 +00:00
Org admin api (#7030)
* [org admin] moved related APIs from seafile-js to org-admin-api.js; use 'orgAdminAPI' instead of 'seafileAPI' for the dialogs * [org admin] use 'orgAdminAPI' instead of 'seafileAPI' for the pages
This commit is contained in:
@@ -5,7 +5,7 @@ import { gettext, orgID } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
import UserSelect from '../user-select';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import OrgUserInfo from '../../models/org-user';
|
||||
|
||||
const propTypes = {
|
||||
@@ -34,7 +34,7 @@ class AddOrgAdminDialog extends React.Component {
|
||||
addOrgAdmin = () => {
|
||||
if (!this.state.selectedOption) return;
|
||||
const userEmail = this.state.selectedOption.email;
|
||||
seafileAPI.orgAdminSetOrgAdmin(orgID, userEmail, true).then(res => {
|
||||
orgAdminAPI.orgAdminSetOrgAdmin(orgID, userEmail, true).then(res => {
|
||||
let userInfo = new OrgUserInfo(res.data);
|
||||
this.props.onAddedOrgAdmin(userInfo);
|
||||
}).catch(error => {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Form, FormGroup, Label } from 'reactstrap';
|
||||
import { gettext, orgID } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
|
||||
const propTypes = {
|
||||
groupID: PropTypes.string,
|
||||
@@ -28,7 +28,7 @@ class AddDepartmentDialog extends React.Component {
|
||||
if (this.props.parentGroupID) {
|
||||
parentGroup = this.props.parentGroupID;
|
||||
}
|
||||
seafileAPI.orgAdminAddDepartGroup(orgID, parentGroup, this.state.departmentName.trim()).then((res) => {
|
||||
orgAdminAPI.orgAdminAddDepartGroup(orgID, parentGroup, this.state.departmentName.trim()).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onAddNewDepartment(res.data);
|
||||
}).catch(error => {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Alert } from 'reactstrap';
|
||||
import { gettext, orgID } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
import UserSelect from '../user-select';
|
||||
@@ -32,7 +32,7 @@ class AddMemberDialog extends React.Component {
|
||||
const email = this.state.selectedOption[0].email;
|
||||
this.refs.orgSelect.clearSelect();
|
||||
this.setState({ errMessage: [] });
|
||||
seafileAPI.orgAdminAddGroupMember(orgID, this.props.groupID, email).then((res) => {
|
||||
orgAdminAPI.orgAdminAddGroupMember(orgID, this.props.groupID, email).then((res) => {
|
||||
this.setState({ selectedOption: null });
|
||||
if (res.data.failed.length > 0) {
|
||||
this.setState({ errMessage: res.data.failed[0].error_msg });
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Form, FormGroup, Label, Alert } from 'reactstrap';
|
||||
import { gettext, orgID } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
@@ -24,7 +24,7 @@ class AddRepoDialog extends React.Component {
|
||||
handleSubmit = () => {
|
||||
let isValid = this.validateName();
|
||||
if (isValid) {
|
||||
seafileAPI.orgAdminAddDepartmentRepo(orgID, this.props.groupID, this.state.repoName.trim()).then((res) => {
|
||||
orgAdminAPI.orgAdminAddDepartmentRepo(orgID, this.props.groupID, this.state.repoName.trim()).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onAddNewRepo(res.data);
|
||||
}).catch(error => {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext, orgID } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../../components/toast';
|
||||
|
||||
@@ -22,7 +22,7 @@ class DeleteDepartDialog extends React.Component {
|
||||
deleteDepart = () => {
|
||||
const { groupID } = this.props;
|
||||
this.props.toggle();
|
||||
seafileAPI.orgAdminDeleteDepartGroup(orgID, groupID).then((res) => {
|
||||
orgAdminAPI.orgAdminDeleteDepartGroup(orgID, groupID).then((res) => {
|
||||
this.props.onDeleteDepartment(groupID);
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext, orgID } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
|
||||
@@ -21,7 +21,7 @@ class DeleteMemberDialog extends React.Component {
|
||||
|
||||
deleteMember = () => {
|
||||
const userEmail = this.props.member.email;
|
||||
seafileAPI.orgAdminDeleteGroupMember(orgID, this.props.groupID, userEmail).then((res) => {
|
||||
orgAdminAPI.orgAdminDeleteGroupMember(orgID, this.props.groupID, userEmail).then((res) => {
|
||||
if (res.data.success) {
|
||||
this.props.onMemberChanged();
|
||||
this.props.toggle();
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext, orgID } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
|
||||
@@ -14,7 +14,7 @@ class DeleteRepoDialog extends React.Component {
|
||||
|
||||
deleteRepo = () => {
|
||||
const { repo } = this.props;
|
||||
seafileAPI.orgAdminDeleteDepartmentRepo(orgID, this.props.groupID, this.props.repo.repo_id).then((res) => {
|
||||
orgAdminAPI.orgAdminDeleteDepartmentRepo(orgID, this.props.groupID, this.props.repo.repo_id).then((res) => {
|
||||
if (res.data.success) {
|
||||
this.props.onDeleteRepo(repo.repo_id);
|
||||
this.props.toggle();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
@@ -28,7 +28,7 @@ class FileUpdateDetailDialog extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
seafileAPI.orgAdminGetFileUpdateDetail(this.props.repoID, this.props.commitID).then(res => {
|
||||
orgAdminAPI.orgAdminGetFileUpdateDetail(this.props.repoID, this.props.commitID).then(res => {
|
||||
this.setState({
|
||||
time: res.data.date_time,
|
||||
renamed: this.state.renamed.concat(res.data.renamed),
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Form, FormGroup, Label } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
|
||||
@@ -35,7 +35,7 @@ class RenameDepartmentDialog extends React.Component {
|
||||
let isValid = this.validateName();
|
||||
const { orgID, groupID } = this.props;
|
||||
if (isValid) {
|
||||
seafileAPI.orgAdminUpdateDepartGroup(orgID, groupID, this.state.departmentName.trim()).then((res) => {
|
||||
orgAdminAPI.orgAdminUpdateDepartGroup(orgID, groupID, this.state.departmentName.trim()).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onDepartmentNameChanged(res.data);
|
||||
toaster.success(gettext('Name updated'));
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, InputGroupAddon, InputGroup } from 'reactstrap';
|
||||
import { gettext, orgID } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
|
||||
@@ -28,7 +28,7 @@ class SetGroupQuotaDialog extends React.Component {
|
||||
if ((quota.length && myReg.test(quota)) || quota == -2) {
|
||||
this.setState({ errMessage: '' });
|
||||
let newQuota = this.state.quota == -2 ? this.state.quota : this.state.quota * 1000000;
|
||||
seafileAPI.orgAdminSetGroupQuota(orgID, this.props.groupID, newQuota).then((res) => {
|
||||
orgAdminAPI.orgAdminSetGroupQuota(orgID, this.props.groupID, newQuota).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onSetQuota(res.data);
|
||||
}).catch(error => {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
@@ -37,7 +37,7 @@ class SetOrgUserContactEmail extends React.Component {
|
||||
submitBtnDisabled: true
|
||||
});
|
||||
|
||||
seafileAPI.orgAdminSetOrgUserContactEmail(orgID, email, contactEmail).then((res) => {
|
||||
orgAdminAPI.orgAdminSetOrgUserContactEmail(orgID, email, contactEmail).then((res) => {
|
||||
const newContactEmail = contactEmail ? res.data.contact_email : '';
|
||||
this.props.updateContactEmail(newContactEmail);
|
||||
this.props.toggleDialog();
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import React from 'react';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalHeader, ModalBody, ModalFooter, InputGroup, InputGroupAddon, InputGroupText } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
@@ -45,7 +44,7 @@ class SetOrgUserDefaultQuota extends React.Component {
|
||||
submitBtnDisabled: true
|
||||
});
|
||||
|
||||
seafileAPI.orgAdminSetOrgUserDefaultQuota(orgID, quota).then((res) => {
|
||||
orgAdminAPI.orgAdminSetOrgUserDefaultQuota(orgID, quota).then((res) => {
|
||||
this.props.updateQuota(res.data.user_default_quota);
|
||||
this.props.toggleDialog();
|
||||
}).catch((error) => {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
@@ -39,7 +39,7 @@ class SetOrgUserName extends React.Component {
|
||||
|
||||
// when name is '', api returns the previous name
|
||||
// but newName needs to be ''
|
||||
seafileAPI.orgAdminSetOrgUserName(orgID, email, name).then((res) => {
|
||||
orgAdminAPI.orgAdminSetOrgUserName(orgID, email, name).then((res) => {
|
||||
const newName = name ? res.data.name : '';
|
||||
this.props.updateName(newName);
|
||||
this.props.toggleDialog();
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalHeader, ModalBody, ModalFooter, InputGroup, InputGroupAddon, InputGroupText } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
@@ -46,7 +46,7 @@ class SetOrgUserQuota extends React.Component {
|
||||
submitBtnDisabled: true
|
||||
});
|
||||
|
||||
seafileAPI.orgAdminSetOrgUserQuota(orgID, email, quota).then((res) => {
|
||||
orgAdminAPI.orgAdminSetOrgUserQuota(orgID, email, quota).then((res) => {
|
||||
this.props.updateQuota(res.data.quota_total);
|
||||
this.props.toggleDialog();
|
||||
}).catch((error) => {
|
||||
|
@@ -5,6 +5,7 @@ import { Button, Modal, ModalHeader, ModalBody, ModalFooter,
|
||||
import makeAnimated from 'react-select/animated';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../utils/system-admin-api';
|
||||
import { orgAdminAPI } from '../../utils/org-admin-api';
|
||||
import { gettext, isPro, orgID } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
@@ -61,7 +62,7 @@ class TransferDialog extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.isOrgAdmin) {
|
||||
seafileAPI.orgAdminListDepartments(orgID).then((res) => {
|
||||
orgAdminAPI.orgAdminListDepartments(orgID).then((res) => {
|
||||
this.updateOptions(res);
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
|
Reference in New Issue
Block a user