-
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
[Screenshotting] Add possibility to capture expressions #128552
Conversation
7b3e72e
to
71f0152
Compare
Pinging @elastic/kibana-app-services (Team:AppServicesUx) |
* 2.0. | ||
*/ | ||
|
||
.expression { |
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.
These class names are quite generic which increases the likelihood of style overrides elsewhere in Kibana should this file ever get loaded more globally. To minimize this possibility, we recommend use a unique, 3-letter prefix such as .scrExpression
and the child could be .scrExpression__viz
, for example
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.
@ryankeairns That's a good point. I followed your recommendation and prefixed that, although I didn't add the prefix to the .visualization
class since we override styles of the generic class here.
Could you please take another look?
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.
Great work @dokmic 🍻 , I really like the overloaded getScreenshots method.
I still need to test this and I'd like to get your thoughts on my idea about rather composing formatting and screenshotting.
import type { ExpressionRendererParams } from 'src/plugins/expressions/public'; | ||
import { useExpressionRenderer } from '../../../../../src/plugins/expressions/public'; | ||
import { SCREENSHOTTING_EXPRESSION, SCREENSHOTTING_EXPRESSION_INPUT } from '../../common'; | ||
import { ScreenshotModeContext } from './screenshot_mode_context'; |
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.
You can rather create a useScreenshotModeContext hook and import useContext there. One fewer thing to import here.
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.
I would rather keep it that way since it is more up to the component implementation.
/** | ||
* PDFs can be a single, long page or they can be multiple pages. For example: | ||
* | ||
* => When creating a PDF intended for print multiple PNGs will be spread out across pages | ||
* => When creating a PDF from a Canvas workpad, each page in the workpad will be placed on a separate page | ||
*/ | ||
export type PdfLayoutParams = LayoutParams<typeof supportedLayouts[number]>; | ||
export type PdfLayoutParams = LayoutParams<Values<typeof LayoutTypes>>; |
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.
IMO it's better to be explicit about which layout types are supported. If we ever add one that shouldn't be supported in PDF this will hide it.
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.
That is an excellent point. I've updated that. But to make it pretty, I've changed the LayoutTypes
to TypeScript's enum
.
renderErrors: string[]; | ||
}; | ||
} | ||
export interface PdfScreenshotResult { |
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.
This is a nice improvement!
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.
This code look good to me, great work @dokmic !
I think one missing piece is an integration or functional test to prove that the changes are working as expected but since this code is not being used anywhere I'm happy that we do this in a follow up PR.
setEmpty(false); | ||
setError(newError); | ||
setLoading(false); |
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.
Was this causing unnecessary re-renders? I thought react bundled these together (or is working on bundling them together) https://reactjs.org/docs/faq-state.html#when-is-setstate-asynchronous
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.
That's right but only for the actual rendering. It still re-renders the component (or calls the component function in our case) using that hook.
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.
This is really great! I am exciting to see the next steps for capturing expressions in a feature.
I would like to see an additional test in the getScreenshots
method, following the code paths where it is called with an expression in the options. After that, this would LGTM
c05da85
to
4988c76
Compare
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.
Appreciate the change, LGTM
await screenshots | ||
.getScreenshots({ | ||
...options, | ||
expression: 'kibana', |
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.
🍌
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.
LGTM
@elasticmachine merge upstream |
💛 Build succeeded, but was flakyTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
async chunk count
History
To update your PR or re-run it, just comment with: |
Summary
Apart from the screenshotting functionality this PR also fixes the following:
Checklist
For maintainers