Skip to content

Commit 921c942

Browse files
Michail Yasonikcchaoscchaoskibanamachine
authored
Unifying converting listing pages to new layout (#98651)
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> Co-authored-by: cchaos <caroline.horn@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 238fc3a commit 921c942

File tree

18 files changed

+1042
-649
lines changed

18 files changed

+1042
-649
lines changed
124 KB
Loading
130 KB
Loading
124 KB
Loading

dev_docs/building_blocks.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ Check out the Map Embeddable if you wish to embed a map in your application.
7070

7171
**Github labels**: `Team:Geo`
7272

73+
### KibanaPageTemplate
74+
75+
All Kibana pages should use KibanaPageTemplate to setup their pages. It's 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.
76+
77+
Check out <DocLink id="kibDevDocsKBTTutorial" text="the KibanaPageTemplate tutorial" /> for more implementation guidance.
78+
79+
**Github labels**: `EUI`
80+
7381
## Searching
7482

7583
### Index Patterns
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
id: kibDevDocsKBLTutorial
3+
slug: /kibana-dev-docs/tutorials/kibana-page-layout
4+
title: KibanaPageLayout component
5+
summary: Learn how to create pages in Kibana
6+
date: 2021-03-20
7+
tags: ['kibana', 'dev', 'ui', 'tutorials']
8+
---
9+
10+
`KibanaPageLayout` 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.
11+
12+
Refer to EUI's documentation on [EuiPageTemplate](https://elastic.github.io/eui/#/layout/page) for constructing page layouts.
13+
14+
## `isEmptyState`
15+
16+
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.
17+
18+
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.
19+
20+
```tsx
21+
<KibanaPageLayout
22+
isEmptyState={true}
23+
pageHeader={{
24+
iconType: 'dashboardApp',
25+
pageTitle: 'Dashboards',
26+
description: "You don't have any dashboards yet.",
27+
rightSideItems: [
28+
<EuiButton fill iconType="plusInCircleFilled">
29+
Create new dashboard
30+
</EuiButton>,
31+
],
32+
}}
33+
/>
34+
```
35+
36+
![Screenshot of demo empty state code. Shows the Kibana navigation bars and a centered empty state with the dashboard app icon, a level 1 heading "Dashboards", body text "You don't have any dashboards yet.", and a button that says "Create new dashboard".](../assets/kibana_default_empty_state.png)
37+
38+
<DocCallOut color="warning" title="Missing page header content can lead to an anemic empty state">
39+
Because all properties of the page header are optional, the empty state has the potential to
40+
render blank. Make sure your empty state doesn't leave the user confused.
41+
</DocCallOut>
42+
43+
### Custom empty state
44+
45+
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 KibanaPageLayout.
46+
47+
```tsx
48+
<KibanaPageLayout isEmptyState={true}>
49+
<EuiEmptyPrompt
50+
title={<h1>No data</h1>}
51+
body="You have no data. Would you like some of ours?"
52+
actions={[
53+
<EuiButton fill iconType="plusInCircleFilled">
54+
Get sample data
55+
</EuiButton>,
56+
]}
57+
/>
58+
</KibanaPageLayout>
59+
```
60+
61+
![Screenshot of demo custom empty state code. Shows the Kibana navigation bars and a centered empty state with the a level 1 heading "No data", body text "You have no data. Would you like some of ours?", and a button that says "Get sample data".](../assets/kibana_custom_empty_state.png)
62+
63+
### Empty states with a page header
64+
65+
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>`.
66+
67+
```tsx
68+
<KibanaPageLayout
69+
isEmptyState={true}
70+
pageHeader={{
71+
pageTitle: 'Dashboards',
72+
}}
73+
>
74+
<EuiEmptyPrompt
75+
title={<h2>No data</h2>}
76+
body="You have no data. Would you like some of ours?"
77+
actions={[
78+
<EuiButton fill iconType="plusInCircleFilled">
79+
Get sample data
80+
</EuiButton>,
81+
]}
82+
/>
83+
</KibanaPageLayout>
84+
```
85+
86+
![Screenshot of demo custom empty state code with a page header. Shows the Kibana navigation bars, a level 1 heading "Dashboards", and a centered empty state with the a level 2 heading "No data", body text "You have no data. Would you like some of ours?", and a button that says "Get sample data".](../assets/kibana_header_and_empty_state.png)

0 commit comments

Comments
 (0)