diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts index b586e0593ab6f..b26f935612755 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts @@ -36,11 +36,18 @@ interface Params { signal?: AbortSignal; } -export interface EqlResponseError { - code: EQL_ERROR_CODES; - messages?: string[]; - error?: Error; -} +export type EqlResponseError = + | { + code: + | EQL_ERROR_CODES.INVALID_SYNTAX + | EQL_ERROR_CODES.INVALID_EQL + | EQL_ERROR_CODES.MISSING_DATA_SOURCE; + messages: string[]; + } + | { + code: EQL_ERROR_CODES.FAILED_REQUEST; + error: Error; + }; export interface ValidateEqlResponse { valid: boolean; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/save_with_errors_confirmation/index.tsx b/x-pack/plugins/security_solution/public/common/hooks/use_confirm_validation_errors_modal/confirm_validation_errors_modal.tsx similarity index 59% rename from x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/save_with_errors_confirmation/index.tsx rename to x-pack/plugins/security_solution/public/common/hooks/use_confirm_validation_errors_modal/confirm_validation_errors_modal.tsx index 3f14945bedadc..52ef0465e39aa 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/save_with_errors_confirmation/index.tsx +++ b/x-pack/plugins/security_solution/public/common/hooks/use_confirm_validation_errors_modal/confirm_validation_errors_modal.tsx @@ -5,41 +5,39 @@ * 2.0. */ -import React from 'react'; - +import React, { memo } from 'react'; import { EuiConfirmModal, EuiSpacer, EuiText } from '@elastic/eui'; - import * as i18n from './translations'; -interface SaveWithErrorsModalProps { +interface ConfirmValidationErrorsModalProps { errors: string[]; onCancel: () => void; onConfirm: () => void; } -const SaveWithErrorsModalComponent = ({ +export const ConfirmValidationErrorsModal = memo(function ConfirmValidationErrorsModal({ errors, onCancel, onConfirm, -}: SaveWithErrorsModalProps) => { +}: ConfirmValidationErrorsModalProps): JSX.Element { return ( <> - {i18n.SAVE_WITH_ERRORS_MODAL_MESSAGE(errors.length)} + {i18n.SAVE_WITH_ERRORS_MESSAGE(errors.length)}