Skip to content

Commit 18521a3

Browse files
committed
Use POST when saving to workspace
1 parent aafa005 commit 18521a3

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

src/firefly/js/ui/WorkspaceViewer.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {memo} from 'react';
22
import PropTypes from 'prop-types';
3-
import {get} from 'lodash';
3+
import {get, truncate} from 'lodash';
44
import {isFunction, isNil, isEmpty} from 'lodash';
55
import {useFieldGroupConnector} from './FieldGroupConnector.jsx';
66
import {FieldGroup} from './FieldGroup.jsx';
@@ -383,7 +383,7 @@ function doUploadWorkspace(file, params={}) {
383383
* @param options
384384
*/
385385
export function doDownloadWorkspace(url, options) {
386-
fetchUrl(url, options).then( (response) => {
386+
fetchUrl(url, {method: 'post', ...options}).then( (response) => {
387387
response.json().then( (value) => {
388388
if (value.ok === 'true') {
389389
dispatchWorkspaceCreatePath({files: value.result});
@@ -392,7 +392,7 @@ export function doDownloadWorkspace(url, options) {
392392
'Save to workspace');
393393
}
394394
});
395-
});
395+
}).catch(({message}) => showInfoPopup(truncate(message, {length: 200}), 'Unexpected error'));
396396
}
397397

398398
export function workspacePopupMsg(msg, title) {

src/firefly/js/util/WebUtil.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,9 @@ export function fetchUrl(url, options, doValidation= true, enableDefOptions= tru
320320
if (response.ok) {
321321
return response;
322322
} else if(response.status === 401){
323-
return new Error('You are no longer logged in');
323+
throw new Error('You are no longer logged in');
324324
} else {
325-
return new Error(`${url} failed with status: ${response}.statusText`);
326-
}
327-
}).catch( (error) => {
328-
if (error.name === 'AbortError') {
329-
throw error; // fetch aborted
330-
} else {
331-
throw new Error(`Request failed: ${url}`, error);
325+
throw new Error(`Request failed with status ${response.status}: ${url}`);
332326
}
333327
});
334328
}

src/firefly/js/visualize/WorkspaceCntlr.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ function createPath(action) {
166166
dispatch(action);
167167
} else {
168168
workspacePopupMsg('Create workspace path fails: '+ value.status,
169-
'Create workspace foloder');
169+
'Create workspace folder');
170170
}
171171
});
172172
}).catch( (error) => {
173-
workspacePopupMsg('Create workspace path fails" ' + error.message,
174-
' Create workspace foloder');
173+
workspacePopupMsg('Create workspace path fails: ' + error.message,
174+
' Create workspace folder');
175175
});
176176
}
177177
}

0 commit comments

Comments
 (0)