diff --git a/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx b/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx index 8ce02076d4d0a9..d294ffca863414 100644 --- a/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx +++ b/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { @@ -86,7 +86,11 @@ export function ActionBar({ onChangeCount(newDocCount); } }; - + useEffect(() => { + if (newDocCount !== docCount && newDocCount === 0) { + setNewDocCount(docCount); + } + }, [docCount, newDocCount]); return (
diff --git a/src/plugins/discover/public/application/angular/context_app.html b/src/plugins/discover/public/application/angular/context_app.html index ef7bc092061766..d20b1ca999af92 100644 --- a/src/plugins/discover/public/application/angular/context_app.html +++ b/src/plugins/discover/public/application/angular/context_app.html @@ -10,33 +10,23 @@ > - - + - - -
- - -
+ reason="contextApp.state.loadingStatus.anchor.reason" + default-step-size="contextApp.state.queryParameters.defaultStepSize" + predecessor-count="contextApp.state.queryParameters.predecessorCount" + predecessor-available="contextApp.state.rows.predecessors.length" + predecessor-status="contextApp.state.loadingStatus.predecessors.status" + on-change-predecessor-count="contextApp.actions.fetchGivenPredecessorRows" + successor-count="contextApp.state.queryParameters.successorCount" + successor-available="contextApp.state.rows.successors.length" + successor-status="contextApp.state.loadingStatus.successors.status" + on-change-successor-count="contextApp.actions.fetchGivenSuccessorRows" +> diff --git a/src/plugins/discover/public/application/components/context_app/context_app_legacy.scss b/src/plugins/discover/public/application/components/context_app/context_app_legacy.scss new file mode 100644 index 00000000000000..87194d834827b2 --- /dev/null +++ b/src/plugins/discover/public/application/components/context_app/context_app_legacy.scss @@ -0,0 +1,5 @@ +.dscCxtAppContent { + border: none; + background-color: transparent; + box-shadow: none; +} diff --git a/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx b/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx index 25576a90729447..77dd0a6d647c68 100644 --- a/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx +++ b/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx @@ -24,6 +24,7 @@ import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { DocTableLegacy } from '../../angular/doc_table/create_doc_table_react'; import { findTestSubject } from '@elastic/eui/lib/test'; import { ActionBar } from '../../angular/context/components/action_bar/action_bar'; +import { ContextErrorMessage } from '../context_error_message'; describe('ContextAppLegacy test', () => { const hit = { @@ -53,6 +54,7 @@ describe('ContextAppLegacy test', () => { minimumVisibleRows: 5, indexPattern, status: 'loaded', + reason: 'no reason', defaultStepSize: 5, predecessorCount: 10, successorCount: 10, @@ -76,9 +78,19 @@ describe('ContextAppLegacy test', () => { const props = { ...defaultProps }; props.status = 'loading'; const component = mountWithIntl(); - expect(component.find('DocTableLegacy').length).toBe(0); + expect(component.find(DocTableLegacy).length).toBe(0); const loadingIndicator = findTestSubject(component, 'contextApp_loadingIndicator'); expect(loadingIndicator.length).toBe(1); expect(component.find(ActionBar).length).toBe(2); }); + + it('renders error message', () => { + const props = { ...defaultProps }; + props.status = 'failed'; + props.reason = 'something went wrong'; + const component = mountWithIntl(); + expect(component.find(DocTableLegacy).length).toBe(0); + const errorMessage = component.find(ContextErrorMessage); + expect(errorMessage.length).toBe(1); + }); }); diff --git a/src/plugins/discover/public/application/components/context_app/context_app_legacy.tsx b/src/plugins/discover/public/application/components/context_app/context_app_legacy.tsx index afb4a9a981e214..b5387ec51db81b 100644 --- a/src/plugins/discover/public/application/components/context_app/context_app_legacy.tsx +++ b/src/plugins/discover/public/application/components/context_app/context_app_legacy.tsx @@ -16,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +import './context_app_legacy.scss'; import React from 'react'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { EuiPanel, EuiText } from '@elastic/eui'; +import { EuiPanel, EuiText, EuiPageContent, EuiPage } from '@elastic/eui'; +import { ContextErrorMessage } from '../context_error_message'; import { DocTableLegacy, DocTableLegacyProps, @@ -35,6 +37,7 @@ export interface ContextAppProps { minimumVisibleRows: number; sorting: string[]; status: string; + reason: string; defaultStepSize: number; predecessorCount: number; successorCount: number; @@ -56,6 +59,7 @@ function isLoading(status: string) { export function ContextAppLegacy(renderProps: ContextAppProps) { const status = renderProps.status; const isLoaded = status === LOADING_STATUS.LOADED; + const isFailed = status === LOADING_STATUS.FAILED; const actionBarProps = (type: string) => { const { @@ -111,18 +115,24 @@ export function ContextAppLegacy(renderProps: ContextAppProps) { return ( - - - {loadingFeedback()} - {isLoaded ? ( - -
- -
-
- ) : null} - -
+ {isFailed ? ( + + ) : ( + + + + {loadingFeedback()} + {isLoaded ? ( + +
+ +
+
+ ) : null} + +
+
+ )}
); } diff --git a/src/plugins/discover/public/application/components/context_app/context_app_legacy_directive.ts b/src/plugins/discover/public/application/components/context_app/context_app_legacy_directive.ts index 4a315be513a0dc..bc4b7c4babd21e 100644 --- a/src/plugins/discover/public/application/components/context_app/context_app_legacy_directive.ts +++ b/src/plugins/discover/public/application/components/context_app/context_app_legacy_directive.ts @@ -27,6 +27,7 @@ export function createContextAppLegacy(reactDirective: any) { ['columns', { watchDepth: 'collection' }], ['minimumVisibleRows', { watchDepth: 'reference' }], ['status', { watchDepth: 'reference' }], + ['reason', { watchDepth: 'reference' }], ['defaultStepSize', { watchDepth: 'reference' }], ['predecessorCount', { watchDepth: 'reference' }], ['predecessorAvailable', { watchDepth: 'reference' }], diff --git a/src/plugins/discover/public/application/components/context_error_message/context_error_message_directive.ts b/src/plugins/discover/public/application/components/context_error_message/context_error_message_directive.ts deleted file mode 100644 index 925d560761a84c..00000000000000 --- a/src/plugins/discover/public/application/components/context_error_message/context_error_message_directive.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 { ContextErrorMessage } from './context_error_message'; - -export function createContextErrorMessageDirective(reactDirective: any) { - return reactDirective(ContextErrorMessage, [ - ['status', { watchDepth: 'reference' }], - ['reason', { watchDepth: 'reference' }], - ]); -} diff --git a/src/plugins/discover/public/application/components/context_error_message/index.ts b/src/plugins/discover/public/application/components/context_error_message/index.ts index f20f2ccf8afa0a..dfa9602408f8f2 100644 --- a/src/plugins/discover/public/application/components/context_error_message/index.ts +++ b/src/plugins/discover/public/application/components/context_error_message/index.ts @@ -18,4 +18,3 @@ */ export { ContextErrorMessage } from './context_error_message'; -export { createContextErrorMessageDirective } from './context_error_message_directive'; diff --git a/src/plugins/discover/public/get_inner_angular.ts b/src/plugins/discover/public/get_inner_angular.ts index 55a75240909bf5..651a26cad755db 100644 --- a/src/plugins/discover/public/get_inner_angular.ts +++ b/src/plugins/discover/public/get_inner_angular.ts @@ -52,7 +52,6 @@ import { createTopNavDirective, createTopNavHelper, } from '../../kibana_legacy/public'; -import { createContextErrorMessageDirective } from './application/components/context_error_message'; import { DiscoverStartPlugins } from './plugin'; import { getScopedHistory } from './kibana_services'; import { createDiscoverLegacyDirective } from './application/components/create_discover_legacy_directive'; @@ -137,8 +136,7 @@ export function initializeInnerAngularModule( .config(watchMultiDecorator) .run(registerListenEventListener) .directive('renderComplete', createRenderCompleteDirective) - .directive('discoverLegacy', createDiscoverLegacyDirective) - .directive('contextErrorMessage', createContextErrorMessageDirective); + .directive('discoverLegacy', createDiscoverLegacyDirective); } function createLocalPromiseModule() {