Skip to content

[Reporting] Refactor public plugin to expose shareable panel components #101078

@tsullivan

Description

@tsullivan

The Reporting public plugin should expose React components to other plugins. The components are needed for providing a consistent experience around sending the requests to generate a report. The plugin itself should only be required to provide the dynamic info needed: the report job parameters, and any minor customization needed in the panel UI.

Currently, Reporting exposes the ScreenCapturePanel component here: https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/public/plugin.ts#L104. This is not ideal for a publicly exposed component, because the props to that component require services such as toast and ReportingAPIClient.

This issue is to create a wrapper around ScreenCapturePanel to make it easier for consuming plugins to use. That way, a plugin like Canvas can add a Reporting panel to its share menu by calling the Reporting plugin in a way like:

The Reporting public plugin should expose React components to other plugins. The components are needed for providing a consistent experience around sending the requests to generate a report. The plugin itself should only be required to provide the dynamic info needed: the report job parameters, and any minor customization needed in the panel UI.

Currently, Reporting exposes the ScreenCapturePanel component here: https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/public/plugin.ts#L104. This is not ideal for a publicly exposed component, because the props to that component require services such as toast and ReportingAPIClient.

This issue is to create a wrapper around ScreenCapturePanel to make it easier for consuming plugins to use. That way, a plugin like Canvas can add a Reporting panel to its share menu by calling the Reporting plugin in a way like:

const shareMenuPanels = {
  id: 0,
  items: [
  {
    name: 'Reporting Menu',
    panel: {
      id: 1,
      title: 'Generate PDF',
      content: (
        <services.reporting.components.ReportingPanelPDF
          getJobParams={() => getPdfJobParams(sharingData, services.basePath)}
          layoutOption="canvas"
          onClose={closePopover}
        />
      ),
    },
    'data-test-subj': 'sharePanel-PDFReports',
  }]
};

NOTE: In the future, Reporting will be refactored to remove implementation of the export types. At that point, the ReportingPanelPDF component will be hosted by a separate plugin outside of Reporting.

NOTE: This solution applies to Canvas since it does not use the global header. There should be a separate issue to allow consuming plugins to simply register a callback with Reporting from the public/plugin.ts file to integrate with Reporting.

Metadata

Metadata

Assignees

Labels

chorezDeprecated Feature:ReportingUse Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions