Skip to content
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

Merged
merged 33 commits into from
Oct 29, 2019

Conversation

wylieconlon
Copy link
Contributor

@wylieconlon wylieconlon commented Oct 25, 2019

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:

  1. Configure a single layer in the XY chart visualization
  2. Switch the index pattern using the data panel
  3. Drag a new field into the middle, and it will create a new layer

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:

Screenshot 2019-10-25 15 32 19

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:

  1. Start on the Metric visualization

  2. Drag a field into the metric slot, do not drag into the middle

  3. Switch index patterns on the left side

  4. Drag a new field in

  5. The metric should be updated, and you should not see any suggestions that contain other layers.

  6. Start on an empty XY chart

  7. Switch to the data table

  8. Drag a field in

  9. You should see suggestions that don't involve layers

  10. Switch to the data table

  11. Configure some kind of table

  12. Switch the index pattern on the left

  13. Drag a new field in, and you should see suggestions without layers

chrisdavies and others added 24 commits October 17, 2019 15:25
…vies/kibana into chris-lens-workspace-loading-indicator
Added TODO for using chart loader when area is completely empty
- Hide chart if Empty not Loading
- Fix relative positioning for progress bar since className is no longer passed (super hacky)
@wylieconlon wylieconlon added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Lens v7.5.0 v7.6.0 labels Oct 25, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@elasticmachine
Copy link
Contributor

💔 Build Failed

@wylieconlon
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💔 Build Failed

@wylieconlon wylieconlon marked this pull request as ready for review October 28, 2019 22:08
@wylieconlon wylieconlon requested a review from a team October 28, 2019 22:08
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@chrisdavies chrisdavies left a 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',
Copy link
Contributor

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
Copy link
Contributor

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 ||
Copy link
Contributor

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 ||

Copy link
Contributor Author

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

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@chrisdavies chrisdavies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@wylieconlon wylieconlon merged commit dad9d6b into elastic:master Oct 29, 2019
@wylieconlon wylieconlon deleted the lens/fix-metric-crash branch October 29, 2019 23:05
wylieconlon pushed a commit to wylieconlon/kibana that referenced this pull request Oct 29, 2019
…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
wylieconlon pushed a commit to wylieconlon/kibana that referenced this pull request Oct 29, 2019
…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
wylieconlon pushed a commit that referenced this pull request Oct 30, 2019
… (#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
wylieconlon pushed a commit that referenced this pull request Oct 30, 2019
… (#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.5.0 v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Lens crash on the metric visualization
3 participants