mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: Wrap addons form in FormTemplate (#1138)
* feat: Wrap addons form in FormTemplate * Change styled button section
This commit is contained in:
		
							parent
							
								
									4c5eb20e09
								
							
						
					
					
						commit
						e5b2f907e4
					
				
							
								
								
									
										57
									
								
								frontend/src/component/addons/AddonForm/AddonForm.styles.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								frontend/src/component/addons/AddonForm/AddonForm.styles.tsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | |||||||
|  | import { styled } from '@mui/system'; | ||||||
|  | import { FormControlLabel, TextField } from '@mui/material'; | ||||||
|  | import Autocomplete from '@mui/material/Autocomplete'; | ||||||
|  | 
 | ||||||
|  | export const StyledForm = styled('form')({ | ||||||
|  |     display: 'flex', | ||||||
|  |     flexDirection: 'column', | ||||||
|  |     height: '100%', | ||||||
|  |     gap: '1rem', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledAutocomplete = styled(Autocomplete)({ | ||||||
|  |     paddingBottom: '36px', | ||||||
|  |     marginTop: '0px', | ||||||
|  | }); | ||||||
|  | export const StyledFormSection = styled('section')({ | ||||||
|  |     marginBottom: '36px', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledHelpText = styled('p')({ | ||||||
|  |     marginBottom: '0.5rem', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledContainer = styled('div')({ | ||||||
|  |     maxWidth: '600px', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledButtonContainer = styled('div')({ | ||||||
|  |     marginTop: 'auto', | ||||||
|  |     display: 'flex', | ||||||
|  |     justifyContent: 'flex-end', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledButtonSection = styled('section')(({ theme }) => ({ | ||||||
|  |     'padding-top': '16px', | ||||||
|  |     '& > *': { | ||||||
|  |         marginRight: theme.spacing(1), | ||||||
|  |     }, | ||||||
|  | })); | ||||||
|  | 
 | ||||||
|  | export const StyledTextField = styled(TextField)({ | ||||||
|  |     width: '100%', | ||||||
|  |     marginBottom: '1rem', | ||||||
|  |     marginTop: '0px', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledSelectAllFormControlLabel = styled(FormControlLabel)({ | ||||||
|  |     paddingBottom: '16px', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledTitle = styled('h4')({ | ||||||
|  |     marginBottom: '8px', | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const StyledAddonParameterContainer = styled('div')({ | ||||||
|  |     marginTop: '25px', | ||||||
|  | }); | ||||||
| @ -6,35 +6,39 @@ import React, { | |||||||
|     useState, |     useState, | ||||||
|     VFC, |     VFC, | ||||||
| } from 'react'; | } from 'react'; | ||||||
| import { Button, FormControlLabel, Switch, TextField } from '@mui/material'; | import { | ||||||
|  |     Button, | ||||||
|  |     Divider, | ||||||
|  |     FormControlLabel, | ||||||
|  |     Switch, | ||||||
|  |     TextField, | ||||||
|  | } from '@mui/material'; | ||||||
| import produce from 'immer'; | import produce from 'immer'; | ||||||
| import { styles as themeStyles } from 'component/common'; |  | ||||||
| import { trim } from 'component/common/util'; | import { trim } from 'component/common/util'; | ||||||
| import { IAddon, IAddonProvider } from 'interfaces/addons'; | import { IAddon, IAddonProvider } from 'interfaces/addons'; | ||||||
| import { AddonParameters } from './AddonParameters/AddonParameters'; | import { AddonParameters } from './AddonParameters/AddonParameters'; | ||||||
| import cloneDeep from 'lodash.clonedeep'; | import cloneDeep from 'lodash.clonedeep'; | ||||||
| import { PageContent } from 'component/common/PageContent/PageContent'; |  | ||||||
| import { useNavigate } from 'react-router-dom'; | import { useNavigate } from 'react-router-dom'; | ||||||
| import useAddonsApi from 'hooks/api/actions/useAddonsApi/useAddonsApi'; | import useAddonsApi from 'hooks/api/actions/useAddonsApi/useAddonsApi'; | ||||||
| import useToast from 'hooks/useToast'; | import useToast from 'hooks/useToast'; | ||||||
| import { makeStyles } from 'tss-react/mui'; |  | ||||||
| import { formatUnknownError } from 'utils/formatUnknownError'; | import { formatUnknownError } from 'utils/formatUnknownError'; | ||||||
| import useProjects from '../../../hooks/api/getters/useProjects/useProjects'; | import useProjects from '../../../hooks/api/getters/useProjects/useProjects'; | ||||||
| import { useEnvironments } from '../../../hooks/api/getters/useEnvironments/useEnvironments'; | import { useEnvironments } from '../../../hooks/api/getters/useEnvironments/useEnvironments'; | ||||||
| import { AddonMultiSelector } from './AddonMultiSelector/AddonMultiSelector'; | import { AddonMultiSelector } from './AddonMultiSelector/AddonMultiSelector'; | ||||||
| 
 | import FormTemplate from 'component/common/FormTemplate/FormTemplate'; | ||||||
| const useStyles = makeStyles()(theme => ({ | import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig'; | ||||||
|     nameInput: { | import PermissionButton from '../../common/PermissionButton/PermissionButton'; | ||||||
|         marginRight: '1.5rem', | import { ADMIN } from '../../providers/AccessProvider/permissions'; | ||||||
|     }, | import { | ||||||
|     formSection: { padding: '10px 28px' }, |     StyledForm, | ||||||
|     buttonsSection: { |     StyledFormSection, | ||||||
|         padding: '10px 28px', |     StyledHelpText, | ||||||
|         '& > *': { |     StyledTextField, | ||||||
|             marginRight: theme.spacing(1), |     StyledContainer, | ||||||
|         }, |     StyledButtonContainer, | ||||||
|     }, |     StyledButtonSection, | ||||||
| })); | } from './AddonForm.styles'; | ||||||
|  | import { useTheme } from '@mui/system'; | ||||||
| 
 | 
 | ||||||
| interface IAddonFormProps { | interface IAddonFormProps { | ||||||
|     provider?: IAddonProvider; |     provider?: IAddonProvider; | ||||||
| @ -52,7 +56,7 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|     const { createAddon, updateAddon } = useAddonsApi(); |     const { createAddon, updateAddon } = useAddonsApi(); | ||||||
|     const { setToastData, setToastApiError } = useToast(); |     const { setToastData, setToastApiError } = useToast(); | ||||||
|     const navigate = useNavigate(); |     const navigate = useNavigate(); | ||||||
|     const { classes: styles } = useStyles(); |     const theme = useTheme(); | ||||||
|     const { projects: availableProjects } = useProjects(); |     const { projects: availableProjects } = useProjects(); | ||||||
|     const selectableProjects = availableProjects.map(project => ({ |     const selectableProjects = availableProjects.map(project => ({ | ||||||
|         value: project.id, |         value: project.id, | ||||||
| @ -67,6 +71,7 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|         value: event, |         value: event, | ||||||
|         label: event, |         label: event, | ||||||
|     })); |     })); | ||||||
|  |     const { uiConfig } = useUiConfig(); | ||||||
|     const [formValues, setFormValues] = useState(initialValues); |     const [formValues, setFormValues] = useState(initialValues); | ||||||
|     const [errors, setErrors] = useState<{ |     const [errors, setErrors] = useState<{ | ||||||
|         containsErrors: boolean; |         containsErrors: boolean; | ||||||
| @ -81,6 +86,18 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|         parameters: {}, |         parameters: {}, | ||||||
|     }); |     }); | ||||||
|     const submitText = editMode ? 'Update' : 'Create'; |     const submitText = editMode ? 'Update' : 'Create'; | ||||||
|  |     let url = `${uiConfig.unleashUrl}/api/admin/addons${ | ||||||
|  |         editMode ? `/${formValues.id}` : `` | ||||||
|  |     }`;
 | ||||||
|  | 
 | ||||||
|  |     const formatApiCode = () => { | ||||||
|  |         return `curl --location --request ${ | ||||||
|  |             editMode ? 'PUT' : 'POST' | ||||||
|  |         } '${url}' \\ | ||||||
|  |         --header 'Authorization: INSERT_API_KEY' \\ | ||||||
|  |         --header 'Content-Type: application/json' \\ | ||||||
|  |         --data-raw '${JSON.stringify(formValues, undefined, 2)}'`;
 | ||||||
|  |     }; | ||||||
| 
 | 
 | ||||||
|     useEffect(() => { |     useEffect(() => { | ||||||
|         if (!provider) { |         if (!provider) { | ||||||
| @ -162,7 +179,9 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
| 
 | 
 | ||||||
|     const onSubmit: FormEventHandler<HTMLFormElement> = async event => { |     const onSubmit: FormEventHandler<HTMLFormElement> = async event => { | ||||||
|         event.preventDefault(); |         event.preventDefault(); | ||||||
|         if (!provider) return; |         if (!provider) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         const updatedErrors = cloneDeep(errors); |         const updatedErrors = cloneDeep(errors); | ||||||
|         updatedErrors.containsErrors = false; |         updatedErrors.containsErrors = false; | ||||||
| @ -222,24 +241,24 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|     } = provider ? provider : ({} as Partial<IAddonProvider>); |     } = provider ? provider : ({} as Partial<IAddonProvider>); | ||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         <PageContent header={`Configure ${name} addon`}> |         <FormTemplate | ||||||
|             <section className={styles.formSection}> |             title={`${submitText} ${name} addon`} | ||||||
|                 {description}  |             description={description || ''} | ||||||
|                 <a href={documentationUrl} target="_blank" rel="noreferrer"> |             documentationLink={documentationUrl} | ||||||
|                     Read more |             documentationLinkLabel="Addon documentation" | ||||||
|                 </a> |             formatApiCode={formatApiCode} | ||||||
|                 <p className={themeStyles.error}>{errors.general}</p> |         > | ||||||
|             </section> |             <StyledForm onSubmit={onSubmit}> | ||||||
|             <form onSubmit={onSubmit}> |                 <StyledContainer> | ||||||
|                 <section className={styles.formSection}> |                     <StyledFormSection> | ||||||
|                     <TextField |                         <StyledTextField | ||||||
|                             size="small" |                             size="small" | ||||||
|                             label="Provider" |                             label="Provider" | ||||||
|                             name="provider" |                             name="provider" | ||||||
|                             value={formValues.provider} |                             value={formValues.provider} | ||||||
|                             disabled |                             disabled | ||||||
|  |                             hidden={true} | ||||||
|                             variant="outlined" |                             variant="outlined" | ||||||
|                         className={styles.nameInput} |  | ||||||
|                         /> |                         /> | ||||||
|                         <FormControlLabel |                         <FormControlLabel | ||||||
|                             control={ |                             control={ | ||||||
| @ -250,9 +269,13 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|                             } |                             } | ||||||
|                             label={formValues.enabled ? 'Enabled' : 'Disabled'} |                             label={formValues.enabled ? 'Enabled' : 'Disabled'} | ||||||
|                         /> |                         /> | ||||||
|                 </section> |                     </StyledFormSection> | ||||||
|                 <section className={styles.formSection}> |                     <StyledFormSection> | ||||||
|                     <TextField |                         <StyledHelpText> | ||||||
|  |                             What is your addon description? | ||||||
|  |                         </StyledHelpText> | ||||||
|  | 
 | ||||||
|  |                         <StyledTextField | ||||||
|                             size="small" |                             size="small" | ||||||
|                             style={{ width: '80%' }} |                             style={{ width: '80%' }} | ||||||
|                             minRows={4} |                             minRows={4} | ||||||
| @ -266,18 +289,21 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|                             onChange={setFieldValue('description')} |                             onChange={setFieldValue('description')} | ||||||
|                             variant="outlined" |                             variant="outlined" | ||||||
|                         /> |                         /> | ||||||
|                 </section> |                     </StyledFormSection> | ||||||
| 
 | 
 | ||||||
|                 <section className={styles.formSection}> |                     <StyledFormSection> | ||||||
|                         <AddonMultiSelector |                         <AddonMultiSelector | ||||||
|                             options={selectableEvents || []} |                             options={selectableEvents || []} | ||||||
|                             selectedItems={formValues.events} |                             selectedItems={formValues.events} | ||||||
|                             onChange={setEventValues} |                             onChange={setEventValues} | ||||||
|                             entityName={'event'} |                             entityName={'event'} | ||||||
|                             selectAllEnabled={false} |                             selectAllEnabled={false} | ||||||
|  |                             description={ | ||||||
|  |                                 'Select what events you want your addon to be notified about' | ||||||
|  |                             } | ||||||
|                         /> |                         /> | ||||||
|                 </section> |                     </StyledFormSection> | ||||||
|                 <section className={styles.formSection}> |                     <StyledFormSection> | ||||||
|                         <AddonMultiSelector |                         <AddonMultiSelector | ||||||
|                             options={selectableProjects} |                             options={selectableProjects} | ||||||
|                             selectedItems={formValues.projects || []} |                             selectedItems={formValues.projects || []} | ||||||
| @ -285,8 +311,8 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|                             entityName={'project'} |                             entityName={'project'} | ||||||
|                             selectAllEnabled={true} |                             selectAllEnabled={true} | ||||||
|                         /> |                         /> | ||||||
|                 </section> |                     </StyledFormSection> | ||||||
|                 <section className={styles.formSection}> |                     <StyledFormSection> | ||||||
|                         <AddonMultiSelector |                         <AddonMultiSelector | ||||||
|                             options={selectableEnvironments} |                             options={selectableEnvironments} | ||||||
|                             selectedItems={formValues.environments || []} |                             selectedItems={formValues.environments || []} | ||||||
| @ -294,8 +320,8 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|                             entityName={'environment'} |                             entityName={'environment'} | ||||||
|                             selectAllEnabled={true} |                             selectAllEnabled={true} | ||||||
|                         /> |                         /> | ||||||
|                 </section> |                     </StyledFormSection> | ||||||
|                 <section className={styles.formSection}> |                     <StyledFormSection> | ||||||
|                         <AddonParameters |                         <AddonParameters | ||||||
|                             provider={provider} |                             provider={provider} | ||||||
|                             config={formValues} |                             config={formValues} | ||||||
| @ -303,16 +329,25 @@ export const AddonForm: VFC<IAddonFormProps> = ({ | |||||||
|                             editMode={editMode} |                             editMode={editMode} | ||||||
|                             setParameterValue={setParameterValue} |                             setParameterValue={setParameterValue} | ||||||
|                         /> |                         /> | ||||||
|                 </section> |                     </StyledFormSection> | ||||||
|                 <section className={styles.buttonsSection}> |                 </StyledContainer> | ||||||
|                     <Button type="submit" color="primary" variant="contained"> |                 <Divider /> | ||||||
|  |                 <StyledButtonContainer> | ||||||
|  |                     <StyledButtonSection theme={theme}> | ||||||
|  |                         <PermissionButton | ||||||
|  |                             type="submit" | ||||||
|  |                             color="primary" | ||||||
|  |                             variant="contained" | ||||||
|  |                             permission={ADMIN} | ||||||
|  |                         > | ||||||
|                             {submitText} |                             {submitText} | ||||||
|                     </Button> |                         </PermissionButton> | ||||||
|                         <Button type="button" onClick={onCancel}> |                         <Button type="button" onClick={onCancel}> | ||||||
|                             Cancel |                             Cancel | ||||||
|                         </Button> |                         </Button> | ||||||
|                 </section> |                     </StyledButtonSection> | ||||||
|             </form> |                 </StyledButtonContainer> | ||||||
|         </PageContent> |             </StyledForm> | ||||||
|  |         </FormTemplate> | ||||||
|     ); |     ); | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -12,7 +12,6 @@ import { | |||||||
|     Box, |     Box, | ||||||
|     capitalize, |     capitalize, | ||||||
|     Checkbox, |     Checkbox, | ||||||
|     FormControlLabel, |  | ||||||
|     Paper, |     Paper, | ||||||
|     TextField, |     TextField, | ||||||
| } from '@mui/material'; | } from '@mui/material'; | ||||||
| @ -20,6 +19,12 @@ import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank'; | |||||||
| import CheckBoxIcon from '@mui/icons-material/CheckBox'; | import CheckBoxIcon from '@mui/icons-material/CheckBox'; | ||||||
| import { ConditionallyRender } from '../../../common/ConditionallyRender/ConditionallyRender'; | import { ConditionallyRender } from '../../../common/ConditionallyRender/ConditionallyRender'; | ||||||
| import { SelectAllButton } from '../../../admin/apiToken/ApiTokenForm/SelectProjectInput/SelectAllButton/SelectAllButton'; | import { SelectAllButton } from '../../../admin/apiToken/ApiTokenForm/SelectProjectInput/SelectAllButton/SelectAllButton'; | ||||||
|  | import { | ||||||
|  |     StyledHelpText, | ||||||
|  |     StyledSelectAllFormControlLabel, | ||||||
|  |     StyledTitle, | ||||||
|  |     StyledAutocomplete, | ||||||
|  | } from '../AddonForm.styles'; | ||||||
| 
 | 
 | ||||||
| export interface IAddonMultiSelectorProps { | export interface IAddonMultiSelectorProps { | ||||||
|     options: IAutocompleteBoxOption[]; |     options: IAutocompleteBoxOption[]; | ||||||
| @ -29,6 +34,7 @@ export interface IAddonMultiSelectorProps { | |||||||
|     onFocus?: () => void; |     onFocus?: () => void; | ||||||
|     entityName: string; |     entityName: string; | ||||||
|     selectAllEnabled: boolean; |     selectAllEnabled: boolean; | ||||||
|  |     description?: string; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const ALL_OPTIONS = '*'; | const ALL_OPTIONS = '*'; | ||||||
| @ -47,6 +53,7 @@ export const AddonMultiSelector: VFC<IAddonMultiSelectorProps> = ({ | |||||||
|     onFocus, |     onFocus, | ||||||
|     entityName, |     entityName, | ||||||
|     selectAllEnabled = true, |     selectAllEnabled = true, | ||||||
|  |     description, | ||||||
| }) => { | }) => { | ||||||
|     const [isWildcardSelected, selectWildcard] = useState( |     const [isWildcardSelected, selectWildcard] = useState( | ||||||
|         selectedItems.includes(ALL_OPTIONS) |         selectedItems.includes(ALL_OPTIONS) | ||||||
| @ -117,8 +124,7 @@ export const AddonMultiSelector: VFC<IAddonMultiSelectorProps> = ({ | |||||||
|         </Fragment> |         </Fragment> | ||||||
|     ); |     ); | ||||||
|     const SelectAllFormControl = () => ( |     const SelectAllFormControl = () => ( | ||||||
|         <Box sx={{ mt: 1, mb: 0.25, ml: 1.5 }}> |         <StyledSelectAllFormControlLabel | ||||||
|             <FormControlLabel |  | ||||||
|             data-testid={`select-all-${entityName}s`} |             data-testid={`select-all-${entityName}s`} | ||||||
|             control={ |             control={ | ||||||
|                 <Checkbox |                 <Checkbox | ||||||
| @ -128,42 +134,45 @@ export const AddonMultiSelector: VFC<IAddonMultiSelectorProps> = ({ | |||||||
|             } |             } | ||||||
|             label={`ALL current and future ${entityName}s`} |             label={`ALL current and future ${entityName}s`} | ||||||
|         /> |         /> | ||||||
|         </Box> |  | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const HelpText = () => ( |     const DefaultHelpText = () => ( | ||||||
|         <p> |         <StyledHelpText> | ||||||
|             Selecting {entityName}(s) here will filter events so that your addon |             Selecting {entityName}(s) here will filter events so that your addon | ||||||
|             will only receive events that are tagged with one of your{' '} |             will only receive events that are tagged with one of your{' '} | ||||||
|             {entityName}s. |             {entityName}s. | ||||||
|         </p> |         </StyledHelpText> | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         <React.Fragment> |         <React.Fragment> | ||||||
|             <h4>{capitalize(entityName)}s</h4> |             <StyledTitle>{capitalize(entityName)}s</StyledTitle> | ||||||
|  |             <ConditionallyRender | ||||||
|  |                 condition={description !== undefined} | ||||||
|  |                 show={<StyledHelpText>{description}</StyledHelpText>} | ||||||
|  |             /> | ||||||
|             <ConditionallyRender |             <ConditionallyRender | ||||||
|                 condition={selectAllEnabled} |                 condition={selectAllEnabled} | ||||||
|                 show={<HelpText />} |                 show={<DefaultHelpText />} | ||||||
|             /> |             /> | ||||||
|             <span className={themeStyles.error}>{error}</span> |             <span className={themeStyles.error}>{error}</span> | ||||||
|             <br /> |  | ||||||
|             <Box sx={{ mt: -1, mb: 3 }}> |  | ||||||
|             <ConditionallyRender |             <ConditionallyRender | ||||||
|                 condition={selectAllEnabled} |                 condition={selectAllEnabled} | ||||||
|                 show={<SelectAllFormControl />} |                 show={<SelectAllFormControl />} | ||||||
|             /> |             /> | ||||||
|                 <Autocomplete |             <StyledAutocomplete | ||||||
|                 disabled={isWildcardSelected} |                 disabled={isWildcardSelected} | ||||||
|                 multiple |                 multiple | ||||||
|                 limitTags={2} |                 limitTags={2} | ||||||
|                 options={options} |                 options={options} | ||||||
|                 disableCloseOnSelect |                 disableCloseOnSelect | ||||||
|  |                 //@ts-expect-error
 | ||||||
|                 getOptionLabel={({ label }) => label} |                 getOptionLabel={({ label }) => label} | ||||||
|                 fullWidth |                 fullWidth | ||||||
|                 groupBy={() => 'Select/Deselect all'} |                 groupBy={() => 'Select/Deselect all'} | ||||||
|                 renderGroup={renderGroup} |                 renderGroup={renderGroup} | ||||||
|                 PaperComponent={CustomPaper} |                 PaperComponent={CustomPaper} | ||||||
|  |                 //@ts-expect-error
 | ||||||
|                 renderOption={renderOption} |                 renderOption={renderOption} | ||||||
|                 renderInput={renderInput} |                 renderInput={renderInput} | ||||||
|                 value={ |                 value={ | ||||||
| @ -174,11 +183,11 @@ export const AddonMultiSelector: VFC<IAddonMultiSelectorProps> = ({ | |||||||
|                           ) |                           ) | ||||||
|                 } |                 } | ||||||
|                 onChange={(_, input) => { |                 onChange={(_, input) => { | ||||||
|  |                     //@ts-expect-error
 | ||||||
|                     const state = input.map(({ value }) => value); |                     const state = input.map(({ value }) => value); | ||||||
|                     onChange(state); |                     onChange(state); | ||||||
|                 }} |                 }} | ||||||
|             /> |             /> | ||||||
|             </Box> |  | ||||||
|         </React.Fragment> |         </React.Fragment> | ||||||
|     ); |     ); | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { TextField } from '@mui/material'; | import { TextField } from '@mui/material'; | ||||||
| import { IAddonConfig, IAddonProviderParams } from 'interfaces/addons'; | import { IAddonConfig, IAddonProviderParams } from 'interfaces/addons'; | ||||||
| import { ChangeEventHandler } from 'react'; | import { ChangeEventHandler } from 'react'; | ||||||
|  | import { StyledAddonParameterContainer } from '../../AddonForm.styles'; | ||||||
| 
 | 
 | ||||||
| const resolveType = ({ type = 'text', sensitive = false }, value: string) => { | const resolveType = ({ type = 'text', sensitive = false }, value: string) => { | ||||||
|     if (sensitive && value === MASKED_VALUE) { |     if (sensitive && value === MASKED_VALUE) { | ||||||
| @ -32,7 +33,7 @@ export const AddonParameter = ({ | |||||||
|     const error = parametersErrors[definition.name]; |     const error = parametersErrors[definition.name]; | ||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         <div style={{ width: '80%', marginTop: '25px' }}> |         <StyledAddonParameterContainer> | ||||||
|             <TextField |             <TextField | ||||||
|                 size="small" |                 size="small" | ||||||
|                 style={{ width: '100%' }} |                 style={{ width: '100%' }} | ||||||
| @ -51,6 +52,6 @@ export const AddonParameter = ({ | |||||||
|                 variant="outlined" |                 variant="outlined" | ||||||
|                 helperText={definition.description} |                 helperText={definition.description} | ||||||
|             /> |             /> | ||||||
|         </div> |         </StyledAddonParameterContainer> | ||||||
|     ); |     ); | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ import { | |||||||
|     AddonParameter, |     AddonParameter, | ||||||
|     IAddonParameterProps, |     IAddonParameterProps, | ||||||
| } from './AddonParameter/AddonParameter'; | } from './AddonParameter/AddonParameter'; | ||||||
|  | import { StyledTitle } from '../AddonForm.styles'; | ||||||
| 
 | 
 | ||||||
| interface IAddonParametersProps { | interface IAddonParametersProps { | ||||||
|     provider?: IAddonProvider; |     provider?: IAddonProvider; | ||||||
| @ -21,10 +22,9 @@ export const AddonParameters = ({ | |||||||
|     editMode, |     editMode, | ||||||
| }: IAddonParametersProps) => { | }: IAddonParametersProps) => { | ||||||
|     if (!provider) return null; |     if (!provider) return null; | ||||||
| 
 |  | ||||||
|     return ( |     return ( | ||||||
|         <React.Fragment> |         <React.Fragment> | ||||||
|             <h4>Parameters</h4> |             <StyledTitle>Parameters</StyledTitle> | ||||||
|             {editMode ? ( |             {editMode ? ( | ||||||
|                 <p> |                 <p> | ||||||
|                     Sensitive parameters will be masked with value "<i>*****</i> |                     Sensitive parameters will be masked with value "<i>*****</i> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user