From cc315e49c103043399d0c78fdec4b9bfab85fa81 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 1 Jul 2024 10:44:50 -0400 Subject: [PATCH] 15814: Fix runtime typecheck error Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../workbench2/cypress/e2e/create-workflow.cy.js | 2 +- services/workbench2/src/models/workflow.ts | 13 +++++++++---- .../src/views/process-panel/process-io-card.tsx | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/services/workbench2/cypress/e2e/create-workflow.cy.js b/services/workbench2/cypress/e2e/create-workflow.cy.js index 15d40dd37d..f4e4a92c8d 100644 --- a/services/workbench2/cypress/e2e/create-workflow.cy.js +++ b/services/workbench2/cypress/e2e/create-workflow.cy.js @@ -320,7 +320,7 @@ describe('Create workflow tests', function () { cy.get('[data-cy=new-process-panel]').contains('Run workflow').click(); cy.get('[data-cy=process-io-card]').should('contain', 'exposed_value_xyz'); - cy.get('[data-cy=process-io-card]').should('contain', 'exposed_value_xyz'); + cy.get('[data-cy=process-io-card]').should('contain', 'Cannot display secret'); cy.get('[data-cy=process-io-card]').should('not.contain', 'secret_value_xyz'); cy.url().then((url) => { diff --git a/services/workbench2/src/models/workflow.ts b/services/workbench2/src/models/workflow.ts index df19359993..b7a115da6d 100644 --- a/services/workbench2/src/models/workflow.ts +++ b/services/workbench2/src/models/workflow.ts @@ -103,6 +103,10 @@ export interface Directory { basename?: string; } +export interface SecretInclude { + $include: string; +} + export interface GenericCommandInputParameter { id: string; label?: string; @@ -130,10 +134,8 @@ export type IntArrayCommandInputParameter = GenericArrayCommandInputParameter; export type FileArrayCommandInputParameter = GenericArrayCommandInputParameter; export type DirectoryArrayCommandInputParameter = GenericArrayCommandInputParameter; +export type SecretCommandInputParameter = GenericArrayCommandInputParameter; -type SecretInclude = { - $include: string; -} export type WorkflowInputsData = { [key: string]: boolean | number | string | File | Directory | SecretInclude; @@ -232,8 +234,11 @@ export const getEnumType = (input: GenericCommandInputParameter) => { return null; }; +export const isSecret = (input: GenericCommandInputParameter) => + (typeof input.value === 'object') && input.value.$include?.startsWith("/secrets/"); + export const stringifyInputType = ({ type }: CommandInputParameter) => { - if (typeof type === 'string') { + if (typeof type === 'string') { return type; } else if (type instanceof Array) { return type.join(' | '); diff --git a/services/workbench2/src/views/process-panel/process-io-card.tsx b/services/workbench2/src/views/process-panel/process-io-card.tsx index a551a0d8ec..42a9616049 100644 --- a/services/workbench2/src/views/process-panel/process-io-card.tsx +++ b/services/workbench2/src/views/process-panel/process-io-card.tsx @@ -43,6 +43,7 @@ import { IntCommandInputParameter, isArrayOfType, isPrimitiveOfType, + isSecret, StringArrayCommandInputParameter, StringCommandInputParameter, getEnumType, @@ -689,7 +690,7 @@ type FileWithSecondaryFiles = { export const getIOParamDisplayValue = (auth: AuthState, input: CommandInputParameter | CommandOutputParameter, pdh?: string): ProcessIOValue[] => { switch (true) { - case (typeof input.value === 'object') && input.value.$include?.startsWith("/secrets/"): + case isSecret(input): return [{ display: }]; case isPrimitiveOfType(input, CWLType.BOOLEAN): -- 2.30.2