-
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
[Lens] Improve layer suggestions and fix layer crash in metric #49389
[Lens] Improve layer suggestions and fix layer crash in metric #49389
Conversation
…e-loading-indicator
…vies/kibana into chris-lens-workspace-loading-indicator
Added TODO for using chart loader when area is completely empty
…' into expressions-loading-errors
- Hide chart if Empty not Loading - Fix relative positioning for progress bar since className is no longer passed (super hacky)
More layout fixes
…ens/fix-metric-crash
Pinging @elastic/kibana-app (Team:KibanaApp) |
💔 Build Failed |
@elasticmachine merge upstream |
💔 Build Failed |
💚 Build Succeeded |
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 w/ tweaks. My only concern is that this is complex enough that there are probably new, buggy edge-cases being introduced. However, it does fix some real issues, so, I think it's worth moving forward.
@@ -80,6 +89,9 @@ function buildSuggestion({ | |||
changeType, | |||
label, | |||
}, | |||
|
|||
// layerBehavior: layerBehavior || 'replace', |
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 commented out code.
.map(([layerId, layer], index) => { | ||
const hasMatchingLayer = layers.some( | ||
([otherLayerId, otherLayer]) => | ||
!(otherLayerId === layerId) && otherLayer.indexPatternId === layer.indexPatternId |
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.
Nit: !(otherLayerId === layerId)
is much clearer when written otherLayerId !== layerId
@@ -20,6 +20,7 @@ export function getSuggestions({ | |||
// We only render metric charts for single-row queries. We require a single, numeric column. | |||
if ( | |||
table.isMultiRow || | |||
table.columns.length === 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.
Line 23 and 24 could be united into table.columns.length >= 0 ||
or just table.columns.length ||
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're right that they can be combined, but the condition is actually table.columns.length !== 1
💚 Build Succeeded |
💚 Build Succeeded |
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
💚 Build Succeeded |
…ic#49389) * Add loading indicator to Lens workspace panel * [Expressions] [Lens] Handle loading and errors in ExpressionRenderer * Using loading$ observable and improve tests * [Lens] Fix layer crash and improve layer suggestions * Using CSS and to handle layout of expression renderer Added TODO for using chart loader when area is completely empty * Improve error handling and simplify code * Fix cleanup behavior * Fix double render and prevent error cases in xy chart * Fix context for use in dashboards * Remove className from expression rendere component * Improve handling of additional interpreter args * More layout fixes - Hide chart if Empty not Loading - Fix relative positioning for progress bar since className is no longer passed (super hacky) * Build suggestions that remove layers * Update tests and add keptLayerIds everywhere * Fix bug where datatable would accept multi-layer suggestions * Build more suggestions that work with metric/datatable * Fix issue with chart switching from empty * Fix datatable multiple layer issue
…ic#49389) * Add loading indicator to Lens workspace panel * [Expressions] [Lens] Handle loading and errors in ExpressionRenderer * Using loading$ observable and improve tests * [Lens] Fix layer crash and improve layer suggestions * Using CSS and to handle layout of expression renderer Added TODO for using chart loader when area is completely empty * Improve error handling and simplify code * Fix cleanup behavior * Fix double render and prevent error cases in xy chart * Fix context for use in dashboards * Remove className from expression rendere component * Improve handling of additional interpreter args * More layout fixes - Hide chart if Empty not Loading - Fix relative positioning for progress bar since className is no longer passed (super hacky) * Build suggestions that remove layers * Update tests and add keptLayerIds everywhere * Fix bug where datatable would accept multi-layer suggestions * Build more suggestions that work with metric/datatable * Fix issue with chart switching from empty * Fix datatable multiple layer issue
… (#49693) * Add loading indicator to Lens workspace panel * [Expressions] [Lens] Handle loading and errors in ExpressionRenderer * Using loading$ observable and improve tests * [Lens] Fix layer crash and improve layer suggestions * Using CSS and to handle layout of expression renderer Added TODO for using chart loader when area is completely empty * Improve error handling and simplify code * Fix cleanup behavior * Fix double render and prevent error cases in xy chart * Fix context for use in dashboards * Remove className from expression rendere component * Improve handling of additional interpreter args * More layout fixes - Hide chart if Empty not Loading - Fix relative positioning for progress bar since className is no longer passed (super hacky) * Build suggestions that remove layers * Update tests and add keptLayerIds everywhere * Fix bug where datatable would accept multi-layer suggestions * Build more suggestions that work with metric/datatable * Fix issue with chart switching from empty * Fix datatable multiple layer issue
… (#49694) * Add loading indicator to Lens workspace panel * [Expressions] [Lens] Handle loading and errors in ExpressionRenderer * Using loading$ observable and improve tests * [Lens] Fix layer crash and improve layer suggestions * Using CSS and to handle layout of expression renderer Added TODO for using chart loader when area is completely empty * Improve error handling and simplify code * Fix cleanup behavior * Fix double render and prevent error cases in xy chart * Fix context for use in dashboards * Remove className from expression rendere component * Improve handling of additional interpreter args * More layout fixes - Hide chart if Empty not Loading - Fix relative positioning for progress bar since className is no longer passed (super hacky) * Build suggestions that remove layers * Update tests and add keptLayerIds everywhere * Fix bug where datatable would accept multi-layer suggestions * Build more suggestions that work with metric/datatable * Fix issue with chart switching from empty * Fix datatable multiple layer issue
Closes #48966
Before this PR, both the datasource and visualizations were expected to provide single-layer suggestions, and the frame had buggy logic which only removes a layer from the datasource if you are switching from one visualization to another. The decision to add or remove layers is up to each datasource, so that's the main goal of this change.
Another change made here is to the behavior after the following steps are taken:
In this PR, we still create a new layer, but we also generate a new set of suggestions whenever the user has more than one layer that allows them to easily remove all but one layer:
These suggestions are a workaround because we found the "remove layer" button to be not very discoverable. The suggestion titles will show the index pattern name if it's unique, otherwise they will say "Show only layer 1"
Other cases tested here:
Start on the Metric visualization
Drag a field into the metric slot, do not drag into the middle
Switch index patterns on the left side
Drag a new field in
The metric should be updated, and you should not see any suggestions that contain other layers.
Start on an empty XY chart
Switch to the data table
Drag a field in
You should see suggestions that don't involve layers
Switch to the data table
Configure some kind of table
Switch the index pattern on the left
Drag a new field in, and you should see suggestions without layers