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

Charts plugin (combining ui/color_maps and EuiUtils) #55469

Merged
merged 67 commits into from
Jan 28, 2020

Conversation

nickofthyme
Copy link
Contributor

@nickofthyme nickofthyme commented Jan 21, 2020

Summary

  • The EuiUtils plugin is now the theme service of the new Charts plugin
  • ui/color_maps is now the colorMaps service of the new Charts plugin
  • Fix all imports of each to pull from new Charts plugin
  • Add theme methods to both setup and start contract of Charts plugin
  • Move ui/vis/components/colors into new Charts plugin

Checklist

For maintainers

nickofthyme and others added 30 commits December 18, 2019 14:03
Add `kbn_vislib_vis_types` to sass lint

Co-Authored-By: Caroline Horn <[email protected]>
@nickofthyme nickofthyme marked this pull request as ready for review January 23, 2020 00:49
@nickofthyme nickofthyme requested a review from a team as a code owner January 23, 2020 00:49
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

maps changes LGTM
code review, tested in chrome

this.colorsService.init(uiSettings);

return {
colorMaps: colorMapsService,
Copy link
Contributor

Choose a reason for hiding this comment

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

You are exposing the color maps service via the contract, but it looks like it is just offering static helper functions and is not tied to any internal state of the plugin - is this correct? If yes you can just re-export it from the top level index.ts of the charts plugin and import where needed. Then this problem is also solved directly.


return (value: string) => {
// @ts-ignore
return colorMapping[value] || this.mappedColors.get(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you specify colorMapping as Partial<Record<string, string>> in https://github.com/elastic/kibana/pull/55469/files#diff-4026f17dfd1c005f7bc2f012cb664948R50 , then you don't need to overwrite type checking here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice!

this._mappedColors = new MappedColors(uiSettings);
}

vislibColor(arrayOfStringsOrNumbers?: any, colorMapping = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's just used by vislib right now, but can we rename that function? Maybe createColorLookupFunction - naming is hard :D But I think it's better than having that legacy name in here

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Tested locally in watcher and EUI utils looks to be working as expected.

Left some non-blocker comments.

useChartsTheme: jest.fn(),
},
// For our test harness, we don't use this mocked out http service
http: httpServiceMock.createSetupContract(),
};
} as any;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rather scope the as any here to theme: {...} as any?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup great point

}

/** @public */
export type ChartsPluginStart = ChartsPluginSetup;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to expose the same interface for start and setup from this plugin? This seems like something that would most naturally fit into just setup.

Also, if we just expose at setup time we can remove the need to check for inited services and remove init step entirely. Not a blocker though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's necessary long term but it was currently being used in both so I resorted to the init approach over using getStartServices.

@nickofthyme
Copy link
Contributor Author

@nreese Could you check this once more please? I moved some services to static exports.

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.

LGTM, tested and still seems to work fine for me

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

lgtm

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@nickofthyme nickofthyme merged commit 05ed2d6 into elastic:master Jan 28, 2020
@nickofthyme nickofthyme deleted the kpm/charts-plugin branch January 28, 2020 14:14
nickofthyme added a commit that referenced this pull request Jan 28, 2020
* Combine ui/color_maps and EuiUtils into new Charts plugin
* EuiUtils is now the theme service
* ui/color_maps is now the colorMaps service
* Fix all imports of each to pull from new Charts plugin
* Add theme methods to both setup and start contracts
* Move and jestify heatMapColors tests
* Convert remaining js files to ts
* Move vis/color to Charts plugin
* Update missed visTypeVislib naming
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 28, 2020
* master: (21 commits)
  [SIEM][Detection Engine] critical blocker updates to latest ECS version
  [Monitoring] Fix inaccuracies in logstash pipeline listing metrics (elastic#55868)
  Resetting errors and removing duplicates (elastic#56054)
  Add flag to opt out from sub url tracking (elastic#55672)
  [SIEM][Detection Engine] critical bug, fixes duplicate tags
  [ML] Anomaly Detection: Fix persist/restore of refreshInterval in globalState. (elastic#56113)
  [ML] Single Metric Viewer: Fix annnotations refresh. (elastic#56107)
  adapt ObjectToConfigAdapter.getFlattenedPaths to consider arrays as final values (elastic#56105)
  Add Appender.receiveAllLevels option to fix LegacyAppender (elastic#55752)
  [ML] Process delimited files like semi-structured text (elastic#56038)
  Charts plugin (combining ui/color_maps and EuiUtils) (elastic#55469)
  fix tutorial documentation (elastic#55996)
  [ML] Fix persist/restore of time/refreshInterval in data visualizer. (elastic#56122)
  [Index Management] Fix errors with validation (elastic#56072)
  [Index Management] Add try/catch when parsing index filter from URI (elastic#56051)
  [NP] add HTTP resources testing strategies (elastic#54908)
  [ML] Single Metric Viewer: Fix brush update on short recent timespans. (elastic#56125)
  [Uptime] Add timeout for slow process to skipped functional tests (elastic#56065)
  refactor (elastic#56121)
  Move tests in dashboard into appropriate folders (elastic#55304)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants