-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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/Tech Debt] Convert PdfMaker class to TypeScript #81242
Conversation
margin: [0, 0, subheadingMarginBottom, 20], | ||
}, | ||
warning: { | ||
color: '#f39c12', // same as @brand-warning in Kibana colors.less |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this comment is a bit outdated.
Will leave it as-is until it becomes an issue.
alignment: 'left', | ||
fontSize: headingFontSize, | ||
bold: true, | ||
margin: [headingMarginTop, 0, headingMarginBottom, 0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compare to
kibana/x-pack/plugins/reporting/server/export_types/printable_pdf/lib/pdf/index.js
Lines 268 to 269 in a74cea3
marginTop: headingMarginTop, | |
marginBottom: headingMarginBottom, |
The previous code used invalid properties: marginTop
, marginBottom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the margin(Left|Top|Right|Bottom)
is supported in the code, which means the previous code should be expected to work. So changing to margin: [x, y, z, q]
should lead to the same result.
alignment: 'left', | ||
fontSize: subheadingFontSize, | ||
italics: true, | ||
margin: [0, 0, subheadingMarginBottom, 20], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code used invalid deprecated properties: marginBottom
, marginLeft
kibana/x-pack/plugins/reporting/server/export_types/printable_pdf/lib/pdf/index.js
Lines 275 to 276 in a74cea3
marginLeft: 20, | |
marginBottom: subheadingMarginBottom, |
|
||
getBuffer(): Promise<Buffer | null> { | ||
return new Promise((resolve, reject) => { | ||
if (!this._pdfDoc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the previous code did the undefined check outside of the Promise, which caused TS to complain about lines 143-145
kibana/x-pack/plugins/reporting/server/export_types/printable_pdf/lib/pdf/index.js
Line 138 in a74cea3
if (!this._pdfDoc) { |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Test it out on a few different workpads and all seems good!
💚 Build SucceededMetrics [docs]async chunks size
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |
…1242) * convert pdf.js to TS * more typescript * simplify caller * more typescript * more typescript * fix the code to match the expected interface * very cool comment * interface correction * remove unused class method * add unit test for PdfMaker * file rename for typo correction Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* master: (63 commits) [KP] Fix Headers timeout issue (elastic#81140) [ML] Functional tests - stabilize typing with checks service method (elastic#81338) tabify - support docs (elastic#80351) [Security Solution][Detections] Look-back time logic fix (elastic#81383) [Workplace Search] Add top-level tests for Groups (elastic#81215) [Fleet] Fix agent action observable for long polling (elastic#81376) [Maps] fix feature tooltip remains open when zoom level change hides layer (elastic#81373) skip flaky suite (elastic#78689) chore(NA): add spec-to-console and plugin-helpers as devOnly dependencies (elastic#81357) Ensure some data is returned (elastic#81375) Change dumb-init to tini (elastic#81126) [Reporting/Tech Debt] Convert PdfMaker class to TypeScript (elastic#81242) Use Storybook Controls instead of Knobs (elastic#80705) [junit] make sure that report paths are unique (elastic#81255) bump elastic/elasticsearch-js version to 7.10.0-rc1 (elastic#81288) run ssl tests on CI (elastic#81320) Fix alert defaults (elastic#81207) [ML] DF Analytics wizard: ensure user can set mml manually or select to use given estimate (elastic#81078) Add UI notifier to indicate secret fields and to remember / reenter values (elastic#80657) [Monitoring] Use async/await (elastic#81200) ...
…81400) * convert pdf.js to TS * more typescript * simplify caller * more typescript * more typescript * fix the code to match the expected interface * very cool comment * interface correction * remove unused class method * add unit test for PdfMaker * file rename for typo correction Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
Preliminary cleanup and work on tech debt for #78726
Problem: Canvas integrates with Reporting using the
preserve_layout
option for PDF. This is not ideal as Canvas pages themselves are the only layout that the user wants in the report.In a future PR, we will add a new Layout class for Canvas that will just use the image as the page contents, instead of a layout with a header, margins, and a footer.
Until we can do that, this PR is needed to take care of tech debt on the classes that are involved with generating a PDF using a Layout.
Cleanups:
x-pack/plugins/reporting/server/export_types/printable_pdf/lib/pdf/index.js
by moving helper functions to separate files@types/pdfmake
to ensure our objects are structured with the right interfaceany
usage and fixed it.Layout
definitions to account for the way PdfMaker is using the layout objectsChecklist
Delete any items that are not applicable to this PR.
For maintainers