16647: Added the responsible person renderer
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 7 May 2021 21:24:38 +0000 (23:24 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 7 May 2021 21:24:38 +0000 (23:24 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

src/views-components/data-explorer/renderers.tsx
src/views/collection-panel/collection-panel.tsx

index 93abb15e237ddc73424271f26762cbab3d6471bb..71d6f824258aaf8d54e692d8037247db880eb5ea 100644 (file)
@@ -5,7 +5,7 @@
 import * as React from 'react';
 import { Grid, Typography, withStyles, Tooltip, IconButton, Checkbox } from '@material-ui/core';
 import { FavoriteStar, PublicFavoriteStar } from '../favorite-star/favorite-star';
-import { ResourceKind, TrashableResource } from '~/models/resource';
+import { Resource, ResourceKind, TrashableResource } from '~/models/resource';
 import { ProjectIcon, FilterGroupIcon, CollectionIcon, ProcessIcon, DefaultIcon, ShareIcon, CollectionOldVersionIcon, WorkflowIcon } from '~/components/icon/icon';
 import { formatDate, formatFileSize, formatTime } from '~/common/formatters';
 import { resourceLabel } from '~/common/labels';
@@ -468,6 +468,38 @@ export const ResourceOwnerWithName =
             </Typography>;
         });
 
+export const ResponsiblePerson =
+    compose(
+        connect(
+            (state: RootState, props: { uuid: string }) => {
+                let responsiblePersonName = '';
+                let resource: Resource | undefined = getResource<GroupContentsResource & UserResource>(props.uuid)(state.resources);
+
+                while (resource && resource.kind !== ResourceKind.USER) {
+                    resource = getResource<GroupContentsResource & UserResource>(resource.ownerUuid)(state.resources);
+                }
+
+                if (resource && resource.kind === ResourceKind.USER) {
+                    responsiblePersonName = getUserFullname(resource as UserResource) || (resource as GroupContentsResource).name;
+                }
+
+                return { uuid: props.uuid, responsiblePersonName };
+            }),
+        withStyles({}, { withTheme: true }))
+        ((props: { uuid: string, responsiblePersonName: string, theme: ArvadosTheme }) => {
+            const { uuid, responsiblePersonName, theme } = props;
+
+            if (responsiblePersonName === '') {
+                return <Typography style={{ color: theme.palette.primary.main }} inline noWrap>
+                    {uuid}
+                </Typography>;
+            }
+
+            return <Typography style={{ color: theme.palette.primary.main }} inline noWrap>
+                {responsiblePersonName} ({uuid})
+                </Typography>;
+        });
+
 const renderType = (type: string, subtype: string) =>
     <Typography noWrap>
         {resourceLabel(type, subtype)}
index 7d54992ebd222eca77df3bfea7f877f258de5e1f..4505393230d5980c6be933f7795f0c5a0015a5f1 100644 (file)
@@ -32,7 +32,7 @@ import { getProgressIndicator } from '~/store/progress-indicator/progress-indica
 import { COLLECTION_PANEL_LOAD_FILES, loadCollectionFiles, COLLECTION_PANEL_LOAD_FILES_THRESHOLD } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
 import { Link } from 'react-router-dom';
 import { Link as ButtonLink } from '@material-ui/core';
-import { ResourceOwnerWithName } from '~/views-components/data-explorer/renderers';
+import { ResourceOwnerWithName, ResponsiblePerson } from '~/views-components/data-explorer/renderers';
 
 type CssRules = 'root'
     | 'button'
@@ -301,6 +301,11 @@ export const CollectionDetailsAttributes = (props: { item: CollectionResource, t
                 label='Owner' linkToUuid={item.ownerUuid}
                 uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />
         </Grid>
+        <Grid item xs={12} md={mdSize}>
+            <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+                label='Responsible person' linkToUuid={item.ownerUuid}
+                uuidEnhancer={(uuid: string) => <ResponsiblePerson uuid={item.ownerUuid} />} />
+        </Grid>
         <Grid item xs={12} md={mdSize}>
             <DetailsAttribute classLabel={classes.label} classValue={classes.value}
                 label='Head version'