1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

[file view] added 'catch' for requests

* added 'getErrorMsg' to utils.js
This commit is contained in:
llj
2019-07-04 16:20:13 +08:00
parent 15e715c346
commit 16015ee8e7
2 changed files with 31 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
import watermark from 'watermark-dom';
import { seafileAPI } from '../../utils/seafile-api';
import { siteName } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import toaster from '../toast';
import FileInfo from './file-info';
import FileToolbar from './file-toolbar';
import CommentPanel from './comment-panel';
@@ -45,12 +47,18 @@ class FileView extends React.Component {
this.setState({
isStarred: false
});
}).catch((error) => {
const errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
});
} else {
seafileAPI.starItem(repoID, filePath).then((res) => {
this.setState({
isStarred: true
});
}).catch((error) => {
const errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
});
}
}
@@ -62,6 +70,9 @@ class FileView extends React.Component {
isLocked: false,
lockedByMe: false
});
}).catch((error) => {
const errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
});
} else {
seafileAPI.lockfile(repoID, filePath).then((res) => {
@@ -69,6 +80,9 @@ class FileView extends React.Component {
isLocked: true,
lockedByMe: true
});
}).catch((error) => {
const errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
});
}
}