1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 23:29:49 +00:00

optimize code and structure

This commit is contained in:
Junxiang Huang
2024-06-12 09:56:53 +08:00
parent f68a6cc098
commit 0e3886e254
4 changed files with 20 additions and 20 deletions

View File

@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Utils } from '../../utils/utils';
import { gettext } from '../../utils/constants';
import toaster from '../../components/toast';
import seahubManageAPI from './seahub-manage-api';
import seahubMetadataAPI from './seahub-metadata-api';
const propTypes = {
repoID: PropTypes.string.isRequired,
@@ -48,11 +48,11 @@ class MetadataManageView extends React.Component {
};
onClick = () => {
seahubManageAPI.getMetadataManagementEnabledStatus(this.props.repoID).then((res) => {
seahubMetadataAPI.getMetadataManagementEnabledStatus(this.props.repoID).then((res) => {
if (res.data.enabled){
this.viewMetadata();
} else if (confirm(gettext('Enable-Metadata-Manage?'))){
seahubManageAPI.enableMetadataManagement(this.props.repoID).then((res) => {
seahubMetadataAPI.enableMetadataManagement(this.props.repoID).then((res) => {
this.viewMetadata();
}).catch((error) => {
let errMessage = Utils.getErrorMsg(error);

View File

@@ -2,7 +2,7 @@ import axios from 'axios';
import cookie from 'react-cookies';
import { siteRoot } from '../../utils/constants';
class SeahubManageAPI {
class SeahubMetadataAPI {
init({ server, username, password, token }) {
this.server = server;
this.username = username;
@@ -50,7 +50,7 @@ class SeahubManageAPI {
enableMetadataManagement(repoID) {
const url = this.server + '/api/v2.1/repos/' + repoID + '/metadata/';
return this.req.post(url);
return this.req.put(url);
}
disableMetadataManagement(repoID) {
@@ -91,8 +91,8 @@ class SeahubManageAPI {
}
}
const seahubManageAPI = new SeahubManageAPI();
const seahubMetadataAPI = new SeahubMetadataAPI();
const xcsrfHeaders = cookie.load('sfcsrftoken');
seahubManageAPI.initForSeahubUsage({ siteRoot, xcsrfHeaders });
seahubMetadataAPI.initForSeahubUsage({ siteRoot, xcsrfHeaders });
export default seahubManageAPI;
export default seahubMetadataAPI;