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

[Console] Refactoring more legacy code and implementing minor fixes #51312

Merged
merged 5 commits into from
Nov 25, 2019

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Nov 21, 2019

Summary

In preparation for future work on Console this contribution proposes we create state slices using React Context (similar to redux, but less verbose since the state model here isn't that big). Some features of the new model:

  • Flux like architecture (more reactive model)
  • Use hooks as actions/sagas
  • Enables flexibility for future changes given that contexts can be pulled in as/where needed

Future work this will compliment:

  • Introducing new modes into the editor (e.g., SQL), there is now a better pattern for where to place something like this with EditorContext.
  • UX/UI improvements around request lifecycles. With the RequestContext we can consume this in the UI where we need it
  • Moving toward new features and more user/business data we can create a specific context for it

Fixes included here:

  • Switching between using or not using triple quotes now happens "live" (before you had to re-run your request)
  • Fixed ES lint issues with the existing react hooks

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@jloleysens jloleysens added Feature:Console Dev Tools Console Feature Feature:Dev Tools v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes v7.6.0 labels Nov 21, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

@jloleysens nice job with the refactor. Looks great! I did some generally testing against Console and did not find any regressions.

{
files: ['src/legacy/core_plugins/console/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can #49543 be closed once this PR is merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep!

*/

import { Reducer } from 'react';
import { produce } from 'immer';
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL about immer 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha yeah it's really great 🎉

Copy link
Member

Choose a reason for hiding this comment

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

Talking about immer, it seems we need to add this dependency into package.json, I see it only in xpack/package.json, but this is OSS plugin @jloleysens (curious if this code works at all in OSS-only build?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@azasypkin After building with node ./scripts/build.js --oss --docker --skip-archives --skip-os-packages and opening console I saw the following:

Screenshot 2020-01-02 at 11 43 57

I'll open a fix PR shortly 👍. Thanks for weighing in here!

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@jloleysens jloleysens merged commit 793f1f1 into elastic:master Nov 25, 2019
@jloleysens jloleysens deleted the console/refactor branch November 25, 2019 17:28
jloleysens added a commit to jloleysens/kibana that referenced this pull request Nov 25, 2019
…lastic#51312)

* First part of context refactor

* Finised "hook"ing in to new context for old editor output. Also fixed passing through of content type

* Remove comment

* - update console history behaviour - don't scroll into view on click. Doesn't really make sense.
- make triple quote setting update in place
jloleysens added a commit that referenced this pull request Nov 26, 2019
…51312) (#51622)

* First part of context refactor

* Finised "hook"ing in to new context for old editor output. Also fixed passing through of content type

* Remove comment

* - update console history behaviour - don't scroll into view on click. Doesn't really make sense.
- make triple quote setting update in place
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Console Dev Tools Console Feature Feature:Dev Tools release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants