From de3449747805daaf2d2ada30381f17b0bf49e8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Thu, 14 Mar 2024 16:32:14 +0000 Subject: [PATCH] chore: drop action definition required (#6567) https://linear.app/unleash/issue/2-2046/implement-dynamic-action-parameters Follow up to https://github.com/Unleash/unleash/pull/6554 Cleans up the `required` property in action definitions after adapting to using the `parameters` property instead. --- .../ProjectActionsActionItem.tsx | 12 +++++++----- src/lib/util/constants/actions.ts | 4 ---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsFormStep/ProjectActionsFormStepActions/ProjectActionsActionItem.tsx b/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsFormStep/ProjectActionsFormStepActions/ProjectActionsActionItem.tsx index 8f2ddcf2cb..cf5a06d11d 100644 --- a/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsFormStep/ProjectActionsFormStepActions/ProjectActionsActionItem.tsx +++ b/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsFormStep/ProjectActionsFormStepActions/ProjectActionsActionItem.tsx @@ -87,11 +87,13 @@ export const ProjectActionsActionItem = ({ ...action, error: undefined, }); - if ( - actionDefinition?.required.some( - (required) => !executionParams[required], - ) - ) { + + const requiredParameters = + actionDefinition?.parameters + .filter(({ optional }) => !optional) + .map(({ name }) => name) || []; + + if (requiredParameters.some((required) => !executionParams[required])) { stateChanged({ ...action, error: 'Please fill all required fields.', diff --git a/src/lib/util/constants/actions.ts b/src/lib/util/constants/actions.ts index 1c038ed7cd..71f6b4cc8f 100644 --- a/src/lib/util/constants/actions.ts +++ b/src/lib/util/constants/actions.ts @@ -9,8 +9,6 @@ export type ActionDefinition = { category?: string; permissions: string[]; parameters: ActionDefinitionParameter[]; - // TODO: Remove this in favor of parameters (filter by !optional) - required: string[]; }; export const ACTIONS = new Map([ @@ -22,7 +20,6 @@ export const ACTIONS = new Map([ category: 'Feature toggles', permissions: ['UPDATE_FEATURE_ENVIRONMENT'], parameters: toggleFeatureParameters, - required: ['project', 'environment', 'featureName'], }, ], [ @@ -34,7 +31,6 @@ export const ACTIONS = new Map([ category: 'Feature toggles', permissions: ['UPDATE_FEATURE_ENVIRONMENT'], parameters: toggleFeatureParameters, - required: ['project', 'environment', 'featureName'], }, ], ]);