-
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
[Security Solution] Add custom features to lens #138995
Conversation
…ana into lensEmbeddables/enhancement
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
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.
Hi @angorayc ! First off, thank you for taking the initiative to contribute "upstream" to Lens to unblock yourself from using the embeddable!
You're on the right track, but we should change how the metric alignment parameter makes it to the metric-component.tsx
.
Currently you have it set up like this:
metricAlignment
gets set as part of the Lens embeddable'sinput
- then it gets passed in the
handlers.variables
- then it gets added to the renderer's vis config
Since the metric alignment parameter only applies to the legacy metric vis type, we should change it so that metricAlignment becomes part of the lensAttributes instead of being part of the embeddable input. So, we should
Add metricAlignment as an optional argument to the legacy metric expression function
first it needs to be added to the type
kibana/src/plugins/chart_expressions/expression_legacy_metric/common/types/expression_functions.ts
Lines 21 to 33 in c5b1afd
export interface MetricArguments { | |
percentageMode: boolean; | |
colorMode: ColorMode; | |
showLabels: boolean; | |
palette?: PaletteOutput<CustomPaletteState>; | |
font: Style; | |
labelFont: Style; | |
labelPosition: LabelPositionType; | |
metric: Array<ExpressionValueVisDimension | string>; | |
bucket?: ExpressionValueVisDimension | string; | |
colorFullBackground: boolean; | |
autoScale?: boolean; | |
} |
then, to the expression function args
Line 47 in c5b1afd
args: { |
Get the value of the alignment from the args instead of the handlers.variables
Line 179 in c5b1afd
metric: { |
Add alignment
as an optional member in the legacy metric state
kibana/x-pack/plugins/lens/common/types.ts
Lines 87 to 96 in c5b1afd
export interface LegacyMetricState { | |
layerId: string; | |
accessor?: string; | |
layerType: LayerType; | |
colorMode?: ColorMode; | |
palette?: PaletteOutput<CustomPaletteParams>; | |
titlePosition?: 'top' | 'bottom'; | |
size?: string; | |
textAlign?: 'left' | 'right' | 'center'; | |
} |
Attach the metricAlignment
argument to the expression AST when present
kibana/x-pack/plugins/lens/public/visualizations/legacy_metric/visualization.tsx
Line 107 in c5b1afd
arguments: { |
Let me know if you have any questions about how this all fits together!
…ana into lensEmbeddables/enhancement
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
…ana into lensEmbeddables/enhancement
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.
Looking good! Left a couple of comments.
@flash1293 do you know who owns the interpreter_functional
tests? @angorayc ran the functional tests with the updateBaselines
option locally and it seems like it has changed a bunch of visual baselines that weren't failing before.
...hart_expressions/expression_legacy_metric/common/expression_functions/metric_vis_function.ts
Outdated
Show resolved
Hide resolved
...hart_expressions/expression_legacy_metric/common/expression_functions/metric_vis_function.ts
Outdated
Show resolved
Hide resolved
…ana into lensEmbeddables/enhancement
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!
src/plugins/chart_expressions/expression_legacy_metric/public/components/with_auto_scale.tsx
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Sorry for being late to the party - I would say appservices which means they are now back to the viseditors/visualizations team |
Summary
Security Solution is migrating existing charts to Lens Embeddables but keep the custom inspectors.
In this PR we made some changes to allow Embeddables to use a custom inspector, and allow metric to align left or center:
To see the result of Lens Embeddables on Security Solutions, please run #138995, add this to kibana.dev.yml, and visit any of the explore pages:
Screen.Recording.2022-10-27.at.15.11.41.mov