Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modal with details to shard error toast #41649

Merged
merged 39 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dd3f5a8
Add details to shard error toast
kertal Jul 22, 2019
89cbbde
Implement failure modal with lots of details
kertal Jul 23, 2019
887447d
Merge remote-tracking branch 'upstream/master' into kertal-pr-shard-e…
kertal Jul 23, 2019
6b6a82b
Rename types file tsx to ts
kertal Jul 24, 2019
52575a0
Convert styles to SCSS
kertal Jul 24, 2019
0b28a3a
Add jest test for rendering modal
kertal Jul 24, 2019
f391153
Update core API change
kertal Jul 24, 2019
377311c
Merge remote-tracking branch 'upstream/master' into kertal-pr-shard-e…
kertal Jul 24, 2019
63b581d
Fix duplicate translation
kertal Jul 24, 2019
6184c1d
Add more jest tests
kertal Jul 24, 2019
2191575
Convert mock json to typescript
kertal Jul 24, 2019
40b1b9b
SCSS adaptions
kertal Jul 25, 2019
42bdbcb
Merge remote-tracking branch 'upstream/master' into kertal-pr-shard-e…
kertal Jul 25, 2019
43c14b3
Fix SCSS !important usage
kertal Jul 25, 2019
03bffa4
Use EuiSpacer to set margin of description header
kertal Jul 25, 2019
9a68a57
Remove unused EuiCodeEditor
kertal Jul 25, 2019
7e4127e
Refactoring for better accessibility
kertal Jul 26, 2019
3d70f70
Add license header to description_header
kertal Jul 26, 2019
90f8556
Add i18n to the component failure msg
kertal Jul 26, 2019
20fbfbd
Remove SCSS hack that will fixed by EUI upgrade
kertal Jul 26, 2019
24061f8
Remove another codeblock SCSS class
kertal Jul 26, 2019
e1d82fe
Remove hard coded width of codeblock
kertal Jul 26, 2019
448dd5a
Set size of button starting the modal to 's'
kertal Jul 26, 2019
d53ce40
Update snapshot
kertal Jul 26, 2019
fe6104d
Add additional Text to Warning Toast
kertal Jul 29, 2019
683df23
Add missing key to header components mapping
kertal Jul 29, 2019
437ed38
Cleanup of ShardFailureModal
kertal Jul 29, 2019
979623d
Cleanup of ShardFailureDescription
kertal Jul 29, 2019
79c80a3
Cleanup of ShardFailureDescriptionHeader
kertal Jul 29, 2019
bbaad1f
Translate table column header
kertal Jul 29, 2019
f8a4036
Convert any types to unknown
kertal Jul 29, 2019
f2f8d5a
Reformat description header
kertal Jul 29, 2019
0f8c0b0
Update snapshot tests
kertal Jul 29, 2019
102d495
IE11 DescriptionList width fix
kertal Jul 29, 2019
ecce5e8
Merge remote-tracking branch 'upstream/master' into kertal-pr-shard-e…
kertal Jul 29, 2019
23e26b0
Remove unused EuiTitle
kertal Jul 29, 2019
ca6b3fb
Improve ShardFailureDescriptionHeader component
kertal Jul 29, 2019
c4b1440
Improving the button starting the modal
kertal Jul 29, 2019
893dfc1
SCSS formatting fix
kertal Jul 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/public/overlays/overlay_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface OverlayStart {
openModal: (
modalChildren: React.ReactNode,
modalProps?: {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
}
Expand Down
1 change: 1 addition & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ export interface OverlayStart {
}) => OverlayRef;
// (undocumented)
openModal: (modalChildren: React.ReactNode, modalProps?: {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
}) => OverlayRef;
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/public/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@import './accessibility/index';
@import './chrome/index';
@import './courier/index';
@import './collapsible_sidebar/index';
@import './directives/index';
@import './error_allow_explicit_index/index';
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/public/courier/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './fetch/components/shard_failure_modal';
43 changes: 35 additions & 8 deletions src/legacy/ui/public/courier/fetch/call_response_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSpacer } from '@elastic/eui';
import { toastNotifications } from '../../notify';
import { RequestFailure } from '../../errors';
import { RequestStatus } from './req_status';
import { SearchError } from '../search_strategy/search_error';
import { i18n } from '@kbn/i18n';
import { ShardFailureOpenModalButton } from './components/shard_failure_open_modal_button';

export function CallResponseHandlersProvider(Promise) {
const ABORTED = RequestStatus.ABORTED;
Expand All @@ -39,16 +41,37 @@ export function CallResponseHandlersProvider(Promise) {
toastNotifications.addWarning({
title: i18n.translate('common.ui.courier.fetch.requestTimedOutNotificationMessage', {
defaultMessage: 'Data might be incomplete because your request timed out',
})
}),
});
}

if (response._shards && response._shards.failed) {
const title = i18n.translate('common.ui.courier.fetch.shardsFailedNotificationMessage', {
defaultMessage: '{shardsFailed} of {shardsTotal} shards failed',
values: {
shardsFailed: response._shards.failed,
shardsTotal: response._shards.total,
},
});
const description = i18n.translate('common.ui.courier.fetch.shardsFailedNotificationDescription', {
defaultMessage: 'The data you are seeing might be incomplete or wrong.',
});

const text = (
<>
{description}
<EuiSpacer size="s"/>
<ShardFailureOpenModalButton
request={searchRequest.fetchParams.body}
response={response}
title={title}
/>
</>
);

toastNotifications.addWarning({
title: i18n.translate('common.ui.courier.fetch.shardsFailedNotificationMessage', {
defaultMessage: '{shardsFailed} of {shardsTotal} shards failed',
values: { shardsFailed: response._shards.failed, shardsTotal: response._shards.total }
})
title,
text,
});
}

Expand All @@ -65,7 +88,11 @@ export function CallResponseHandlersProvider(Promise) {
if (searchRequest.filterError(response)) {
return progress();
} else {
return searchRequest.handleFailure(response.error instanceof SearchError ? response.error : new RequestFailure(null, response));
return searchRequest.handleFailure(
response.error instanceof SearchError
? response.error
: new RequestFailure(null, response)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { Request } from '../shard_failure_types';
export const shardFailureRequest = {
version: true,
size: 500,
sort: [],
_source: {
excludes: [],
},
stored_fields: ['*'],
script_fields: {},
docvalue_fields: [],
query: {},
highlight: {},
} as Request;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { ResponseWithShardFailure } from '../shard_failure_types';

export const shardFailureResponse = {
_shards: {
total: 2,
successful: 1,
skipped: 0,
failed: 1,
failures: [
{
shard: 0,
index: 'repro2',
node: 'itsmeyournode',
reason: {
type: 'script_exception',
reason: 'runtime error',
script_stack: ["return doc['targetfield'].value;", ' ^---- HERE'],
script: "return doc['targetfield'].value;",
lang: 'painless',
caused_by: {
type: 'illegal_argument_exception',
reason: 'Gimme reason',
},
},
},
],
},
} as ResponseWithShardFailure;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading