-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Lens] Fix embeddable title and description for reporting and dashboard tooltip #78767
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
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 see why you used the approach in this PR by pushing description and title into the visualization state so it can be piped through the layers, but I'm not sure I like the approach because it magically extends the state which was intended to be private to the visualization.
I propose passing down these things to the toExpression
function explicitly by extending the global types:
toExpression: (
state: T,
datasourceLayers: Record<string, DatasourcePublicAPI>
) => Ast | string | null;
becomes
toExpression: (
state: T,
datasourceLayers: Record<string, DatasourcePublicAPI>,
title?: string,
description?: string
) => Ast | string | null;
@@ -79,7 +81,7 @@ export async function persistedStateToExpression( | |||
|
|||
return buildExpression({ | |||
visualization, | |||
visualizationState, | |||
visualizationState: { ...(visualizationState as object), title, description }, |
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'm not sure I like this approach - it assumes a certain state structure we don't guarantee and it seems like it's breaking the current isolation between frame and individual visualizations to magically set state.
Refactored the code. Some |
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.
Tested and LGTM! I included some tests for Lens by Value and found that the titles were not rendered, so I want to loop in @ThomThomson to see if that's expected.
type VisualizeEmbeddable = any; | ||
|
||
function getViewDescription(embeddable: IEmbeddable | VisualizeEmbeddable) { | ||
if (embeddable.type === VISUALIZE_EMBEDDABLE_TYPE) { | ||
if (embeddable.getVisualizationDescription) { |
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.
Could this be embeddable.getDescription
instead? Not all embeddables are visualizations
LGTM, on Reporting integration changes. |
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.
@wylieconlon it seems like the placeholder titles are only missing because master hasn't been merged in since that was added.
Additionally, I agree with on the naming of the getDescription
function, and have one comment below
@@ -109,11 +109,10 @@ function renderTooltip(description: string) { | |||
); | |||
} | |||
|
|||
const VISUALIZE_EMBEDDABLE_TYPE = 'visualization'; | |||
type VisualizeEmbeddable = any; |
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 know this wasn't added in this PR, but I'm not a huge fan of using any
like this. Now that this description
is added to both lens and visualize, I wonder if it would be worth adding an optional getDescription
function to IEmbeddable
.
If not, at least the any
could be removed with something like:
type EmbeddableWithDescription = IEmbeddable & { getDescription: () => string };
function getViewDescription(embeddable: IEmbeddable) {
return (embeddable as EmbeddableWithDescription).getDescription?.() || '';
}
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
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.
Thanks for getting rid of that any
. New changes LGTM!
…rd tooltip (elastic#78767) Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…aly-detection-partition-field * 'master' of github.com:elastic/kibana: (76 commits) Fix z-index of KQL Suggestions dropdown (elastic#79184) [babel] remove unused/unneeded babel plugins (elastic#79173) [Search] Fix timeout upgrade link (elastic#79045) Always Show Embeddable Panel Header in Edit Mode (elastic#79152) [Ingest]: add more test for transform index (elastic#79154) [ML] DF Analytics: Collapsable sections on results pages (elastic#76641) [Fleet] Fix agent policy change action migration (elastic#79046) [Ingest Manager] Match package spec `dataset`->`data_stream` and `config_templates`->`policy_templates` renaming (elastic#78699) Revert "[Metrics UI] Add ability to override datafeeds and job config for partition field (elastic#78875)" [ML] Update transform cloning to include description and new fields (elastic#78364) chore(NA): remove non existing plugin paths from case api integration tests (elastic#79127) [Ingest Manager] Ensure we trigger agent policy updated event when we bump revision. (elastic#78836) [Metrics UI] Display No Data context.values as [NO DATA] (elastic#78038) [Monitoring] Missing data alert (elastic#78208) [Lens] Fix embeddable title and description for reporting and dashboard tooltip (elastic#78767) [Lens] Consistent Drag and Drop styles (elastic#78674) [ML] Model management UI fixes and enhancements (elastic#79072) [Metrics UI] Add ability to override datafeeds and job config for partition field (elastic#78875) [Security Solution]Fix basepath used by endpoint telemetry tests (elastic#79027) update rum agent version which contains longtasks (elastic#79105) ...
Summary
This PR aims to correctly propagate to the Lens embeddable both title and description information to the
VisualizationContainer
element, used for reporting. ( #70725 )While in the area, it also addresses rendering differences with Visualize description tooltip behaviour in Dashboard of Lens embeddables. ( #69638 )
Reporting fixes:
Note: the metric visualization was using the metric title as embeddable title, while this PR separate the two things. An idea could be to use the
metricTitle
as fallback for thetitle
, but I do not see much value in it asmetricTitle
is already shown.Dashboard tooltip with description:
Fixes: #70725 and #69638
Checklist