Skip to content

Commit

Permalink
[App Search] Refactor empty engine polling to EngineLogic (elastic#10…
Browse files Browse the repository at this point in the history
…3041)

* Set up isEngineEmpty and isEngineSchemaEmpty selectors

+ update selector tests with mock engines to just an `engine` var (I saw Jason do this down below for `searchKey` and liked it, so I copied it)
+ update Documents & Search UI pages to new selectors

* Update EngineOverview to use isEngineEmpty + remove polling

- Per Casey, polling is primarily only needed to dynamically update from empty state to non-empty state, which we're going to handle at the engine level in the next commit

* Add empty engine polling behavior

- Now that both Engines Overview, Documents, and Search UI views have empty states that are hooked up to EngineLogic, this poll will update all of the above pages automatically when a new document comes in!

* [Misc UI polish] Add (+) icon to Index documents button

- to match other create page header buttons

* [PR feedback] Test improvements

Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
  • Loading branch information
3 people committed Jun 24, 2021
1 parent 3dc053f commit a66653a
Show file tree
Hide file tree
Showing 15 changed files with 379 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DocumentCreationButton: React.FC = () => {
<>
<EuiButton
fill
color="primary"
iconType="plusInCircle"
data-test-subj="IndexDocumentsButton"
onClick={showCreationModes}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { Documents } from '.';
describe('Documents', () => {
const values = {
isMetaEngine: false,
engine: { document_count: 1 },
myRole: { canManageEngineDocuments: true },
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { DOCUMENTS_TITLE } from './constants';
import { SearchExperience } from './search_experience';

export const Documents: React.FC = () => {
const { isMetaEngine, engine } = useValues(EngineLogic);
const { isMetaEngine, isEngineEmpty } = useValues(EngineLogic);
const { myRole } = useValues(AppLogic);

return (
Expand All @@ -32,7 +32,7 @@ export const Documents: React.FC = () => {
rightSideItems:
myRole.canManageEngineDocuments && !isMetaEngine ? [<DocumentCreationButton />] : [],
}}
isEmptyState={!engine.document_count}
isEmptyState={isEngineEmpty}
emptyState={<EmptyState />}
>
{isMetaEngine && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';

export const POLLING_DURATION = 5000;

export const POLLING_ERROR_TITLE = i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.pollingErrorMessage',
{ defaultMessage: 'Could not fetch engine data' }
);

export const POLLING_ERROR_TEXT = i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.pollingErrorDescription',
{ defaultMessage: 'Please check your connection or manually reload the page.' }
);
Loading

0 comments on commit a66653a

Please sign in to comment.