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

Expose NP FieldFormats service to server side #55419

Merged
merged 27 commits into from
Jan 27, 2020
Merged

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Jan 21, 2020

Closes: #54571

Summary

The fieldFormats service is used on the server side as well.
At the moment, it resides in src/legacy/ui/field_formats/mixin/field_formats_service.ts and only the FE plugin exposes it.

We should expose the field registry from the server side plugin at data.fieldFormats.

Dev Docs

The fieldFormats service is used on the server side as well.
At the moment, it resides in src/legacy/ui/field_formats/mixin/field_formats_service.ts and only the FE plugin exposes it.

Checklist

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

For maintainers

@alexwizp alexwizp force-pushed the 54571 branch 2 times, most recently from 09ee28a to d6cb97f Compare January 22, 2020 08:37
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@alexwizp alexwizp marked this pull request as ready for review January 22, 2020 12:11
@alexwizp alexwizp requested a review from a team as a code owner January 22, 2020 12:11
@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -244,15 +244,15 @@ module.exports = {
{
target: [
'(src|x-pack)/plugins/**/*',
'!(src|x-pack)/plugins/*/server/**/*',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified to add support for:
x-pack/legacy/plugins/reporting/export_types/csv/server/

# Conflicts:
#	src/legacy/core_plugins/kibana/index.js
#	src/legacy/ui/ui_mixin.js
@alexwizp alexwizp changed the title Expose NP FieldFormats service to server side [WIP] Expose NP FieldFormats service to server side Jan 22, 2020
@alexwizp alexwizp added the WIP Work in progress label Jan 22, 2020
@alexwizp alexwizp requested a review from a team as a code owner January 27, 2020 08:46
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.

Kibana app changes lgtm - however it would be nice if we would export FieldFormat separately from the top level so we don't have to pull it out of the helper. Not a blocker though

# Conflicts:
#	src/legacy/ui/public/agg_types/agg_config.ts
#	src/legacy/ui/public/agg_types/agg_type.ts
#	src/legacy/ui/public/agg_types/buckets/terms.ts
#	src/plugins/data/public/search/search_source/search_source.ts
Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

As far as I'm concerned, I'm ok with merging this.
We can figure out the exact interface of field formats on the server side with @elastic/kibana-platform and do a follow up.

@lukeelmers what do you think?

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@elastic elastic deleted a comment from kibanamachine Jan 27, 2020
@elastic elastic deleted a comment from kibanamachine Jan 27, 2020
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.

LGTM! Thanks for dealing with all of the merge conflicts as we were reviewing @alexwizp 😉

Comment on lines +55 to +59
/** @public */
export type FieldFormatsSetup = ReturnType<FieldFormatsService['setup']>;

/** @public */
export type FieldFormatsStart = ReturnType<FieldFormatsService['start']>;
Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes I misread that on the server the returned fieldFormatsRegistry is wrapped in the service factory. I thought they actually returned the same values which was why I commented in the first place.

In this case I agree with @lizozom, I don't want to block this PR on resolving it, so let's revisit later.

For now @alexwizp would you please add a TODO on the server service code noting that we should come back and remove the factory so server/client can have the same interface?

@lukeelmers
Copy link
Member

Just a note that I'm adding the dev docs label to this PR so that it shows up in our tooling as "missing docs" -- that way we don't forget to make the necessary updates as we approach release.

@lukeelmers lukeelmers added release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. and removed release_note:skip Skip the PR/issue when compiling release notes WIP Work in progress labels Jan 27, 2020
Copy link
Contributor

@eliperelman eliperelman left a comment

Choose a reason for hiding this comment

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

LGTM for migration.md

@alexwizp alexwizp merged commit 5d6dbf0 into elastic:master Jan 27, 2020
alexwizp added a commit to alexwizp/kibana that referenced this pull request Jan 27, 2020
* Expose NP FieldFormats service to server side

* fix CI

* fix PR comments

* fix PR comments

* fix CI

* getFieldFormatsRegistry -> getFieldFormatRegistry

* fix CI

* memoize - add resolve cache function

* fix Jest

* move IFieldFormatMetaParams to types.ts

* FieldFormatRegistry -> FieldFormatsRegistry

* update src/core/MIGRATION.md

* update public contract

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

# Conflicts:
#	x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.js
alexwizp added a commit that referenced this pull request Jan 27, 2020
* Expose NP FieldFormats service to server side (#55419)

* Expose NP FieldFormats service to server side

* fix CI

* fix PR comments

* fix PR comments

* fix CI

* getFieldFormatsRegistry -> getFieldFormatRegistry

* fix CI

* memoize - add resolve cache function

* fix Jest

* move IFieldFormatMetaParams to types.ts

* FieldFormatRegistry -> FieldFormatsRegistry

* update src/core/MIGRATION.md

* update public contract

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

# Conflicts:
#	x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.js

* fix merge conflict
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 28, 2020
…ve-out-legacy

* 'master' of github.com:elastic/kibana: (187 commits)
  [ML] Reseting categorization validation if category field is cleared (elastic#56029)
  [SIEM] Fields browser readable (elastic#56000)
  [docs] Remove unused callout (elastic#56032)
  Refactor saved object management registry usage (elastic#54155)
  [SIEM][Detection Engine] critical blocker, updates the pre-packaged rules, removes dead ones, adds license file (elastic#56090)
  Fix failing snapshot artifact tests when using env var (elastic#56063)
  Fix Github PR comment formatting (elastic#56078)
  [Maps] fix join metric field selection bugs (elastic#56044)
  Create a new menu for observability links (elastic#54847)
  [SIEM] [Detection Engine] Fixes histogram intervals  (elastic#55969)
  make test less flaky by retrying if list is re-rendered (elastic#55949)
  Remove matrix build support (elastic#54202)
  Add animation to service map layout (elastic#56042)
  [Canvas] Remove Angular and unnecessary reporting config from Canvas (elastic#54050)
  [Uptime] Simplify snapshot max to Infinity (elastic#55931)
  [Uptime] Reintroduce a column for url (elastic#55451)
  Cleanup action task params objects after successful execution (elastic#55227)
  [CI] Retry flaky tests (elastic#53961)
  Expose NP FieldFormats service to server side (elastic#55419)
  [Endpoint] EMT-65: make endpoint data types common, restructure (elastic#54772)
  ...

# Conflicts:
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/containers/panel.tsx
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/context.tsx
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/index.ts
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/split_panel.test.tsx
#	src/legacy/ui/public/vis/editors/default/default_editor.tsx
#	src/plugins/console/public/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/plugins/console/public/application/components/split_panel/components/resizer.tsx
#	src/plugins/console/public/application/components/split_panel/containers/panel.tsx
#	src/plugins/console/public/application/components/split_panel/containers/panel_container.tsx
#	src/plugins/console/public/application/components/split_panel/context.tsx
#	src/plugins/console/public/application/components/split_panel/index.ts
#	src/plugins/console/public/application/components/split_panel/registry.ts
#	src/plugins/console/public/application/components/split_panel/split_panel.test.tsx
#	src/plugins/kibana_react/public/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/plugins/kibana_react/public/split_panel/containers/panel.tsx
#	src/plugins/kibana_react/public/split_panel/context.tsx
#	src/plugins/kibana_react/public/split_panel/index.ts
#	src/plugins/kibana_react/public/split_panel/split_panel.test.tsx
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 28, 2020
* master: (77 commits)
  [ML] Reseting categorization validation if category field is cleared (elastic#56029)
  [SIEM] Fields browser readable (elastic#56000)
  [docs] Remove unused callout (elastic#56032)
  Refactor saved object management registry usage (elastic#54155)
  [SIEM][Detection Engine] critical blocker, updates the pre-packaged rules, removes dead ones, adds license file (elastic#56090)
  Fix failing snapshot artifact tests when using env var (elastic#56063)
  Fix Github PR comment formatting (elastic#56078)
  [Maps] fix join metric field selection bugs (elastic#56044)
  Create a new menu for observability links (elastic#54847)
  [SIEM] [Detection Engine] Fixes histogram intervals  (elastic#55969)
  make test less flaky by retrying if list is re-rendered (elastic#55949)
  Remove matrix build support (elastic#54202)
  Add animation to service map layout (elastic#56042)
  [Canvas] Remove Angular and unnecessary reporting config from Canvas (elastic#54050)
  [Uptime] Simplify snapshot max to Infinity (elastic#55931)
  [Uptime] Reintroduce a column for url (elastic#55451)
  Cleanup action task params objects after successful execution (elastic#55227)
  [CI] Retry flaky tests (elastic#53961)
  Expose NP FieldFormats service to server side (elastic#55419)
  [Endpoint] EMT-65: make endpoint data types common, restructure (elastic#54772)
  ...
@@ -70,6 +77,14 @@ export const reporting = (kibana: any) => {
const pluginsSetup: ReportingSetupDeps = {
usageCollection: server.newPlatform.setup.plugins.usageCollection,
};

const fieldFormatServiceFactory = async (uiSettings: IUiSettingsClient) => {
const [, plugins] = await coreSetup.getStartServices();
Copy link
Member

Choose a reason for hiding this comment

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

Hi, what does this do? This is not the only core service that we use. Why is it only necessary to implement this one using a callback?

Copy link
Member

Choose a reason for hiding this comment

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

I talked to @alexwizp and we came to an understanding that this belongs in the existing ReportingPlugin#start method: https://github.com/elastic/kibana/blob/f0fbb99/x-pack/legacy/plugins/reporting/server/plugin.ts#L114

@alexwizp will make that change, so the Reporting team does not absorb the added tech debt and can keep focus on our other migration tasks.

const kbToBase64Length = (kb: number) => {
return Math.floor((kb * 1024 * 8) / 6);
};

interface ReportingDeps {
data: DataPluginStart;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this interface? It seems redundant with ReportingSetupDeps

@tsullivan
Copy link
Member

@alexwizp @lukeelmers I have some questions about the changes to the Reporting code. When we look at how other dependencies are being pulled in for Reporting migration, this one really stands out.

@tsullivan tsullivan mentioned this pull request Jan 30, 2020
19 tasks
@kibanamachine
Copy link
Contributor

💔 Build Failed

History

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:FieldFormatters Feature:NP Migration release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose NP FieldFormats service to server side
8 participants