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 { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, WorkflowIcon, ShareIcon } from '~/components/icon/icon';
+import { ProjectIcon, 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 { 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';
-const renderName = (dispatch: Dispatch, item: { name: string; uuid: string, kind: string }) =>
+const renderName = (dispatch: Dispatch, item: GroupContentsResource) =>
<Grid container alignItems="center" wrap="nowrap" spacing={16}>
<Grid item>
- {renderIcon(item.kind)}
+ {renderIcon(item)}
</Grid>
<Grid item>
<Typography color="primary" style={{ width: 'auto', cursor: 'pointer' }} onClick={() => dispatch<any>(navigateTo(item.uuid))}>
export const ResourceName = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
- return resource || { name: '', uuid: '', kind: '' };
- })((resource: { name: string; uuid: string, kind: string } & DispatchProp<any>) => renderName(resource.dispatch, resource));
+ return resource;
+ })((resource: GroupContentsResource & DispatchProp<any>) => renderName(resource.dispatch, resource));
-const renderIcon = (kind: string) => {
- switch (kind) {
+const renderIcon = (item: GroupContentsResource) => {
+ switch (item.kind) {
case ResourceKind.PROJECT:
return <ProjectIcon />;
case ResourceKind.COLLECTION:
- return <CollectionIcon />;
+ if (item.uuid === item.currentVersionUuid) {
+ return <CollectionIcon />;
+ }
+ return <CollectionOldVersionIcon />;
case ResourceKind.PROCESS:
return <ProcessIcon />;
case ResourceKind.WORKFLOW:
return <Typography noWrap style={{ minWidth: '100px' }}>{formatDate(date)}</Typography>;
};
-const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ownerUuid: string }) =>
+const renderWorkflowName = (item: WorkflowResource) =>
<Grid container alignItems="center" wrap="nowrap" spacing={16}>
<Grid item>
- {renderIcon(item.kind)}
+ {renderIcon(item)}
</Grid>
<Grid item>
<Typography color="primary" style={{ width: '100px' }}>
export const ResourceWorkflowName = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource<WorkflowResource>(props.uuid)(state.resources);
- return resource || { name: '', uuid: '', kind: '', ownerUuid: '' };
+ return resource;
})(renderWorkflowName);
const getPublicUuid = (uuidPrefix: string) => {
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>(props.uuid)(state.resources);
+
+ if (resource) {
+ ownerName = (resource as any).fullName || resource.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>
+ {uuid} ({ownerName})
+ </Typography>;
+ });
+
const renderType = (type: string) =>
<Typography noWrap>
{resourceLabel(type)}
})((props: { type: string }) => renderType(props.type));
export const ResourceStatus = connect((state: RootState, props: { uuid: string }) => {
- return { resource: getResource<GroupContentsResource>(props.uuid)(state.resources) };
- })((props: { resource: GroupContentsResource }) =>
- (props.resource && props.resource.kind === ResourceKind.COLLECTION)
+ return { resource: getResource<GroupContentsResource>(props.uuid)(state.resources) };
+})((props: { resource: GroupContentsResource }) =>
+ (props.resource && props.resource.kind === ResourceKind.COLLECTION)
? <CollectionStatus uuid={props.resource.uuid} />
: <ProcessStatus uuid={props.resource.uuid} />
- );
+);
export const CollectionStatus = connect((state: RootState, props: { uuid: string }) => {
- return { collection: getResource<CollectionResource>(props.uuid)(state.resources) };
- })((props: { collection: CollectionResource }) =>
- (props.collection.uuid !== props.collection.currentVersionUuid)
- ? <Typography>old version</Typography>
- : <Typography>current</Typography>
- );
+ return { collection: getResource<CollectionResource>(props.uuid)(state.resources) };
+})((props: { collection: CollectionResource }) =>
+ (props.collection.uuid !== props.collection.currentVersionUuid)
+ ? <Typography>version {props.collection.version}</Typography>
+ : <Typography>head version</Typography>
+);
export const ProcessStatus = compose(
connect((state: RootState, props: { uuid: string }) => {
export const ProcessStartDate = connect(
(state: RootState, props: { uuid: string }) => {
const process = getProcess(props.uuid)(state.resources);
- return { date: ( process && process.container ) ? process.container.startedAt : '' };
+ return { date: (process && process.container) ? process.container.startedAt : '' };
})((props: { date: string }) => renderDate(props.date));
export const renderRunTime = (time: number) =>