From: Daniel Kutyła Date: Fri, 7 May 2021 21:24:38 +0000 (+0200) Subject: 16647: Added the responsible person renderer X-Git-Tag: 2.2.0~3^2~4 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/3efbabfcd06a10b83f1f130141d6c1f6017037cf 16647: Added the responsible person renderer Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- 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) => } /> + + } /> +