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

Move ensureDefaultIndexPattern into data plugin #63100

Merged
merged 14 commits into from
Apr 24, 2020

Conversation

sulemanof
Copy link
Contributor

@sulemanof sulemanof commented Apr 9, 2020

Summary

Since we started moving legacy plugins into NP,
this comment #59895 (comment) became more than relevant.
While importing ensureDefaultIndexPattern statically, it gets into different plugins bundles, so such variables as bannerId & timeoutId, which are tracked for banner appeared, are not in sync between apps and eventually ends up with duplicated banners (currently the dashboard is in NP, but discover & visualize are about to be moved, so there would be 3 copies of the same banner):

duplicated_banner

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@sulemanof sulemanof force-pushed the np/move_ensure_index_pattern branch from 1345cb5 to 6d0a4e0 Compare April 9, 2020 13:33
@sulemanof sulemanof marked this pull request as ready for review April 9, 2020 14:57
@sulemanof sulemanof requested a review from a team April 9, 2020 14:57
@sulemanof sulemanof requested a review from a team as a code owner April 9, 2020 14:57
@sulemanof sulemanof added release_note:skip Skip the PR/issue when compiling release notes v7.8.0 v8.0.0 labels Apr 9, 2020
@@ -182,6 +183,7 @@ export class DataPublicPlugin implements Plugin<DataPublicPluginSetup, DataPubli
ui: {
IndexPatternSelect: createIndexPatternSelect(core.savedObjects.client),
SearchBar,
ensureDefaultIndexPattern: createEnsureDefaultIndexPattern(core, indexPatterns),
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 this should not be exported from here.
It's not really a UI component, and the naming makes it extra unclear.
It looks more like it should be a useDefaultIndexPattern hook, that is exported from kibana_react.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would be the best way to implement this (except the thing about showing the warning banner, it would be disappeared right after a plugin is destroyed),
but unfortunately, right now it's only used across angular driven plugins and I guess there is no way to integrate this pattern well there

Copy link
Contributor

Choose a reason for hiding this comment

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

@lizozom What do you think about exporting this from IndexPatternsService?

Copy link
Member

Choose a reason for hiding this comment

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

It looks more like it should be a useDefaultIndexPattern hook, that is exported from kibana_react

I agree the ergonomics of this would be better. The only problem is that the way this helper is currently written (with bannerId and timeoutId being stateful), means we really have no choice but to put it somewhere in the runtime contract of the data plugin, as kibana_utils and kibana_react are only imported statically.

I don't have strong feelings on whether it goes in ui or IndexPatternsService, but since it contains state that needs to be shared across apps, it seems those are our only options outside of refactoring the function altogether and storing that state elsewhere (e.g. sessionStorage).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So what would be the final decision?
Should it stay in ui or moved into IndexPatternsService, or even postponed in respect of #57401 ?

Copy link
Member

Choose a reason for hiding this comment

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

If @lizozom doesn't like the idea of putting it in ui, then IMHO it's fine to put it on IndexPatternsService. She should be available tomorrow and can hopefully chime in if she has any other ideas.

or even postponed in respect of #57401 ?

I don't think we should wait on that issue to fix this bug. That discussion is still in early stages & I don't know when the actual implementation will be prioritized.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sulemanof

I think moving it to the index pattern service is better.
It's not an actual UI component.

Thanks!

@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

@sulemanof
Copy link
Contributor Author

This was eventually moved into IndexPatternsService.
Ready for review. cc @lukeelmers @flash1293

@sulemanof
Copy link
Contributor Author

@elasticmachine merge upstream

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.

Tested in Chrome and works as expected. Just wondering why documentation changed for the search service...

isStringType: (agg: import("./search").AggConfig) => boolean;
isType: (type: string) => (agg: import("./search").AggConfig) => boolean;
isType: (...types: string[]) => (agg: import("./search").AggConfig) => boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this change coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems all of the docs changes were not directly related to changes in this PR,
because after the last merge with the master, all of them are just gone (means the same changes have been already merged -> https://github.com/elastic/kibana/blob/master/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md#search-variable)

Copy link
Contributor

Choose a reason for hiding this comment

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

Weird, I thought we had a check for that in the build.

Copy link
Contributor

Choose a reason for hiding this comment

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

CI checks that the latest api.json file is up to date and committed but doesn't verify that docs (based on this file) are up to date. so if you --accept api changes but don't commit the new docs this could happen.

…dex_pattern

# Conflicts:
#	docs/development/plugins/data/public/kibana-plugin-plugins-data-public.createsearchsource.md
#	src/plugins/data/public/public.api.md
Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

Code changes here LGTM.

My only nit would be that it'd be nice to add ensureDefaultIndexPattern to our src/data/public/mocks.ts for completeness. The mocks aren't complete for index patterns ATM anyway, but even a simple jest.fn() would be a useful starting point and save us from needing to add this later.

@sulemanof sulemanof requested a review from a team as a code owner April 24, 2020 11:28
@sulemanof
Copy link
Contributor Author

My only nit would be that it'd be nice to add ensureDefaultIndexPattern to our src/data/public/mocks.ts for completeness. The mocks aren't complete for index patterns ATM anyway, but even a simple jest.fn() would be a useful starting point and save us from needing to add this later.

@lukeelmers I'd just deleted the mock in this commit to prevent adding the platform team into this thread, because it makes to update couple of snapshots in management, since it has already lasted too long 😄
Returned back, snapshots updated. Hope this will end up eventually 🙂

Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

👍 For platform changes

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@sulemanof sulemanof merged commit 9bda6bd into elastic:master Apr 24, 2020
@sulemanof sulemanof deleted the np/move_ensure_index_pattern branch April 24, 2020 13:20
sulemanof added a commit to sulemanof/kibana that referenced this pull request Apr 24, 2020
* Move ensure_default_index_pattern into data plugin

* Update docs to include ensureDefaultIndexPattern

* Fix translations

* Move helper into index_patterns service

* Update docs

* Remove mock

* Add mock

Co-authored-by: Elastic Machine <[email protected]>
sulemanof added a commit that referenced this pull request Apr 24, 2020
* Move ensure_default_index_pattern into data plugin

* Update docs to include ensureDefaultIndexPattern

* Fix translations

* Move helper into index_patterns service

* Update docs

* Remove mock

* Add mock

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 27, 2020
…bana into ingest-node-pipeline/open-flyout-create-edit

* 'feature/ingest-node-pipelines' of github.com:elastic/kibana: (116 commits)
  [Ingest Node Pipelines] More lenient treatment of on-failure value (elastic#64411)
  Report Deletion via UI- functional test (elastic#64031)
  Bump handlebars dependency from 4.5.3 to 4.7.6 (elastic#64402)
  [Uptime] Update TLS settings (elastic#64111)
  [alerting] removes usage of any throughout Alerting Services code (elastic#64161)
  [CANVAS] Moves notify to a canvas service (elastic#63268)
  [Canvas] Misc NP Stuff (elastic#63703)
  update apm index pattern (elastic#64232)
  Task/hostlist pagination (elastic#63722)
  [NP] Vega migration (elastic#63849)
  Move ensureDefaultIndexPattern into data plugin (elastic#63100)
  [Fleet] Fix agent status count to not include unenrolled agents (elastic#64106)
  Migrate graph_workspace saved object registration to Kibana platform (elastic#64157)
  Index pattern management UI -> TypeScript and New Platform Ready (edit_index_pattern) (elastic#64184)
  [ML] EuiDataGrid ml/transform components. (elastic#63447)
  [ML] Moving to kibana capabilities (elastic#64057)
  Move input_control_vis into NP (elastic#63333)
  remove reference to local application service in graph (elastic#64288)
  KQL removes leading zero and breaks query (elastic#62748)
  [FieldFormats] Cleanup: rename IFieldFormatType -> FieldFormatInstanceType (elastic#64193)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported release_note:skip Skip the PR/issue when compiling release notes v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants