From 3efbabfcd06a10b83f1f130141d6c1f6017037cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Fri, 7 May 2021 23:24:38 +0200 Subject: [PATCH] 16647: Added the responsible person renderer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- .../data-explorer/renderers.tsx | 34 ++++++++++++++++++- .../collection-panel/collection-panel.tsx | 7 +++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index 93abb15e..71d6f824 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -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 = ; }); +export const ResponsiblePerson = + compose( + connect( + (state: RootState, props: { uuid: string }) => { + let responsiblePersonName = ''; + let resource: Resource | undefined = getResource(props.uuid)(state.resources); + + while (resource && resource.kind !== ResourceKind.USER) { + resource = getResource(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 + {uuid} + ; + } + + return + {responsiblePersonName} ({uuid}) + ; + }); + const renderType = (type: string, subtype: string) => {resourceLabel(type, subtype)} diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index 7d54992e..45053932 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -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) => } /> + + } /> +