From ad864049dadd1fce2bfe233be29d6b52447638ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Fri, 23 Feb 2024 08:24:32 +0000 Subject: [PATCH] fix: only show visible environments for that project in actions (#6318) https://linear.app/unleash/issue/2-1969/actions-form-only-show-environments-scoped-to-the-current-project Filters the environment options in actions to only show environments that are currently visible for that project, safeguarding users from configuring actions for invalid environments. ![image](https://github.com/Unleash/unleash/assets/14320932/115cc9cd-99a2-4863-aec0-8264459ef18a) --- .../ProjectActionsActionItem.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsActionItem.tsx b/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsActionItem.tsx index 48911c78c3a5..94bcd89ac7b5 100644 --- a/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsActionItem.tsx +++ b/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsModal/ProjectActionsForm/ProjectActionsActionItem.tsx @@ -1,11 +1,11 @@ import { IconButton, Tooltip, styled } from '@mui/material'; import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect'; import { Delete } from '@mui/icons-material'; -import { useProjectEnvironments } from 'hooks/api/getters/useProjectEnvironments/useProjectEnvironments'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useFeatureSearch } from 'hooks/api/getters/useFeatureSearch/useFeatureSearch'; import { ActionsActionState } from './useProjectActionsForm'; import { ProjectActionsFormItem } from './ProjectActionsFormItem'; +import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview'; const StyledItemRow = styled('div')(({ theme }) => ({ display: 'flex', @@ -31,7 +31,12 @@ export const ProjectActionsActionItem = ({ }) => { const { action: actionName } = action; const projectId = useRequiredPathParam('projectId'); - const environments = useProjectEnvironments(projectId); + const { project } = useProjectOverview(projectId); + + const environments = project.environments.map( + ({ environment }) => environment, + ); + const { features } = useFeatureSearch({ project: `IS:${projectId}` }); const header = ( @@ -78,9 +83,9 @@ export const ProjectActionsActionItem = ({ ({ - label: env.name, - key: env.name, + options={environments.map((environment) => ({ + label: environment, + key: environment, }))} value={action.executionParams.environment as string} onChange={(selected) =>