+export const ResourceOwnerWithName = ownerFromResourceId(_resourceWithName);
+
+export const ResourceWithName = userFromID(_resourceWithName);
+
+export const UserNameFromID = compose(userFromID)((props: { uuid: string; displayAsText?: string; userFullname: string; dispatch: Dispatch }) => {
+ const { uuid, userFullname, dispatch } = props;
+
+ if (userFullname === '') {
+ dispatch<any>(loadResource(uuid, false));
+ }
+ return <span>{userFullname ? userFullname : uuid}</span>;
+});
+
+export const ResponsiblePerson = compose(
+ connect((state: RootState, props: { uuid: string; parentRef: HTMLElement | null }) => {
+ let responsiblePersonName: string = '';
+ let responsiblePersonUUID: string = '';
+ let responsiblePersonProperty: string = '';
+
+ if (state.auth.config.clusterConfig.Collections.ManagedProperties) {
+ let index = 0;
+ const keys = Object.keys(state.auth.config.clusterConfig.Collections.ManagedProperties);
+
+ while (!responsiblePersonProperty && keys[index]) {
+ const key = keys[index];
+ if (state.auth.config.clusterConfig.Collections.ManagedProperties[key].Function === 'original_owner') {
+ responsiblePersonProperty = key;
+ }
+ index++;
+ }
+ }
+
+ let resource: Resource | undefined = getResource<GroupContentsResource & UserResource>(props.uuid)(state.resources);
+
+ while (resource && resource.kind !== ResourceKind.USER && 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>