mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[SLO][Embeddable] Fix Kibana reporting screenshot issue (#169929)
Resolves https://github.com/elastic/kibana/issues/169716
## 🍒 Summary
The reporting plugin waits for a renderComplete signal when the
embeddable has finished loading any data and is correctly rendered so
the headless Chromium can take a screenshot. This PR calls the
RenderCompleteDispatcher on the SLO Overview embeddable when all the
child components have finished loading.
https://elastic.slack.com/archives/CFFQ7RP9B/p1614267987040400
## How to test
- Add an SLO panel to the dashboard
- click on share -> PDF reports > Generate PDF on the top right
navigation bar
- No Timeout error should appear on the generated PDF
<img width="1407" alt="Screenshot 2023-10-26 at 15 05 05"
src="45c2c868
-edbe-426e-bc05-5794c2bfa91e">
---------
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
c84a62d342
commit
18dc8feb5b
5 changed files with 28 additions and 3 deletions
|
@ -11,7 +11,7 @@ import { toMountPoint } from '@kbn/react-kibana-mount';
|
|||
import type { CoreStart } from '@kbn/core/public';
|
||||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import type { EmbeddableSloProps, SloEmbeddableInput } from './types';
|
||||
import type { SloEmbeddableInput, EmbeddableSloProps } from './types';
|
||||
|
||||
import { ObservabilityPublicPluginsStart } from '../../..';
|
||||
import { SloConfiguration } from './slo_configuration';
|
||||
|
|
|
@ -20,7 +20,6 @@ import {
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { SloSelector } from './slo_selector';
|
||||
|
||||
import type { EmbeddableSloProps } from './types';
|
||||
|
||||
interface SloConfigurationProps {
|
||||
|
|
|
@ -50,8 +50,19 @@ export class SLOEmbeddable extends AbstractEmbeddable<SloEmbeddableInput, Embedd
|
|||
this.updateInput({ title });
|
||||
}
|
||||
|
||||
public reportsEmbeddableLoad() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public onRenderComplete() {
|
||||
this.renderComplete.dispatchComplete();
|
||||
}
|
||||
|
||||
public render(node: HTMLElement) {
|
||||
super.render(node);
|
||||
this.node = node;
|
||||
// required for the export feature to work
|
||||
this.node.setAttribute('data-shared-item', '');
|
||||
this.setTitle(
|
||||
this.input.title ||
|
||||
i18n.translate('xpack.observability.sloEmbeddable.displayTitle', {
|
||||
|
@ -69,6 +80,7 @@ export class SLOEmbeddable extends AbstractEmbeddable<SloEmbeddableInput, Embedd
|
|||
<KibanaContextProvider services={this.deps}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<SloOverview
|
||||
onRenderComplete={() => this.onRenderComplete()}
|
||||
sloId={sloId}
|
||||
sloInstanceId={sloInstanceId}
|
||||
lastReloadRequestTime={this.input.lastReloadRequestTime}
|
||||
|
|
|
@ -20,7 +20,12 @@ import { paths } from '../../../../common/locators/paths';
|
|||
|
||||
import { EmbeddableSloProps } from './types';
|
||||
|
||||
export function SloOverview({ sloId, sloInstanceId, lastReloadRequestTime }: EmbeddableSloProps) {
|
||||
export function SloOverview({
|
||||
sloId,
|
||||
sloInstanceId,
|
||||
lastReloadRequestTime,
|
||||
onRenderComplete,
|
||||
}: EmbeddableSloProps) {
|
||||
const {
|
||||
uiSettings,
|
||||
application: { navigateToUrl },
|
||||
|
@ -39,6 +44,13 @@ export function SloOverview({ sloId, sloInstanceId, lastReloadRequestTime }: Emb
|
|||
useEffect(() => {
|
||||
refetch();
|
||||
}, [lastReloadRequestTime, refetch]);
|
||||
useEffect(() => {
|
||||
if (!onRenderComplete) return;
|
||||
|
||||
if (!isLoading) {
|
||||
onRenderComplete();
|
||||
}
|
||||
}, [isLoading, onRenderComplete]);
|
||||
|
||||
const percentFormat = uiSettings.get('format:percent:defaultPattern');
|
||||
const isSloNotFound = !isLoading && slo === undefined;
|
||||
|
@ -97,6 +109,7 @@ export function SloOverview({ sloId, sloInstanceId, lastReloadRequestTime }: Emb
|
|||
</LoadingContainer>
|
||||
);
|
||||
}
|
||||
|
||||
const TargetCopy = i18n.translate('xpack.observability.sloEmbeddable.overview.sloTargetLabel', {
|
||||
defaultMessage: 'Target',
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ export interface EmbeddableSloProps {
|
|||
sloId: string | undefined;
|
||||
sloInstanceId: string | undefined;
|
||||
lastReloadRequestTime?: number | undefined;
|
||||
onRenderComplete?: () => void;
|
||||
}
|
||||
|
||||
export type SloEmbeddableInput = EmbeddableInput & EmbeddableSloProps;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue