15814: Secret inputs now render as password inputs
authorPeter Amstutz <peter.amstutz@curii.com>
Mon, 17 Jun 2024 21:25:00 +0000 (17:25 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 24 Jun 2024 18:17:03 +0000 (14:17 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

services/workbench2/src/models/workflow.ts
services/workbench2/src/views/run-process-panel/inputs/string-input.tsx

index fc22cb860c393f77ed33957551860020f0b42b6e..f968cef93126475ddfe30e384b43db972b883c6f 100644 (file)
@@ -5,6 +5,7 @@
 import { Resource, ResourceKind } from "./resource";
 import { safeLoad } from 'js-yaml';
 import { CommandOutputParameter } from "cwlts/mappings/v1.0/CommandOutputParameter";
+import { CwlSecrets } from 'models/process';
 
 export interface WorkflowResource extends Resource {
     kind: ResourceKind.WORKFLOW;
@@ -111,6 +112,7 @@ export interface GenericCommandInputParameter<Type, Value> {
     type?: Type | Array<Type | CWLType.NULL>;
     value?: Value;
     disabled?: boolean;
+    secret?: boolean;
 }
 export type GenericArrayCommandInputParameter<Type, Value> = GenericCommandInputParameter<CommandInputArraySchema<Type>, Value[]>;
 
@@ -152,11 +154,22 @@ export const getWorkflow = (workflowDefinition: WorkflowResourceDefinition) => {
 
 export const getWorkflowInputs = (workflowDefinition: WorkflowResourceDefinition) => {
     if (!workflowDefinition) { return undefined; }
-    return getWorkflow(workflowDefinition)
-        ? getWorkflow(workflowDefinition)!.inputs
-        : undefined;
+    const wf = getWorkflow(workflowDefinition);
+    if (!wf) { return undefined; }
+    const inputs = wf.inputs;
+    if (wf.hints) {
+       const secrets = wf.hints.find(item => item.class === 'http://commonwl.org/cwltool#Secrets') as CwlSecrets | undefined;
+       if (secrets && secrets.secrets) {
+           inputs.forEach((param) => {
+               param.secret = secrets.secrets.includes(param.id);
+           });
+       }
+    }
+
+    return inputs;
 };
 
+
 export const getWorkflowOutputs = (workflowDefinition: WorkflowResourceDefinition) => {
     if (!workflowDefinition) { return undefined; }
     return getWorkflow(workflowDefinition)
index e497004801ea0fce01cdcf24edacff0c2226065a..1560e4a2133ed2974d9907ecbf0307767f423e3d 100644 (file)
@@ -37,4 +37,5 @@ const Input = (props: GenericInputProps) =>
         fullWidth
         error={props.meta.touched && !!props.meta.error}
         disabled={props.commandInput.disabled}
-        {...props.input} />;
\ No newline at end of file
+       type={props.commandInput.secret ? 'password' : 'text'}
+        {...props.input} />;