1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-28 17:55:15 +02:00
unleash.unleash/frontend/src/component/playground/Playground/PlaygroundForm/PlaygroundForm.tsx
Fredrik Strand Oseberg d4fcf52020 feat/playground-second-iteration (#1139)
* fix: rearrange ui

* fix: make request on load

* fix: default to the first environment

* feat: add codemirror

* fix: layout

* fix: styling

* feat: add popover

* feat: variant popover

* fix: add sticky

* feat: resolve input

* refactor: date field

* fix: move deps

* fix: clean up any

* fix: resolve import

* fix: hide columns on mobile

* fix: search style

* fix: rename styles

* fix: PR comments

* fix: add popover for guidance

* fix: guidance popover

* fix: verbose function

* fix: wording

Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
2022-07-22 13:15:28 +02:00

87 lines
2.7 KiB
TypeScript

import { Box, Button, Divider, useTheme } from '@mui/material';
import { GuidanceIndicator } from 'component/common/GuidanceIndicator/GuidanceIndicator';
import { IEnvironment } from 'interfaces/environments';
import { FormEvent, VFC } from 'react';
import { getEnvironmentOptions } from '../playground.utils';
import { PlaygroundCodeFieldset } from './PlaygroundCodeFieldset/PlaygroundCodeFieldset';
import { PlaygroundConnectionFieldset } from './PlaygroundConnectionFieldset/PlaygroundConnectionFieldset';
interface IPlaygroundFormProps {
environments: IEnvironment[];
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
environment: string;
projects: string[];
setProjects: React.Dispatch<React.SetStateAction<string[]>>;
setEnvironment: React.Dispatch<React.SetStateAction<string>>;
context: string | undefined;
setContext: React.Dispatch<React.SetStateAction<string | undefined>>;
}
export const PlaygroundForm: VFC<IPlaygroundFormProps> = ({
environments,
environment,
onSubmit,
projects,
setProjects,
setEnvironment,
context,
setContext,
}) => {
const theme = useTheme();
return (
<Box
component="form"
onSubmit={onSubmit}
sx={{
display: 'flex',
flexDirection: 'column',
}}
>
<PlaygroundConnectionFieldset
environment={environment}
projects={projects}
setEnvironment={setEnvironment}
setProjects={setProjects}
environmentOptions={getEnvironmentOptions(environments)}
/>
<Divider
variant="fullWidth"
sx={{
mb: 2,
borderColor: theme.palette.dividerAlternative,
borderStyle: 'dashed',
}}
/>
<PlaygroundCodeFieldset context={context} setContext={setContext} />
<Divider
variant="fullWidth"
sx={{
mt: 3,
mb: 2,
borderColor: theme.palette.dividerAlternative,
}}
/>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}}
>
<GuidanceIndicator type="secondary">3</GuidanceIndicator>
<Button
variant="contained"
size="large"
type="submit"
sx={{ marginLeft: 'auto' }}
>
Try configuration
</Button>
</Box>
</Box>
);
};