Add file viewer icon customization
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 13 Dec 2018 14:35:21 +0000 (15:35 +0100)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 13 Dec 2018 14:35:21 +0000 (15:35 +0100)
Feature #13540

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

public/file-viewers-example.json
src/models/file-viewers-config.ts
src/views-components/context-menu/actions/file-viewer-actions.tsx

index 7c8aefcb5b9a5b8b21b352920c933f9a294446e0..27adb70bd228a1fd7ef7b4f69c1205ad16cb94dc 100644 (file)
@@ -6,7 +6,8 @@
             ".zip"
         ],
         "url": "https://doc.arvados.org",
-        "filePathParam": "filePath"
+        "filePathParam": "filePath",
+        "iconUrl": "https://material.io/tools/icons/static/icons/baseline-next_week-24px.svg"
     },
     {
         "name": "Collection browser",
index 5c23dd4974cfc2a0841e57af14dc81373bcc6bcf..e95116baa0788f4fbd13c5d75eb597f8ba2eef82 100644 (file)
@@ -39,4 +39,9 @@ export interface FileViewer {
      * `https://bam-viewer.com?filePath=/path/to/file`
      */
     filePathParam: string;
+
+    /**
+     * Icon that will display next to a label
+     */
+    iconUrl?: string;
 }
index f1a46952d5712008ebda3efca3f7988a9abf2089..961e182860c77d9db5542bec33f31ee28e0d6bbc 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
-import { ListItemText, ListItem, ListItemIcon } from "@material-ui/core";
+import { ListItemText, ListItem, ListItemIcon, Icon } from "@material-ui/core";
 import { RootState } from '~/store/store';
 import { getNodeValue } from '~/models/tree';
 import { CollectionDirectory, CollectionFile, CollectionFileType } from '~/models/collection-file';
@@ -65,7 +65,13 @@ export const FileViewerActions = connect(mapStateToProps)(
                     onClick={onClick}
                     target='_blank'>
                     <ListItemIcon>
-                        <OpenIcon />
+                        {
+                            viewer.iconUrl
+                                ? <Icon>
+                                    <img src={viewer.iconUrl} />
+                                </Icon>
+                                : <OpenIcon />
+                        }
                     </ListItemIcon>
                     <ListItemText>
                         {viewer.name}