mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 09:51:26 +00:00
fix code format (#6365)
This commit is contained in:
@@ -4,10 +4,9 @@ import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Resumablejs from '@seafile/resumablejs';
|
||||
import MD5 from 'MD5';
|
||||
import { resumableUploadFileBlockSize, maxUploadFileSize, maxNumberOfFilesForFileupload } from '../../utils/constants';
|
||||
import { gettext, resumableUploadFileBlockSize, maxUploadFileSize, maxNumberOfFilesForFileupload } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import UploadProgressDialog from './upload-progress-dialog';
|
||||
import toaster from '../toast';
|
||||
import '../../css/file-uploader.css';
|
||||
@@ -15,7 +14,7 @@ import '../../css/file-uploader.css';
|
||||
const propTypes = {
|
||||
token: PropTypes.string.isRequired,
|
||||
repoID: PropTypes.string.isRequired,
|
||||
//direntList: PropTypes.array.isRequired,
|
||||
// direntList: PropTypes.array.isRequired,
|
||||
filetypes: PropTypes.array,
|
||||
chunkSize: PropTypes.number,
|
||||
withCredentials: PropTypes.bool,
|
||||
@@ -79,7 +78,7 @@ class FileUploader extends React.Component {
|
||||
|
||||
this.resumable.assignBrowse(this.uploadInput.current, true);
|
||||
|
||||
//Enable or Disable DragAnd Drop
|
||||
// Enable or Disable DragAnd Drop
|
||||
if (this.props.dragAndDrop === true) {
|
||||
this.resumable.enableDropOnDocument();
|
||||
}
|
||||
@@ -151,26 +150,26 @@ class FileUploader extends React.Component {
|
||||
maxFileSizeErrorCallback = (file) => {
|
||||
let { forbidUploadFileList } = this.state;
|
||||
forbidUploadFileList.push(file);
|
||||
this.setState({forbidUploadFileList: forbidUploadFileList});
|
||||
this.setState({ forbidUploadFileList: forbidUploadFileList });
|
||||
};
|
||||
|
||||
onChunkingComplete = (resumableFile) => {
|
||||
|
||||
//get parent_dir relative_path
|
||||
// get parent_dir relative_path
|
||||
let path = this.props.path === '/' ? '/' : this.props.path + '/';
|
||||
let fileName = resumableFile.fileName;
|
||||
let relativePath = resumableFile.relativePath;
|
||||
let isFile = fileName === relativePath;
|
||||
|
||||
//update formdata
|
||||
// update formdata
|
||||
resumableFile.formData = {};
|
||||
if (isFile) { // upload file
|
||||
resumableFile.formData = {
|
||||
resumableFile.formData = {
|
||||
parent_dir: path,
|
||||
};
|
||||
} else { // upload folder
|
||||
let relative_path = relativePath.slice(0, relativePath.lastIndexOf('/') + 1);
|
||||
resumableFile.formData = {
|
||||
resumableFile.formData = {
|
||||
parent_dir: path,
|
||||
relative_path: relative_path
|
||||
};
|
||||
@@ -307,7 +306,7 @@ class FileUploader extends React.Component {
|
||||
|
||||
onProgress = () => {
|
||||
let progress = Math.round(this.resumable.progress() * 100);
|
||||
this.setState({totalProgress: progress});
|
||||
this.setState({ totalProgress: progress });
|
||||
Utils.registerGlobalVariable('uploader', 'totalProgress', progress);
|
||||
};
|
||||
|
||||
@@ -390,7 +389,7 @@ class FileUploader extends React.Component {
|
||||
}
|
||||
return item;
|
||||
});
|
||||
this.setState({uploadFileList: uploadFileList});
|
||||
this.setState({ uploadFileList: uploadFileList });
|
||||
};
|
||||
|
||||
onFileError = (resumableFile, message) => {
|
||||
@@ -400,7 +399,7 @@ class FileUploader extends React.Component {
|
||||
} else {
|
||||
// eg: '{"error": "Internal error" \n }'
|
||||
let errorMessage = message.replace(/\n/g, '');
|
||||
errorMessage = JSON.parse(errorMessage);
|
||||
errorMessage = JSON.parse(errorMessage);
|
||||
error = errorMessage.error;
|
||||
if (error === 'File locked by others.') {
|
||||
error = gettext('File is locked by others.');
|
||||
@@ -418,7 +417,7 @@ class FileUploader extends React.Component {
|
||||
return item;
|
||||
});
|
||||
|
||||
this.loaded = 0; // reset loaded data;
|
||||
this.loaded = 0; // reset loaded data;
|
||||
this.setState({
|
||||
retryFileList: this.state.retryFileList,
|
||||
uploadFileList: uploadFileList
|
||||
@@ -481,7 +480,7 @@ class FileUploader extends React.Component {
|
||||
};
|
||||
|
||||
generateUniqueIdentifier = (file) => {
|
||||
let relativePath = file.webkitRelativePath||file.relativePath||file.fileName||file.name;
|
||||
let relativePath = file.webkitRelativePath || file.relativePath || file.fileName || file.name;
|
||||
return MD5(relativePath + new Date()) + relativePath;
|
||||
};
|
||||
|
||||
@@ -510,7 +509,7 @@ class FileUploader extends React.Component {
|
||||
this.resumable.files = [];
|
||||
// reset upload link loaded
|
||||
this.isUploadLinkLoaded = false;
|
||||
this.setState({isUploadProgressDialogShow: false, uploadFileList: [], forbidUploadFileList: []});
|
||||
this.setState({ isUploadProgressDialogShow: false, uploadFileList: [], forbidUploadFileList: [] });
|
||||
Utils.registerGlobalVariable('uploader', 'isUploadProgressDialogShow', false);
|
||||
};
|
||||
|
||||
@@ -531,7 +530,7 @@ class FileUploader extends React.Component {
|
||||
this.loaded = 0;
|
||||
}
|
||||
|
||||
this.setState({uploadFileList: uploadFileList});
|
||||
this.setState({ uploadFileList: uploadFileList });
|
||||
};
|
||||
|
||||
onCancelAllUploading = () => {
|
||||
@@ -655,8 +654,8 @@ class FileUploader extends React.Component {
|
||||
};
|
||||
|
||||
cancelFileUpload = () => {
|
||||
this.resumable.files.pop(); //delete latest file;
|
||||
this.setState({isUploadRemindDialogShow: false});
|
||||
this.resumable.files.pop(); // delete latest file;
|
||||
this.setState({ isUploadRemindDialogShow: false });
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@@ -39,7 +39,7 @@ class UploadListItem extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({uploadState: uploadState});
|
||||
this.setState({ uploadState: uploadState });
|
||||
}
|
||||
|
||||
onUploadCancel = (e) => {
|
||||
@@ -89,7 +89,7 @@ class UploadListItem extends React.Component {
|
||||
{resumableFile.isUploading() && (
|
||||
<div className="progress-container">
|
||||
<div className="progress">
|
||||
<div className="progress-bar" role="progressbar" style={{width: `${progress}%`}} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div className="progress-bar" role="progressbar" style={{ width: `${progress}%` }} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{(resumableFile.remainingTime === -1) && <div className="progress-text">{gettext('Preparing to upload...')}</div>}
|
||||
{(resumableFile.remainingTime > 0) && <div className="progress-text">{gettext('Remaining')}{' '}{Utils.formatTime(resumableFile.remainingTime)}</div>}
|
||||
@@ -99,7 +99,7 @@ class UploadListItem extends React.Component {
|
||||
{!resumableFile.isUploading() && (
|
||||
<div className="progress-container d-flex align-items-center">
|
||||
<div className="progress">
|
||||
<div className="progress-bar" role="progressbar" style={{width: `${progress}%`}} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div className="progress-bar" role="progressbar" style={{ width: `${progress}%` }} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@@ -109,7 +109,7 @@ class UploadListItem extends React.Component {
|
||||
<>
|
||||
<div className="progress-container d-flex align-items-center">
|
||||
<div className="progress">
|
||||
<div className="progress-bar" role="progressbar" style={{width: `${progress}%`}} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div className="progress-bar" role="progressbar" style={{ width: `${progress}%` }} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
{this.state.uploadState === UPLOAD_UPLOADING && (
|
||||
@@ -134,7 +134,7 @@ class UploadListItem extends React.Component {
|
||||
{this.state.uploadState === UPLOAD_ERROR && (
|
||||
<div className="d-flex align-items-center">
|
||||
<span className="upload-failure-icon sf3-font sf3-font-info mr-2"></span>
|
||||
<span className="upload-failure-msg" dangerouslySetInnerHTML={{__html: error}}></span>
|
||||
<span className="upload-failure-msg" dangerouslySetInnerHTML={{ __html: error }}></span>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
|
@@ -16,7 +16,7 @@ const propTypes = {
|
||||
onUploadCancel: PropTypes.func.isRequired,
|
||||
onUploadRetry: PropTypes.func.isRequired,
|
||||
onUploadRetryAll: PropTypes.func.isRequired,
|
||||
isUploading : PropTypes.bool.isRequired
|
||||
isUploading: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
class UploadProgressDialog extends React.Component {
|
||||
@@ -34,7 +34,7 @@ class UploadProgressDialog extends React.Component {
|
||||
|
||||
onMinimizeUpload = (e) => {
|
||||
e.nativeEvent.stopImmediatePropagation();
|
||||
this.setState({isMinimized: !this.state.isMinimized});
|
||||
this.setState({ isMinimized: !this.state.isMinimized });
|
||||
};
|
||||
|
||||
onCloseUpload = (e) => {
|
||||
@@ -59,7 +59,7 @@ class UploadProgressDialog extends React.Component {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="uploader-list-view mw-100" style={{height: this.state.isMinimized ? document.querySelector('.uploader-list-header').offsetHeight : '20rem'}}>
|
||||
<div className="uploader-list-view mw-100" style={{ height: this.state.isMinimized ? document.querySelector('.uploader-list-header').offsetHeight : '20rem' }}>
|
||||
<div className="uploader-list-header flex-shrink-0">
|
||||
<div>
|
||||
{isUploading ? (
|
||||
@@ -67,7 +67,7 @@ class UploadProgressDialog extends React.Component {
|
||||
<span>{gettext('File Uploading...')}</span>
|
||||
<span className="ml-2">{`${totalProgress}% (${Utils.formatBitRate(uploadBitrate)})`}</span>
|
||||
<div className="progress">
|
||||
<div className="progress-bar" role="progressbar" style={{width: `${totalProgress}%`}} aria-valuenow={totalProgress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div className="progress-bar" role="progressbar" style={{ width: `${totalProgress}%` }} aria-valuenow={totalProgress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
|
Reference in New Issue
Block a user