[ARVADOS-WORKBENCH2] updated: 2.1.0-19-g79598ecb

Git user git at public.arvados.org
Sun Oct 18 22:12:37 UTC 2020


Summary of changes:
 src/common/redirect-to.test.ts |  9 +++++----
 src/common/redirect-to.ts      | 14 +++++++-------
 2 files changed, 12 insertions(+), 11 deletions(-)

       via  79598ecbcb4c3523c194d59241035d99c7515320 (commit)
       via  fa56d9acbdc2c18486f1bb10559df6628f49458b (commit)
      from  ffc9666a04b0cef18a15571c1a0f4fdc41e87b75 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 79598ecbcb4c3523c194d59241035d99c7515320
Merge: fa56d9ac ffc9666a
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Mon Oct 19 00:11:38 2020 +0200

    Merge branch '16812-token-appears-in-the-download-URL' of git.arvados.org:arvados-workbench2 into 16812-token-appears-in-the-download-URL
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>


commit fa56d9acbdc2c18486f1bb10559df6628f49458b
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Sun Oct 18 16:03:00 2020 +0200

    16812: Reverted changes in download action, fixed keep links
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/common/redirect-to.test.ts b/src/common/redirect-to.test.ts
index c7d3a84e..e25d7be9 100644
--- a/src/common/redirect-to.test.ts
+++ b/src/common/redirect-to.test.ts
@@ -7,7 +7,8 @@ import { storeRedirects, handleRedirects } from './redirect-to';
 describe('redirect-to', () => {
     const { location } = window;
     const config: any = {
-        keepWebServiceUrl: 'http://localhost'
+        keepWebServiceUrl: 'http://localhost',
+        keepWebServiceInlineUrl: 'http://localhost'
     };
     const redirectTo = '/test123';
     const locationTemplate = {
@@ -37,7 +38,7 @@ describe('redirect-to', () => {
                 ...locationTemplate,
                 href: `${location.href}?redirectTo=${redirectTo}`,
             } as any;
-            Object.defineProperty(window, 'sessionStorage', {
+            Object.defineProperty(window, 'localStorage', {
                 value: {
                     setItem: jest.fn(),
                 },
@@ -50,7 +51,7 @@ describe('redirect-to', () => {
             storeRedirects();
 
             // then
-            expect(window.sessionStorage.setItem).toHaveBeenCalledWith('redirectTo', redirectTo);
+            expect(window.localStorage.setItem).toHaveBeenCalledWith('redirectTo', redirectTo);
         });
     });
 
@@ -61,7 +62,7 @@ describe('redirect-to', () => {
                 ...locationTemplate,
                 href: `${location.href}?redirectTo=${redirectTo}`,
             } as any;;
-            Object.defineProperty(window, 'sessionStorage', {
+            Object.defineProperty(window, 'localStorage', {
                 value: {
                     getItem: () => redirectTo,
                     removeItem: jest.fn(),
diff --git a/src/common/redirect-to.ts b/src/common/redirect-to.ts
index 7cb0d580..f5ece21b 100644
--- a/src/common/redirect-to.ts
+++ b/src/common/redirect-to.ts
@@ -8,22 +8,22 @@ const REDIRECT_TO_KEY = 'redirectTo';
 
 export const storeRedirects = () => {
     if (window.location.href.indexOf(REDIRECT_TO_KEY) > -1) {
-        const { location: { href }, sessionStorage } = window;
+        const { location: { href }, localStorage } = window;
         const redirectUrl = href.split(`${REDIRECT_TO_KEY}=`)[1];
 
-        if (sessionStorage) {
-            sessionStorage.setItem(REDIRECT_TO_KEY, redirectUrl);
+        if (localStorage) {
+            localStorage.setItem(REDIRECT_TO_KEY, redirectUrl);
         }
     }
 };
 
 export const handleRedirects = (token: string, config: Config) => {
-    const { sessionStorage } = window;
+    const { localStorage } = window;
     const { keepWebServiceUrl } = config;
 
-    if (sessionStorage && sessionStorage.getItem(REDIRECT_TO_KEY)) {
-        const redirectUrl = sessionStorage.getItem(REDIRECT_TO_KEY);
-        sessionStorage.removeItem(REDIRECT_TO_KEY);
+    if (localStorage && localStorage.getItem(REDIRECT_TO_KEY)) {
+        const redirectUrl = localStorage.getItem(REDIRECT_TO_KEY);
+        localStorage.removeItem(REDIRECT_TO_KEY);
         if (redirectUrl) {
             const sep = redirectUrl.indexOf("?") > -1 ? "&" : "?";
             window.location.href = `${keepWebServiceUrl}${redirectUrl}${sep}api_token=${token}`;
diff --git a/src/views-components/context-menu/actions/download-action.tsx b/src/views-components/context-menu/actions/download-action.tsx
index 224d4308..7468954f 100644
--- a/src/views-components/context-menu/actions/download-action.tsx
+++ b/src/views-components/context-menu/actions/download-action.tsx
@@ -47,7 +47,7 @@ export const DownloadAction = (props: { href?: any, download?: any, onClick?: ()
     return props.href || props.kind === 'files'
         ? <a
             style={{ textDecoration: 'none' }}
-            href={props.kind === 'files' ? undefined : props.href}
+            href={props.kind === 'files' ? undefined : `${props.href}?disposition=attachment`}
             onClick={props.onClick}
             {...downloadProps}>
             <ListItem button onClick={() => props.kind === 'files' ? createZip(props.href, props.download) : undefined}>
@@ -61,4 +61,4 @@ export const DownloadAction = (props: { href?: any, download?: any, onClick?: ()
             </ListItem>
         </a>
         : null;
-};
+};
\ No newline at end of file
diff --git a/src/views-components/context-menu/actions/download-collection-file-action.tsx b/src/views-components/context-menu/actions/download-collection-file-action.tsx
index 437b22ed..7849109d 100644
--- a/src/views-components/context-menu/actions/download-collection-file-action.tsx
+++ b/src/views-components/context-menu/actions/download-collection-file-action.tsx
@@ -8,7 +8,6 @@ import { DownloadAction } from "./download-action";
 import { getNodeValue } from "../../../models/tree";
 import { ContextMenuKind } from '../context-menu';
 import { filterCollectionFilesBySelection } from "~/store/collection-panel/collection-panel-files/collection-panel-files-state";
-import { sanitizeToken } from "./helpers";
 
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
@@ -17,7 +16,7 @@ const mapStateToProps = (state: RootState) => {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
-                href: sanitizeToken(file.url, true),
+                href: file.url,
                 kind: 'file',
                 currentCollectionUuid
             };
@@ -25,7 +24,7 @@ const mapStateToProps = (state: RootState) => {
     } else {
         const files = filterCollectionFilesBySelection(state.collectionPanelFiles, true);
         return {
-            href: files.map(file => sanitizeToken(file.url, true)),
+            href: files.map(file => file.url),
             kind: 'files',
             currentCollectionUuid
         };
diff --git a/src/views-components/context-menu/actions/file-viewer-action.tsx b/src/views-components/context-menu/actions/file-viewer-action.tsx
index 9af2ef92..a631424e 100644
--- a/src/views-components/context-menu/actions/file-viewer-action.tsx
+++ b/src/views-components/context-menu/actions/file-viewer-action.tsx
@@ -3,16 +3,22 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
+import { connect } from 'react-redux';
 import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
 import { OpenIcon } from "~/components/icon/icon";
 import { sanitizeToken } from "./helpers";
+import { RootState } from "~/store/store";
 
-export const FileViewerAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => {
+export const FileViewerAction = (props: any) => {
+    const {
+        keepWebServiceUrl,
+        keepWebInlineServiceUrl,
+    } = props;
 
     return props.href
         ? <a
             style={{ textDecoration: 'none' }}
-            href={sanitizeToken(props.href, true)}
+            href={sanitizeToken(props.href.replace(keepWebServiceUrl, keepWebInlineServiceUrl), true)}
             target="_blank"
             onClick={props.onClick}>
             <ListItem button>
@@ -21,8 +27,16 @@ export const FileViewerAction = (props: { href?: any, download?: any, onClick?:
                 </ListItemIcon>
                 <ListItemText>
                     Open in new tab
-                 </ListItemText>
+                    </ListItemText>
             </ListItem>
         </a>
         : null;
 };
+
+const mapStateToProps = ({ auth }: RootState): any => ({
+    keepWebServiceUrl: auth.config.keepWebServiceUrl,
+    keepWebInlineServiceUrl: auth.config.keepWebInlineServiceUrl,
+});
+
+
+export default connect(mapStateToProps, null)(FileViewerAction);

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list