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

NP Migration: Move doc views registry and existing doc views into discover plugin #53465

Merged
merged 11 commits into from
Jan 7, 2020

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Dec 18, 2019

Moves the doc views registry into the setup contract of the discover plugin. Default doc views (json view and table) are also moved into the shimmed discover plugin.

Dev docs

The ui/registry/doc_views registry is removed in favor of the same functionality exposed through the setup contract of the discover plugin in core_plugins/kibana.

Old way of registering a doc view:

import { addDocView } from 'ui/registry/doc_views';

addDocView({
  title: '',
  order: 10,
  component: MyComponent,
});

New way of registering a doc view:

import { setup } from '../src/legacy/core_plugins/kibana/public/discover';

setup.addDocView({
  title: '',
  order: 10,
  component: MyComponent,
});

@flash1293 flash1293 added Feature:Discover Discover Application release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. v8.0.0 Feature:NP Migration v7.6.0 labels Dec 18, 2019
@flash1293 flash1293 requested a review from a team as a code owner December 18, 2019 10:56
@@ -43,7 +43,7 @@ describe('Test of <Doc /> helper / hook', () => {
`);
});

test('useEsDocSearch', () => {
test('useEsDocSearch', async () => {
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 is just a small cleanup getting rid of the async state update outside of act(...) warnings.
The latest react update made it possible to wait for the async updates by using asynchronous act. In the case of this test the assertions assumed no async functions would be called, so the mocks had to be slightly adjusted.

@@ -67,7 +67,7 @@ async function mountDoc(search: () => void, update = false, indexPatternGetter:
indexPatternService,
} as DocProps;
let comp!: ReactWrapper;
act(() => {
await act(async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some here - getting rid of react warnings during test run

@@ -25,7 +25,7 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { Doc, DocProps } from './doc';

jest.mock('../doc_viewer/doc_viewer', () => ({
DocViewer: 'test',
DocViewer: () => null,
Copy link
Contributor Author

@flash1293 flash1293 Dec 18, 2019

Choose a reason for hiding this comment

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

If the doc viewer is actually rendered (which happens now because of async act), test throws another warning because it's not a valid react component

@flash1293 flash1293 added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Dec 18, 2019
@flash1293 flash1293 requested a review from kertal December 18, 2019 13:20
@@ -1173,6 +1173,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| `ui/registry/field_formats` | `data.fieldFormats` | |
| `ui/registry/feature_catalogue` | `home.featureCatalogue.register` | Must add `home` as a dependency in your kibana.json. |
| `ui/registry/vis_types` | `visualizations.types` | -- |
| `ui/registry/doc_views` | `discover.addDocView` | Currently shimmed in the old platform - use `import { setup } from '../kibana/public/discover'; setup.addDocView(...)` |
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 ready to be consumed by new platform plugins? it means no webpack imports, no global angular

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's still in the legacy world for now, good point. I will remove it.

@kertal
Copy link
Member

kertal commented Dec 19, 2019

@elasticmachine merge upstream

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Started to test, and have a question, I've added the following code in discover/index.ts, to test if Angular rendering works (it does 👍 )


setup.addDocView({
  title: 'JSON-2',
  order: 30,
  directive: {
    template: '<pre>{{hitJson}}</pre>',
    scope: {
      hit: '=',
    },
    controller: ($scope: any) => {
      $scope.hitJson = JSON.stringify($scope.hit, null, 2);
    },
  },
});

but typescript complains, it might be a Promise, which could be the case, but it isn't here?

Bildschirmfoto 2019-12-19 um 17 20 02

That removes the warning, but is it wise? many thx

export const setup = pluginInstance.setup(npSetup.core, {
  ...npSetup.plugins,
  __LEGACY: {
    chrome,
  },
}) as DiscoverSetup;

@flash1293
Copy link
Contributor Author

Good point @kertal, I improved the types by changing the definition of plugin to:

export const plugin = (context: PluginInitializerContext) => {
  return new DiscoverPlugin();
};

Now .setup will refer to the actual return value of the setup method which is not async. This would also have been resolved by the planned changes to make all lifecycle methods synchronous.

@kertal kertal self-requested a review December 20, 2019 16:51
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Code LGTM, didn't test again, but it worked yesterday, also with a legacy angular component.

@flash1293 flash1293 requested a review from a team December 30, 2019 15:18
@kibanamachine
Copy link
Contributor

💔 Build Failed

History

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

@elastic elastic deleted a comment from elasticmachine Dec 30, 2019
@kibanamachine
Copy link
Contributor

💔 Build Failed

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

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@flash1293 flash1293 merged commit c02531a into elastic:master Jan 7, 2020
@flash1293 flash1293 deleted the shim-doc-views-registry branch January 7, 2020 15:53
flash1293 added a commit to flash1293/kibana that referenced this pull request Jan 7, 2020
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 7, 2020
…le-saved-objects

* 'master' of github.com:elastic/kibana: (86 commits)
  [Uptime] Added date range filter into expanded list query (elastic#52609)
  [SIEM] Add react/display-name eslint rule (elastic#53107)
  [SIEM] Enable eslint prefer-template rule (elastic#53983)
  Elasticsearch snapshots automation (elastic#53706)
  [SIEM] Enable eslint react/no-children-prop (elastic#53985)
  [DOCS][Reporting] Adds info about using a custom reporting index (elastic#54052)
  Changing background color to align with EUI color (elastic#54060)
  Fix linting issues (elastic#54068)
  NP Migration: Move doc views registry and existing doc views into discover plugin (elastic#53465)
  [ML] DF Analytics job creation: Add 'excludes' input field to form (elastic#53856)
  EMT-issue-65: add endpoint list api (elastic#53861)
  [SIEM] Fix doubled drag handles in Timeline (elastic#52679)
  Functional tests: refactor visualize_page (elastic#53845)
  [Dashboard] Redesign empty screen in readonly mode (elastic#54073)
  [ML] Support search for partitions on Single Metric Viewer (elastic#53879)
  update apm index pattern (elastic#54095)
  Add data ui for envoyproxy Metricbeat Module (elastic#53476)
  [ML] persist the brush when expanded to full width (elastic#54020)
  Skip failing test (elastic#54100)
  [APM] Show errors on the timeline instead of under the transaction (elastic#53756)
  ...

# Conflicts:
#	src/legacy/core_plugins/console/public/np_ready/application/contexts/services_context.tsx
#	src/legacy/core_plugins/console/public/np_ready/application/index.tsx
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 7, 2020
…/kibana into feature/console-saved-objects

* 'feature/console-saved-objects' of github.com:jloleysens/kibana: (86 commits)
  [Uptime] Added date range filter into expanded list query (elastic#52609)
  [SIEM] Add react/display-name eslint rule (elastic#53107)
  [SIEM] Enable eslint prefer-template rule (elastic#53983)
  Elasticsearch snapshots automation (elastic#53706)
  [SIEM] Enable eslint react/no-children-prop (elastic#53985)
  [DOCS][Reporting] Adds info about using a custom reporting index (elastic#54052)
  Changing background color to align with EUI color (elastic#54060)
  Fix linting issues (elastic#54068)
  NP Migration: Move doc views registry and existing doc views into discover plugin (elastic#53465)
  [ML] DF Analytics job creation: Add 'excludes' input field to form (elastic#53856)
  EMT-issue-65: add endpoint list api (elastic#53861)
  [SIEM] Fix doubled drag handles in Timeline (elastic#52679)
  Functional tests: refactor visualize_page (elastic#53845)
  [Dashboard] Redesign empty screen in readonly mode (elastic#54073)
  [ML] Support search for partitions on Single Metric Viewer (elastic#53879)
  update apm index pattern (elastic#54095)
  Add data ui for envoyproxy Metricbeat Module (elastic#53476)
  [ML] persist the brush when expanded to full width (elastic#54020)
  Skip failing test (elastic#54100)
  [APM] Show errors on the timeline instead of under the transaction (elastic#53756)
  ...
flash1293 added a commit that referenced this pull request Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application Feature:NP Migration release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants