[ARVADOS-WORKBENCH2] updated: 1.2.0-484-g91bf126
Git user
git at public.curoverse.com
Fri Sep 28 09:15:50 EDT 2018
Summary of changes:
src/components/workflow-inputs-form/validators.ts | 21 ++++++++++
.../workflow-inputs-form/workflow-input.tsx | 18 +++++++++
src/models/workflow.ts | 47 +++++++++++++++++-----
.../workflow-panel/workflow-description-card.tsx | 6 +--
4 files changed, 80 insertions(+), 12 deletions(-)
create mode 100644 src/components/workflow-inputs-form/validators.ts
create mode 100644 src/components/workflow-inputs-form/workflow-input.tsx
via 91bf126bc097ea203c1c081adc187e7567367a35 (commit)
from 952aa1c7170d4b24951f40ed66b5f19a53d11daf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 91bf126bc097ea203c1c081adc187e7567367a35
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Fri Sep 28 15:15:34 2018 +0200
Create separate types for command inputs
Feature #13863
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/components/workflow-inputs-form/validators.ts b/src/components/workflow-inputs-form/validators.ts
new file mode 100644
index 0000000..9e1e24e
--- /dev/null
+++ b/src/components/workflow-inputs-form/validators.ts
@@ -0,0 +1,21 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { CommandInputParameter } from '~/models/workflow';
+import { require } from '~/validators/require';
+import { CWLType } from '../../models/workflow';
+
+
+const alwaysValid = () => undefined;
+
+export const required = ({ type }: CommandInputParameter) => {
+ if (type instanceof Array) {
+ for (const t of type) {
+ if (t === CWLType.NULL) {
+ return alwaysValid;
+ }
+ }
+ }
+ return require;
+};
diff --git a/src/components/workflow-inputs-form/workflow-input.tsx b/src/components/workflow-inputs-form/workflow-input.tsx
new file mode 100644
index 0000000..3a15d15
--- /dev/null
+++ b/src/components/workflow-inputs-form/workflow-input.tsx
@@ -0,0 +1,18 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { CommandInputParameter } from '~/models/workflow';
+import { TextField } from '@material-ui/core';
+import { required } from '~/components/workflow-inputs-form/validators';
+
+export interface WorkflowInputProps {
+ input: CommandInputParameter;
+}
+export const WorkflowInput = ({ input }: WorkflowInputProps) =>
+ <TextField
+ label={`${input.label || input.id}${required(input)() ? '*' : ''}`}
+ name={input.id}
+ helperText={input.doc}
+ fullWidth />;
\ No newline at end of file
diff --git a/src/models/workflow.ts b/src/models/workflow.ts
index 923a9cb..95cc926 100644
--- a/src/models/workflow.ts
+++ b/src/models/workflow.ts
@@ -31,13 +31,19 @@ export interface CommandLineTool {
outputs: any[];
}
-export interface CommandInputParameter {
- id: string;
- label?: string;
- doc?: string | string[];
- default?: any;
- type?: CWLType | CWLType[] | CommandInputEnumSchema | CommandInputArraySchema;
-}
+export type CommandInputParameter =
+ BooleanCommandInputParameter |
+ IntCommandInputParameter |
+ LongCommandInputParameter |
+ FloatCommandInputParameter |
+ DoubleCommandInputParameter |
+ StringCommandInputParameter |
+ FileCommandInputParameter |
+ DirectoryCommandInputParameter |
+ StringArrayCommandInputParameter |
+ FileArrayCommandInputParameter |
+ DirectoryArrayCommandInputParameter |
+ EnumCommandInputParameter;
export enum CWLType {
NULL = 'null',
@@ -58,8 +64,8 @@ export interface CommandInputEnumSchema {
name?: string;
}
-export interface CommandInputArraySchema {
- items: CWLType;
+export interface CommandInputArraySchema<ItemType> {
+ items: ItemType;
type: 'array';
label?: string;
}
@@ -78,6 +84,29 @@ export interface Directory {
basename?: string;
}
+export interface GenericCommandInputParameter<Type, Value> {
+ id: string;
+ label?: string;
+ doc?: string | string[];
+ default?: Value;
+ type?: Type | Array<Type | CWLType.NULL>;
+}
+export type GenericArrayCommandInputParameter<Type, Value> = GenericCommandInputParameter<CommandInputArraySchema<Type>, Value[]>;
+
+export type BooleanCommandInputParameter = GenericCommandInputParameter<CWLType.BOOLEAN, boolean>;
+export type IntCommandInputParameter = GenericCommandInputParameter<CWLType.INT, number>;
+export type LongCommandInputParameter = GenericCommandInputParameter<CWLType.LONG, number>;
+export type FloatCommandInputParameter = GenericCommandInputParameter<CWLType.FLOAT, number>;
+export type DoubleCommandInputParameter = GenericCommandInputParameter<CWLType.DOUBLE, number>;
+export type StringCommandInputParameter = GenericCommandInputParameter<CWLType.STRING, string>;
+export type FileCommandInputParameter = GenericCommandInputParameter<CWLType.FILE, File>;
+export type DirectoryCommandInputParameter = GenericCommandInputParameter<CWLType.DIRECTORY, Directory>;
+export type EnumCommandInputParameter = GenericCommandInputParameter<CommandInputEnumSchema, string>;
+
+export type StringArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.STRING, string>;
+export type FileArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.FILE, File>;
+export type DirectoryArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.DIRECTORY, Directory>;
+
export const parseWorkflowDefinition = (workflow: WorkflowResource): WorkflowResoruceDefinition => {
const definition = safeLoad(workflow.definition);
return definition;
diff --git a/src/views/workflow-panel/workflow-description-card.tsx b/src/views/workflow-panel/workflow-description-card.tsx
index 57cf89f..f6b2fcb 100644
--- a/src/views/workflow-panel/workflow-description-card.tsx
+++ b/src/views/workflow-panel/workflow-description-card.tsx
@@ -7,8 +7,8 @@ import { StyleRulesCallback, WithStyles, withStyles, CardContent, Tab, Tabs, Pap
import { ArvadosTheme } from '~/common/custom-theme';
import { WorkflowIcon } from '~/components/icon/icon';
import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
-import { WorkflowResource, parseWorkflowDefinition, getWorkflowInputs, stringifyInputType } from '~/models/workflow';
-import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
+import { WorkflowResource, parseWorkflowDefinition, getWorkflowInputs } from '~/models/workflow';
+import { WorkflowInput } from '~/components/workflow-inputs-form/workflow-input';
export type CssRules = 'root' | 'tab';
@@ -54,7 +54,7 @@ export const WorkflowDetailsCard = withStyles(styles)(
</CardContent>}
{value === 1 && <CardContent>
{workflow && this.inputs
- ? this.inputs.map(input => <DetailsAttribute key={input.id} label={input.label || ''} value={stringifyInputType(input)} />)
+ ? this.inputs.map(input => <WorkflowInput key={input.id} input={input}/>)
: <DataTableDefaultView
icon={WorkflowIcon}
messages={['Please select a workflow to see its description.']} />}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list