mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 18:03:48 +00:00
support undo operation when delete single file/folder (#5475)
This commit is contained in:
@@ -1056,11 +1056,17 @@ class LibContentView extends React.Component {
|
|||||||
deleteFolder = () => {
|
deleteFolder = () => {
|
||||||
const { repoID } = this.props;
|
const { repoID } = this.props;
|
||||||
const { folderToDelete: path } = this.state;
|
const { folderToDelete: path } = this.state;
|
||||||
seafileAPI.deleteDir(repoID, path).then(() => {
|
seafileAPI.deleteDir(repoID, path).then((res) => {
|
||||||
this.deleteItemAjaxCallback(path, true);
|
this.deleteItemAjaxCallback(path, true);
|
||||||
let name = Utils.getFileName(path);
|
let name = Utils.getFileName(path);
|
||||||
var msg = gettext('Successfully deleted {name}').replace('{name}', name);
|
var msg = gettext('Successfully deleted {name}').replace('{name}', name);
|
||||||
toaster.success(msg);
|
const successTipWithUndo = (
|
||||||
|
<>
|
||||||
|
<span>{msg}</span>
|
||||||
|
<a className="action-link p-0 ml-1" href="#" onClick={this.restoreDeletedDirents.bind(this, res.data.commit_id, [path])}>{gettext('Undo')}</a>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
toaster.success(successTipWithUndo, {duration: 5});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
if (errMessage === gettext('Error')) {
|
if (errMessage === gettext('Error')) {
|
||||||
@@ -1078,11 +1084,17 @@ class LibContentView extends React.Component {
|
|||||||
this.toggleDeleteFolderDialog();
|
this.toggleDeleteFolderDialog();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
seafileAPI.deleteFile(repoID, path).then(() => {
|
seafileAPI.deleteFile(repoID, path).then((res) => {
|
||||||
this.deleteItemAjaxCallback(path, isDir);
|
this.deleteItemAjaxCallback(path, isDir);
|
||||||
let name = Utils.getFileName(path);
|
let name = Utils.getFileName(path);
|
||||||
var msg = gettext('Successfully deleted {name}').replace('{name}', name);
|
var msg = gettext('Successfully deleted {name}').replace('{name}', name);
|
||||||
toaster.success(msg);
|
const successTipWithUndo = (
|
||||||
|
<>
|
||||||
|
<span>{msg}</span>
|
||||||
|
<a className="action-link p-0 ml-1" href="#" onClick={this.restoreDeletedDirents.bind(this, res.data.commit_id, [path])}>{gettext('Undo')}</a>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
toaster.success(successTipWithUndo, {duration: 5});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
if (errMessage === gettext('Error')) {
|
if (errMessage === gettext('Error')) {
|
||||||
|
@@ -525,7 +525,10 @@ class DirView(APIView):
|
|||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
return Response({'success': True})
|
result = {}
|
||||||
|
result['success'] = True
|
||||||
|
result['commit_id'] = repo.head_cmmt_id
|
||||||
|
return Response(result)
|
||||||
|
|
||||||
|
|
||||||
class DirDetailView(APIView):
|
class DirDetailView(APIView):
|
||||||
|
@@ -713,4 +713,7 @@ class FileView(APIView):
|
|||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
return Response({'success': True})
|
result = {}
|
||||||
|
result['success'] = True
|
||||||
|
result['commit_id'] = repo.head_cmmt_id
|
||||||
|
return Response(result)
|
||||||
|
Reference in New Issue
Block a user