From e1045d9e290ce5bd33dbc04af096e6987da3f25b Mon Sep 17 00:00:00 2001 From: Jordy Quak Date: Wed, 13 Nov 2024 12:30:08 +0100 Subject: [PATCH 1/4] feat: add createActionInputVariable --- __tests__/validations/component.test.tsx | 32 +++++++++++++++++++++++ src/validations/prefab/componentOption.ts | 10 +++++++ 2 files changed, 42 insertions(+) diff --git a/__tests__/validations/component.test.tsx b/__tests__/validations/component.test.tsx index 1a19b208..0afafdfc 100644 --- a/__tests__/validations/component.test.tsx +++ b/__tests__/validations/component.test.tsx @@ -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, {})); +}); diff --git a/src/validations/prefab/componentOption.ts b/src/validations/prefab/componentOption.ts index db15589b..896f14a3 100644 --- a/src/validations/prefab/componentOption.ts +++ b/src/validations/prefab/componentOption.ts @@ -90,6 +90,16 @@ 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().required(), + type: Joi.string().required(), + }), + }), + }) .when('type', { is: 'VARIABLE', then: Joi.object({ From 815c7998e85f44a2be3484a1da071981c70ba52b Mon Sep 17 00:00:00 2001 From: Jordy Quak Date: Thu, 14 Nov 2024 13:19:25 +0100 Subject: [PATCH 2/4] fix: add value key --- src/validations/prefab/componentOption.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/validations/prefab/componentOption.ts b/src/validations/prefab/componentOption.ts index 896f14a3..15e92344 100644 --- a/src/validations/prefab/componentOption.ts +++ b/src/validations/prefab/componentOption.ts @@ -97,6 +97,7 @@ const optionConfigurationSchema = Joi.when('type', { createActionInputVariable: Joi.object({ name: Joi.string().required(), type: Joi.string().required(), + value: Joi.string().allow(''), }), }), }) From af809910e6fb9df3c21c21fc5ab8556ca809356f Mon Sep 17 00:00:00 2001 From: Jordy Quak Date: Thu, 14 Nov 2024 14:24:28 +0100 Subject: [PATCH 3/4] fix: make name optional --- src/validations/prefab/componentOption.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validations/prefab/componentOption.ts b/src/validations/prefab/componentOption.ts index 15e92344..41435ac5 100644 --- a/src/validations/prefab/componentOption.ts +++ b/src/validations/prefab/componentOption.ts @@ -95,7 +95,7 @@ const optionConfigurationSchema = Joi.when('type', { then: Joi.object({ ...optionConfigurationSchemaBase, createActionInputVariable: Joi.object({ - name: Joi.string().required(), + name: Joi.string().optional(), type: Joi.string().required(), value: Joi.string().allow(''), }), From 2d0716b49f45d54f81c5fee9e7fc69afe5e37f5d Mon Sep 17 00:00:00 2001 From: Jordy Quak Date: Mon, 18 Nov 2024 10:22:26 +0100 Subject: [PATCH 4/4] fix: make value optional --- src/validations/prefab/componentOption.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validations/prefab/componentOption.ts b/src/validations/prefab/componentOption.ts index 41435ac5..5f3c806a 100644 --- a/src/validations/prefab/componentOption.ts +++ b/src/validations/prefab/componentOption.ts @@ -97,7 +97,7 @@ const optionConfigurationSchema = Joi.when('type', { createActionInputVariable: Joi.object({ name: Joi.string().optional(), type: Joi.string().required(), - value: Joi.string().allow(''), + value: Joi.string().allow('').optional(), }), }), })