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

Inject UI plugins into injectedMetadata #31840

Merged
merged 13 commits into from
Mar 20, 2019
Merged

Conversation

joshdover
Copy link
Contributor

@joshdover joshdover commented Feb 22, 2019

Summary

Phase 1 of #18874
Blocked by #32578

This modifies the PluginService to expose a Map of UI plugins and their manifests, in topological order by their dependencies. That data is then exposed to injectedMetadata via the ui_render_mixin in the legacy platform, and read back out via the new platform's client-side InjectedMetadataService, preserving the topological order.

In future PRs, I'll use this data to load plugin bundles, initialize, and start plugins.

@joshdover joshdover added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.0.0 v7.2.0 labels Feb 22, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@joshdover joshdover marked this pull request as ready for review February 25, 2019 21:13
@joshdover joshdover requested review from azasypkin and epixa and removed request for epixa and azasypkin February 25, 2019 21:13
@joshdover joshdover added the WIP Work in progress label Feb 27, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@joshdover joshdover force-pushed the np-ui-plugins branch 3 times, most recently from ff7da46 to 2c5d2b1 Compare March 5, 2019 18:18
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@joshdover joshdover removed the WIP Work in progress label Mar 5, 2019
@joshdover
Copy link
Contributor Author

@azasypkin @restrry This is ready for review again. The main change is now I'm exposing the entire PluginManifest to the client-side code. This involved moving some type information around to be accessible to both client-side and server-side code and renaming some of the exposed interfaces.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@@ -17,6 +17,7 @@
* under the License.
*/

import { DiscoveredPlugin } from 'src/core/server';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a TypeScript feature to allow imports from the root of the project like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yeah I think my editor did that automatically, I'll make it relative.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@epixa
Copy link
Contributor

epixa commented Mar 12, 2019

One problem I see here is that it appears like more information is being injected in the browser and thus exposed to users than is necessary. Specifically I'd be concerned about file system path information being sent. To prevent the possibility of someone adding more information to plugin discovery in the future and not realizing it will get exposed to the browser, we should whitelist only the properties that are strictly necessary.

@joshdover
Copy link
Contributor Author

joshdover commented Mar 12, 2019

@epixa

One problem I see here is that it appears like more information is being injected in the browser and thus exposed to users than is necessary. Specifically I'd be concerned about file system path information being sent. To prevent the possibility of someone adding more information to plugin discovery in the future and not realizing it will get exposed to the browser, we should whitelist only the properties that are strictly necessary.

Good point. For solving this, I prefer to have core deciding what should and should not be exposed to the browser and then making that clear to consumers. How about changing the PluginServiceStart interface to:

/** Safe to expose to browser */
export interface DiscoveredPlugin {
  readonly id: PluginName;
  readonly configPath: ConfigPath;
  readonly requiredPlugins: ReadonlyArray<PluginName>;
  readonly optionalPlugins: ReadonlyArray<PluginName>;
}

/** Safe to use on server */
export interface DiscoveredPluginInternal extends DiscoveredPlugin {
  readonly path: string;
}

export interface PluginServiceStart {
  contracts: Map<PluginName, unknown>;
  uiPlugins: {
    public: Map<PluginName, DiscoveredPlugin>;
    internal: Map<PluginName, DiscoveredPluginInternal>;
  }
}

@epixa
Copy link
Contributor

epixa commented Mar 13, 2019

I think the terminology is a little wonky. I hate there is a concept of internal when we already have a concept of server.

I think I'm OK with that for now though.

@joshdover
Copy link
Contributor Author

I debated that a few times as well, but I think core.plugins.uiPlugins.server was just even more confusing than internal. I'll add good comment docs to uiPlugins as well to explain the difference.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@joshdover joshdover requested a review from epixa March 15, 2019 19:49
@elasticmachine
Copy link
Contributor

💔 Build Failed

@mshustov
Copy link
Contributor

retest

Copy link
Contributor

@mshustov mshustov left a comment

Choose a reason for hiding this comment

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

ok for me

src/core/server/plugins/plugins_service.ts Show resolved Hide resolved
src/core/server/plugins/plugins_system.test.ts Outdated Show resolved Hide resolved
src/core/server/plugins/plugins_system.ts Outdated Show resolved Hide resolved
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@joshdover
Copy link
Contributor Author

@epixa Did you have any more feedback on this one?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@joshdover
Copy link
Contributor Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@joshdover joshdover merged commit e51f329 into elastic:master Mar 20, 2019
@joshdover joshdover deleted the np-ui-plugins branch March 20, 2019 15:26
joshdover added a commit to joshdover/kibana that referenced this pull request Mar 20, 2019
This modifies the PluginService to expose a Map of UI plugins and their manifests, in topological order by their dependencies. That data is then exposed to injectedMetadata via the ui_render_mixin in the legacy platform, and read back out via the new platform's client-side InjectedMetadataService, preserving the topological order.
@joshdover joshdover added the release_note:skip Skip the PR/issue when compiling release notes label Mar 20, 2019
joshdover added a commit that referenced this pull request Mar 20, 2019
This modifies the PluginService to expose a Map of UI plugins and their manifests, in topological order by their dependencies. That data is then exposed to injectedMetadata via the ui_render_mixin in the legacy platform, and read back out via the new platform's client-side InjectedMetadataService, preserving the topological order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants