Skip to content

Commit

Permalink
feat: add createActionInputVariable (#475)
Browse files Browse the repository at this point in the history
* feat: add createActionInputVariable

* fix: add value key

* fix: make name optional

* fix: make value optional

---------

Co-authored-by: Jordy Quak <[email protected]>
  • Loading branch information
jrquak and Jordy Quak authored Nov 18, 2024
1 parent 9ef5b57 commit 879d251
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions __tests__/validations/component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1175,3 +1175,35 @@ test('Success when value is an array with empty string in variable option', (t:

t.notThrows(() => validatePrefabs(prefabs, {}));
});

test('Success when adding createActionInputVariable in the option configuration of an ACTION_JS_INPUT', (t: Context): void => {
const prefabs: Prefab[] = [
{
name: 'Component Name',
icon: 'TitleIcon',
category: 'CONTENT',
structure: [
{
name: 'something',
options: [
{
value: [''],
label: 'something',
key: 'something',
type: 'ACTION_JS_VARIABLE',
configuration: {
createActionInputVariable: {
name: 'Test Name',
type: 'STRING',
},
},
},
],
descendants: [],
},
],
},
];

t.notThrows(() => validatePrefabs(prefabs, {}));
});
11 changes: 11 additions & 0 deletions src/validations/prefab/componentOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ const optionConfigurationSchema = Joi.when('type', {
}),
otherwise: Joi.object(optionConfigurationSchemaBase),
})
.when('type', {
is: 'ACTION_JS_VARIABLE',
then: Joi.object({
...optionConfigurationSchemaBase,
createActionInputVariable: Joi.object({
name: Joi.string().optional(),
type: Joi.string().required(),
value: Joi.string().allow('').optional(),
}),
}),
})
.when('type', {
is: 'VARIABLE',
then: Joi.object({
Expand Down

0 comments on commit 879d251

Please sign in to comment.