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

VisTypesRegistryProvider => VisualizationsPlugin interface - Draft #43459

Closed
wants to merge 27 commits into from

Conversation

mattkime
Copy link
Contributor

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

Checklist

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

For maintainers

@mattkime mattkime requested a review from a team August 16, 2019 15:24
@mattkime mattkime changed the title swap registry with map swap registry with map - draft Aug 16, 2019
export const VisTypesRegistryProvider = {
register: (obj: VisType) => visTypes.set(obj.name, obj),
get: (key: string) => visTypes.get(key),
getAll: () => new Map(visTypes),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe change this to

getAll: () => visTypes.values(),

or

getAll: () => [...visTypes.values()],

interface VisTypesRegistryAccessors {
byName: { [typeName: string]: VisType };
}
export type VisTypesRegistry = Map<string, VisType>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe remove this line.

And instead add

export interface NewPlatformVisTypePluginContract {
  registerVisType: (visType: VisType) => void;
  get: (name: string) => VisType;
  getAll: () => IterableIterator<VisType>;
}

@mattkime mattkime added non-issue Indicates to automation that a pull request should not appear in the release notes v7.4.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:AppArch labels Aug 23, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch

@mattkime mattkime changed the title swap registry with map - draft VisTypesRegistryProvider => VisTypes New Platform interface Aug 23, 2019
@mattkime mattkime changed the title VisTypesRegistryProvider => VisTypes New Platform interface VisTypesRegistryProvider => VisualizationsPlugin interface Aug 23, 2019
@mattkime mattkime changed the title VisTypesRegistryProvider => VisualizationsPlugin interface VisTypesRegistryProvider => VisualizationsPlugin interface - Draft Aug 23, 2019
@elastic elastic deleted a comment from elasticmachine Aug 26, 2019
@elastic elastic deleted a comment from elasticmachine Aug 26, 2019
@elastic elastic deleted a comment from elasticmachine Aug 26, 2019
@elastic elastic deleted a comment from elasticmachine Aug 26, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@mattkime mattkime added v7.5.0 and removed v7.4.0 labels Aug 26, 2019
@mattkime
Copy link
Contributor Author

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@streamich streamich mentioned this pull request Aug 29, 2019
13 tasks
@elasticmachine
Copy link
Contributor

💔 Build Failed

VisTypesRegistryProvider.register(gaugeVisTypeProvider);
VisTypesRegistryProvider.register(goalVisTypeProvider);
async function registerItems() {
const $injector = await chrome.dangerouslyGetActiveInjector();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ppisljar chrome.dangerouslyGetActiveInjector(); doesn't return in the browser tests and some 80 tests fail. Perhaps we need an alternative way of registering these - what the best way to do it for a karma test?

Copy link
Member

Choose a reason for hiding this comment

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

hmm ... interesting .... i had a feeling we did this in other places that were tested by karma and it was working, will try to look into it later today if time allows.

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

i didn't check the tests yet as there are quite a few merge conflicts, but i looked thru the code and had some other comments.

@@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n';
import chrome from 'ui/chrome';
import { VisRequestHandlersRegistryProvider as RequestHandlersProvider } from 'ui/registry/vis_request_handlers';
import { VisResponseHandlersRegistryProvider as ResponseHandlerProvider } from 'ui/registry/vis_response_handlers';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
import { VisTypesRegistryProvider as visTypes } from 'ui/registry/vis_types';
Copy link
Member

Choose a reason for hiding this comment

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

you should get the registry from visualizations plugin


constructor() {
this.filters = new FiltersService();
this.types = new TypesService();
this.visualizations = new Map();
}

public setup() {
return {
filters: this.filters.setup(),
types: this.types.setup(),
Copy link
Member

Choose a reason for hiding this comment

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

its actually this types service that we should replace with 'visualizations' you created here.
types currently point to ui/registry/vis_types, but we should replace it with the map you created and provide register/get/getAll functions

@@ -64,7 +64,7 @@ describe('VegaVisualizations', () => {
uiSettings: $injector.get('config'),
};

visualizations.types.VisTypesRegistryProvider.register(() =>
visualizations.types.VisTypesRegistryProvider.register(
Copy link
Member

Choose a reason for hiding this comment

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

then we should replace all usages to the new one:
visualization.types.register(...)

@@ -18,7 +18,7 @@
*/

import './_saved_vis';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
import { VisTypesRegistryProvider as visTypes } from 'ui/registry/vis_types';
Copy link
Member

Choose a reason for hiding this comment

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

and fix all imports pointing to the old registry to import the new one

@@ -43,7 +43,7 @@ export function VisualizeListingController($injector, createNewVis) {
const kbnUrl = $injector.get('kbnUrl');
const savedObjectClient = Private(SavedObjectsClientProvider);

this.visTypeRegistry = Private(VisTypesRegistryProvider);
this.visTypeRegistry = VisTypesRegistryProvider.getAll();
Copy link
Member

Choose a reason for hiding this comment

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

as well as every place we read from the registry

@mattkime mattkime closed this Nov 12, 2019
@mattkime mattkime deleted the visTypeRegisteryD18n branch November 12, 2019 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration non-issue Indicates to automation that a pull request should not appear in the release notes release_note:skip Skip the PR/issue when compiling release notes v7.5.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants