-
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
Charts plugin (combining ui/color_maps and EuiUtils) #55469
Conversation
Add `kbn_vislib_vis_types` to sass lint Co-Authored-By: Caroline Horn <[email protected]>
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.
maps changes LGTM
code review, tested in chrome
src/plugins/charts/public/plugin.ts
Outdated
this.colorsService.init(uiSettings); | ||
|
||
return { | ||
colorMaps: colorMapsService, |
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 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); |
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.
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.
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.
Nice!
this._mappedColors = new MappedColors(uiSettings); | ||
} | ||
|
||
vislibColor(arrayOfStringsOrNumbers?: any, colorMapping = {}) { |
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.
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
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 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; |
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.
Could we rather scope the as any
here to theme: {...} as any
?
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.
Yup great point
} | ||
|
||
/** @public */ | ||
export type ChartsPluginStart = ChartsPluginSetup; |
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.
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 init
ed services and remove init
step entirely. Not a blocker though.
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.
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
.
@nreese Could you check this once more please? I moved some services to static exports. |
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.
LGTM, tested and still seems to work fine for me
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.
lgtm
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* 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
* 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) ...
Summary
EuiUtils
plugin is now thetheme
service of the newCharts
pluginui/color_maps
is now thecolorMaps
service of the newCharts
pluginCharts
plugintheme
methods to bothsetup
andstart
contract ofCharts
pluginui/vis/components/colors
into newCharts
pluginChecklist
For maintainers