mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* put back savedObjectId in error message * fix type error
This commit is contained in:
parent
abcb93e6a2
commit
bd2fa77f8d
2 changed files with 22 additions and 2 deletions
|
@ -23,6 +23,8 @@ import React, { useCallback, useState } from 'react';
|
|||
import {
|
||||
ImportDataResponse,
|
||||
ImportDataProps,
|
||||
ImportRulesResponseError,
|
||||
ImportResponseError,
|
||||
} from '../../../detections/containers/detection_engine/rules';
|
||||
import {
|
||||
displayErrorToast,
|
||||
|
@ -48,6 +50,12 @@ interface ImportDataModalProps {
|
|||
title: string;
|
||||
}
|
||||
|
||||
const isImportRulesResponseError = (
|
||||
error: ImportRulesResponseError | ImportResponseError
|
||||
): error is ImportRulesResponseError => {
|
||||
return (error as ImportRulesResponseError).rule_id !== undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Modal component for importing Rules from a json file
|
||||
*/
|
||||
|
@ -96,7 +104,11 @@ export const ImportDataModalComponent = ({
|
|||
}
|
||||
if (importResponse.errors.length > 0) {
|
||||
const formattedErrors = importResponse.errors.map((e) =>
|
||||
failedDetailed(e.rule_id, e.error.status_code, e.error.message)
|
||||
failedDetailed(
|
||||
isImportRulesResponseError(e) ? e.rule_id : e.id,
|
||||
e.error.status_code,
|
||||
e.error.message
|
||||
)
|
||||
);
|
||||
displayErrorToast(errorMessage, formattedErrors, dispatchToaster);
|
||||
}
|
||||
|
|
|
@ -234,10 +234,18 @@ export interface ImportRulesResponseError {
|
|||
};
|
||||
}
|
||||
|
||||
export interface ImportResponseError {
|
||||
id: string;
|
||||
error: {
|
||||
status_code: number;
|
||||
message: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ImportDataResponse {
|
||||
success: boolean;
|
||||
success_count: number;
|
||||
errors: ImportRulesResponseError[];
|
||||
errors: Array<ImportRulesResponseError | ImportResponseError>;
|
||||
}
|
||||
|
||||
export interface ExportDocumentsProps {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue