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

Add server rendering service to enable standalone route rendering #52161

Merged
merged 23 commits into from
Dec 29, 2019

Conversation

eliperelman
Copy link
Contributor

@eliperelman eliperelman commented Dec 4, 2019

Summary

Introduces a new backend application service which exposes rendering ability from a registered provider. The new server rendering service exposes a RenderingProvider to core for contextual rendering access during an HTTP request: await context.core.rendering.render(). This can be used directly as the content (i.e. response body) for a bootstrapped page.

Blocks #51527.

TODO

  • File an issue to migrate the bootstrap.js endpoint
  • File an issue to remove injected vars from KP
  • Ping teams to removed injected vars

Checklist

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

For maintainers

Dev Docs

Render a bootstrapped HTML page from a route handler using the RenderingService from your server plugin:

const router = createRouter();

router.get(
  { path: '/', validate: false },
  (context, request, response) =>
    response.ok({
      headers: {
        'content-security-policy': context.core.http.csp.header,
      },
      body: await context.core.rendering.render(),
    })
);

@eliperelman eliperelman added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. v8.0.0 v7.6.0 labels Dec 4, 2019
@eliperelman eliperelman requested review from a team as code owners December 4, 2019 09:43
@eliperelman eliperelman self-assigned this Dec 4, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@elasticmachine
Copy link
Contributor

💔 Build Failed

src/core/server/rendering/rendering_provider.tsx Outdated Show resolved Hide resolved
src/core/server/http/csp.test.ts Outdated Show resolved Hide resolved
src/core/server/http/http_config.ts Outdated Show resolved Hide resolved
src/core/server/http/http_service.mock.ts Show resolved Hide resolved
src/core/server/legacy/legacy_service.ts Outdated Show resolved Hide resolved
src/core/server/rendering/types.ts Show resolved Hide resolved
src/legacy/server/kbn_server.d.ts Outdated Show resolved Hide resolved
src/legacy/ui/ui_render/ui_render_mixin.js Outdated Show resolved Hide resolved
src/plugins/testbed/server/index.ts Outdated Show resolved Hide resolved
test/api_integration/apis/core/index.js Outdated Show resolved Hide resolved
@eliperelman eliperelman force-pushed the feature/rendering-service branch from db70d9c to 813641e Compare December 4, 2019 18:47
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@joshdover joshdover left a comment

Choose a reason for hiding this comment

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

A few issues I noticed:

  • The Kibana logo is missing on the bootstrap loading page spinner
  • The frontend fails to boot with this error: A legacy application is already registered with the id "siem" (I'm guessing you already noticed this one though)

src/core/server/rendering/types.ts Outdated Show resolved Hide resolved
src/core/server/rendering/types.ts Outdated Show resolved Hide resolved
src/core/server/rendering/rendering_service.ts Outdated Show resolved Hide resolved
src/core/server/rendering/rendering_service.ts Outdated Show resolved Hide resolved
src/legacy/ui/ui_render/ui_render_mixin.js Show resolved Hide resolved
test/api_integration/apis/core/index.js Outdated Show resolved Hide resolved
src/core/server/rendering/create_metadata_factory.ts Outdated Show resolved Hide resolved
@eliperelman eliperelman force-pushed the feature/rendering-service branch from 64c967e to becf2bb Compare December 28, 2019 04:21
@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

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

@eliperelman eliperelman merged commit 054ec70 into elastic:master Dec 29, 2019
eliperelman added a commit to eliperelman/kibana that referenced this pull request Dec 29, 2019
…astic#52161)

* Add server rendering service to enable standalone route rendering

* Update renovate config

* Move legacy rendering functionality to legacy service

* Use config for exposed variable in new platform

* Lint changes from rebase

* Rebase artifact

* Remove RenderingProvider, add tests for legacy vars implementation, review notes

* Add UI app functionality to legacy service

* Update rendering snapshots

* Update docs

* Fix up functional tests

* Clean up legacy types

* Revise types from reverting injected metadata changes

* Update translations and broken tests

* Mock legacy internals in legacy tests

* Add missing doc types

* Rename InternalRenderOptions to LegacyRenderOptions

* Remove extraneous legacy exports, review nits

* Functional tests fixes

* Rebase, attempt CI test fixes

* Only allow specified appIds in testbed rendering integration test

* Update snapshot names

* Review nits
eliperelman added a commit that referenced this pull request Dec 29, 2019
…2161) (#53832)

* Add server rendering service to enable standalone route rendering

* Update renovate config

* Move legacy rendering functionality to legacy service

* Use config for exposed variable in new platform

* Lint changes from rebase

* Rebase artifact

* Remove RenderingProvider, add tests for legacy vars implementation, review notes

* Add UI app functionality to legacy service

* Update rendering snapshots

* Update docs

* Fix up functional tests

* Clean up legacy types

* Revise types from reverting injected metadata changes

* Update translations and broken tests

* Mock legacy internals in legacy tests

* Add missing doc types

* Rename InternalRenderOptions to LegacyRenderOptions

* Remove extraneous legacy exports, review nits

* Functional tests fixes

* Rebase, attempt CI test fixes

* Only allow specified appIds in testbed rendering integration test

* Update snapshot names

* Review nits
gmmorris added a commit to gmmorris/kibana that referenced this pull request Dec 30, 2019
* master:
  Allow chromeless applications to render via non-/app routes (elastic#51527)
  Add server rendering service to enable standalone route rendering (elastic#52161)
jloleysens added a commit to jloleysens/kibana that referenced this pull request Dec 30, 2019
…le-saved-objects

* 'master' of github.com:elastic/kibana: (250 commits)
  Allow chromeless applications to render via non-/app routes (elastic#51527)
  Add server rendering service to enable standalone route rendering (elastic#52161)
  Possibility to filter when testing scripted fields (elastic#35379) (elastic#44220)
  Update maps telemetry mappings to account for recent updates (elastic#53803)
  [Maps] Only show legend when layer is visible (elastic#53781)
  remove use of experimental fs.promises api (elastic#53346)
  [APM] Add log statements for flaky test (elastic#53775)
  [APM] Transaction page throws unhandled exception if transactions doesn't have  `http.request` (elastic#53760)
  Licensing plugin functional tests (elastic#53580)
  [Lens] Disable saving visualization until there are no changes to the document (elastic#52982)
  [Monitoring] Added safeguard for some EUI components (elastic#53318)
  [Vega] Shim new platform - cleanup vega_visualization dependencies (elastic#53605)
  Display changed field formats without requiring hard page refresh. (elastic#53746)
  Upgrade EUI to v17.3.1 (elastic#53655)
  [APM] Fix missing apm indicies (elastic#53541)
  Disable inspector for timelion (elastic#53747)
  Clean up search servie (elastic#53701)
  [Dashboard] Grid: removing double handler (elastic#53707)
  Remove SavedObjectRegistryProvider from codebase (elastic#53455)
  Move ui/courier into data shim plugin (elastic#52359)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 2, 2020
…ris/kibana into alerting/created_at-and-updated_at

* 'alerting/created_at-and-updated_at' of github.com:gmmorris/kibana:
  Allow chromeless applications to render via non-/app routes (elastic#51527)
  Add server rendering service to enable standalone route rendering (elastic#52161)
jkelastic pushed a commit to jkelastic/kibana that referenced this pull request Jan 8, 2020
…astic#52161)

* Add server rendering service to enable standalone route rendering

* Update renovate config

* Move legacy rendering functionality to legacy service

* Use config for exposed variable in new platform

* Lint changes from rebase

* Rebase artifact

* Remove RenderingProvider, add tests for legacy vars implementation, review notes

* Add UI app functionality to legacy service

* Update rendering snapshots

* Update docs

* Fix up functional tests

* Clean up legacy types

* Revise types from reverting injected metadata changes

* Update translations and broken tests

* Mock legacy internals in legacy tests

* Add missing doc types

* Rename InternalRenderOptions to LegacyRenderOptions

* Remove extraneous legacy exports, review nits

* Functional tests fixes

* Rebase, attempt CI test fixes

* Only allow specified appIds in testbed rendering integration test

* Update snapshot names

* Review nits
@kibanamachine
Copy link
Contributor

💔 Build Failed

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

@flash1293
Copy link
Contributor

@eliperelman It seems like there is a small typo in your dev docs example -

        'content-security-policy': context.core.http.csp.header,

should actually be

        'content-security-policy': core.http.csp.header,

At least that's what the types say. Could you confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants