(props.uuid)(state.resources);
return resource || { linkClass: '' };
})(renderLinkClass);
const renderLinkTail = (dispatch: Dispatch, item: { uuid: string, tailUuid: string, tailKind: string }) => {
const currentLabel = resourceLabel(item.tailKind);
const isUnknow = currentLabel === "Unknown";
return (
{!isUnknow ? (
renderLink(dispatch, item.tailUuid, currentLabel)
) : (
{item.tailUuid}
)}
);
};
const renderLink = (dispatch: Dispatch, uuid: string, label: string) =>
dispatch(navigateTo(uuid))}>
{label}: {uuid}
;
export const ResourceLinkTail = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return {
item: resource || { uuid: '', tailUuid: '', tailKind: ResourceKind.NONE }
};
})((props: { item: any } & DispatchProp) =>
renderLinkTail(props.dispatch, props.item));
const renderLinkHead = (dispatch: Dispatch, item: { uuid: string, headUuid: string, headKind: ResourceKind }) =>
renderLink(dispatch, item.headUuid, resourceLabel(item.headKind));
export const ResourceLinkHead = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return {
item: resource || { uuid: '', headUuid: '', headKind: ResourceKind.NONE }
};
})((props: { item: any } & DispatchProp) =>
renderLinkHead(props.dispatch, props.item));
export const ResourceLinkUuid = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return resource || { uuid: '' };
})(renderUuid);
// Process Resources
const resourceRunProcess = (dispatch: Dispatch, uuid: string) => {
return (
{uuid &&
dispatch(openRunProcess(uuid))}>
}
);
};
export const ResourceRunProcess = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return {
uuid: resource ? resource.uuid : ''
};
})((props: { uuid: string } & DispatchProp) =>
resourceRunProcess(props.dispatch, props.uuid));
const renderWorkflowStatus = (uuidPrefix: string, ownerUuid?: string) => {
if (ownerUuid === getPublicUuid(uuidPrefix)) {
return renderStatus(WorkflowStatus.PUBLIC);
} else {
return renderStatus(WorkflowStatus.PRIVATE);
}
};
const renderStatus = (status: string) =>
{status};
export const ResourceWorkflowStatus = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
const uuidPrefix = getUuidPrefix(state);
return {
ownerUuid: resource ? resource.ownerUuid : '',
uuidPrefix
};
})((props: { ownerUuid?: string, uuidPrefix: string }) => renderWorkflowStatus(props.uuidPrefix, props.ownerUuid));
export const ResourceLastModifiedDate = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return { date: resource ? resource.modifiedAt : '' };
})((props: { date: string }) => renderDate(props.date));
export const ResourceCreatedAtDate = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return { date: resource ? resource.createdAt : '' };
})((props: { date: string }) => renderDate(props.date));
export const ResourceTrashDate = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return { date: resource ? resource.trashAt : '' };
})((props: { date: string }) => renderDate(props.date));
export const ResourceDeleteDate = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return { date: resource ? resource.deleteAt : '' };
})((props: { date: string }) => renderDate(props.date));
export const renderFileSize = (fileSize?: number) =>
{formatFileSize(fileSize)}
;
export const ResourceFileSize = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return { fileSize: resource ? resource.fileSizeTotal : 0 };
})((props: { fileSize?: number }) => renderFileSize(props.fileSize));
const renderOwner = (owner: string) =>
{owner}
;
export const ResourceOwner = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return { owner: resource ? resource.ownerUuid : '' };
})((props: { owner: string }) => renderOwner(props.owner));
export const ResourceOwnerName = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
const ownerNameState = state.ownerName;
const ownerName = ownerNameState.find(it => it.uuid === resource!.ownerUuid);
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(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(loadResource(uuid, false));
return
{uuid}
;
}
return
{ownerName} ({uuid})
;
});
const renderType = (type: string, subtype: string) =>
{resourceLabel(type, subtype)}
;
export const ResourceType = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource(props.uuid)(state.resources);
return { type: resource ? resource.kind : '', subtype: resource && resource.kind === ResourceKind.GROUP ? resource.groupClass : '' };
})((props: { type: string, subtype: string }) => renderType(props.type, props.subtype));
export const ResourceStatus = connect((state: RootState, props: { uuid: string }) => {
return { resource: getResource(props.uuid)(state.resources) };
})((props: { resource: GroupContentsResource }) =>
(props.resource && props.resource.kind === ResourceKind.COLLECTION)
?
:
);
export const CollectionStatus = connect((state: RootState, props: { uuid: string }) => {
return { collection: getResource(props.uuid)(state.resources) };
})((props: { collection: CollectionResource }) =>
(props.collection.uuid !== props.collection.currentVersionUuid)
? version {props.collection.version}
: head version
);
export const ProcessStatus = compose(
connect((state: RootState, props: { uuid: string }) => {
return { process: getProcess(props.uuid)(state.resources) };
}),
withStyles({}, { withTheme: true }))
((props: { process?: Process, theme: ArvadosTheme }) => {
const status = props.process ? getProcessStatus(props.process) : "-";
return
{status}
;
});
export const ProcessStartDate = connect(
(state: RootState, props: { uuid: string }) => {
const process = getProcess(props.uuid)(state.resources);
return { date: (process && process.container) ? process.container.startedAt : '' };
})((props: { date: string }) => renderDate(props.date));
export const renderRunTime = (time: number) =>
{formatTime(time, true)}
;
interface ContainerRunTimeProps {
process: Process;
}
interface ContainerRunTimeState {
runtime: number;
}
export const ContainerRunTime = connect((state: RootState, props: { uuid: string }) => {
return { process: getProcess(props.uuid)(state.resources) };
})(class extends React.Component {
private timer: any;
constructor(props: ContainerRunTimeProps) {
super(props);
this.state = { runtime: this.getRuntime() };
}
getRuntime() {
return this.props.process ? getProcessRuntime(this.props.process) : 0;
}
updateRuntime() {
this.setState({ runtime: this.getRuntime() });
}
componentDidMount() {
this.timer = setInterval(this.updateRuntime.bind(this), 5000);
}
componentWillUnmount() {
clearInterval(this.timer);
}
render() {
return renderRunTime(this.state.runtime);
}
});