Skip to content

Commit

Permalink
Merge branch 'master' into pr/83808
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Mar 24, 2021
2 parents 370c5db + 2da269f commit 815edf0
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React, { useState } from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { DiscoverGrid, DiscoverGridProps } from './discover_grid/discover_grid';
Expand Down Expand Up @@ -38,6 +37,7 @@ export function createDiscoverGridDirective(reactDirective: any) {
return reactDirective(DiscoverGridEmbeddable, [
['columns', { watchDepth: 'collection' }],
['indexPattern', { watchDepth: 'reference' }],
['isLoading', { watchDepth: 'reference' }],
['onAddColumn', { watchDepth: 'reference', wrapApply: false }],
['onFilter', { watchDepth: 'reference', wrapApply: false }],
['onRemoveColumn', { watchDepth: 'reference', wrapApply: false }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function getProps(indexPattern: IndexPattern): DiscoverProps {
fetch: jest.fn(),
fetchCounter: 0,
fetchError: undefined,
fetchStatus: 'loading',
fieldCounts: calcFieldCounts({}, esHits, indexPattern),
hits: esHits.length,
indexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function Discover({
fetchCounter,
fetchError,
fieldCounts,
fetchStatus,
histogramData,
hits,
indexPattern,
Expand Down Expand Up @@ -393,6 +394,7 @@ export function Discover({
columns={columns}
expandedDoc={expandedDoc}
indexPattern={indexPattern}
isLoading={fetchStatus === 'loading'}
rows={rows}
sort={(state.sort as SortPairArr[]) || []}
sampleSize={opts.sampleSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export interface DiscoverGridProps {
* The used index pattern
*/
indexPattern: IndexPattern;
/**
* Determines if data is currently loaded
*/
isLoading: boolean;
/**
* Function used to add a column in the document flyout
*/
Expand Down Expand Up @@ -135,6 +139,7 @@ export const DiscoverGrid = ({
ariaLabelledBy,
columns,
indexPattern,
isLoading,
expandedDoc,
onAddColumn,
onFilter,
Expand Down Expand Up @@ -258,7 +263,13 @@ export const DiscoverGrid = ({
isDarkMode: services.uiSettings.get('theme:darkMode'),
}}
>
<>
<span
data-test-subj="discoverDocTable"
data-render-complete={isLoading ? 'false' : 'true'}
data-shared-item=""
data-title={searchTitle}
data-description={searchDescription}
>
<KibanaContextProvider services={{ uiSettings: services.uiSettings }}>
<EuiDataGridMemoized
aria-describedby={randomId}
Expand Down Expand Up @@ -335,7 +346,7 @@ export const DiscoverGrid = ({
services={services}
/>
)}
</>
</span>
</DiscoverGridContext.Provider>
);
};
4 changes: 4 additions & 0 deletions src/plugins/discover/public/application/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export interface DiscoverProps {
* Statistics by fields calculated using the fetched documents
*/
fieldCounts: Record<string, number>;
/**
* Current state of data fetching
*/
fetchStatus: string;
/**
* Histogram aggregation data
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class SearchEmbeddable
throw new Error('Search scope not defined');
}
this.searchInstance = this.$compile(
this.services.uiSettings.get('doc_table:legacy', true) ? searchTemplate : searchTemplateGrid
this.services.uiSettings.get('doc_table:legacy') ? searchTemplate : searchTemplateGrid
)(this.searchScope);
const rootNode = angular.element(domNode);
rootNode.append(this.searchInstance);
Expand Down Expand Up @@ -226,6 +226,8 @@ export class SearchEmbeddable
this.updateInput({ sort });
};

searchScope.isLoading = true;

const useNewFieldsApi = !getServices().uiSettings.get(SEARCH_FIELDS_FROM_SOURCE, false);
searchScope.useNewFieldsApi = useNewFieldsApi;

Expand Down Expand Up @@ -336,6 +338,9 @@ export class SearchEmbeddable
searchSource.getSearchRequestBody().then((body: Record<string, unknown>) => {
inspectorRequest.json(body);
});
this.searchScope.$apply(() => {
this.searchScope!.isLoading = true;
});
this.updateOutput({ loading: true, error: undefined });

try {
Expand All @@ -353,9 +358,13 @@ export class SearchEmbeddable
this.searchScope.$apply(() => {
this.searchScope!.hits = resp.hits.hits;
this.searchScope!.totalHitCount = resp.hits.total as number;
this.searchScope!.isLoading = false;
});
} catch (error) {
this.updateOutput({ loading: false, error });
this.searchScope.$apply(() => {
this.searchScope!.isLoading = false;
});
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<discover-grid
class="dscDiscoverGrid"
columns="columns"
data-description="{{description}}"
data-shared-item
data-title="{{sharedItemTitle}}"
search-description="description"
search-title="sharedItemTitle"
data-test-subj="embeddedSavedSearchDocTable"
index-pattern="indexPattern"
is-loading="isLoading"
on-add-column="addColumn"
on-filter="filter"
on-remove-column="removeColumn"
on-set-columns="setColumns"
on-sort="setSortOrder"
render-complete
rows="hits"
sample-size="500"
settings="settings"
Expand Down
19 changes: 19 additions & 0 deletions x-pack/test/functional/apps/dashboard/reporting/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const config = getService('config');
const es = getService('es');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');

describe('Dashboard Reporting Screenshots', () => {
before('initialize tests', async () => {
Expand Down Expand Up @@ -150,6 +151,24 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(res.status).to.equal(200);
expect(res.get('content-type')).to.equal('application/pdf');
});

it('downloads a PDF file with saved search given EuiDataGrid enabled', async function () {
await kibanaServer.uiSettings.replace({ 'doc_table:legacy': false });
// Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs
// function is taking about 15 seconds per comparison in jenkins.
this.timeout(300000);
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard');
await PageObjects.reporting.openPdfReportingPanel();
await PageObjects.reporting.clickGenerateReportButton();

const url = await PageObjects.reporting.getReportURL(60000);
const res = await PageObjects.reporting.getResponse(url);

expect(res.status).to.equal(200);
expect(res.get('content-type')).to.equal('application/pdf');
await kibanaServer.uiSettings.replace({});
});
});
});
}

0 comments on commit 815edf0

Please sign in to comment.