Skip to content

[#1707] Fixes bug introduced by library migration #1750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/modules/IDE/actions/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function submitFile(formProps, files, parentId, projectId) {
});
}

export function handleCreateFile(formProps) {
export function handleCreateFile(formProps, setSelected = true) {
return (dispatch, getState) => {
const state = getState();
const { files } = state;
Expand All @@ -97,7 +97,9 @@ export function handleCreateFile(formProps) {
if (updatedAt) dispatch(setProjectSavedTime(updatedAt));
dispatch(closeNewFileModal());
dispatch(setUnsavedChanges(true));
dispatch(setSelectedFile(file.id));
if (setSelected) {
dispatch(setSelectedFile(file.id));
}
resolve();
})
.catch((error) => {
Expand Down
10 changes: 5 additions & 5 deletions client/modules/IDE/actions/uploader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import apiClient from '../../../utils/apiClient';
import getConfig from '../../../utils/getConfig';
import { createFile } from './files';
import { handleCreateFile } from './files';
import { TEXT_FILE_REGEX } from '../../../../server/utils/fileUtils';

const s3BucketHttps =
Expand Down Expand Up @@ -48,7 +48,7 @@ export function dropzoneAcceptCallback(userId, file, done) {
if (file.name.match(TEXT_FILE_REGEX) && file.size < MAX_LOCAL_FILE_SIZE) {
localIntercept(file)
.then((result) => {
file.content = result; // eslint-disable-line
file.content = result; // eslint-disable-line
done('Uploading plaintext file locally.');
file.previewElement.classList.remove('dz-error');
file.previewElement.classList.add('dz-success');
Expand Down Expand Up @@ -103,7 +103,7 @@ export function dropzoneSendingCallback(file, xhr, formData) {
}

export function dropzoneCompleteCallback(file) {
return (dispatch, getState) => { // eslint-disable-line
return (dispatch) => { // eslint-disable-line
if (
(!file.name.match(TEXT_FILE_REGEX) || file.size >= MAX_LOCAL_FILE_SIZE) &&
file.status !== 'error'
Expand All @@ -125,13 +125,13 @@ export function dropzoneCompleteCallback(file) {
name: file.name,
url: `${s3BucketHttps}${file.postData.key}`
};
createFile(formParams)(dispatch, getState);
dispatch(handleCreateFile(formParams, false));
} else if (file.content !== undefined) {
const formParams = {
name: file.name,
content: file.content
};
createFile(formParams)(dispatch, getState);
dispatch(handleCreateFile(formParams, false));
}
};
}
2 changes: 1 addition & 1 deletion client/modules/IDE/components/UploadFileModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const limit = getConfig('UPLOAD_LIMIT') || 250000000;
const limitText = prettyBytes(limit);

class UploadFileModal extends React.Component {
propTypes = {
static propTypes = {
reachedTotalSizeLimit: PropTypes.bool.isRequired,
closeModal: PropTypes.func.isRequired,
t: PropTypes.func.isRequired
Expand Down