1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
unleash.unleash/frontend/src/component/project/Project/CreateProject/NewProjectForm.tsx

353 lines
14 KiB
TypeScript
Raw Normal View History

import { Typography, styled } from '@mui/material';
import Input from 'component/common/Input/Input';
import type { ProjectMode } from '../hooks/useProjectEnterpriseSettingsForm';
import { ReactComponent as ProjectIcon } from 'assets/icons/projectIconSmall.svg';
import {
MultiselectList,
SingleSelectList,
TableSelect,
} from './SelectionButton';
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
import { useEnvironments } from 'hooks/api/getters/useEnvironments/useEnvironments';
import StickinessIcon from '@mui/icons-material/FormatPaint';
import ProjectModeIcon from '@mui/icons-material/Adjust';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import EnvironmentsIcon from '@mui/icons-material/CloudCircle';
import { useStickinessOptions } from 'hooks/useStickinessOptions';
import { ReactComponent as ChangeRequestIcon } from 'assets/icons/merge.svg';
import type { ReactNode } from 'react';
import theme from 'themes/theme';
const StyledForm = styled('form')(({ theme }) => ({
background: theme.palette.background.default,
}));
const StyledFormSection = styled('div')(({ theme }) => ({
'& + *': {
borderBlockStart: `1px solid ${theme.palette.divider}`,
},
padding: theme.spacing(6),
}));
const TopGrid = styled(StyledFormSection)(({ theme }) => ({
display: 'grid',
gridTemplateAreas:
'"icon header" "icon project-name" "icon project-description"',
gridTemplateColumns: 'auto 1fr',
gap: theme.spacing(4),
}));
const StyledIcon = styled(ProjectIcon)(({ theme }) => ({
fill: theme.palette.primary.main,
stroke: theme.palette.primary.main,
}));
const StyledHeader = styled(Typography)(({ theme }) => ({
gridArea: 'header',
alignSelf: 'center',
fontWeight: 'lighter',
}));
const ProjectNameContainer = styled('div')(({ theme }) => ({
gridArea: 'project-name',
}));
const ProjectDescriptionContainer = styled('div')(({ theme }) => ({
gridArea: 'project-description',
}));
const StyledInput = styled(Input)(({ theme }) => ({
width: '100%',
fieldset: { border: 'none' },
}));
const OptionButtons = styled(StyledFormSection)(({ theme }) => ({
display: 'flex',
flexFlow: 'row wrap',
gap: theme.spacing(2),
}));
const FormActions = styled(StyledFormSection)(({ theme }) => ({
display: 'flex',
gap: theme.spacing(5),
justifyContent: 'flex-end',
}));
type FormProps = {
projectId: string;
projectName: string;
projectDesc: string;
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
projectStickiness: string;
featureLimit?: string;
featureCount?: number;
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
projectMode: string;
projectEnvironments: Set<string>;
projectChangeRequestConfiguration: Record<
string,
{ requiredApprovals: number }
>;
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
setProjectStickiness: React.Dispatch<React.SetStateAction<string>>;
setProjectEnvironments: (envs: Set<string>) => void;
setProjectId: React.Dispatch<React.SetStateAction<string>>;
setProjectName: React.Dispatch<React.SetStateAction<string>>;
setProjectDesc: React.Dispatch<React.SetStateAction<string>>;
setFeatureLimit?: React.Dispatch<React.SetStateAction<string>>;
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
setProjectMode: React.Dispatch<React.SetStateAction<ProjectMode>>;
updateProjectChangeRequestConfig: {
disableChangeRequests: (env: string) => void;
enableChangeRequests: (env: string, requiredApprovals: number) => void;
};
handleSubmit: (e: any) => void;
errors: { [key: string]: string };
mode: 'Create' | 'Edit';
clearErrors: () => void;
validateProjectId: () => void;
overrideDocumentation: (args: { text: string; icon: ReactNode }) => void;
clearDocumentationOverride: () => void;
};
const PROJECT_NAME_INPUT = 'PROJECT_NAME_INPUT';
const PROJECT_DESCRIPTION_INPUT = 'PROJECT_DESCRIPTION_INPUT';
export const NewProjectForm: React.FC<FormProps> = ({
children,
handleSubmit,
projectName,
projectDesc,
projectStickiness,
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
projectEnvironments,
projectChangeRequestConfiguration,
featureLimit,
featureCount,
projectMode,
setProjectMode,
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
setProjectEnvironments,
setProjectId,
setProjectName,
setProjectDesc,
setProjectStickiness,
updateProjectChangeRequestConfig,
setFeatureLimit,
errors,
mode,
clearErrors,
overrideDocumentation,
clearDocumentationOverride,
}) => {
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
const { isEnterprise } = useUiConfig();
const { environments: allEnvironments } = useEnvironments();
const activeEnvironments = allEnvironments.filter((env) => env.enabled);
const handleProjectNameUpdate = (
e: React.ChangeEvent<HTMLInputElement>,
) => {
const input = e.target.value;
setProjectName(input);
};
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
const projectModeOptions = [
{ value: 'open', label: 'open' },
{ value: 'protected', label: 'protected' },
{ value: 'private', label: 'private' },
];
const stickinessOptions = useStickinessOptions(projectStickiness);
const selectionButtonData = {
environments: {
icon: <EnvironmentsIcon />,
text: `Each feature flag can have a separate configuration per environment. This setting configures which environments your project should start with.`,
},
stickiness: {
icon: <StickinessIcon />,
text: 'Stickiness is used to guarantee that your users see the same result when using a gradual rollout. Default stickiness allows you to choose which field is used by default in this project.',
},
mode: {
icon: <ProjectModeIcon />,
text: 'Mode defines who should be allowed to interact and see your project. Private mode hides the project from anyone except the project owner and members.',
},
changeRequests: {
icon: <ChangeRequestIcon />,
text: 'Change requests can be configured per environment and require changes to go through an approval process before being applied.',
},
};
return (
<StyledForm
onSubmit={(submitEvent) => {
handleSubmit(submitEvent);
}}
>
<TopGrid>
<StyledIcon aria-hidden='true' />
<StyledHeader variant='h2'>New project</StyledHeader>
<ProjectNameContainer>
<StyledInput
label='Project name'
aria-required
value={projectName}
onChange={handleProjectNameUpdate}
error={Boolean(errors.name)}
errorText={errors.name}
onFocus={() => {
delete errors.name;
}}
data-testid={PROJECT_NAME_INPUT}
autoFocus
InputProps={{
style: { fontSize: theme.typography.h1.fontSize },
}}
InputLabelProps={{
style: { fontSize: theme.typography.h1.fontSize },
}}
size='medium'
/>
</ProjectNameContainer>
<ProjectDescriptionContainer>
<StyledInput
size='medium'
className='description'
label='Description (optional)'
multiline
maxRows={20}
value={projectDesc}
onChange={(e) => setProjectDesc(e.target.value)}
data-testid={PROJECT_DESCRIPTION_INPUT}
InputProps={{
style: { fontSize: theme.typography.h2.fontSize },
}}
InputLabelProps={{
style: { fontSize: theme.typography.h2.fontSize },
}}
/>
</ProjectDescriptionContainer>
</TopGrid>
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
<OptionButtons>
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
<MultiselectList
description={selectionButtonData.environments.text}
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
selectedOptions={projectEnvironments}
options={activeEnvironments.map((env) => ({
label: env.name,
value: env.name,
}))}
onChange={setProjectEnvironments}
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
button={{
label:
projectEnvironments.size > 0
? `${projectEnvironments.size} selected`
: 'All environments',
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
icon: <EnvironmentsIcon />,
}}
search={{
label: 'Filter project environments',
placeholder: 'Select project environments',
}}
onOpen={() =>
overrideDocumentation(selectionButtonData.environments)
}
onClose={clearDocumentationOverride}
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
/>
<SingleSelectList
description={selectionButtonData.stickiness.text}
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
options={stickinessOptions.map(({ key, ...rest }) => ({
value: key,
...rest,
}))}
onChange={(value: any) => {
setProjectStickiness(value);
}}
button={{
label: projectStickiness,
icon: <StickinessIcon />,
}}
search={{
label: 'Filter stickiness options',
placeholder: 'Select default stickiness',
}}
onOpen={() =>
overrideDocumentation(selectionButtonData.stickiness)
}
onClose={clearDocumentationOverride}
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
/>
<ConditionallyRender
condition={isEnterprise()}
show={
<SingleSelectList
description={selectionButtonData.mode.text}
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
options={projectModeOptions}
onChange={(value: any) => {
setProjectMode(value);
}}
button={{
label: projectMode,
icon: <ProjectModeIcon />,
}}
search={{
label: 'Filter project mode options',
placeholder: 'Select project mode',
}}
onOpen={() =>
overrideDocumentation(selectionButtonData.mode)
}
onClose={clearDocumentationOverride}
support setting mode and stickiness in new project form (#6972) This PR is a combination of two PRs: This PR adds a functioning environment selection button to the new project creation form. Selected environments are added to the payload and to the API preview. The implementation is mostly lifted from the existing FilterItem component we have for search filters. However, our need here is less complex, so I've removed some of the things we don't need. There is still more cleanup to be done, however, but I'd like to implement the rest of the submenus first, to see what we really do need in the end. --- This PR adds support for stickiness and project mode in the new project creation form. Achieve this, it does a few things: 1. Moves `resolveStickinessOptions` from `frontend/src/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx` and into a separate hook. This component was used by the old project creation form. Because the new form has a different input, but needs the same option, moved that code into a reusable hook. 2. It adds functioning buttons for project stickiness and mode. 3. It adds labels to the search inputs for the dropdowns. Inputs *must* have labels to meet a11y requirements. However, the designs don't have labels, so we can hide them visually. Though that leads to another issue (refer to the screen shot below). 4. It updates the `SelectionButton` component to handle both single- and multiselect cases. It instead exports these two subcomponents. These are currently in one file, but I'll split them out into their separate files in a later PR. As a side effect of working with the selection buttons, it also improves how we handle keyboard interaction for these buttons. Here's what it looks like for single-select lists. Notice the missing part of the input's border around the top (where the label *would* be if we showed it). We should figure out how best to handle it. I've done like this for now, but we can sort it out later. ![image](https://github.com/Unleash/unleash/assets/17786332/5af979c2-6635-481e-8d3e-5aad1c0ab46f)
2024-05-03 07:27:13 +02:00
/>
}
/>
<ConditionallyRender
condition={isEnterprise()}
show={
<TableSelect
description={
selectionButtonData.changeRequests.text
}
disabled={projectEnvironments.size === 0}
activeEnvironments={activeEnvironments
.filter((env) =>
projectEnvironments.has(env.name),
)
.map((env) => ({
name: env.name,
type: env.type,
}))}
updateProjectChangeRequestConfiguration={
updateProjectChangeRequestConfig
}
button={{
label:
Object.keys(
projectChangeRequestConfiguration,
).length > 0
? `${
Object.keys(
projectChangeRequestConfiguration,
).length
} selected`
: 'Configure change requests',
icon: <ChangeRequestIcon />,
}}
search={{
label: 'Filter environments',
placeholder: 'Filter environments',
}}
projectChangeRequestConfiguration={
projectChangeRequestConfiguration
}
onOpen={() =>
overrideDocumentation(
selectionButtonData.changeRequests,
)
}
onClose={clearDocumentationOverride}
/>
}
/>
</OptionButtons>
<FormActions>{children}</FormActions>
</StyledForm>
);
};