mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
Upgrade EUI to v63.0.6 - updates to new EuiPageTemplate and deprecates old page components (#139524)
* Update all usages of EuiPageTemplate to EuiPageTemplate_Deprecated * EuiPageContent_Deprecated as EuiPageContent * EuiPageContentBody_Deprecated as EuiPageContentBody * EuiPageContentHeader_Deprecated as EuiPageContentHeader * EuiPageContentHeaderSection_Deprecated as EuiPageContentHeaderSection * EuiPageSideBar_Deprecated as EuiPageSideBar * EuiPageContent__Deprecated to EuiPageContent_Deprecated * Fix rogue semi-colons * WIP: NoDataConfigPage & NoDataPage converted to new template - `withSolutionNav` not yet handled * WIP: KibanaPageTemplateInner converted to use new template - Pushes existing `pageHeader` prompts onto created EuiPageTemplate.PageHeader - Uses `isEmptyState` to push `pageHeader` props to EuiPageTemplate.EmptyPrompt instead (if `children` are not supplied) * WIP: `withSolutionNav` now renders the sidebar content properly - Collapsing isn’t working (minWidth isn’t updating) * Fixing stickiness of sidebar * [Security] Fixed SecuritySolutionTemplateWrapper’s usage - Moved `bottomBar` to EuiPageTemplate.BottomBar (now contained in just the page contents) - Change EuiPanel children wrapper with EuiPageTemplate.Section * [O11y] Wrap `children` with EuiPageTemplate.Section * Fix getting_started usage * WIP: Fixing types * Removing `template` pass through * Set EUI to 63.0.0 * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * More import fixes * Sidebar component update * Expand `KibanaPageTemplate` to all namespaced EUI counterparts - Updated `docs/tutorials` mdx page - Fixed SolutionNav prop types * Updated the tutorial mdx page * [Stack Management] Updated app layout to new template - Some temporary props applied for BWC until all other pages can be converted - Converted `API Keys` page’s layout (and especially prompt usags) to new paradigm * Fix circular dep * Fix new circular dependency - copying and pasting types from KibanaPageTemplateProps, but ah well * [Security Solution] Remove `template` prop - no longer a prop on Kibana/EuiPageTemplate * [O11y] Allow customizing EuiPageTemplate.Section wrapper - converts pageBodyProps - fixes non-centered loading template * [Enterprise Search] Update page templates - fix layouts by auto-wrapping an EuiPageSection for padding, while adding a `customPageSections` prop for more custom sections/layouts - re-center 404 errors - update tests * Update KibanaPageTemplate tests * Update snapshots * Fix FTR test with removed EUI classNames * Fix FTR tests with changed kbn classNames * Update failing dashboard snapshots - drop shadow changed slightly in EUI * Fix failing Security Cypress test * [O11y] Fix Inventory page using deprecated CSS hooks * [O11y][Uptime] Fix missing bottom bars - Modifies ObservabilityPageTemplate to accept a `bottomBar` prop (a la the old EuiPageTemplate behavior) NOTE: This opinionated page layout structure is starting to feel like it could be potentially limiting / have all the same pitfalls the previous EuiPageTemplate did. If so, consider something closer to the Enterprise Search page template conversion (`customPageSections`). - Misc cleanup: Use `KibanaPageTemplate` over `EuiPageTemplate` * [O11y] Fix route template typing - Since theObservabilityPageTemplate is using the new Eui/KibanaPageTemplate, its child templates and types need to be updated accordingly * Fix broken minWidth behavior - was an EUI issue that required a patch release + update snapshots * [Security Solution] Type fixes, restore empty state - Fix empty state logic removed in a previous commit - bogarts KibanaPageTemplate's `isEmptyState` prop instead of using `template="noData"` - extend template wrappers to past ...rest to underlying Kibana/EuiPageTemplate + replace EuiPageTemplate with KibanaPageTemplate for consistency * Fix failing synthetics selector * Grab EUI v63.0.6 - for deprecation tags and section tag support * Fix Kibana Overview plugin layout - needs to use KibanaPageTemplate.Section to get padding back - use `bottomBorder` prop over horizontal rules - restore previous page color via panelled=false * Convert Home plugin to new KibanaPageTemplate - use KibanaPageTemplate.Section instead to preserve page width/paddings - use `bottomBorder` instead of `EuiHorizontalRule` - NOTE: This causes margins to decrease slightly from xxl to xl (largest padding available for EuiPageSection) - this can be restored by CSS overrides if desired - update CSS to preserve previous looks, + convert to logical properties * [O11y] Fix non-centered empty/loading states * [O11y] Restore subdued background on various empty state prompts * [O11y] Fix all instances of views that require a scrollable full-height child + restore comment for inventory view * [O11y][ux] Fix broken sidebar - The entire app was missing a wrapping EuiProvider, and as such breakpoint utils were not working, and the sidebar was missing + misc cleanup - remove unnecessary fragment - remove role="main" attr - now that EuiPageTemplate sets a `main` tag, they'll conflict - add isEmptyState to center loading component * [APM Cypress tests] harden flaky test * [APM Cypress tests] Fix failing Cypress test, again Co-authored-by: cchaos <caroline.horn@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
801600746d
commit
98f73d674a
325 changed files with 2198 additions and 1982 deletions
|
@ -2,20 +2,108 @@
|
|||
id: kibDevDocsKPTTutorial
|
||||
slug: /kibana-dev-docs/tutorials/kibana-page-template
|
||||
title: Kibana Page Template
|
||||
description: Learn how to create pages in Kibana
|
||||
description: Learn how to create page layouts in Kibana
|
||||
date: 2021-03-20
|
||||
tags: ['kibana', 'dev', 'ui', 'tutorials']
|
||||
tags: ['kibana', 'dev', 'ui', 'tutorials', 'pages', 'layout']
|
||||
---
|
||||
|
||||
`KibanaPageTemplate` is a thin wrapper around [EuiPageTemplate](https://elastic.github.io/eui/#/layout/page) that makes setting up common types of Kibana pages quicker and easier while also adhering to any Kibana-specific requirements and patterns.
|
||||
<DocCallOut color="warning" title="Multiple Packages">
|
||||
Be sure to import the `KibanaPageTemplate` from `@kbn/shared-ux-page-kibana-template`.
|
||||
</DocCallOut>
|
||||
|
||||
Refer to EUI's documentation on [**EuiPageTemplate**](https://elastic.github.io/eui/#/layout/page) for constructing page layouts.
|
||||
`KibanaPageTemplate` is a Kibana-specific wrapper around [EuiPageTemplate](https://elastic.github.io/eui/#/templates/page-template) and it's namespaced components such as `KibanaPageTemplate.Header`. This component makes setting up common types of Kibana pages quicker and easier while also adhering to certain Kibana-specific requirements and patterns.
|
||||
|
||||
**Refer to EUI's own documentation on [**EuiPageTemplate**](https://elastic.github.io/eui/#/templates/page-template) for constructing page layouts and inherited props.**
|
||||
|
||||
The following props are Kibana-specific extensions.
|
||||
|
||||
## `solutionNav`
|
||||
|
||||
To add left side navigation for your solution, we recommend using the provided `solutionNav` prop which is an object that extends [**EuiSideNavProps**](https://elastic.github.io/eui/#/navigation/side-nav).
|
||||
|
||||
Simply pass your array of `solutionNav.items` and the required `solution.name` and the template component will then handle the mobile views and collapsibility. For solutions and larger applications, we recommend also passing an `solutionNav.icon`.
|
||||
|
||||
```tsx
|
||||
<KibanaPageTemplate
|
||||
solutionNav={{
|
||||
name: 'Management',
|
||||
icon: 'managementApp',
|
||||
items: [
|
||||
{
|
||||
name: 'Root item',
|
||||
items: [
|
||||
{ name: 'Navigation item', href: '#' },
|
||||
{ name: 'Navigation item', href: '#' },
|
||||
]
|
||||
}
|
||||
]
|
||||
}}
|
||||
>
|
||||
{...}
|
||||
</KibanaPageTemplate>
|
||||
```
|
||||
|
||||
> When using `EuiSideNav`, root level items should not be linked but provide section labelling only.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
If you need custom solution navigation **content**, you can pass your own `solutionNav.children` instead of the items or supply your own componen with `<KibanaPageTemplate.Sidebar>` We still recommend using [**EuiSideNav**](https://elastic.github.io/eui/#/navigation/side-nav).
|
||||
|
||||
## `noDataConfig`
|
||||
|
||||
Increases the consistency in messaging across all the solutions during the getting started process when no data exists. Each solution/template instance decides when is the most appropriate time to show this configuration, but is messaged specifically towards having **no indices and/or data views at all or that match the particular solution**.
|
||||
|
||||
This is a built-in configuration that displays a very specific UI and requires very specific object keys. It will also ignore all other configurations of the template including `pageHeader` and `children`, with the exception of continuing to show `solutionNav`.
|
||||
|
||||
The `noDataConfig` is of type [`NoDataPageProps`](https://github.com/elastic/kibana/blob/main/packages/kbn-shared-ux-components/src/page_template/no_data_page/types.ts):
|
||||
|
||||
1. `solution: string`: Single name for the current solution, used to auto-generate the title, logo, and description _(required)_
|
||||
2. `docsLink: string`: Required to set the docs link for the whole solution _(required)_
|
||||
3. `logo?: string`: Optionally replace the auto-generated logo
|
||||
4. `pageTitle?: string`: Optionally replace the auto-generated page title (h1)
|
||||
5. `action: NoDataPageActions`: An object of `NoDataPageActions` configurations with a single primary key _(required)_
|
||||
|
||||
### `NoDataPageActions`
|
||||
|
||||
There is currently only one promotoed path to ingesting data and that is through the Fleet / Ingest UI. This gets presented to the user by rendering a card that provides consistent messaging. It is mostly pre-configured but require specific `href`s and/or `onClick` handlers for directing the user to the right location for that solution.
|
||||
|
||||
Optionally you can also replace the `button` label by passing a string, or the whole button component by passing a `ReactNode`.
|
||||
|
||||
```tsx
|
||||
// Perform your own check
|
||||
const hasData = checkForData();
|
||||
|
||||
// No data configuration
|
||||
const noDataConfig: KibanaPageTemplateProps['noDataConfig'] = {
|
||||
solution: 'Analytics',
|
||||
logo: 'logoKibana',
|
||||
docsLink: '#',
|
||||
action: {
|
||||
elasticAgent: {
|
||||
href: '#',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Conditionally apply the configuration if there is no data
|
||||
<KibanaPageTemplate
|
||||
solutionNav={/* Solution navigation still show if it exists and use the right template type */}
|
||||
pageHeader={/* Page header will be ignored */}
|
||||
noDataConfig={hasData ? undefined : noDataConfig}
|
||||
>
|
||||
{/* Children will be ignored */}
|
||||
</KibanaPageTemplate>;
|
||||
```
|
||||
|
||||

|
||||
|
||||
## `isEmptyState`
|
||||
|
||||
Use the `isEmptyState` prop for when there is no page content to show. For example, before the user has created something, when no search results are found, before data is populated, or when permissions aren't met.
|
||||
Use the `isEmptyState` prop for when there is no page **content** to show. This is for when the user **has data** but has not created the thing that the page displays. For example, before the user has created something, when no search results are found, before data is populated, or when permissions aren't met.
|
||||
|
||||
The default empty state uses any `pageHeader` info provided to populate an [**EuiEmptyPrompt**](https://elastic.github.io/eui/#/display/empty-prompt) and uses the `centeredBody` template type.
|
||||
This prop is a simple boolean uses any `pageHeader` info provided to populate an centered [**EuiPageTemplate.EmptyPrompt**](https://elastic.github.io/eui/#/templates/page-template#empty-pages-or-content).
|
||||
|
||||
```tsx
|
||||
<KibanaPageTemplate
|
||||
|
@ -40,13 +128,13 @@ The default empty state uses any `pageHeader` info provided to populate an [**Eu
|
|||
render blank. Make sure your empty state doesn't leave the user confused.
|
||||
</DocCallOut>
|
||||
|
||||
### Custom empty state
|
||||
### Custom empty states
|
||||
|
||||
You can also provide a custom empty prompt to replace the pre-built one. You'll want to remove any `pageHeader` props and pass an [`EuiEmptyPrompt`](https://elastic.github.io/eui/#/display/empty-prompt) directly as the child of KibanaPageTemplate.
|
||||
You can also provide a custom empty prompt to replace the pre-built one using [`KibanaPageTemplate.EmptyPrompt`](https://elastic.github.io/eui/#/display/empty-prompt) as a child of KibanaPageTemplate.
|
||||
|
||||
```tsx
|
||||
<KibanaPageTemplate isEmptyState={true}>
|
||||
<EuiEmptyPrompt
|
||||
<KibanaPageTemplate>
|
||||
<KibanaPageTemplate.EmptyPrompt
|
||||
title={<h1>No data</h1>}
|
||||
body="You have no data. Would you like some of ours?"
|
||||
actions={[
|
||||
|
@ -62,16 +150,15 @@ You can also provide a custom empty prompt to replace the pre-built one. You'll
|
|||
|
||||
### Empty states with a page header
|
||||
|
||||
When passing both a `pageHeader` configuration and `isEmptyState`, the component will render the proper template (`centeredContent`). Be sure to reduce the heading level within your child empty prompt to `<h2>`.
|
||||
When passing both a `pageHeader` configuration and rendering a `KibanaPageTemplate.EmptyPrompt`, be sure to reduce the heading level within your child empty prompt to `<h2>`.
|
||||
|
||||
```tsx
|
||||
<KibanaPageTemplate
|
||||
isEmptyState={true}
|
||||
pageHeader={{
|
||||
pageTitle: 'Dashboards',
|
||||
}}
|
||||
>
|
||||
<EuiEmptyPrompt
|
||||
<KibanaPageTemplate.EmptyPrompt
|
||||
title={<h2>No data</h2>}
|
||||
body="You have no data. Would you like some of ours?"
|
||||
actions={[
|
||||
|
@ -84,89 +171,3 @@ When passing both a `pageHeader` configuration and `isEmptyState`, the component
|
|||
```
|
||||
|
||||

|
||||
|
||||
## `solutionNav`
|
||||
|
||||
To add left side navigation for your solution, we recommend passing [**EuiSideNav**](https://elastic.github.io/eui/#/navigation/side-nav) props to the `solutionNav` prop. The template component will then handle the mobile views and add the solution nav embellishments. On top of the EUI props, you'll need to pass your solution `name` and an optional `icon`.
|
||||
|
||||
If you need to custom side bar content, you will need to pass you own navigation component to `pageSideBar`. We still recommend using [**EuiSideNav**](https://elastic.github.io/eui/#/navigation/side-nav).
|
||||
|
||||
When using `EuiSideNav`, root level items should not be linked but provide section labelling only.
|
||||
|
||||
```tsx
|
||||
<KibanaPageTemplate
|
||||
solutionNav={{
|
||||
name: 'Management',
|
||||
icon: 'managementApp',
|
||||
items: [
|
||||
{
|
||||
name: 'Root item',
|
||||
items: [
|
||||
{ name: 'Navigation item', href: '#' },
|
||||
{ name: 'Navigation item', href: '#' },
|
||||
]
|
||||
}
|
||||
]
|
||||
}}
|
||||
>
|
||||
{...}
|
||||
</KibanaPageTemplate>
|
||||
```
|
||||
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## `noDataConfig`
|
||||
|
||||
Increases the consistency in messaging across all the solutions during the getting started process when no data exists. Each solution/template instance decides when is the most appropriate time to show this configuration, but is messaged specifically towards having no indices or index patterns at all or that match the particular solution.
|
||||
|
||||
This is a built-in configuration that displays a very specific UI and requires very specific keys. It will also ignore all other configurations of the template including `pageHeader` and `children`, with the exception of continuing to show `solutionNav`.
|
||||
|
||||
The `noDataConfig` is of type [`NoDataPagProps`](https://github.com/elastic/kibana/blob/main/src/plugins/kibana_react/public/page_template/no_data_page/no_data_page.tsx):
|
||||
|
||||
1. `solution: string`: Single name for the current solution, used to auto-generate the title, logo, and description *(required)*
|
||||
2. `docsLink: string`: Required to set the docs link for the whole solution *(required)*
|
||||
3. `logo?: string`: Optionally replace the auto-generated logo
|
||||
4. `pageTitle?: string`: Optionally replace the auto-generated page title (h1)
|
||||
5. `actions: NoDataPageActionsProps`: An object of `NoDataPageActions` configurations with unique primary keys *(required)*
|
||||
|
||||
### `NoDataPageActions`
|
||||
|
||||
There are two main actions for adding data that we promote throughout Kibana, Elastic Agent and Beats. They are added to the cards that are displayed by using the keys `elasticAgent` and `beats` respectively. For consistent messaging, these two cards are pre-configured but require specific `href`s and/or `onClick` handlers for directing the user to the right location for that solution.
|
||||
|
||||
It also accepts a `recommended` prop as a boolean to promote one or more of the cards through visuals added to the UI. It will also place the `recommended` ones first in the list. Optionally you can also replace the `button` label by passing a string, or the whole component by passing a `ReactNode`.
|
||||
|
||||
|
||||
```tsx
|
||||
// Perform your own check
|
||||
const hasData = checkForData();
|
||||
|
||||
// No data configuration
|
||||
const noDataConfig: KibanaPageTemplateProps['noDataConfig'] = {
|
||||
solution: 'Analytics',
|
||||
logo: 'logoKibana',
|
||||
docsLink: '#',
|
||||
actions: {
|
||||
beats: {
|
||||
href: '#',
|
||||
},
|
||||
elasticAgent: {
|
||||
href: '#',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Conditionally apply the configuration if there is no data
|
||||
<KibanaPageTemplate
|
||||
solutionNav={/* Solution navigation still show if it exists and use the right template type */}
|
||||
pageHeader={/* Page header will be ignored */}
|
||||
noDataConfig={hasData ? undefined : noDataConfig}
|
||||
>
|
||||
{/* Children will be ignored */}
|
||||
</KibanaPageTemplate>
|
||||
```
|
||||
|
||||
|
||||

|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue