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

feat: add createActionInputVariable #475

Merged
merged 4 commits into from
Nov 18, 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
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
Loading