mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 01:12:03 +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 React, { Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
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 { Utils } from '../../utils/utils';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import URLDecorator from '../../utils/url-decorator';
|
import URLDecorator from '../../utils/url-decorator';
|
||||||
@@ -486,10 +486,20 @@ class DirentGridView extends React.Component {
|
|||||||
return dirent.name;
|
return dirent.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
if (useGoFileserver) {
|
||||||
isZipDialogOpen: true,
|
seafileAPI.zipDownload(repoID, path, selectedDirentNames).then((res) => {
|
||||||
downloadItems: selectedDirentNames
|
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 = () => {
|
onCreateFolderToggle = () => {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
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 { Utils } from '../../utils/utils';
|
||||||
import TextTranslation from '../../utils/text-translation';
|
import TextTranslation from '../../utils/text-translation';
|
||||||
import URLDecorator from '../../utils/url-decorator';
|
import URLDecorator from '../../utils/url-decorator';
|
||||||
@@ -340,10 +340,20 @@ class DirentListView extends React.Component {
|
|||||||
return dirent.name;
|
return dirent.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
if (useGoFileserver) {
|
||||||
isProgressDialogShow: true,
|
seafileAPI.zipDownload(repoID, path, selectedDirentNames).then((res) => {
|
||||||
downloadItems: selectedDirentNames
|
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;
|
location.href = url;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!useGoFileserver) {
|
if (useGoFileserver) {
|
||||||
this.setState({
|
|
||||||
isZipDialogOpen: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const target = this.props.selectedDirentList.map(dirent => dirent.name);
|
const target = this.props.selectedDirentList.map(dirent => dirent.name);
|
||||||
seafileAPI.zipDownload(repoID, path, target).then((res) => {
|
seafileAPI.zipDownload(repoID, path, target).then((res) => {
|
||||||
const zipToken = res.data['zip_token'];
|
const zipToken = res.data['zip_token'];
|
||||||
@@ -99,6 +95,10 @@ class SelectedDirentsToolbar extends React.Component {
|
|||||||
errorMsg: errorMsg
|
errorMsg: errorMsg
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
isZipDialogOpen: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user