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

Visualize: Reload on ui state change and fix ui state for tsvb #63699

Merged
merged 9 commits into from
May 5, 2020

Conversation

flash1293
Copy link
Contributor

Fixes #51888
Fixes #49626

Currently sorting the TSVB table doesn't work (in editor as well as on dashboard). There are two underlying issues for this, both having architectural implications.

Issue 1: Re-run expression from within a visualization

The TSVB table visualization is special in the regard that it provides interactivity which changes the underlying data and requires to run the expression again to fetch new data - when the sort order is changed, this information is stored in the UI state, but currently there is no mechanism for this change to trigger a full reload as well. The reason for this is that other usages of the UI state (changing colors) work just fine without running the expression again and can be handled locally within the rendered component.

This PR introduces a mechanism to trigger an additional run by exploiting the fact the uiState is passed into the renderer:


As uiState is an event emitter as well, it can pass a reload event back to the consumer of the visualization which can trigger a re-run. Currently this has to happen in two places (visualize_embeddable and editor) because the uiState is overwritten in the latter case.

Issue 2 uiState in embeddable input is too specific

The visualize embeddable passes down uiState from its input to the visualization, but it only considers color overwrites:

The TSVB table sorting is stored in a table.sort key which is not considered and overwritten.

This PR adds the table input to the list of properties to pass into the uiState of the visualization, but maybe a better solution would be to have a dedicated section (e.g. persistedUiState) for this which contains both the overwritten colors and the table sorting in its respective keys. However this would be a breaking change and BWC would be hard to achieve (for example because of state stored in URLs).

@@ -74,6 +74,8 @@ export class VisEditor extends Component {

handleUiState = (field, value) => {
this.props.vis.uiState.set(field, value);
// reload visualization because data might need to be re-fetched
this.props.vis.uiState.emit('reload');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is re-running the expression when ui state changes in TSVB

@@ -105,6 +106,7 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
this.timefilter = timefilter;
this.vis = vis;
this.vis.uiState.on('change', this.uiStateChangeHandler);
this.vis.uiState.on('reload', this.reload);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is making sure the reload is picked up when visualize embeddable is used on the dashboard

@@ -405,6 +405,9 @@ function VisualizeAppController($scope, $route, $injector, $timeout, kbnUrlState
stateContainer
);
vis.uiState = persistedState;
vis.uiState.on('reload', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is making sure the reload is picked up when visualize embeddable is used in visualize editor

@flash1293 flash1293 marked this pull request as ready for review April 16, 2020 14:40
@flash1293 flash1293 requested a review from a team April 16, 2020 14:40
@flash1293 flash1293 requested a review from a team as a code owner April 16, 2020 14:40
@flash1293 flash1293 added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix Team:AppArch Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.7.1 v7.8.0 v8.0.0 labels Apr 16, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

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

Tested functionality and it LGTM. Your explanation was very helpful! Given that you've made a new event listener, can you verify that it's being cleaned up in the right places in the code?

@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@streamich streamich left a comment

Choose a reason for hiding this comment

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

AppArch changes LGTM.

@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

@flash1293
Copy link
Contributor Author

Good point @wylieconlon , it's not cleaning them up properly. I will add that.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@flash1293 flash1293 merged commit e5c8aca into elastic:master May 5, 2020
@flash1293 flash1293 deleted the fix-tsvb-table-sorting branch May 5, 2020 13:10
flash1293 added a commit to flash1293/kibana that referenced this pull request May 5, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request May 5, 2020
* master: (133 commits)
  Cleanup Typescript index pattern field editor / Expression functions for bucket agg (elastic#65254)
  Removes legacy infra plugin and moves saved objects registration to NP (elastic#64848)
  Added support for docLinks plugin in Connectors forms and missing save capabilities for modal dialog (elastic#64986)
  [SIEM] Removes prebuilt rules number dependency (elastic#65128)
  [Maps] add categorical palettes with 20 and 30 categories (elastic#64701)
  [CI] Slack alerts - Elasticsearch snapshot failures (elastic#64724)
  [Uptime] Console errors in case index missing (elastic#65115)
  [SIEM][CASE] Dynamic fields mapping based on connector (elastic#64412)
  [test/functional] Tsfy page objects (elastic#64887)
  [Maps] [Telemetry] Track geo_point and geo_shape index patterns separately (elastic#65195)
  [Maps] Add global fit to data (elastic#64702)
  Visualize: Reload on ui state change and fix ui state for tsvb (elastic#63699)
  [SIEM] [Cases] External service selection per case (elastic#64775)
  [Uptime] Set ML anomaly look-back to 2w (from 24h) / Add spinner (elastic#65055)
  [Metrics UI] Remove APM Hard Dependency (elastic#64952)
  [Ingest] Datastream list: add icons and dashboard links (elastic#65048)
  disable plugins. they could access ES via SO repository (elastic#65242)
  Feature fleet enrollment instructions (elastic#65176)
  [SIEM] Adds 'Configure connector' Cypress test (elastic#64807)
  [TSVB] Fix std deviation band mode (elastic#64413)
  ...
flash1293 added a commit to flash1293/kibana that referenced this pull request May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.7.1 v7.8.0 v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TSVB] Table sorting broken TSVB Sorting by column not working in dashboards
5 participants