X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/8a85c509e4f2100082cfed6157d31c8651b861c9..c57c9f8553e59144b4adeafc90ce2fa2ac946962:/src/models/workflow.ts diff --git a/src/models/workflow.ts b/src/models/workflow.ts index d7d97c4c..a858c0d7 100644 --- a/src/models/workflow.ts +++ b/src/models/workflow.ts @@ -13,7 +13,8 @@ export interface WorkflowResource extends Resource { } export interface WorkflowResoruceDefinition { cwlVersion: string; - $graph: Array; + graph?: Array; + $graph?: Array; } export interface Workflow { class: 'Workflow'; @@ -41,6 +42,8 @@ export type CommandInputParameter = FileCommandInputParameter | DirectoryCommandInputParameter | StringArrayCommandInputParameter | + IntArrayCommandInputParameter | + FloatArrayCommandInputParameter | FileArrayCommandInputParameter | DirectoryArrayCommandInputParameter | EnumCommandInputParameter; @@ -90,6 +93,8 @@ export interface GenericCommandInputParameter { doc?: string | string[]; default?: Value; type?: Type | Array; + value?: Value; + disabled?: boolean; } export type GenericArrayCommandInputParameter = GenericCommandInputParameter, Value[]>; @@ -104,6 +109,8 @@ export type DirectoryCommandInputParameter = GenericCommandInputParameter; export type StringArrayCommandInputParameter = GenericArrayCommandInputParameter; +export type IntArrayCommandInputParameter = GenericArrayCommandInputParameter; +export type FloatArrayCommandInputParameter = GenericArrayCommandInputParameter; export type FileArrayCommandInputParameter = GenericArrayCommandInputParameter; export type DirectoryArrayCommandInputParameter = GenericArrayCommandInputParameter; @@ -116,11 +123,19 @@ export const parseWorkflowDefinition = (workflow: WorkflowResource): WorkflowRes }; export const getWorkflowInputs = (workflowDefinition: WorkflowResoruceDefinition) => { - const mainWorkflow = workflowDefinition.$graph.find(item => item.class === 'Workflow' && item.id === '#main'); - return mainWorkflow - ? mainWorkflow.inputs - : undefined; + if (workflowDefinition.graph) { + const mainWorkflow = workflowDefinition.graph.find(item => item.class === 'Workflow' && item.id === '#main'); + return mainWorkflow + ? mainWorkflow.inputs + : undefined; + } else { + const mainWorkflow = workflowDefinition.$graph!.find(item => item.class === 'Workflow' && item.id === '#main'); + return mainWorkflow + ? mainWorkflow.inputs + : undefined; + } }; + export const getInputLabel = (input: CommandInputParameter) => { return `${input.label || input.id}`; }; @@ -141,6 +156,12 @@ export const isPrimitiveOfType = (input: GenericCommandInputParameter, ? input.type.indexOf(type) > -1 : input.type === type; +export const isArrayOfType = (input: GenericCommandInputParameter, type: CWLType) => + typeof input.type === 'object' && + input.type.type === 'array' + ? input.type.items === type + : false; + export const stringifyInputType = ({ type }: CommandInputParameter) => { if (typeof type === 'string') { return type;