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

cleanup visualizations api #59958

Merged
merged 28 commits into from
Mar 23, 2020
Merged

cleanup visualizations api #59958

merged 28 commits into from
Mar 23, 2020

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Mar 11, 2020

Summary

  • update visualizations/vis
    • typescript
    • remove most of the methods
    • remove inheritance from eventemitter
  • update visualizations/expressions/vis
    • typescript
    • new type to differ from visualizations/vis
  • introduce new type SavedVis which represents visualization as saved in .kibana index
  • introduce new type SerializedVis which is serialized Vis object
  • utilities to convert between SavedVis and SerializedVis
  • all data information is now present on Vis object (before filters,query,timerange, savedSearchId were missing)

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

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

@ppisljar ppisljar marked this pull request as ready for review March 12, 2020 19:12
@ppisljar ppisljar requested a review from a team March 12, 2020 19:12
@ppisljar ppisljar requested a review from a team as a code owner March 12, 2020 19:12
@ppisljar ppisljar added release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0 labels Mar 12, 2020
@ppisljar ppisljar force-pushed the api/vis1 branch 2 times, most recently from 8f93b09 to 999ceeb Compare March 16, 2020 07:03
@ppisljar ppisljar changed the title Api/vis1 cleanup visualizations api Mar 16, 2020
@ppisljar ppisljar force-pushed the api/vis1 branch 4 times, most recently from e4d16bf to 8d0d452 Compare March 16, 2020 15:38
@ppisljar ppisljar force-pushed the api/vis1 branch 4 times, most recently from a11b2da to 4082665 Compare March 17, 2020 11:23
Comment on lines 348 to 357
const visState = stateContainer.getState().vis;
const state = {
type: visState.type,
title: visState.title,
params: visState.params,
data: {
aggs: visState.aggs,
},
};
vis.setState(state);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems you skip this suggestion (at least didn't see an answer), but I think it will simplify code.
If you only need to extract aggs and put them into data, you could simplify this:

const { vis: { aggs, ...visState } }= stateContainer.getState();
vis.setState({ ...visState, data: { aggs } });

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

Did a pass through to test the various vis types (Chrome macOS); from what I can tell everything seems to be working as expected.

visualizations plugin changes LGTM overall, once we get the last conflicts fixed & a green build.

# Conflicts:
#	src/legacy/core_plugins/tile_map/public/tile_map_type.js
#	src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx
#	src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts
#	src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx
#	src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts
#	src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx
#	src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts
#	src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts
#	src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx
#	src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx
#	src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts
#	src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx
#	src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts
#	src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts
#	src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx
#	src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts
@@ -703,6 +737,9 @@ function VisualizeAppController(
searchSource.setField('index', currentIndex);
searchSource.setParent(searchSourceGrandparent);

delete savedVis.savedSearchId;
delete vis.data.savedSearchId;
Copy link
Contributor

Choose a reason for hiding this comment

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

We are handling the linked state in url. Callinng stateContainer.transitions.unlinkSavedSearch will set linked: false, which will remove savedSearchId from both savedVis and vis.data objects in handleLinkedSearch, so there is no necessity to do it here.

}

export function LinkedSearch({ savedSearch, vis }: LinkedSearchProps) {
export function LinkedSearch({ vis, savedSearch, eventEmitter }: LinkedSearchProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

vis is an extra prop in LinkedSearch now

query,
});

return () => {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra returning a function, which doesn't do anything, should be removed.

savedObj: VisSavedObject;
vis: Vis;
eventEmitter: EventEmitter;
embeddableHandler: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK this should be VisualizeEmbeddable type, shouldn't it?

@@ -27,7 +26,6 @@ export interface VisOptionsProps<VisParamType = unknown> {
isTabSelected: boolean;
stateParams: VisParamType;
vis: Vis;
uiState: PersistedState;
Copy link
Contributor

Choose a reason for hiding this comment

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

When you removed passing down the uiState into vis options tab, we lost next functionality:

  • create a gauge vis;
  • change a color for a metric in the legend (in options tab you'll see the Reset colors button) - the uiState should be preserved in the url;
  • reload the page - you'll lost the actual ui state (color is lost, button is not shown)

@sulemanof
Copy link
Contributor

Whila naviating back in TSVB there is an error appeared:

image

Steps to reproduce:

  • create a TSVB vis;
  • change the agg to be grouped by any term;
  • go back - error occured, visualization is not updated;

Copy link
Contributor

@sulemanof sulemanof left a comment

Choose a reason for hiding this comment

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

All of the specified issues were resolved!
Apart from that, didn't find anything else broken in visualize (was mostly focused on testing there)
Left some nits, but overall LGTM!
Great step over moving to NP!

@@ -54,18 +56,18 @@ export interface VisualizeAppStateTransitions {
state: VisualizeAppState
) => ({ query, parentFilters }: { query?: Query; parentFilters?: Filter[] }) => VisualizeAppState;
updateVisState: (state: VisualizeAppState) => (vis: PureVisState) => VisualizeAppState;
updateUiState: (state: VisualizeAppState) => (uiState: PersistedState) => VisualizeAppState;
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra type

@@ -82,6 +82,7 @@ export function useVisualizeAppState({ stateDefaults, kbnUrlStateStorage }: Argu
linked: false,
}),
updateVisState: state => newVisState => ({ ...state, vis: toObject(newVisState) }),
updateUiState: state => newUiState => ({ ...state, uiState: newUiState }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra method

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@ppisljar ppisljar merged commit ed55531 into elastic:master Mar 23, 2020
ppisljar added a commit to ppisljar/kibana that referenced this pull request Mar 23, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 23, 2020
* master: (26 commits)
  [Alerting] Fixes flaky test in Alert Instances Details page (elastic#60893)
  cleanup visualizations api (elastic#59958)
  Inline timezoneProvider function, remove ui/vis/lib/timezone  (elastic#60475)
  [SIEM] Adds 'Open one signal' Cypress test (elastic#60484)
  [UA] Upgrade assistant migration meta data can become stale (elastic#60789)
  [Metrics Alerts] Remove metric field from doc count on backend (elastic#60679)
  [Uptime] Skip failing location test temporarily (elastic#60938)
  [ML] Disabling datafeed editing when job is running (elastic#60751)
  Adding `authc.invalidateAPIKeyAsInternalUser` (elastic#60717)
  [SIEM] Add license check to ML Rule form (elastic#60691)
  Adding `authc.grantAPIKeyAsInternalUser`  (elastic#60423)
  Support Histogram Data Type (elastic#59387)
  [Upgrade Assistant] Fix edge case where reindex op can falsely be seen as stale (elastic#60770)
  [SIEM] [Cases] Update case icons (elastic#60812)
  [TSVB] Fix percentiles band mode (elastic#60741)
  Fix formatter on range aggregation (elastic#58651)
  Goodbye, legacy data plugin 👋 (elastic#60449)
  [Metrics UI] Alerting for metrics explorer and inventory (elastic#58779)
  [Remote clustersadopt changes to remote info API (elastic#60795)
  Only run xpack siem cypress in PRs when there are siem changes (elastic#60661)
  ...
ppisljar added a commit that referenced this pull request Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants