Skip to content

Commit

Permalink
Create connector modal won't change
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Mar 6, 2020
1 parent 81733f7 commit 06019dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ interface ActionConnectorProps {
connector: ActionConnector;
dispatch: React.Dispatch<ReducerAction>;
actionTypeName: string;
serverError?: {
body: { message: string; error: string };
};
errors: IErrorObject;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
}
Expand All @@ -50,6 +53,7 @@ export const ActionConnectorForm = ({
connector,
dispatch,
actionTypeName,
serverError,
errors,
actionTypeRegistry,
}: ActionConnectorProps) => {
Expand Down Expand Up @@ -106,7 +110,7 @@ export const ActionConnectorForm = ({
const FieldsComponent = actionTypeRegistered.actionConnectorFields;

return (
<EuiForm>
<EuiForm isInvalid={!!serverError} error={serverError?.body.message}>
<EuiFormRow
id="actionName"
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ export const ConnectorAddModal = ({
const setConnector = (value: any) => {
dispatch({ command: { type: 'setConnector' }, payload: { key: 'connector', value } });
};
const [serverError, setServerError] = useState<{
body: { message: string; error: string };
} | null>(null);

const closeModal = useCallback(() => {
setAddModalVisibility(false);
setConnector(initialConnector);
setServerError(null);
}, [initialConnector, setAddModalVisibility]);

if (!addModalVisible) {
Expand Down Expand Up @@ -93,19 +97,7 @@ export const ConnectorAddModal = ({
return savedConnector;
})
.catch(errorRes => {
if (toastNotifications) {
toastNotifications.addDanger(
i18n.translate(
'xpack.triggersActionsUI.sections.addModalConnectorForm.createErrorNotificationText',
{
defaultMessage: 'Failed to create connector: {message}',
values: {
message: errorRes.body?.message ?? '',
},
}
)
);
}
setServerError(errorRes);
return undefined;
});

Expand Down Expand Up @@ -153,6 +145,7 @@ export const ConnectorAddModal = ({
connector={connector}
actionTypeName={actionType.name}
dispatch={dispatch}
serverError={serverError}
errors={errors}
actionTypeRegistry={actionTypeRegistry}
/>
Expand Down

0 comments on commit 06019dd

Please sign in to comment.