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

Remove src/plugins/vis_default_editor -> src/plugins/visualizations cyclic dependencies #86988

Merged
merged 15 commits into from
Jan 11, 2021

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Dec 29, 2020

Part of #84750

Summary

Removes circular dependencies between vis_default_editor and visualizations plugins.

The dependencies that were removed based on the node scripts/find_plugins_with_circular_deps --debug script.

Dev docs

What was changed in that PR:

  1. ISchemas and Schema interfaces were moved from vis_default_editor to visualizations plugin.
  2. Schemas class was moved from vis_default_editor to visualizations plugin (now it's a private class, we should not use it out of visualizations plugin)
  3. Type definition object for visualizations was changed:

Before:

  {
       editorConfig: {
         schemas: new Schemas([{schemaObject1, schemasObject2}])
      }
    }

Now:

{
     editorConfig: {
       schemas: [{schemaObject1, schemasObject2}]
    }
  }

@alexwizp alexwizp self-assigned this Dec 29, 2020
@alexwizp alexwizp added v7.12.0 v8.0.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure release_note:skip Skip the PR/issue when compiling release notes Feature:Visualizations Generic visualization features (in case no more specific feature label is available) labels Dec 29, 2020
@elastic elastic deleted a comment from kibanamachine Dec 29, 2020
@alexwizp alexwizp marked this pull request as ready for review December 29, 2020 16:10
@alexwizp alexwizp requested a review from a team December 29, 2020 16:10
@alexwizp alexwizp requested a review from a team as a code owner December 29, 2020 16:10
@elasticmachine
Copy link
Contributor

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

Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

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

operations - Circular dependency list LGTM

tooltip?: ReactNode;
}
import { AggGroupNames, AggParam } from '../../data/public';
import type { ISchemas, Schema } from '../../visualizations/public';

export class Schemas implements ISchemas {
Copy link
Contributor

Choose a reason for hiding this comment

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

discuss: I don't have a strong opinion here, but I'm not sure the Schemas class should stay in vis_default_editor since now..
Is there any reason to leave it here ?
Assuming interfaces were moved into visualizations, the class definition should be also moved there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I've checked that and looks like you are right. visualizations is more suitable place for that. Initially I thought that we use it only in vis_default_editor

Copy link
Contributor

@stratoula stratoula Jan 5, 2021

Choose a reason for hiding this comment

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

I don't have a strong opinion either but I think that Schemas class is highly connected with the editor so I am not sure that it should be part of the visualizations plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stratoula I don't agree with you that it's more connected with vis_default_editor. From my point of view It's related to visualizations cause other plugins read this value though public schemas field in VisType object (see src/plugins/visualizations/public/vis_types/base_vis_type.ts)

What I did it my last commit:

  • Schemas marked as private for vizualizations plugin and now we use it only from one place. In future we can probably remove it cause I don't see any reason to keep that class. We use it only for restructure initial type.editorConfig.schemas array. Perhaps we can create simple static functions to make this more obvious.

@timroes please correct me if I'm wrong but I see our current design like on screen below (sorry for ugly picture). The main idea here that our visualizations should not know about about the visDefaultEditor and use API-types from visualizations plugin. It allow us to simply change change the editor just by modifying schema in future

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok Aliaksei, I see your point and the last change has made things a little bit better. I will approve it as it removes the dependencies between the plugins.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Schemas were already a bit on the fence and still are unfortunately. While I think the sole purpose they are used today are the default editor and to build its UI (and thus I would say semantically they belong most into the default editor plugin), we returned them as a high level concept from the VisType as Alexej mentioned and thus they became a core concept of the vis registration itself (and should belong in visualizations).

So I would see two options:

  • Change the API that Schemas will not be returned as a core concept of visualization registry, but be purely part of the editor, e.g. by passing it into a property of the default editor explciitly and always specifying the default editor explicitly (like registerVisType({ ..., editor: () => <DefaultEditor schemas={schemas} />, ... })) and then move then also in vis default editor and keep them there, or
  • (the easier solution for now): don't change the APIs and keep them as they are, in which case I think they need to live in Visualizations for now, since they are a high level concern of VisType (and the registry).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timroes It's looks like a right things, but unfortunately not only the vis_default_editor uses schemas and it was a blocker why I didn't remove it at all in that PR. At least one plugin vis_type_xy reads that value (see src/plugins/vis_type_xy/public/editor/components/options/metrics_axes/index.tsx) and to avoid any regression I decided to keep it in visualizations plugin. Semantically currently it's a best place for that.

From my point of view, we should:

