//
// SPDX-License-Identifier: AGPL-3.0
-import * as React from 'react';
+import React from 'react';
import { Grid, Typography, withStyles, Tooltip, IconButton, Checkbox } from '@material-ui/core';
import { FavoriteStar, PublicFavoriteStar } from '../favorite-star/favorite-star';
-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';
+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';
import { connect, DispatchProp } from 'react-redux';
-import { RootState } from '~/store/store';
-import { getResource } from '~/store/resources/resources';
-import { GroupContentsResource } from '~/services/groups-service/groups-service';
-import { getProcess, Process, getProcessStatus, getProcessStatusColor, getProcessRuntime } from '~/store/processes/process';
-import { ArvadosTheme } from '~/common/custom-theme';
+import { RootState } from 'store/store';
+import { getResource } from 'store/resources/resources';
+import { GroupContentsResource } from 'services/groups-service/groups-service';
+import { getProcess, Process, getProcessStatus, getProcessStatusColor, getProcessRuntime } from 'store/processes/process';
+import { ArvadosTheme } from 'common/custom-theme';
import { compose, Dispatch } from 'redux';
-import { WorkflowResource } from '~/models/workflow';
-import { ResourceStatus as WorkflowStatus } from '~/views/workflow-panel/workflow-panel-view';
-import { getUuidPrefix, openRunProcess } from '~/store/workflow-panel/workflow-panel-actions';
-import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions';
-import { getUserFullname, User, UserResource } from '~/models/user';
-import { toggleIsActive, toggleIsAdmin } from '~/store/users/users-actions';
-import { LinkResource } from '~/models/link';
-import { navigateTo } from '~/store/navigation/navigation-action';
-import { withResourceData } from '~/views-components/data-explorer/with-resources';
-import { CollectionResource } from '~/models/collection';
-import { IllegalNamingWarning } from '~/components/warning/warning';
-import { loadResource } from '~/store/resources/resources-actions';
-import { GroupClass } from '~/models/group';
+import { WorkflowResource } from 'models/workflow';
+import { ResourceStatus as WorkflowStatus } from 'views/workflow-panel/workflow-panel-view';
+import { getUuidPrefix, openRunProcess } from 'store/workflow-panel/workflow-panel-actions';
+import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions';
+import { getUserFullname, User, UserResource } from 'models/user';
+import { toggleIsActive, toggleIsAdmin } from 'store/users/users-actions';
+import { LinkResource } from 'models/link';
+import { navigateTo } from 'store/navigation/navigation-action';
+import { withResourceData } from 'views-components/data-explorer/with-resources';
+import { CollectionResource } from 'models/collection';
+import { IllegalNamingWarning } from 'components/warning/warning';
+import { loadResource } from 'store/resources/resources-actions';
+import { GroupClass } from 'models/group';
const renderName = (dispatch: Dispatch, item: GroupContentsResource) =>
<Grid container alignItems="center" wrap="nowrap" spacing={16}>
export const TokenUserId = withResourceData('userId', renderCommonData);
-// Compute Node Resources
-const renderNodeInfo = (data: string) => {
- return <Typography>{JSON.stringify(data, null, 4)}</Typography>;
-};
-
const clusterColors = [
['#f44336', '#fff'],
['#2196f3', '#fff'],
}}>{clusterId}</span>;
};
-export const ComputeNodeInfo = withResourceData('info', renderNodeInfo);
-
-export const ComputeNodeDomain = withResourceData('domain', renderCommonData);
-
-export const ComputeNodeFirstPingAt = withResourceData('firstPingAt', renderCommonDate);
-
-export const ComputeNodeHostname = withResourceData('hostname', renderCommonData);
-
-export const ComputeNodeIpAddress = withResourceData('ipAddress', renderCommonData);
-
-export const ComputeNodeJobUuid = withResourceData('jobUuid', renderCommonData);
-
-export const ComputeNodeLastPingAt = withResourceData('lastPingAt', renderCommonDate);
-
// Links Resources
const renderLinkName = (item: { name: string }) =>
<Typography noWrap>{item.name || '(none)'}</Typography>;
export const ResourceFileSize = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource<CollectionResource>(props.uuid)(state.resources);
+
+ if (resource && resource.kind !== ResourceKind.COLLECTION) {
+ return { fileSize: '' };
+ }
+
return { fileSize: resource ? resource.fileSizeTotal : 0 };
})((props: { fileSize?: number }) => renderFileSize(props.fileSize));
return { owner: ownerName ? ownerName!.name : resource!.ownerUuid };
})((props: { owner: string }) => renderOwner(props.owner));
-export const ResourceOwnerWithName =
- compose(
- connect(
- (state: RootState, props: { uuid: string }) => {
- let ownerName = '';
- const resource = getResource<GroupContentsResource & UserResource>(props.uuid)(state.resources);
+const userFromID =
+ connect(
+ (state: RootState, props: { uuid: string }) => {
+ let userFullname = '';
+ const resource = getResource<GroupContentsResource & UserResource>(props.uuid)(state.resources);
- if (resource) {
- ownerName = getUserFullname(resource as User) || (resource as GroupContentsResource).name;
- }
+ if (resource) {
+ userFullname = getUserFullname(resource as User) || (resource as GroupContentsResource).name;
+ }
- return { uuid: props.uuid, ownerName };
- }),
+ return { uuid: props.uuid, userFullname };
+ });
+
+export const ResourceOwnerWithName =
+ compose(
+ userFromID,
withStyles({}, { withTheme: true }))
- ((props: { uuid: string, ownerName: string, dispatch: Dispatch, theme: ArvadosTheme }) => {
- const { uuid, ownerName, dispatch, theme } = props;
+ ((props: { uuid: string, userFullname: string, dispatch: Dispatch, theme: ArvadosTheme }) => {
+ const { uuid, userFullname, dispatch, theme } = props;
- if (ownerName === '') {
+ if (userFullname === '') {
dispatch<any>(loadResource(uuid, false));
return <Typography style={{ color: theme.palette.primary.main }} inline noWrap>
{uuid}
}
return <Typography style={{ color: theme.palette.primary.main }} inline noWrap>
- {ownerName} ({uuid})
+ {userFullname} ({uuid})
</Typography>;
});
+export const UserNameFromID =
+ compose(userFromID)(
+ (props: { uuid: 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 }) => {
- let responsiblePersonName = '';
+ (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) {
- resource = getResource<GroupContentsResource & UserResource>(resource.ownerUuid)(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: 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 === '') {
+ if (!responsiblePersonName) {
return <Typography style={{ color: theme.palette.primary.main }} inline noWrap>
{uuid}
</Typography>;