[ARVADOS-WORKBENCH2] updated: 1.3.1-432-ga348284b

Git user git at public.curoverse.com
Thu Apr 11 11:24:08 UTC 2019


Summary of changes:
 .../collection-files-item-action-set.ts            |  4 +--
 ...ction.tsx => collection-file-viewer-action.tsx} | 21 ++++++----------
 .../context-menu/actions/download-action.tsx       |  8 +++---
 .../context-menu/actions/file-viewer-action.tsx    | 29 ++++++++++++++++++++++
 4 files changed, 42 insertions(+), 20 deletions(-)
 copy src/views-components/context-menu/actions/{download-collection-file-action.tsx => collection-file-viewer-action.tsx} (52%)
 create mode 100644 src/views-components/context-menu/actions/file-viewer-action.tsx

       via  a348284b0d9d4ab86f2b595dd6baefc4b5c96695 (commit)
      from  d3b0b8600fa0728321311e163c0c886dbd139334 (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 a348284b0d9d4ab86f2b595dd6baefc4b5c96695
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date:   Thu Apr 11 13:23:56 2019 +0200

    refs #14855-downloading-has-different-behaviour-in-a-specific-environment
    
    Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>

diff --git a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
index 94f702e8..61603edf 100644
--- a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
@@ -6,7 +6,7 @@ import { ContextMenuActionSet } from "../context-menu-action-set";
 import { RenameIcon, RemoveIcon } from "~/components/icon/icon";
 import { DownloadCollectionFileAction } from "../actions/download-collection-file-action";
 import { openFileRemoveDialog, openRenameFileDialog } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
-import { FileViewerActions } from '~/views-components/context-menu/actions/file-viewer-actions';
+import { CollectionFileViewerAction } from '~/views-components/context-menu/actions/collection-file-viewer-action';
 
 
 export const collectionFilesItemActionSet: ContextMenuActionSet = [[{
@@ -25,6 +25,6 @@ export const collectionFilesItemActionSet: ContextMenuActionSet = [[{
         dispatch<any>(openFileRemoveDialog(resource.uuid));
     }
 }], [{
-    component: FileViewerActions,
+    component: CollectionFileViewerAction,
     execute: () => { return; },
 }]];
diff --git a/src/views-components/context-menu/actions/collection-file-viewer-action.tsx b/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
new file mode 100644
index 00000000..0a202daf
--- /dev/null
+++ b/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
@@ -0,0 +1,31 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { connect } from "react-redux";
+import { RootState } from "../../../store/store";
+import { FileViewerAction } from '~/views-components/context-menu/actions/file-viewer-action';
+import { getNodeValue } from "~/models/tree";
+import { CollectionFileType } from "~/models/collection-file";
+import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
+
+const mapStateToProps = (state: RootState) => {
+    const { resource } = state.contextMenu;
+    const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
+    if (resource && resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM) {
+        const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
+        if (file) {
+            return {
+                href: file.url,
+                download: file.type === CollectionFileType.DIRECTORY ? undefined : file.name,
+                kind: 'file',
+                currentCollectionUuid
+            };
+        }
+    } else {
+        return ;
+    }
+    return ;
+};
+
+export const CollectionFileViewerAction = connect(mapStateToProps)(FileViewerAction);
diff --git a/src/views-components/context-menu/actions/download-action.tsx b/src/views-components/context-menu/actions/download-action.tsx
index 2ec7fe1c..7fcf7c2c 100644
--- a/src/views-components/context-menu/actions/download-action.tsx
+++ b/src/views-components/context-menu/actions/download-action.tsx
@@ -20,16 +20,16 @@ export const DownloadAction = (props: { href?: any, download?: any, onClick?: ()
                 const splittedByDot = href.split('.');
                 if (splittedByDot[splittedByDot.length - 1] !== 'json') {
                     if (fileUrls.length === id) {
-                        zip.file(download[id-1], data);
+                        zip.file(download[id - 1], data);
                         zip.generateAsync({ type: 'blob' }).then((content) => {
                             FileSaver.saveAs(content, `download-${props.currentCollectionUuid}.zip`);
                         });
                     } else {
-                        zip.file(download[id-1], data);
+                        zip.file(download[id - 1], data);
                         zip.generateAsync({ type: 'blob' });
                     }
                 } else {
-                    zip.file(download[id-1], JSON.stringify(data));
+                    zip.file(download[id - 1], JSON.stringify(data));
                     zip.generateAsync({ type: 'blob' });
                 }
                 id++;
@@ -40,7 +40,7 @@ export const DownloadAction = (props: { href?: any, download?: any, onClick?: ()
     return props.href || props.kind === 'files'
         ? <a
             style={{ textDecoration: 'none' }}
-            href={props.kind === 'files' ? null : 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}>
diff --git a/src/views-components/context-menu/actions/file-viewer-action.tsx b/src/views-components/context-menu/actions/file-viewer-action.tsx
new file mode 100644
index 00000000..20dcece4
--- /dev/null
+++ b/src/views-components/context-menu/actions/file-viewer-action.tsx
@@ -0,0 +1,29 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
+import { OpenIcon } from "~/components/icon/icon";
+
+export const FileViewerAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => {
+    const fileProps = props.download ? { download: props.download } : {};
+
+    return props.href
+        ? <a
+            style={{ textDecoration: 'none' }}
+            href={props.href}
+            target="_blank"
+            onClick={props.onClick}
+            {...fileProps}>
+            <ListItem button>
+                    <ListItemIcon>
+                        <OpenIcon />
+                    </ListItemIcon>
+                <ListItemText>
+                    Open in new tab
+                </ListItemText>
+            </ListItem>
+        </a>
+        : null;
+};
\ No newline at end of file

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list