X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/3f7e1a8afad27920adf8f03ce82eeb1ae58aa84f..e09a9e644ad7937bb3800ca8096f444f6ff4411b:/src/views/process-panel/process-details-attributes.tsx diff --git a/src/views/process-panel/process-details-attributes.tsx b/src/views/process-panel/process-details-attributes.tsx index 4af2c9cd..1f3a73a5 100644 --- a/src/views/process-panel/process-details-attributes.tsx +++ b/src/views/process-panel/process-details-attributes.tsx @@ -5,21 +5,24 @@ import React from "react"; import { Grid, StyleRulesCallback, withStyles } from "@material-ui/core"; import { Dispatch } from 'redux'; -import { formatDate } from "common/formatters"; +import { formatContainerCost, formatDate } from "common/formatters"; import { resourceLabel } from "common/labels"; import { DetailsAttribute } from "components/details-attribute/details-attribute"; import { ResourceKind } from "models/resource"; -import { ContainerRunTime, ResourceWithName } from "views-components/data-explorer/renderers"; +import { CollectionName, ContainerRunTime, ResourceWithName } from "views-components/data-explorer/renderers"; import { getProcess, getProcessStatus } from "store/processes/process"; import { RootState } from "store/store"; import { connect } from "react-redux"; -import { ProcessResource } from "models/process"; +import { ProcessResource, MOUNT_PATH_CWL_WORKFLOW } from "models/process"; import { ContainerResource } from "models/container"; -import { openProcessInputDialog } from "store/processes/process-input-actions"; import { navigateToOutput, openWorkflow } from "store/process-panel/process-panel-actions"; import { ArvadosTheme } from "common/custom-theme"; import { ProcessRuntimeStatus } from "views-components/process-runtime-status/process-runtime-status"; import { getPropertyChip } from "views-components/resource-properties-form/property-chip"; +import { ContainerRequestResource } from "models/container-request"; +import { filterResources } from "store/resources/resources"; +import { JSONMount } from 'models/mount-types'; +import { getCollectionUrl } from 'models/collection'; type CssRules = 'link' | 'propertyTag'; @@ -38,30 +41,67 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }); const mapStateToProps = (state: RootState, props: { request: ProcessResource }) => { + const process = getProcess(props.request.uuid)(state.resources); + + let workflowCollection = ""; + let workflowPath = ""; + if (process?.containerRequest?.mounts && process.containerRequest.mounts[MOUNT_PATH_CWL_WORKFLOW]) { + const wf = process.containerRequest.mounts[MOUNT_PATH_CWL_WORKFLOW] as JSONMount; + + if (wf.content["$graph"] && + wf.content["$graph"].length > 0 && + wf.content["$graph"][0] && + wf.content["$graph"][0]["steps"] && + wf.content["$graph"][0]["steps"][0]) { + + const REGEX = /keep:([0-9a-f]{32}\+\d+)\/(.*)/; + const pdh = wf.content["$graph"][0]["steps"][0].run.match(REGEX); + if (pdh) { + workflowCollection = pdh[1]; + workflowPath = pdh[2]; + } + } + } + return { - container: getProcess(props.request.uuid)(state.resources)?.container, + container: process?.container, + workflowCollection, + workflowPath, + subprocesses: filterResources((resource: ContainerRequestResource) => + resource.kind === ResourceKind.CONTAINER_REQUEST && + resource.requestingContainerUuid === process?.containerRequest.containerUuid + )(state.resources), }; }; interface ProcessDetailsAttributesActionProps { - openProcessInputDialog: (uuid: string) => void; - navigateToOutput: (uuid: string) => void; + navigateToOutput: (resource: ContainerRequestResource) => void; openWorkflow: (uuid: string) => void; } const mapDispatchToProps = (dispatch: Dispatch): ProcessDetailsAttributesActionProps => ({ - openProcessInputDialog: (uuid) => dispatch(openProcessInputDialog(uuid)), - navigateToOutput: (uuid) => dispatch(navigateToOutput(uuid)), + navigateToOutput: (resource) => dispatch(navigateToOutput(resource)), openWorkflow: (uuid) => dispatch(openWorkflow(uuid)), }); export const ProcessDetailsAttributes = withStyles(styles, { withTheme: true })( connect(mapStateToProps, mapDispatchToProps)( - (props: { request: ProcessResource, container?: ContainerResource, twoCol?: boolean, hideProcessPanelRedundantFields?: boolean, classes: Record } & ProcessDetailsAttributesActionProps) => { + (props: { + request: ProcessResource, container?: ContainerResource, subprocesses: ContainerRequestResource[], + workflowCollection, workflowPath, + twoCol?: boolean, hideProcessPanelRedundantFields?: boolean, classes: Record + } & ProcessDetailsAttributesActionProps) => { const containerRequest = props.request; const container = props.container; + const subprocesses = props.subprocesses; const classes = props.classes; const mdSize = props.twoCol ? 6 : 12; + const workflowCollection = props.workflowCollection; + const workflowPath = props.workflowPath; + const filteredPropertyKeys = Object.keys(containerRequest.properties) + .filter(k => (typeof containerRequest.properties[k] !== 'object')); + const hasTotalCost = containerRequest && containerRequest.cumulativeCost > 0; + const totalCostNotReady = container && container.cost > 0 && container.state === "Running" && containerRequest && containerRequest.cumulativeCost === 0 && subprocesses.length > 0; return @@ -70,10 +110,10 @@ export const ProcessDetailsAttributes = withStyles(styles, { withTheme: true })( } - + - @@ -101,17 +141,34 @@ export const ProcessDetailsAttributes = withStyles(styles, { withTheme: true })( + {(containerRequest && containerRequest.modifiedByUserUuid) && + } /> + } + {(container && container.runtimeUserUuid && container.runtimeUserUuid !== containerRequest.modifiedByUserUuid) && + } /> + } - + - props.navigateToOutput(containerRequest.outputUuid!)}> - - - props.openProcessInputDialog(containerRequest.uuid)}> - - + + {containerRequest.outputUuid && props.navigateToOutput(containerRequest!)}> + + } + {container && + 0 ? formatContainerCost(container.cost) : 'not available'} for this container` + } /> + + {container && workflowCollection && + + } + } {containerRequest.properties.template_uuid && props.openWorkflow(containerRequest.properties.template_uuid)}> @@ -123,13 +180,13 @@ export const ProcessDetailsAttributes = withStyles(styles, { withTheme: true })( {/* - NOTE: The property list should be kept at the bottom, because it spans - the entire available width, without regards of the twoCol prop. - */} + NOTE: The property list should be kept at the bottom, because it spans + the entire available width, without regards of the twoCol prop. + */} - {Object.keys(containerRequest.properties).length > 0 - ? Object.keys(containerRequest.properties).map(k => + {filteredPropertyKeys.length > 0 + ? filteredPropertyKeys.map(k => Array.isArray(containerRequest.properties[k]) ? containerRequest.properties[k].map((v: string) => getPropertyChip(k, v, undefined, classes.propertyTag))