Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reporting] Make "ScreenCapturePanel" shareable for Canvas #100623

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 52 additions & 29 deletions x-pack/examples/reporting_example/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/

import {
EuiButton,
EuiCard,
EuiCode,
EuiContextMenu,
EuiFlexGroup,
EuiFlexItem,
EuiHorizontalRule,
Expand All @@ -17,7 +18,7 @@ import {
EuiPageContent,
EuiPageContentBody,
EuiPageHeader,
EuiPanel,
EuiPopover,
EuiText,
EuiTitle,
} from '@elastic/eui';
Expand Down Expand Up @@ -50,7 +51,19 @@ export const ReportingExampleApp = ({
reporting,
screenshotMode,
}: ReportingExampleAppDeps) => {
const { getDefaultLayoutSelectors, ReportingAPIClient } = reporting;
const { getDefaultLayoutSelectors } = reporting;

// Context Menu
const [isPopoverOpen, setPopover] = useState(false);
const onButtonClick = () => {
setPopover(!isPopoverOpen);
};

const closePopover = () => {
setPopover(false);
};

// Async Logos
const [logos, setLogos] = useState<string[]>([]);

useEffect(() => {
Expand All @@ -61,7 +74,7 @@ export const ReportingExampleApp = ({
});
});

const getPDFJobParams = (): JobParamsPDF => {
const getPDFJobParamsDefault = (): JobParamsPDF => {
return {
layout: {
id: constants.LAYOUT_TYPES.PRESERVE_LAYOUT,
Expand All @@ -73,7 +86,30 @@ export const ReportingExampleApp = ({
};
};

// Render the application DOM.
const panels = [
{ id: 0, items: [{ name: 'PDF Reports', icon: 'document', panel: 1 }] },
{
id: 1,
initialFocusedItemIndex: 1,
title: 'PDF Reports',
items: [
{ name: 'No Layout Option', icon: 'document', panel: 2 },
{ name: 'Print Layout Option', icon: 'document', panel: 3 },
{ name: 'Canvas Layout Option', icon: 'canvasApp', panel: 4 },
],
},
{
id: 2,
title: 'PDF Reports',
content: (
<reporting.components.ReportingPanelPDF
getJobParams={getPDFJobParamsDefault}
onClose={closePopover}
/>
),
},
];

return (
<Router basename={basename}>
<I18nProvider>
Expand All @@ -87,34 +123,21 @@ export const ReportingExampleApp = ({
<EuiPageContent>
<EuiPageContentBody>
<EuiText>
<p>
Use the <EuiCode>ReportingStart.components.ScreenCapturePanel</EuiCode>{' '}
component to add the Reporting panel to your page.
</p>

<EuiHorizontalRule />
<p>Example of a Sharing menu using components from Reporting</p>

<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiPanel>
<reporting.components.ScreenCapturePanel
apiClient={new ReportingAPIClient(http)}
toasts={notifications.toasts}
reportType={constants.PDF_REPORT_TYPE}
getJobParams={getPDFJobParams}
objectId="Visualization:Id:ToEnsure:Visualization:IsSaved"
/>
</EuiPanel>
</EuiFlexItem>
</EuiFlexGroup>
<EuiPopover
id="contextMenuExample"
button={<EuiButton onClick={onButtonClick}>Share</EuiButton>}
isOpen={isPopoverOpen}
closePopover={closePopover}
panelPaddingSize="none"
anchorPosition="downLeft"
>
<EuiContextMenu initialPanelId={0} panels={panels} />
</EuiPopover>

<EuiHorizontalRule />

<p>
The logos below are in a <EuiCode>data-shared-items-container</EuiCode> element
for Reporting.
</p>

<div data-shared-items-container data-shared-items-count="4">
<EuiFlexGroup gutterSize="l">
{logos.map((item, index) => (
Expand Down
87 changes: 1 addition & 86 deletions x-pack/plugins/canvas/i18n/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { BOLD_MD_TOKEN, CANVAS, HTML, JSON, KIBANA, PDF, POST, URL, ZIP } from './constants';
import { BOLD_MD_TOKEN, CANVAS, HTML, JSON, PDF, URL, ZIP } from './constants';

export const ComponentStrings = {
AddEmbeddableFlyout: {
Expand Down Expand Up @@ -1418,95 +1418,10 @@ export const ComponentStrings = {
URL,
},
}),
getCopyReportingConfigMessage: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.copyReportingConfigMessage', {
defaultMessage: 'Copied reporting configuration to clipboard',
}),
getCopyShareConfigMessage: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.copyShareConfigMessage', {
defaultMessage: 'Copied share markup to clipboard',
}),
getExportPDFErrorTitle: (workpadName: string) =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.exportPDFErrorMessage', {
defaultMessage: "Failed to create {PDF} for '{workpadName}'",
values: {
PDF,
workpadName,
},
}),
getExportPDFMessage: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.exportPDFMessage', {
defaultMessage: 'Exporting {PDF}. You can track the progress in Management.',
values: {
PDF,
},
}),
getExportPDFTitle: (workpadName: string) =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.exportPDFTitle', {
defaultMessage: "{PDF} export of workpad '{workpadName}'",
values: {
PDF,
workpadName,
},
}),
getPDFFullPageLayoutHelpText: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.FullPageLayoutHelpText', {
defaultMessage: 'Remove borders and footer logo',
}),
getPDFFullPageLayoutLabel: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.FullPageLayoutLabel', {
defaultMessage: 'Full page layout',
}),
getPDFPanelAdvancedOptionsLabel: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelAdvancedOptionsLabel', {
defaultMessage: 'Advanced options',
}),
getPDFPanelCopyAriaLabel: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyAriaLabel', {
defaultMessage:
'Alternatively, you can generate a {PDF} from a script or with Watcher by using this {URL}. Press Enter to copy the {URL} to clipboard.',
values: {
PDF,
URL,
},
}),
getPDFPanelCopyButtonLabel: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyButtonLabel', {
defaultMessage: 'Copy {POST} {URL}',
values: {
POST,
URL,
},
}),
getPDFPanelCopyDescription: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyDescription', {
defaultMessage:
'Alternatively, copy this {POST} {URL} to call generation from outside {KIBANA} or from Watcher.',
values: {
POST,
KIBANA,
URL,
},
}),
getPDFPanelGenerateButtonLabel: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateButtonLabel', {
defaultMessage: 'Generate {PDF}',
values: {
PDF,
},
}),
getPDFPanelGenerateDescription: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateDescription', {
defaultMessage:
'{PDF}s can take a minute or two to generate based on the size of your workpad.',
values: {
PDF,
},
}),
getPDFPanelOptionsLabel: () =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelOptionsLabel', {
defaultMessage: 'Options',
}),
getShareableZipErrorTitle: (workpadName: string) =>
i18n.translate('xpack.canvas.workpadHeaderShareMenu.shareWebsiteErrorTitle', {
defaultMessage:
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/canvas/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"kibanaUtils",
"lens",
"maps",
"reporting",
"savedObjects",
"visualizations"
]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,34 @@
* 2.0.
*/

import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import React from 'react';
import { platformService } from '../../../../services/stubs/platform';
import { reportingService } from '../../../../services/stubs/reporting';
import { ShareMenu } from '../share_menu.component';

storiesOf('components/WorkpadHeader/ShareMenu', module).add('default', () => (
storiesOf('components/WorkpadHeader/ShareMenu', module).add('minimal', () => (
<ShareMenu
includeReporting={true}
onCopy={action('onCopy')}
sharingData={{
workpad: { id: 'coolworkpad', name: 'Workpad of Cool', height: 10, width: 7 },
pageCount: 11,
}}
sharingServices={{ basePath: platformService.getBasePathInterface() }}
onExport={action('onExport')}
getExportUrl={(type: string) => {
action(`getExportUrl('${type}')`);
return type;
/>
));

storiesOf('components/WorkpadHeader/ShareMenu', module).add('with Reporting', () => (
<ShareMenu
sharingData={{
workpad: { id: 'coolworkpad', name: 'Workpad of Cool', height: 10, width: 7 },
pageCount: 11,
}}
sharingServices={{
basePath: platformService.getBasePathInterface(),
reporting: reportingService.start,
}}
onExport={action('onExport')}
/>
));
Loading