+export const ResourceOwnerWithName =
+ compose(
+ connect(
+ (state: RootState, props: { uuid: string }) => {
+ let ownerName = '';
+ const resource = getResource<GroupContentsResource & UserResource>(props.uuid)(state.resources);
+
+ if (resource) {
+ ownerName = getUserFullname(resource as User) || (resource as GroupContentsResource).name;
+ }
+
+ return { uuid: props.uuid, ownerName };
+ }),
+ withStyles({}, { withTheme: true }))
+ ((props: { uuid: string, ownerName: string, dispatch: Dispatch, theme: ArvadosTheme }) => {
+ const { uuid, ownerName, dispatch, theme } = props;
+
+ if (ownerName === '') {
+ dispatch<any>(loadResource(uuid, false));
+ return <Typography style={{ color: theme.palette.primary.main }} inline noWrap>
+ {uuid}
+ </Typography>;
+ }
+
+ return <Typography style={{ color: theme.palette.primary.main }} inline noWrap>
+ {ownerName} ({uuid})
+ </Typography>;
+ });
+
+export const ResponsiblePerson =
+ compose(
+ connect(
+ (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<GroupContentsResource & UserResource>(props.uuid)(state.resources);
+
+ while (resource && resource.kind !== ResourceKind.USER && resource.kind === ResourceKind.COLLECTION && responsiblePersonProperty) {
+ responsiblePersonUUID = (resource as CollectionResource).properties[responsiblePersonProperty];
+ resource = getResource<GroupContentsResource & UserResource>(responsiblePersonUUID)(state.resources);
+ }
+
+ if (resource && resource.kind === ResourceKind.USER) {
+ responsiblePersonName = getUserFullname(resource as UserResource) || (resource as GroupContentsResource).name;
+ }
+
+ return { uuid: responsiblePersonUUID, responsiblePersonName, parentRef: props.parentRef };
+ }),
+ withStyles({}, { withTheme: true }))
+ ((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 <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) =>