[ARVADOS-WORKBENCH2] updated: 2.2.1-72-gebe8964c

Git user git at public.arvados.org
Mon Aug 23 13:32:09 UTC 2021


Summary of changes:
 .../details-panel/collection-details.tsx             |  4 ++--
 src/views-components/details-panel/details-data.tsx  |  7 ++++++-
 src/views-components/details-panel/details-panel.tsx | 20 +++++++++++++++++---
 src/views-components/details-panel/file-details.tsx  |  4 ++--
 4 files changed, 27 insertions(+), 8 deletions(-)

       via  ebe8964c9f281e379d7f4c4cda3d253dfab35807 (commit)
      from  1f30af2350ce0ef9b7a0c40d7c931a7ff9c2cc6c (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 ebe8964c9f281e379d7f4c4cda3d253dfab35807
Author: Stephen Smith <stephen at curii.com>
Date:   Mon Aug 23 09:31:21 2021 -0400

    15159: Hide file preview when not secure and trustallcontent is false
    
    Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>

diff --git a/src/views-components/details-panel/collection-details.tsx b/src/views-components/details-panel/collection-details.tsx
index 3905427b..dcd2ee48 100644
--- a/src/views-components/details-panel/collection-details.tsx
+++ b/src/views-components/details-panel/collection-details.tsx
@@ -42,8 +42,8 @@ export class CollectionDetails extends DetailsData<CollectionResource> {
         return ['Details', 'Versions'];
     }
 
-    getDetails(tabNumber: number) {
-        switch (tabNumber) {
+    getDetails({tabNr}) {
+        switch (tabNr) {
             case 0:
                 return this.getCollectionInfo();
             case 1:
diff --git a/src/views-components/details-panel/details-data.tsx b/src/views-components/details-panel/details-data.tsx
index 0fae2ac4..bcca325c 100644
--- a/src/views-components/details-panel/details-data.tsx
+++ b/src/views-components/details-panel/details-data.tsx
@@ -5,6 +5,11 @@
 import React from 'react';
 import { DetailsResource } from "models/details";
 
+interface GetDetailsParams {
+  tabNr?: number
+  showPreview?: boolean
+}
+
 export abstract class DetailsData<T extends DetailsResource = DetailsResource> {
     constructor(protected item: T) { }
 
@@ -17,5 +22,5 @@ export abstract class DetailsData<T extends DetailsResource = DetailsResource> {
     }
 
     abstract getIcon(className?: string): React.ReactElement<any>;
-    abstract getDetails(tabNr?: number): React.ReactElement<any>;
+    abstract getDetails({tabNr, showPreview}: GetDetailsParams): React.ReactElement<any>;
 }
diff --git a/src/views-components/details-panel/details-panel.tsx b/src/views-components/details-panel/details-panel.tsx
index 38ac163e..058db81b 100644
--- a/src/views-components/details-panel/details-panel.tsx
+++ b/src/views-components/details-panel/details-panel.tsx
@@ -20,6 +20,8 @@ import { ProcessDetails } from "./process-details";
 import { EmptyDetails } from "./empty-details";
 import { DetailsData } from "./details-data";
 import { DetailsResource } from "models/details";
+import { Config } from 'common/config';
+import { isInlineFileUrlSafe } from "../context-menu/actions/helpers";
 import { getResource } from 'store/resources/resources';
 import { toggleDetailsPanel, SLIDE_TIMEOUT, openDetailsPanel } from 'store/details-panel/details-panel-action';
 import { FileDetails } from 'views-components/details-panel/file-details';
@@ -77,12 +79,13 @@ const getItem = (res: DetailsResource): DetailsData => {
     }
 };
 
-const mapStateToProps = ({ detailsPanel, resources, collectionPanelFiles }: RootState) => {
+const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles }: RootState) => {
     const resource = getResource(detailsPanel.resourceUuid)(resources) as DetailsResource | undefined;
     const file = resource
         ? undefined
         : getNode(detailsPanel.resourceUuid)(collectionPanelFiles);
     return {
+        authConfig: auth.config,
         isOpened: detailsPanel.isOpened,
         tabNr: detailsPanel.tabNr,
         res: resource || (file && file.value) || EMPTY_RESOURCE,
@@ -101,6 +104,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
 export interface DetailsPanelDataProps {
     onCloseDrawer: () => void;
     setActiveTab: (tabNr: number) => void;
+    authConfig: Config;
     isOpened: boolean;
     tabNr: number;
     res: DetailsResource;
@@ -143,7 +147,17 @@ export const DetailsPanel = withStyles(styles)(
             }
 
             renderContent() {
-                const { classes, onCloseDrawer, res, tabNr } = this.props;
+                const { classes, onCloseDrawer, res, tabNr, authConfig } = this.props;
+
+                let shouldShowInlinePreview = false;
+                if (!('kind' in res)) {
+                    shouldShowInlinePreview = isInlineFileUrlSafe(
+                      res ? res.url : "",
+                      authConfig.keepWebServiceUrl,
+                      authConfig.keepWebInlineServiceUrl
+                    ) || authConfig.clusterConfig.Collections.TrustAllContent;
+                }
+
                 const item = getItem(res);
                 return <Grid
                     container
@@ -183,7 +197,7 @@ export const DetailsPanel = withStyles(styles)(
                         </Tabs>
                     </Grid>
                     <Grid item xs className={this.props.classes.tabContainer} >
-                        {item.getDetails(tabNr)}
+                        {item.getDetails({tabNr, showPreview: shouldShowInlinePreview})}
                     </Grid>
                 </Grid >;
             }
diff --git a/src/views-components/details-panel/file-details.tsx b/src/views-components/details-panel/file-details.tsx
index 7c11eb8b..7b128c2c 100644
--- a/src/views-components/details-panel/file-details.tsx
+++ b/src/views-components/details-panel/file-details.tsx
@@ -18,13 +18,13 @@ export class FileDetails extends DetailsData<CollectionFile | CollectionDirector
         return <Icon className={className} />;
     }
 
-    getDetails() {
+    getDetails({showPreview}) {
         const { item } = this;
         return item.type === CollectionFileType.FILE
             ? <>
                 <DetailsAttribute label='Size' value={formatFileSize(item.size)} />
                 {
-                    isImage(item.url) && <>
+                    isImage(item.url) && showPreview && <>
                         <DetailsAttribute label='Preview' />
                         <FileThumbnail file={item} />
                     </>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list