mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-12 13:48:35 +02:00
fix: show addon event select validation (#2031)
* fix: show addon event select validation * fix: addon form parameters error not clearing * fix: addon required parameter field indicators
This commit is contained in:
parent
c64f9a0e20
commit
18fc5eebd2
@ -27,7 +27,7 @@ export const StyledButtonContainer = styled('div')({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const StyledButtonSection = styled('section')(({ theme }) => ({
|
export const StyledButtonSection = styled('section')(({ theme }) => ({
|
||||||
'padding-top': '16px',
|
paddingTop: theme.spacing(2),
|
||||||
'& > *': {
|
'& > *': {
|
||||||
marginRight: theme.spacing(1),
|
marginRight: theme.spacing(1),
|
||||||
},
|
},
|
||||||
|
@ -179,6 +179,7 @@ export const AddonForm: VFC<IAddonFormProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updatedErrors = cloneDeep(errors);
|
const updatedErrors = cloneDeep(errors);
|
||||||
|
updatedErrors.parameters = {};
|
||||||
updatedErrors.containsErrors = false;
|
updatedErrors.containsErrors = false;
|
||||||
|
|
||||||
// Validations
|
// Validations
|
||||||
@ -291,11 +292,11 @@ export const AddonForm: VFC<IAddonFormProps> = ({
|
|||||||
options={selectableEvents || []}
|
options={selectableEvents || []}
|
||||||
selectedItems={formValues.events}
|
selectedItems={formValues.events}
|
||||||
onChange={setEventValues}
|
onChange={setEventValues}
|
||||||
entityName={'event'}
|
entityName="event"
|
||||||
selectAllEnabled={false}
|
selectAllEnabled={false}
|
||||||
description={
|
error={errors.events}
|
||||||
'Select what events you want your addon to be notified about'
|
description="Select what events you want your addon to be notified about."
|
||||||
}
|
required
|
||||||
/>
|
/>
|
||||||
</StyledFormSection>
|
</StyledFormSection>
|
||||||
<StyledFormSection>
|
<StyledFormSection>
|
||||||
@ -303,7 +304,7 @@ export const AddonForm: VFC<IAddonFormProps> = ({
|
|||||||
options={selectableProjects}
|
options={selectableProjects}
|
||||||
selectedItems={formValues.projects || []}
|
selectedItems={formValues.projects || []}
|
||||||
onChange={setProjects}
|
onChange={setProjects}
|
||||||
entityName={'project'}
|
entityName="project"
|
||||||
selectAllEnabled={true}
|
selectAllEnabled={true}
|
||||||
/>
|
/>
|
||||||
</StyledFormSection>
|
</StyledFormSection>
|
||||||
@ -312,7 +313,7 @@ export const AddonForm: VFC<IAddonFormProps> = ({
|
|||||||
options={selectableEnvironments}
|
options={selectableEnvironments}
|
||||||
selectedItems={formValues.environments || []}
|
selectedItems={formValues.environments || []}
|
||||||
onChange={setEnvironments}
|
onChange={setEnvironments}
|
||||||
entityName={'environment'}
|
entityName="environment"
|
||||||
selectAllEnabled={true}
|
selectAllEnabled={true}
|
||||||
/>
|
/>
|
||||||
</StyledFormSection>
|
</StyledFormSection>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { ChangeEvent, Fragment, useState, VFC } from 'react';
|
import React, { ChangeEvent, Fragment, useState, VFC } from 'react';
|
||||||
import { IAutocompleteBoxOption } from '../../../common/AutocompleteBox/AutocompleteBox';
|
import { IAutocompleteBoxOption } from '../../../common/AutocompleteBox/AutocompleteBox';
|
||||||
import { styles as themeStyles } from 'component/common';
|
|
||||||
import {
|
import {
|
||||||
AutocompleteRenderGroupParams,
|
AutocompleteRenderGroupParams,
|
||||||
AutocompleteRenderInputParams,
|
AutocompleteRenderInputParams,
|
||||||
@ -13,6 +12,7 @@ import {
|
|||||||
Paper,
|
Paper,
|
||||||
TextField,
|
TextField,
|
||||||
Autocomplete,
|
Autocomplete,
|
||||||
|
Typography,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
||||||
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
||||||
@ -33,6 +33,7 @@ export interface IAddonMultiSelectorProps {
|
|||||||
entityName: string;
|
entityName: string;
|
||||||
selectAllEnabled: boolean;
|
selectAllEnabled: boolean;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
required?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ALL_OPTIONS = '*';
|
const ALL_OPTIONS = '*';
|
||||||
@ -52,6 +53,7 @@ export const AddonMultiSelector: VFC<IAddonMultiSelectorProps> = ({
|
|||||||
entityName,
|
entityName,
|
||||||
selectAllEnabled = true,
|
selectAllEnabled = true,
|
||||||
description,
|
description,
|
||||||
|
required,
|
||||||
}) => {
|
}) => {
|
||||||
const [isWildcardSelected, selectWildcard] = useState(
|
const [isWildcardSelected, selectWildcard] = useState(
|
||||||
selectedItems.includes(ALL_OPTIONS)
|
selectedItems.includes(ALL_OPTIONS)
|
||||||
@ -144,7 +146,14 @@ export const AddonMultiSelector: VFC<IAddonMultiSelectorProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<StyledTitle>{capitalize(entityName)}s</StyledTitle>
|
<StyledTitle>
|
||||||
|
{capitalize(entityName)}s
|
||||||
|
{required ? (
|
||||||
|
<Typography component="span" color="error">
|
||||||
|
*
|
||||||
|
</Typography>
|
||||||
|
) : null}
|
||||||
|
</StyledTitle>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={description !== undefined}
|
condition={description !== undefined}
|
||||||
show={<StyledHelpText>{description}</StyledHelpText>}
|
show={<StyledHelpText>{description}</StyledHelpText>}
|
||||||
@ -153,7 +162,6 @@ export const AddonMultiSelector: VFC<IAddonMultiSelectorProps> = ({
|
|||||||
condition={selectAllEnabled}
|
condition={selectAllEnabled}
|
||||||
show={<DefaultHelpText />}
|
show={<DefaultHelpText />}
|
||||||
/>
|
/>
|
||||||
<span className={themeStyles.error}>{error}</span>
|
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={selectAllEnabled}
|
condition={selectAllEnabled}
|
||||||
show={<SelectAllFormControl />}
|
show={<SelectAllFormControl />}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { TextField } from '@mui/material';
|
import { TextField, Typography } 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';
|
import { StyledAddonParameterContainer } from '../../AddonForm.styles';
|
||||||
@ -40,7 +40,16 @@ export const AddonParameter = ({
|
|||||||
minRows={definition.type === 'textfield' ? 9 : 0}
|
minRows={definition.type === 'textfield' ? 9 : 0}
|
||||||
multiline={definition.type === 'textfield'}
|
multiline={definition.type === 'textfield'}
|
||||||
type={type}
|
type={type}
|
||||||
label={definition.displayName}
|
label={
|
||||||
|
<>
|
||||||
|
{definition.displayName}
|
||||||
|
{definition.required ? (
|
||||||
|
<Typography component="span" color="error">
|
||||||
|
*
|
||||||
|
</Typography>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
}
|
||||||
name={definition.name}
|
name={definition.name}
|
||||||
placeholder={definition.placeholder || ''}
|
placeholder={definition.placeholder || ''}
|
||||||
InputLabelProps={{
|
InputLabelProps={{
|
||||||
|
@ -33,9 +33,9 @@ const dataDogDefinition: IAddonDefinition = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'apiKey',
|
name: 'apiKey',
|
||||||
displayName: 'DD API KEY',
|
displayName: 'Datadog API key',
|
||||||
placeholder: 'j96c23b0f12a6b3434a8d710110bd862',
|
placeholder: 'j96c23b0f12a6b3434a8d710110bd862',
|
||||||
description: 'Api key from datadog',
|
description: '(Required) API key from Datadog',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
required: true,
|
required: true,
|
||||||
sensitive: true,
|
sensitive: true,
|
||||||
|
@ -25,6 +25,7 @@ const slackDefinition: IAddonDefinition = {
|
|||||||
{
|
{
|
||||||
name: 'url',
|
name: 'url',
|
||||||
displayName: 'Slack webhook URL',
|
displayName: 'Slack webhook URL',
|
||||||
|
description: '(Required)',
|
||||||
type: 'url',
|
type: 'url',
|
||||||
required: true,
|
required: true,
|
||||||
sensitive: true,
|
sensitive: true,
|
||||||
@ -53,7 +54,7 @@ const slackDefinition: IAddonDefinition = {
|
|||||||
name: 'defaultChannel',
|
name: 'defaultChannel',
|
||||||
displayName: 'Default channel',
|
displayName: 'Default channel',
|
||||||
description:
|
description:
|
||||||
'Default channel to post updates to if not specified in the slack-tag',
|
'(Required) Default channel to post updates to if not specified in the slack-tag',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
required: true,
|
required: true,
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
|
@ -25,6 +25,7 @@ const teamsDefinition: IAddonDefinition = {
|
|||||||
{
|
{
|
||||||
name: 'url',
|
name: 'url',
|
||||||
displayName: 'Microsoft Teams webhook URL',
|
displayName: 'Microsoft Teams webhook URL',
|
||||||
|
description: '(Required)',
|
||||||
type: 'url',
|
type: 'url',
|
||||||
required: true,
|
required: true,
|
||||||
sensitive: true,
|
sensitive: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user