kibana/x-pack/plugins/lens/public/visualization_container.tsx

50 lines
1.3 KiB
TypeScript
Raw Normal View History

/*
* 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 './visualization_container.scss';
import React from 'react';
2020-07-13 14:59:16 +02:00
import classNames from 'classnames';
interface Props extends React.HTMLAttributes<HTMLDivElement> {
isReady?: boolean;
reportTitle?: string;
reportDescription?: string;
}
/**
* This is a convenience component that wraps rendered Lens visualizations. It adds reporting
* attributes (data-shared-item, data-render-complete, and data-title).
*/
2020-07-13 14:59:16 +02:00
export function VisualizationContainer({
isReady = true,
reportTitle,
reportDescription,
2020-07-13 14:59:16 +02:00
children,
className,
...rest
}: Props) {
const attributes: Partial<{ 'data-title': string; 'data-description': string }> = {};
if (reportTitle) {
attributes['data-title'] = reportTitle;
}
if (reportDescription) {
attributes['data-description'] = reportDescription;
}
return (
2020-07-13 14:59:16 +02:00
<div
data-shared-item
data-render-complete={isReady}
className={classNames(className, 'lnsVisualizationContainer')}
{...attributes}
2020-07-13 14:59:16 +02:00
{...rest}
>
{children}
</div>
);
}