Skip to content

Commit

Permalink
Match the no results found
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Oct 14, 2021
1 parent 75486b7 commit d704232
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CoreStart } from 'kibana/public';
import ReactDOM from 'react-dom';
import React, { Suspense, useCallback, useState } from 'react';
import useObservable from 'react-use/lib/useObservable';
import { EuiEmptyPrompt } from '@elastic/eui';
import { EuiEmptyPrompt, EuiIcon, EuiSpacer, EuiText } from '@elastic/eui';
import { Filter } from '@kbn/es-query';
import { Required } from 'utility-types';
import { FormattedMessage } from '@kbn/i18n/react';
Expand Down Expand Up @@ -79,10 +79,8 @@ export const EmbeddableWrapper = ({
},
[dataVisualizerListState, onOutputChange]
);
const { configs, searchQueryLanguage, searchString, extendedColumns } = useDataVisualizerGridData(
input,
dataVisualizerListState
);
const { configs, searchQueryLanguage, searchString, extendedColumns, loaded } =
useDataVisualizerGridData(input, dataVisualizerListState);
const getItemIdToExpandedRowMap = useCallback(
function (itemIds: string[], items: FieldVisConfig[]): ItemIdToExpandedRowMap {
return itemIds.reduce((m: ItemIdToExpandedRowMap, fieldName: string) => {
Expand All @@ -103,6 +101,34 @@ export const EmbeddableWrapper = ({
[input, searchQueryLanguage, searchString]
);

if (
loaded &&
(configs.length === 0 ||
// FIXME: Configs might have a placeholder document count stats field
// This will be removed in the future
(configs.length === 1 && configs[0].fieldName === undefined))
) {
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
flex: '1 0 100%',
textAlign: 'center',
}}
>
<EuiText size="xs" color="subdued">
<EuiIcon type="visualizeApp" size="m" color="subdued" />
<EuiSpacer size="m" />
<FormattedMessage
id="xpack.dataVisualizer.index.embeddableNoResultsMessage"
defaultMessage="No results found"
/>
</EuiText>
</div>
);
}
return (
<DataVisualizerTable<FieldVisConfig>
items={configs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,5 +582,6 @@ export const useDataVisualizerGridData = (
extendedColumns,
documentCountStats,
metricsStats,
loaded: metricsLoaded && nonMetricsLoaded,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

runTests(farequoteIndexPatternTestData);
runTests(farequoteKQLSearchTestData);
// runTests(farequoteLuceneSearchTestData);
// runTests(farequoteKQLFiltersSearchTestData);
// runTests(farequoteLuceneFiltersSearchTestData);
// runTests(sampleLogTestData);
runTests(farequoteLuceneSearchTestData);
runTests(farequoteKQLFiltersSearchTestData);
runTests(farequoteLuceneFiltersSearchTestData);
runTests(sampleLogTestData);
});

describe('when disabled', function () {
Expand Down

0 comments on commit d704232

Please sign in to comment.