Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Less io not a node #165

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## @i-vresse/wb-core 3.2.1 - 2024-08-26

### Fixed

- Handle json schema ifthenelse block in file upload ([#164](https://github.com/i-VRESSE/workflow-builder/issues/164))

## @i-vresse/wb-core 3.2.0 - 2024-08-23

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@i-vresse/wb-core",
"version": "3.2.0",
"version": "3.2.1",
"description": "React components to construct a workflow builder application",
"keywords": [
"react",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export function globalParameterKeys (global: IGlobal): Set<string> {
if (global?.schema.properties != null) {
keys = Object.keys(global.schema.properties)
}
if (global?.schema.then !== undefined && typeof global.schema.then !== 'boolean' && global.schema.then.properties !== undefined) {
keys = [...keys, ...Object.keys(global.schema.then.properties)]
}
if (global?.schema.else !== undefined && typeof global.schema.else !== 'boolean' && global.schema.else.properties !== undefined) {
keys = [...keys, ...Object.keys(global.schema.else.properties)]
}
return new Set(keys)
}

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/molecule/addMoleculeValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export function parseMolecules (
if (moleculesPropNameAndSchema === undefined) {
return [[], undefined]
}
// not finding moleculefilepaths in then and else blocks as moleculefilepaths only supported in global schema properties

// find molecule file paths that belongs to this array item
const moleculesPropName = moleculesPropNameAndSchema[0]
if (!(moleculesPropName in globalParameters)) {
Expand Down Expand Up @@ -285,6 +287,7 @@ function walkSchemaForMoleculeFormats (
}
return [k, v]
})
// not finding molecule formats in then and else blocks as if block only supported in global schema
newSchema.properties = Object.fromEntries(entries)
return newSchema
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/resolveMaxItemsFrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function resolveMaxItemsFrom (formSchema: JSONSchema7WithMaxItemsFrom, gl
}
return [k, s]
})
// not finding maxItemsFrom in then and else blocks as only supported in global schema
newFormSchema.properties = Object.fromEntries(entries)
return newFormSchema
}
Expand Down
73 changes: 70 additions & 3 deletions packages/core/src/toml.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dedent from 'ts-dedent'
import { expect, describe, it } from 'vitest'
import { dedupWorkflow, parseWorkflowByCatalogPieces, TomlSchemas, workflow2tomltext, tomlstring2table } from './toml'
import { IParameters } from './types'
import { expect, describe, it, beforeEach } from 'vitest'
import { dedupWorkflow, parseWorkflowByCatalogPieces, TomlSchemas, workflow2tomltext, tomlstring2table, parseWorkflow } from './toml'
import { ICatalog, IParameters } from './types'

describe('workflow2tomltext()', () => {
it('should write list of dicts as array of tables', () => {
Expand Down Expand Up @@ -998,3 +998,70 @@ bar = 4
expect(actual).toEqual(expected)
})
})

describe('parseWorkflow()', () => {
describe('given calalog with if then else block', () => {
let catalog: ICatalog

beforeEach(() => {
catalog = {
title: 'test',
categories: [],
examples: {},
global: {
schema: {
type: 'object',
properties: {
ifpar: {
type: 'boolean',
default: false
}
},
if: {
properties: {
ifpar: {
const: true
}
}
},
then: {
properties: {
thenpar: {
type: 'number'
}
}
},
else: {
properties: {
elsepar: {
type: 'number'
}
}
}
},
uiSchema: {}
},
nodes: []
}
})

it('should have parameters from block be global parameters', () => {
const workflow = `
thenpar = 42
elsepar = 113
`

const result = parseWorkflow(workflow, catalog)

const expected = {
global: {
thenpar: 42,
elsepar: 113
},
nodes: []
}

expect(result).toEqual(expected)
})
})
})
1 change: 0 additions & 1 deletion packages/core/src/toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export function parseWorkflowFromTable (
globalKeys,
tomlSchema4global,
tomSchema4nodes

)
}

Expand Down
1 change: 1 addition & 0 deletions packages/form/src/table/TableFieldTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const TableFieldTemplate = (props: ArrayFieldTemplateProps): JSX.Element
</>
)
}
// not finding description in then and else blocks as not supported in table
const width = widths[key]
return (
<th
Expand Down
Loading