Enable to create/trigger webhooks with no events (#12174)

Co-authored-by: cyril lopez <cyril@strapi.io>
This commit is contained in:
Jean-Sébastien Herbaux 2022-01-12 16:26:06 +01:00 committed by GitHub
parent d8acb3df67
commit ce09d38972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 24 deletions

View File

@ -63,7 +63,7 @@ const EventInput = ({ isDraftAndPublish }) => {
: displayedData.events.default; : displayedData.events.default;
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const { values, errors, handleChange: onChange } = useFormikContext(); const { values, handleChange: onChange } = useFormikContext();
const inputName = 'events'; const inputName = 'events';
const inputValue = values.events; const inputValue = values.events;
@ -100,7 +100,7 @@ const EventInput = ({ isDraftAndPublish }) => {
return ( return (
<Stack size={1}> <Stack size={1}>
<FieldLabel required> <FieldLabel>
{formatMessage({ {formatMessage({
id: 'Settings.webhooks.form.events', id: 'Settings.webhooks.form.events',
defaultMessage: 'Events', defaultMessage: 'Events',
@ -154,14 +154,6 @@ const EventInput = ({ isDraftAndPublish }) => {
})} })}
</tbody> </tbody>
</StyledTable> </StyledTable>
{errors.events && (
<Typography variant="pi" textColor="danger600" data-strapi-field-error>
{formatMessage({
id: 'components.Input.error.validation.required',
defaultMessage: 'This value is required',
})}
</Typography>
)}
</Stack> </Stack>
); );
}; };

View File

@ -29,10 +29,7 @@ const schema = yup.object().shape({
}) })
); );
}), }),
events: yup events: yup.array(),
.array()
.min(1, translatedErrors.min)
.required(translatedErrors.required),
}); });
export default schema; export default schema;

View File

@ -28,16 +28,12 @@ const webhookValidator = yup
) )
.required(); .required();
}), }),
events: yup events: yup.array().of(
.array()
.of(
yup yup
.string() .string()
.oneOf(_.values(webhookUtils.webhookEvents)) .oneOf(_.values(webhookUtils.webhookEvents))
.required() .required()
) ),
.min(1)
.required(),
}) })
.noUnknown(); .noUnknown();