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

[NP] Vis Default Editor plugin #62475

Merged
merged 15 commits into from
Apr 8, 2020

Conversation

sulemanof
Copy link
Contributor

@sulemanof sulemanof commented Apr 3, 2020

Summary

Moves the vis_default_editor plugin into new platform.

Changes mostly contains files movements and paths changes.
Apart from that, since eslint ignores were removed, there are some changes related to exhaustive deps arrays in useCallback, useEffect functions

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Comment on lines -72 to -91
{
files: ['src/legacy/core_plugins/expressions/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: [
'src/legacy/core_plugins/vis_default_editor/public/components/controls/**/*.{ts,tsx}',
],
rules: {
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: ['src/legacy/ui/public/vis/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't need these ignores anymore 🎉


return (
<SwitchParamEditor
{...props}
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 was moved upper since props has a disabled field which overrides local disabled variable.
A separate fix could be prepared for this into 7.7

@flash1293 flash1293 mentioned this pull request Apr 6, 2020
69 tasks
@sulemanof sulemanof added Feature:NP Migration release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.8 v8.0.0 labels Apr 6, 2020
@elasticmachine
Copy link
Contributor

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

@sulemanof sulemanof marked this pull request as ready for review April 6, 2020 15:54
@sulemanof sulemanof requested a review from a team April 6, 2020 15:54
@sulemanof sulemanof requested a review from a team as a code owner April 6, 2020 15:54
@rayafratkina rayafratkina added v7.8.0 and removed v7.8 labels Apr 6, 2020
@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

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.

The move to the new platform looks good to me, but I'm not sure about some of the hooks fixes in a lot of files (see comment in code).

// set parsed values into model after initialization
setValue(filters.map(filter => omit({ ...filter, input: filter.input }, 'id')));
}, []);
if (firstRender.current) {
Copy link
Contributor

@flash1293 flash1293 Apr 7, 2020

Choose a reason for hiding this comment

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

So this firstRender workaround is basically an alternative to disabling linting like in https://github.com/elastic/kibana/pull/62475/files?diff=unified&w=1#diff-68df3519b81dd4040af6faf4820bd3b7R101 , right?

Why are you using both ways in different places? Subjectively I prefer the comment disabling linting for now, this seems dirtier to me.

Ideally I think we should move these "initial setups" out of react components completely, but that's definitely out of scope for this PR.

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 are right, it looks not really in place here and breaks up the React Hooks essentials,
but I wouldn't also use the eslint disabling (the one you mentioned was just accidentally missed, my fault).
I'm not sure how soon we'll be able to refactor this code due to we have a list of blockers and to-dos first to make the default editor more pure and meet meet all of React guidelines (here I mean agg configs restructure, agg types, etc).
In that case I would consider using more explicit helper - useMount from react-use , so this will look like :

import { useMount } from 'react-use';

...

  useMount(() => {
    // set parsed values into model after initialization
    setValue(filters.map(filter => omit({ ...filter, input: filter.input }, 'id')));
  });

What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for this, as we are using react-use in a bunch of places it sounds like a solution that achieves the same hiding the workaround somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@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 file moves are ok.

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.

Tested the places where hooks got changed non-trivially, couldn't find any breakages. LGTM

@sulemanof sulemanof merged commit 314c4f7 into elastic:master Apr 8, 2020
@sulemanof sulemanof deleted the np/vis_default_editor branch April 8, 2020 09:00
sulemanof added a commit to sulemanof/kibana that referenced this pull request Apr 8, 2020
* Move the default_editor to NP

* Fix paths

* Import styles through the visualize

* Other fixes

* Fix ip_ranges exhaustive-deps array

* Fix filters and extend bounds

* Other fixes

* Fix date_ranges tests

* Use useMount on first render

Co-authored-by: Elastic Machine <[email protected]>
sulemanof added a commit that referenced this pull request Apr 8, 2020
* Move the default_editor to NP

* Fix paths

* Import styles through the visualize

* Other fixes

* Fix ip_ranges exhaustive-deps array

* Fix filters and extend bounds

* Other fixes

* Fix date_ranges tests

* Use useMount on first render

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
wayneseymour pushed a commit that referenced this pull request Apr 8, 2020
* Move the default_editor to NP

* Fix paths

* Import styles through the visualize

* Other fixes

* Fix ip_ranges exhaustive-deps array

* Fix filters and extend bounds

* Other fixes

* Fix date_ranges tests

* Use useMount on first render

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Feature:NP Migration release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants