16812: Reverted changes in download action, fixed keep links
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Sun, 18 Oct 2020 14:03:00 +0000 (16:03 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Sun, 18 Oct 2020 14:03:00 +0000 (16:03 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

src/views-components/context-menu/actions/download-action.tsx
src/views-components/context-menu/actions/download-collection-file-action.tsx
src/views-components/context-menu/actions/file-viewer-action.tsx

index 224d43085d630c2734d78c12ae2c5c58ec507db0..7468954fdd97d293837dd8edfebbc0d5a62a241a 100644 (file)
@@ -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
index 437b22ed00cf5c81afc9525741c846be1eb112d0..7849109d3467be508ad0dd67e3f43474490d3393 100644 (file)
@@ -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
         };
index 9af2ef92042a39eb8905345c66af81af9438b6dc..a631424e67bde5f46dbca5e370c3e6bdaa70eb29 100644 (file)
@@ -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);