Skip to content

Commit 8641cf0

Browse files
Merge branch 'master' into use-faster-wait
2 parents 52e38d1 + 3ccdd79 commit 8641cf0

File tree

18 files changed

+106
-72
lines changed

18 files changed

+106
-72
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"@elastic/apm-rum": "^5.2.0",
126126
"@elastic/charts": "19.8.1",
127127
"@elastic/datemath": "5.0.3",
128-
"@elastic/elasticsearch": "7.9.0-rc.1",
128+
"@elastic/elasticsearch": "7.9.0-rc.2",
129129
"@elastic/ems-client": "7.9.3",
130130
"@elastic/eui": "26.3.1",
131131
"@elastic/filesaver": "1.1.2",

x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/setup_environment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const setupEnvironment = () => {
2929
);
3030

3131
mockHttpClient.interceptors.response.use(({ data }) => data);
32+
// This expects HttpSetup but we're giving it AxiosInstance.
33+
// @ts-ignore
3234
initHttp(mockHttpClient);
3335
const { server, httpRequestsMockHelpers } = initHttpRequests();
3436

x-pack/plugins/index_lifecycle_management/public/application/services/api.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import { METRIC_TYPE } from '@kbn/analytics';
8-
import { trackUiMetric } from './ui_metric';
98

109
import {
1110
UIM_POLICY_DELETE,
@@ -15,8 +14,13 @@ import {
1514
UIM_INDEX_RETRY_STEP,
1615
} from '../constants';
1716

17+
import { trackUiMetric } from './ui_metric';
1818
import { sendGet, sendPost, sendDelete, useRequest } from './http';
1919

20+
interface GenericObject {
21+
[key: string]: any;
22+
}
23+
2024
export async function loadNodes() {
2125
return await sendGet(`nodes/list`);
2226
}
@@ -33,7 +37,7 @@ export async function loadPolicies(withIndices: boolean) {
3337
return await sendGet('policies', { withIndices });
3438
}
3539

36-
export async function savePolicy(policy: any) {
40+
export async function savePolicy(policy: GenericObject) {
3741
return await sendPost(`policies`, policy);
3842
}
3943

@@ -58,14 +62,14 @@ export const removeLifecycleForIndex = async (indexNames: string[]) => {
5862
return response;
5963
};
6064

61-
export const addLifecyclePolicyToIndex = async (body: any) => {
65+
export const addLifecyclePolicyToIndex = async (body: GenericObject) => {
6266
const response = await sendPost(`index/add`, body);
6367
// Only track successful actions.
6468
trackUiMetric(METRIC_TYPE.COUNT, UIM_POLICY_ATTACH_INDEX);
6569
return response;
6670
};
6771

68-
export const addLifecyclePolicyToTemplate = async (body: any) => {
72+
export const addLifecyclePolicyToTemplate = async (body: GenericObject) => {
6973
const response = await sendPost(`template`, body);
7074
// Only track successful actions.
7175
trackUiMetric(METRIC_TYPE.COUNT, UIM_POLICY_ATTACH_INDEX_TEMPLATE);

x-pack/plugins/index_lifecycle_management/public/application/services/api_errors.js renamed to x-pack/plugins/index_lifecycle_management/public/application/services/api_errors.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { IHttpFetchError } from 'src/core/public';
78
import { fatalErrors, toasts } from './notification';
89

9-
function createToastConfig(error, errorTitle) {
10+
function createToastConfig(error: IHttpFetchError, errorTitle: string) {
1011
if (error && error.body) {
12+
// Error body shape is defined by the API.
1113
const { error: errorString, statusCode, message } = error.body;
1214

1315
return {
@@ -17,7 +19,7 @@ function createToastConfig(error, errorTitle) {
1719
}
1820
}
1921

20-
export function showApiWarning(error, errorTitle) {
22+
export function showApiWarning(error: IHttpFetchError, errorTitle: string) {
2123
const toastConfig = createToastConfig(error, errorTitle);
2224

2325
if (toastConfig) {
@@ -26,10 +28,10 @@ export function showApiWarning(error, errorTitle) {
2628

2729
// This error isn't an HTTP error, so let the fatal error screen tell the user something
2830
// unexpected happened.
29-
return fatalErrors(error, errorTitle);
31+
return fatalErrors.add(error, errorTitle);
3032
}
3133

32-
export function showApiError(error, errorTitle) {
34+
export function showApiError(error: IHttpFetchError, errorTitle: string) {
3335
const toastConfig = createToastConfig(error, errorTitle);
3436

3537
if (toastConfig) {

x-pack/plugins/index_lifecycle_management/public/application/services/http.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { HttpSetup } from 'src/core/public';
78
import {
89
UseRequestConfig,
910
useRequest as _useRequest,
1011
Error,
1112
} from '../../../../../../src/plugins/es_ui_shared/public';
1213

13-
let _httpClient: any;
14+
interface GenericObject {
15+
[key: string]: any;
16+
}
17+
18+
let _httpClient: HttpSetup;
1419

15-
export function init(httpClient: any): void {
20+
export function init(httpClient: HttpSetup): void {
1621
_httpClient = httpClient;
1722
}
1823

@@ -26,15 +31,15 @@ function getFullPath(path: string): string {
2631
return apiPrefix;
2732
}
2833

29-
export function sendPost(path: string, payload: any): any {
34+
export function sendPost(path: string, payload: GenericObject) {
3035
return _httpClient.post(getFullPath(path), { body: JSON.stringify(payload) });
3136
}
3237

33-
export function sendGet(path: string, query?: any): any {
38+
export function sendGet(path: string, query?: GenericObject): any {
3439
return _httpClient.get(getFullPath(path), { query });
3540
}
3641

37-
export function sendDelete(path: string): any {
42+
export function sendDelete(path: string) {
3843
return _httpClient.delete(getFullPath(path));
3944
}
4045

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ import { removeLifecycleForIndex } from '../../application/services/api';
1313
import { showApiError } from '../../application/services/api_errors';
1414
import { toasts } from '../../application/services/notification';
1515

16-
export class RemoveLifecyclePolicyConfirmModal extends Component {
17-
constructor(props) {
18-
super(props);
19-
this.state = {
20-
policies: [],
21-
selectedPolicyName: null,
22-
selectedAlias: null,
23-
};
24-
}
16+
interface Props {
17+
indexNames: string[];
18+
closeModal: () => void;
19+
reloadIndices: () => void;
20+
}
2521

22+
export class RemoveLifecyclePolicyConfirmModal extends Component<Props> {
2623
removePolicy = async () => {
2724
const { indexNames, closeModal, reloadIndices } = this.props;
2825

x-pack/plugins/infra/public/alerting/common/components/alert_preview.tsx

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ import {
1414
EuiFlexGroup,
1515
EuiFlexItem,
1616
EuiCallOut,
17-
EuiOverlayMask,
18-
EuiModal,
19-
EuiModalHeader,
20-
EuiModalHeaderTitle,
21-
EuiModalBody,
17+
EuiAccordion,
2218
EuiCodeBlock,
23-
EuiLink,
19+
EuiText,
2420
} from '@elastic/eui';
2521
import { FormattedMessage } from '@kbn/i18n/react';
2622
import { i18n } from '@kbn/i18n';
@@ -61,9 +57,6 @@ export const AlertPreview: React.FC<Props> = (props) => {
6157
const [previewResult, setPreviewResult] = useState<
6258
(AlertPreviewSuccessResponsePayload & Record<string, any>) | null
6359
>(null);
64-
const [isErrorModalVisible, setIsErrorModalVisible] = useState<boolean>(false);
65-
const onOpenModal = useCallback(() => setIsErrorModalVisible(true), [setIsErrorModalVisible]);
66-
const onCloseModal = useCallback(() => setIsErrorModalVisible(false), [setIsErrorModalVisible]);
6760

6861
const onSelectPreviewLookbackInterval = useCallback((e) => {
6962
setPreviewLookbackInterval(e.target.value);
@@ -271,33 +264,32 @@ export const AlertPreview: React.FC<Props> = (props) => {
271264
iconType="alert"
272265
>
273266
{previewError.body && (
274-
<FormattedMessage
275-
id="xpack.infra.metrics.alertFlyout.alertPreviewErrorDesc"
276-
defaultMessage="Try again later, or {viewTheError}."
277-
values={{
278-
viewTheError: <EuiLink onClick={onOpenModal}>view the error</EuiLink>,
279-
}}
280-
/>
267+
<>
268+
<FormattedMessage
269+
id="xpack.infra.metrics.alertFlyout.alertPreviewErrorDesc"
270+
defaultMessage="Please try again later or see details for more information."
271+
/>
272+
<EuiSpacer size={'s'} />
273+
<EuiAccordion
274+
id="alertErrorDetailsAccordion"
275+
buttonContent={
276+
<>
277+
<EuiText size="s">
278+
<FormattedMessage
279+
id="xpack.infra.metrics.alertFlyout.errorDetails"
280+
defaultMessage="Details"
281+
/>
282+
</EuiText>
283+
</>
284+
}
285+
>
286+
<EuiSpacer size={'s'} />
287+
<EuiCodeBlock>{previewError.body.message}</EuiCodeBlock>
288+
</EuiAccordion>
289+
</>
281290
)}
282291
</EuiCallOut>
283292
)}
284-
{isErrorModalVisible && (
285-
<EuiOverlayMask>
286-
<EuiModal onClose={onCloseModal}>
287-
<EuiModalHeader>
288-
<EuiModalHeaderTitle>
289-
<FormattedMessage
290-
id="xpack.infra.metrics.alertFlyout.alertPreviewErrorModalTitle"
291-
defaultMessage="Alert preview error"
292-
/>
293-
</EuiModalHeaderTitle>
294-
</EuiModalHeader>
295-
<EuiModalBody>
296-
<EuiCodeBlock>{previewError.body.message}</EuiCodeBlock>
297-
</EuiModalBody>
298-
</EuiModal>
299-
</EuiOverlayMask>
300-
)}
301293
</>
302294
)}
303295
</>

x-pack/plugins/rollup/public/crud_app/services/api_errors.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { IHttpFetchError } from 'src/core/public';
78
import { getNotifications, getFatalErrors } from '../../kibana_services';
89

9-
function createToastConfig(error: any, errorTitle: string) {
10-
// Expect an error in the shape provided by http service.
10+
function createToastConfig(error: IHttpFetchError, errorTitle: string) {
1111
if (error && error.body) {
12+
// Error body shape is defined by the API.
1213
const { error: errorString, statusCode, message } = error.body;
14+
1315
return {
1416
title: errorTitle,
1517
text: `${statusCode}: ${errorString}. ${message}`,
1618
};
1719
}
1820
}
1921

20-
export function showApiWarning(error: any, errorTitle: string) {
22+
export function showApiWarning(error: IHttpFetchError, errorTitle: string) {
2123
const toastConfig = createToastConfig(error, errorTitle);
2224

2325
if (toastConfig) {
@@ -29,7 +31,7 @@ export function showApiWarning(error: any, errorTitle: string) {
2931
return getFatalErrors().add(error, errorTitle);
3032
}
3133

32-
export function showApiError(error: any, errorTitle: string) {
34+
export function showApiError(error: IHttpFetchError, errorTitle: string) {
3335
const toastConfig = createToastConfig(error, errorTitle);
3436

3537
if (toastConfig) {

x-pack/plugins/security_solution/common/endpoint/index_data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ async function indexAlerts(
9494
},
9595
[]
9696
);
97-
await client.bulk({ body, refresh: 'true' });
97+
await client.bulk({ body, refresh: true });
9898
}
9999
}

x-pack/test/api_integration/apis/fleet/agents/acks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function (providerContext: FtrProviderContext) {
3838
await esClient.update({
3939
index: '.kibana',
4040
id: 'fleet-agents:agent1',
41-
refresh: 'true',
41+
refresh: true,
4242
body: {
4343
doc: agentDoc,
4444
},

0 commit comments

Comments
 (0)