-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
{ | ||
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', | ||
}, | ||
}, |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
…nto np/vis_default_editor
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
There was a problem hiding this 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.
There was a problem hiding this 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
* 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]>
* 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]>
* 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]>
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
functionsChecklist
Delete any items that are not applicable to this PR.
For maintainers