elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.78k stars 8.19k forks source link

[Discuss] Refactor PageTemplate Component #125664

Open majagrubic opened 2 years ago

majagrubic commented 2 years ago

Current state

The problem with the current PageTemplate component is that the logic for rendering its layout is closely tied to specific solutions. Eg:

We'd like to create a component that is a bit more lightweight, with the data needed for rendering decoupled from the layout itself.

Proposal

The idea is to create a registry, that could be accessed by a certain plugin. The registry would contain two pieces of information:

  1. how to render layout
  2. no data config

The registry would have 2 corresponding setters and 2 corresponding getters, eg.

addNoDataLayoutProps(name, props)
getNoDataLayoutProps(name)
addNoDataConfig(name, noDataConfig)
getNoDataConfig(name)

The component to render empty state would then only take name as a prop and would render EuiTemplate with appropriate props and a NoDataPage with the appropriate config, both obtained from the register.

The appropriate plugins would need to call the registry at setup time, and add their appropriate configs to the registry. This requires a bit more work on each solution's side than just 1-1 mapping to the new page.

cchaos commented 2 years ago

I see how this idea tackles specifically the "No data" screens. Can this proposal also generally apply to the page layouts that have data?

majagrubic commented 2 years ago

Can you clarify which pages do you mean exactly?

cchaos commented 2 years ago

The KibanaPageTemplate component is currently used by all solutions (with the exception of a few like Discover). If we refactor, it will affect all page layouts, not just the "No data" screens.

For example all the listing pages use it:

image

Observability wraps it creating a specific Observability Page template to handle side navigation and loading states:

image

This proposal only specifies getting/setting the no data configuration, but there's a lot more that the KibanaPageTemplate handles by passing through to EuiPageTemplate like pageHeader content and sidebar configurations. I'm just wondering what the proposal is to continue to support all these settings per page.

majagrubic commented 2 years ago

Thanks for clarifying. My goal is not to tamper with PageTemplate at all for now, I'd just like to extract the "no data" part into a separate component, that would be as lightweight as possible. So to answer your initial question - no, it won't affect the layouts that have data.