mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 00:20:07 +00:00
Fix download file bug in grid mode right click (#7418)
* fix download file use different API * change error message
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { siteRoot, username, enableSeadoc, thumbnailDefaultSize, thumbnailSizeForOriginal, gettext, fileServerRoot, enableWhiteboard } from '../../utils/constants';
|
||||
import { siteRoot, username, enableSeadoc, thumbnailDefaultSize, thumbnailSizeForOriginal, gettext, fileServerRoot, enableWhiteboard, useGoFileserver } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import URLDecorator from '../../utils/url-decorator';
|
||||
@@ -486,10 +486,20 @@ class DirentGridView extends React.Component {
|
||||
return dirent.name;
|
||||
});
|
||||
|
||||
this.setState({
|
||||
isZipDialogOpen: true,
|
||||
downloadItems: selectedDirentNames
|
||||
});
|
||||
if (useGoFileserver) {
|
||||
seafileAPI.zipDownload(repoID, path, selectedDirentNames).then((res) => {
|
||||
const zipToken = res.data['zip_token'];
|
||||
location.href = `${fileServerRoot}zip/${zipToken}`;
|
||||
}).catch((error) => {
|
||||
let errorMsg = Utils.getErrorMsg(error);
|
||||
toaster.danger(errorMsg);
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
isZipDialogOpen: true,
|
||||
downloadItems: selectedDirentNames
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onCreateFolderToggle = () => {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classnames from 'classnames';
|
||||
import { siteRoot, gettext, username, enableSeadoc, thumbnailSizeForOriginal, thumbnailDefaultSize, fileServerRoot, enableWhiteboard } from '../../utils/constants';
|
||||
import { siteRoot, gettext, username, enableSeadoc, thumbnailSizeForOriginal, thumbnailDefaultSize, fileServerRoot, enableWhiteboard, useGoFileserver } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import TextTranslation from '../../utils/text-translation';
|
||||
import URLDecorator from '../../utils/url-decorator';
|
||||
@@ -340,10 +340,20 @@ class DirentListView extends React.Component {
|
||||
return dirent.name;
|
||||
});
|
||||
|
||||
this.setState({
|
||||
isProgressDialogShow: true,
|
||||
downloadItems: selectedDirentNames
|
||||
});
|
||||
if (useGoFileserver) {
|
||||
seafileAPI.zipDownload(repoID, path, selectedDirentNames).then((res) => {
|
||||
const zipToken = res.data['zip_token'];
|
||||
location.href = `${fileServerRoot}zip/${zipToken}`;
|
||||
}).catch((error) => {
|
||||
let errorMsg = Utils.getErrorMsg(error);
|
||||
toaster.danger(errorMsg);
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
isProgressDialogShow: true,
|
||||
downloadItems: selectedDirentNames
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -83,11 +83,7 @@ class SelectedDirentsToolbar extends React.Component {
|
||||
location.href = url;
|
||||
return;
|
||||
}
|
||||
if (!useGoFileserver) {
|
||||
this.setState({
|
||||
isZipDialogOpen: true
|
||||
});
|
||||
} else {
|
||||
if (useGoFileserver) {
|
||||
const target = this.props.selectedDirentList.map(dirent => dirent.name);
|
||||
seafileAPI.zipDownload(repoID, path, target).then((res) => {
|
||||
const zipToken = res.data['zip_token'];
|
||||
@@ -99,6 +95,10 @@ class SelectedDirentsToolbar extends React.Component {
|
||||
errorMsg: errorMsg
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
isZipDialogOpen: true
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user