Skip to content

Commit

Permalink
fix(gui): fixed an issue that could prevent browsers from following p…
Browse files Browse the repository at this point in the history
…rogrammatically triggered downloads

- relative download addresses seem not to be followed, switched to absolute instead

Ticket: None
Changelog: Title
Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
  • Loading branch information
mzedel committed Oct 4, 2024
1 parent 3acc4cd commit f2b6189
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/js/store/devicesSlice/thunks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ describe('troubleshooting related actions', () => {
it('should allow device file transfers', async () => {
const store = mockStore({ ...defaultState });
const link = await store.dispatch(getDeviceFileDownloadLink({ deviceId: 'aDeviceId', path: '/tmp/file' })).unwrap();
expect(link).toBe('/api/management/v1/deviceconnect/devices/aDeviceId/download?path=%2Ftmp%2Ffile');
expect(link).toBe('http://localhost/api/management/v1/deviceconnect/devices/aDeviceId/download?path=%2Ftmp%2Ffile');
const expectedActions = [
{ type: getDeviceFileDownloadLink.pending.type },
{ type: getDeviceFileDownloadLink.fulfilled.type },
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/js/store/devicesSlice/thunks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ export const getSessionDetails = createAsyncThunk(`${sliceName}/getSessionDetail
});

export const getDeviceFileDownloadLink = createAsyncThunk(`${sliceName}/getDeviceFileDownloadLink`, ({ deviceId, path }) =>
Promise.resolve(`${deviceConnect}/devices/${deviceId}/download?path=${encodeURIComponent(path)}`)
Promise.resolve(`${window.location.origin}${deviceConnect}/devices/${deviceId}/download?path=${encodeURIComponent(path)}`)
);

export const deviceFileUpload = createAsyncThunk(`${sliceName}/deviceFileUpload`, ({ deviceId, path, file }, { dispatch }) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/js/store/organizationSlice/thunks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ describe('organization actions', () => {
const storeActions = store.getActions();
expect(storeActions.length).toEqual(expectedActions.length);
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
expect(link).toEqual('/api/management/v1/auditlogs/logs/export?limit=20000&sort=desc');
expect(link).toEqual('http://localhost/api/management/v1/auditlogs/logs/export?limit=20000&sort=desc');
});
});
it('should allow initializing external device providers', async () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/js/store/organizationSlice/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const getAuditLogs = createAsyncThunk(`${sliceName}/getAuditLogs`, (selec
});

export const getAuditLogsCsvLink = createAsyncThunk(`${sliceName}/getAuditLogsCsvLink`, (_, { getState }) =>
Promise.resolve(`${auditLogsApiUrl}/logs/export?limit=20000${prepareAuditlogQuery(getAuditlogState(getState()))}`)
Promise.resolve(`${window.location.origin}${auditLogsApiUrl}/logs/export?limit=20000${prepareAuditlogQuery(getAuditlogState(getState()))}`)
);

export const setAuditlogsState = createAsyncThunk(`${sliceName}/setAuditlogsState`, (selectionState, { dispatch, getState }) => {
Expand Down

0 comments on commit f2b6189

Please sign in to comment.