From 72470537b4b0a8470b6f5360817cc4039d74978c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Wed, 19 May 2021 21:06:03 +0200 Subject: [PATCH] 16647: Added responsible person property check MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- src/common/config.ts | 5 +++ .../data-explorer/renderers.tsx | 31 ++++++++++++++----- .../collection-panel/collection-panel.tsx | 13 +++++--- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/common/config.ts b/src/common/config.ts index 146ca90a..2a02f8c2 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -83,6 +83,11 @@ export interface ClusterConfigJSON { }; Collections: { ForwardSlashNameSubstitution: string; + ManagedProperties?: { + responsible_person_uuid?: { + Function: string, + } + } }; } diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index 71d6f824..ed8e393f 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -471,23 +471,40 @@ export const ResourceOwnerWithName = export const ResponsiblePerson = compose( connect( - (state: RootState, props: { uuid: string }) => { - let responsiblePersonName = ''; + (state: RootState, props: { uuid: string, parentRef: HTMLElement | null }) => { + let responsiblePersonName = null; + let responsiblePersonUUID = null; + let responsiblePersonProperty = null; + + if (state.auth.config.clusterConfig.Collections.ManagedProperties) { + if (state.auth.config.clusterConfig.Collections.ManagedProperties.responsible_person_uuid) { + responsiblePersonProperty = state.auth.config.clusterConfig.Collections.ManagedProperties.responsible_person_uuid.Function; + } + } + let resource: Resource | undefined = getResource(props.uuid)(state.resources); - while (resource && resource.kind !== ResourceKind.USER) { - resource = getResource(resource.ownerUuid)(state.resources); + while (resource && resource.kind !== ResourceKind.USER && resource.kind === ResourceKind.COLLECTION && responsiblePersonProperty) { + responsiblePersonUUID = (resource as CollectionResource).properties[responsiblePersonProperty]; + resource = getResource(responsiblePersonUUID)(state.resources); } if (resource && resource.kind === ResourceKind.USER) { responsiblePersonName = getUserFullname(resource as UserResource) || (resource as GroupContentsResource).name; } - return { uuid: props.uuid, responsiblePersonName }; + return { uuid: responsiblePersonUUID, responsiblePersonName, parentRef: props.parentRef }; }), withStyles({}, { withTheme: true })) - ((props: { uuid: string, responsiblePersonName: string, theme: ArvadosTheme }) => { - const { uuid, responsiblePersonName, theme } = props; + ((props: { uuid: string | null, responsiblePersonName: string, parentRef: HTMLElement | null, theme: ArvadosTheme }) => { + const { uuid, responsiblePersonName, parentRef, theme } = props; + + if (!uuid && parentRef) { + parentRef.style.display = 'none'; + return null; + } else if (parentRef) { + parentRef.style.display = 'block'; + } if (responsiblePersonName === '') { return diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index 45053932..d57afd47 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -285,6 +285,7 @@ export const CollectionDetailsAttributes = (props: { item: CollectionResource, t const isOldVersion = item && item.currentVersionUuid !== item.uuid; const mdSize = props.twoCol ? 6 : 12; const showVersionBrowser = props.showVersionBrowser; + const responsiblePersonRef = React.useRef(null); return } /> - - } /> - +
+ + } /> + +