1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

Feat/multi env select (#4028)

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
andreas-unleash 2023-06-21 17:08:27 +03:00 committed by GitHub
parent 91f1072519
commit 57066cf129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 (
<Box sx={{ pb: 2 }}>
<Box sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
@ -114,18 +122,16 @@ export const PlaygroundConnectionFieldset: VFC<
<Autocomplete
disablePortal
id="environment"
multiple={isAdvancedPlayground}
options={environmentOptions}
sx={{ width: 200, maxWidth: '100%' }}
renderInput={params => (
<TextField {...params} label="Environments" />
)}
size="small"
value={
environmentOptions.filter(({ id }) =>
environments.includes(id)
)[0]
}
value={envValue}
onChange={onEnvironmentsChange}
data-testid={'PLAYGROUND_ENVIRONMENT_SELECT'}
/>
<Autocomplete
disablePortal
@ -145,6 +151,7 @@ export const PlaygroundConnectionFieldset: VFC<
)
}
onChange={onProjectsChange}
data-testid={'PLAYGROUND_PROJECT_SELECT'}
/>
</Box>
</Box>