From 57066cf129433e670e0d98b17f318cb8b4b2f4b7 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Wed, 21 Jun 2023 17:08:27 +0300 Subject: [PATCH] Feat/multi env select (#4028) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About the changes Closes # ### Important files ## Discussion points --------- Signed-off-by: andreas-unleash --- .../PlaygroundConnectionFieldset.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx b/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx index 4bfaa6e12f..5925248cd3 100644 --- a/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundConnectionFieldset/PlaygroundConnectionFieldset.tsx @@ -8,6 +8,7 @@ import { } from '@mui/material'; import useProjects from 'hooks/api/getters/useProjects/useProjects'; import { GuidanceIndicator } from 'component/common/GuidanceIndicator/GuidanceIndicator'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; interface IPlaygroundConnectionFieldsetProps { environments: string[]; @@ -34,6 +35,9 @@ export const PlaygroundConnectionFieldset: VFC< availableEnvironments, }) => { const theme = useTheme(); + const { uiConfig } = useUiConfig(); + + const isAdvancedPlayground = uiConfig.flags.advancedPlayground; const { projects: availableProjects = [] } = useProjects(); const projectsOptions = [ @@ -98,6 +102,10 @@ export const PlaygroundConnectionFieldset: VFC< const isAllProjects = projects.length === 0 || (projects.length === 1 && projects[0] === '*'); + const envValue = isAdvancedPlayground + ? environmentOptions.filter(({ id }) => environments.includes(id)) + : environmentOptions.filter(({ id }) => environments.includes(id))[0]; + return ( @@ -114,18 +122,16 @@ export const PlaygroundConnectionFieldset: VFC< ( )} size="small" - value={ - environmentOptions.filter(({ id }) => - environments.includes(id) - )[0] - } + value={envValue} onChange={onEnvironmentsChange} + data-testid={'PLAYGROUND_ENVIRONMENT_SELECT'} />