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

Reactify visualize app #67848

Merged
merged 27 commits into from
Jun 29, 2020
Merged

Conversation

sulemanof
Copy link
Contributor

@sulemanof sulemanof commented Jun 1, 2020

Summary

De-Angularize Visualize app

Closes #59811
Closes #65613
Closes #68509 , can't reproduce it with these changes.

The main aim of the PR is to get rid of Angular and use React & React-Router in Visualize.
Visualize still uses hash router internally; moving it to browser router which uses the ScopedHistory object under the hood is a separate task, since it will cause a lot of changes in other places.

Visual changes

I've mostly tried to save existing behavior, but eventually added a few changes.
Here they are:

  • experimental vis info banner was changed to use EuiCallOut:

    experimental_vis_info

  • navigation to nonexistent route now is redirected to the visualize landing page (instead of using kibanaLegacy.navigateToDefaultApp() ) and is accompanied by a banner message:

image

  • creating a new vis with invalid params now handled with toasts and redirects to the landing page

Other changes(enhancements)

  • Vis is not reloaded after save, just URL is replaced;
  • added additional error handling with toast notifications (e.x. failed to create a visualization with invalid type or without an index pattern).

Note: Unit tests will be provided in a separate PR to decouple reviewers work 🙂

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@sulemanof sulemanof force-pushed the np/reactify_visualize branch from 11eca48 to ba5ac21 Compare June 12, 2020 07:58
@@ -17,12 +17,8 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';

export const defaultFeedbackMessage = i18n.translate('kibana_utils.defaultFeedbackMessage', {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of exporting defaultFeedbackMessage from kibana_utils to every experimental vis (input_control, vega, metrics), I moved it into visualize: https://github.com/elastic/kibana/pull/67848/files#diff-1d6c318a6f1b7dcab619931a74884297

@@ -104,12 +110,12 @@ function DefaultEditorSideBar({
aggs: state.data.aggs ? (state.data.aggs.aggs.map((agg) => agg.toJSON()) as any) : [],
},
});
eventEmitter.emit('updateVis');
embeddableHandler.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.

Instead of emitting an event from a particular editor, and handle it in visualize as:

image

reload it inside an editor outright (IMHO it's more evident)

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

merge conflict between base and head

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Not finished yet, will continue tomorrow

@@ -56,7 +56,7 @@ export function createSavedVisLoader(services: SavedObjectKibanaServicesWithVisu
source.icon = source.type.icon;
source.image = source.type.image;
source.typeTitle = source.type.title;
source.editUrl = `#/edit/${id}`;
source.editUrl = `/edit/${id}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this should be #/edit/${id} for now as the PR isn't switching to path routing yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I'm not wrong, this is used only used in visualize for navigating to a visualization from the listing page. In new implementation, history.push is used for navigating, where the history object is a hash history object, so it accepts paths without leading #.
Apart from this case, I didn't find any usages of this.
Navigating from other apps (e.x. from discover/dashboard/canvas) works well.
If I missed smth, please let me know! 🙂

>
<VisualizeListing />
</Route>
<Redirect to={VisualizeConstants.LANDING_PAGE_PATH} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note: #68284 will run into conflicts with this because it changes the redirect logic on unmatched routes. We can solve that on the other PR though, no strong opinion on what gets merged first. #68284 is a blocker for 7.9 but otherwise it should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with the VisualizeNoMatch component

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Not sure whether introduced by this change or something else, but the search bar is shown in embedded mode:
Screenshot 2020-06-16 at 10 51 32

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

UI state is not persisted:

  • Create area chart with multiple series
  • Change color of one series by clicking the dot in the legend and selecting another color
  • Save vis
  • Go to listing page
  • Select vis again
  • Color is not selected anymore

Same for table sorting in TSVB

# Conflicts:
#	src/plugins/visualize/public/application/legacy_app.js
@sulemanof
Copy link
Contributor Author

Not sure whether introduced by this change or something else, but the search bar is shown in embedded mode:
Screenshot 2020-06-16 at 10 51 32

Hm, interesting things happen around embeded mode.
In kibana 7.4.0, 7.5.0 full navigation panel exists:

image

but it doesn't exist in 7.0.0 up to 7.4.0, and from 7.6.0 up to master.
So what is the expected behavior?

@flash1293
Copy link
Contributor

Good question. @timroes do you know what's up with that?

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Code seems LGTM to me, but I haven't tested it yet. Will continue it asap. I can confirm so far that #68509 is fixed 🍰

@sulemanof sulemanof requested a review from a team as a code owner June 19, 2020 15:08
Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Tested on Chrome, seems LGTM

@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

SASS files LGTM

# Conflicts:
#	src/plugins/visualize/public/application/editor/editor.js
#	src/plugins/visualize/public/application/legacy_app.js
#	src/plugins/visualize/public/kibana_services.ts
#	src/plugins/visualize/public/plugin.ts
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Only tested the legacy redirect logic in Chrome and Firefox, works like a charm. LGTM 👍

It even fixes the back button breakage on paths that are normalized on the fly 💯

@majagrubic @ThomThomson This PR is a great blueprint for doing the same thing in Dashboard

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 code changes LGTM.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
kibanaUtils 158 -1 159
visualize 179 +4 175
total - +3 -

History

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

@sulemanof sulemanof merged commit 19bda1f into elastic:master Jun 29, 2020
@sulemanof sulemanof deleted the np/reactify_visualize branch June 29, 2020 14:21
sulemanof added a commit that referenced this pull request Jun 30, 2020
* Reactify visualize app

* Fix typescript failures after merging master

* Make sure refresh button works

* Subscribe filter manager fetches

* Use redirect to landing page

* Update savedSearch type

* Add check for TSVB is loaded

* Fix comments

* Fix uiState persistence on vis load

* Remove extra div around TableListView

* Update DTS selectors

* Add error handling for embeddable

* Remove extra argument from useEditorUpdates effect

* Update comments, fix typos

* Remove extra div wrapper

* Apply design suggestions

* Revert accidental config changes

* Apply navigating to dashboard

* Apply redirect legacy urls

* Apply incoming changes

* Apply incoming changes

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Bamieh pushed a commit to Bamieh/kibana that referenced this pull request Jul 1, 2020
* Reactify visualize app

* Fix typescript failures after merging master

* Make sure refresh button works

* Subscribe filter manager fetches

* Use redirect to landing page

* Update savedSearch type

* Add check for TSVB is loaded

* Fix comments

* Fix uiState persistence on vis load

* Remove extra div around TableListView

* Update DTS selectors

* Add error handling for embeddable

* Remove extra argument from useEditorUpdates effect

* Update comments, fix typos

* Remove extra div wrapper

* Apply design suggestions

* Revert accidental config changes

* Apply navigating to dashboard

* Apply redirect legacy urls

* Apply incoming changes

* Apply incoming changes

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
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 Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.9.0 v8.0.0
Projects
None yet
9 participants