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 f9b8424abd5e14d1ecfc8bf5d9c936cc4706feb7 Mon Sep 17 00:00:00 2001 From: Ingmar van Stipriaan Date: Fri, 29 Nov 2024 13:53:04 +0100 Subject: [PATCH 3/4] feat: add createActionInputVariable config on property option --- __tests__/validations/component.test.tsx | 3 +++ src/validations/prefab/componentOption.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/__tests__/validations/component.test.tsx b/__tests__/validations/component.test.tsx index 0afafdfc..2f24b9b3 100644 --- a/__tests__/validations/component.test.tsx +++ b/__tests__/validations/component.test.tsx @@ -945,6 +945,9 @@ test('Success when the reconfigure configuration options of the prefabs are vali type: 'TEXT', value: 'New property', }, + createActionInputVariable: { + type: 'TEXT', + }, manageObjectValues: { selectableObjectKey: true, buttonLabel: 'Manage something', diff --git a/src/validations/prefab/componentOption.ts b/src/validations/prefab/componentOption.ts index 15e92344..b8957f40 100644 --- a/src/validations/prefab/componentOption.ts +++ b/src/validations/prefab/componentOption.ts @@ -81,6 +81,11 @@ const optionConfigurationSchema = Joi.when('type', { type: Joi.string(), value: Joi.string().allow(''), }), + createActionInputVariable: Joi.object({ + name: Joi.string(), + type: Joi.string().required(), + value: Joi.string().allow(''), + }), manageObjectValues: Joi.object({ selectableObjectKey: Joi.boolean().optional(), buttonLabel: Joi.string().optional(), @@ -95,7 +100,7 @@ const optionConfigurationSchema = Joi.when('type', { then: Joi.object({ ...optionConfigurationSchemaBase, createActionInputVariable: Joi.object({ - name: Joi.string().required(), + name: Joi.string(), type: Joi.string().required(), value: Joi.string().allow(''), }), From ba4ead1d123a202703e0010930f42c99649c6de4 Mon Sep 17 00:00:00 2001 From: Ingmar van Stipriaan Date: Mon, 16 Dec 2024 13:26:05 +0100 Subject: [PATCH 4/4] fix: align createActionInputvariable configurations --- src/validations/prefab/componentOption.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validations/prefab/componentOption.ts b/src/validations/prefab/componentOption.ts index 98a4c825..79c81600 100644 --- a/src/validations/prefab/componentOption.ts +++ b/src/validations/prefab/componentOption.ts @@ -82,9 +82,9 @@ const optionConfigurationSchema = Joi.when('type', { value: Joi.string().allow(''), }), createActionInputVariable: Joi.object({ - name: Joi.string(), + name: Joi.string().optional(), type: Joi.string().required(), - value: Joi.string().allow(''), + value: Joi.string().allow('').optional(), }), manageObjectValues: Joi.object({ selectableObjectKey: Joi.boolean().optional(),