  • visualizations plugin should have only Schema interface; It probably should be renamed to EditorSchema
  • Schemas class and ISchema interface should be removed at all;
  • For vis_default_editor we should create simple functions to extract metrics/buckets from the editorConfig.schemas in more obvious way.
  • Think why vis_type_xy uses schemas. Looks strange

But it's out of that PR. If you agree with me or have your own plan to refactor that let's create a new item for that.

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.

LGTM, didn't test
The only my concern is about leaving the Schema class in vis_default_editor, but it's OK to be merged overall

Copy link
Contributor

@kindsun kindsun left a comment

Choose a reason for hiding this comment

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

Region and tile map changes lgtm w/ green CI!

  • code review
  • tested locally in chrome

@alexwizp
Copy link
Contributor Author

alexwizp commented Jan 3, 2021

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor Author

alexwizp commented Jan 5, 2021

@elasticmachine merge upstream

@alexwizp alexwizp added release_note:breaking and removed release_note:skip Skip the PR/issue when compiling release notes labels Jan 5, 2021
@alexwizp
Copy link
Contributor Author

alexwizp commented Jan 6, 2021

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

expected head sha didn’t match current head ref.

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

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.

LGTM, tested locally with Safari. No regressions found and the cyclic dependencies are gone.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visualizations 153 154 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
visDefaultEditor 300.9KB 301.1KB +232.0B
visTypeTable 153.9KB 153.7KB -188.0B
visTypeVislib 643.7KB 643.7KB +1.0B
visualizations 61.4KB 61.4KB +2.0B
total +47.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
regionMap 44.4KB 44.4KB -41.0B
tileMap 44.5KB 44.5KB -41.0B
visDefaultEditor 46.5KB 44.3KB -2.2KB
visTypeMetric 26.4KB 26.3KB -41.0B
visTypeTagcloud 19.0KB 18.9KB -16.0B
visTypeVislib 46.7KB 46.4KB -217.0B
visTypeXy 68.3KB 68.0KB -247.0B
visualizations 169.3KB 171.2KB +1.9KB
total -895.0B

History

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

@alexwizp alexwizp merged commit 66c8b2a into elastic:master Jan 11, 2021
alexwizp added a commit to alexwizp/kibana that referenced this pull request Jan 11, 2021
…yclic dependencies (elastic#86988)

* Remove src/plugins/vis_default_editor -> src/plugins/visualizations cyclic dependencies

Part of elastic#86758

* Update agg_common_props.ts

* Schemas -> visualizations

* fix JEST

* make Schemas class private for visualizations plugin

* fix type error

* fix markdown app in visualize app

* remove visualizations from kibana.json's

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 11, 2021
* master:
  [APM] Define placement “Right” to offset tooltip (elastic#87729)
  Fix UI glitch on SOM delete confirmation modal (elastic#87623)
  Remove src/plugins/vis_default_editor -> src/plugins/visualizations cyclic dependencies (elastic#86988)
  [Timelion] Fix tests flakiness on suggestion click (elastic#87273)
  [Uptime] Fix/details page tabs (elastic#86296)
  [ML] Fix earliest and latest texts for date fields (elastic#87482)
  chore(NA): move grokdebugger plugin test fixtures out of __tests__ folder (elastic#87765)
  [Security Solution] Refactor Cypress scenarios to use internal contex… (elastic#86609)
  [Security Solution] Unskip cypress tests (elastic#86653)
alexwizp added a commit that referenced this pull request Jan 11, 2021
…yclic dependencies (#86988) (#87804)

* Remove src/plugins/vis_default_editor -> src/plugins/visualizations cyclic dependencies

Part of #86758

* Update agg_common_props.ts

* Schemas -> visualizations

* fix JEST

* make Schemas class private for visualizations plugin

* fix type error

* fix markdown app in visualize app

* remove visualizations from kibana.json's

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@timroes timroes added release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. and removed release_note:breaking labels Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants