-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ScopedHistory to AppMountParams (#56705)
- Loading branch information
Showing
58 changed files
with
1,479 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
docs/development/core/public/kibana-plugin-public.appmountparameters.history.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [AppMountParameters](./kibana-plugin-public.appmountparameters.md) > [history](./kibana-plugin-public.appmountparameters.history.md) | ||
|
||
## AppMountParameters.history property | ||
|
||
A scoped history instance for your application. Should be used to wire up your applications Router. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
history: ScopedHistory<HistoryLocationState>; | ||
``` | ||
|
||
## Example | ||
|
||
How to configure react-router with a base path: | ||
|
||
```ts | ||
// inside your plugin's setup function | ||
export class MyPlugin implements Plugin { | ||
setup({ application }) { | ||
application.register({ | ||
id: 'my-app', | ||
appRoute: '/my-app', | ||
async mount(params) { | ||
const { renderApp } = await import('./application'); | ||
return renderApp(params); | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
``` | ||
|
||
```ts | ||
// application.tsx | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Router, Route } from 'react-router-dom'; | ||
|
||
import { CoreStart, AppMountParameters } from 'src/core/public'; | ||
import { MyPluginDepsStart } from './plugin'; | ||
|
||
export renderApp = ({ element, history }: AppMountParameters) => { | ||
ReactDOM.render( | ||
// pass `appBasePath` to `basename` | ||
<Router history={history}> | ||
<Route path="/" exact component={HomePage} /> | ||
</Router>, | ||
element | ||
); | ||
|
||
return () => ReactDOM.unmountComponentAtNode(element); | ||
} | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
docs/development/core/public/kibana-plugin-public.scopedhistory._constructor_.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [(constructor)](./kibana-plugin-public.scopedhistory._constructor_.md) | ||
|
||
## ScopedHistory.(constructor) | ||
|
||
Constructs a new instance of the `ScopedHistory` class | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
constructor(parentHistory: History, basePath: string); | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| parentHistory | <code>History</code> | | | ||
| basePath | <code>string</code> | | | ||
|
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.action.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [action](./kibana-plugin-public.scopedhistory.action.md) | ||
|
||
## ScopedHistory.action property | ||
|
||
The last action dispatched on the history stack. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
get action(): Action; | ||
``` |
18 changes: 18 additions & 0 deletions
18
docs/development/core/public/kibana-plugin-public.scopedhistory.block.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [block](./kibana-plugin-public.scopedhistory.block.md) | ||
|
||
## ScopedHistory.block property | ||
|
||
Not supported. Use [AppMountParameters.onAppLeave](./kibana-plugin-public.appmountparameters.onappleave.md)<!-- -->. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
block: (prompt?: string | boolean | History.TransitionPromptHook<HistoryLocationState> | undefined) => UnregisterCallback; | ||
``` | ||
|
||
## Remarks | ||
|
||
We prefer that applications use the `onAppLeave` API because it supports a more graceful experience that prefers a modal when possible, falling back to a confirm dialog box in the beforeunload case. | ||
|
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.createhref.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [createHref](./kibana-plugin-public.scopedhistory.createhref.md) | ||
|
||
## ScopedHistory.createHref property | ||
|
||
Creates an href (string) to the location. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
createHref: (location: LocationDescriptorObject<HistoryLocationState>) => string; | ||
``` |
13 changes: 13 additions & 0 deletions
13
.../development/core/public/kibana-plugin-public.scopedhistory.createsubhistory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [createSubHistory](./kibana-plugin-public.scopedhistory.createsubhistory.md) | ||
|
||
## ScopedHistory.createSubHistory property | ||
|
||
Creates a `ScopedHistory` for a subpath of this `ScopedHistory`<!-- -->. Useful for applications that may have sub-apps that do not need access to the containing application's history. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
createSubHistory: <SubHistoryLocationState = unknown>(basePath: string) => ScopedHistory<SubHistoryLocationState>; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.go.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [go](./kibana-plugin-public.scopedhistory.go.md) | ||
|
||
## ScopedHistory.go property | ||
|
||
Send the user forward or backwards in the history stack. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
go: (n: number) => void; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.goback.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [goBack](./kibana-plugin-public.scopedhistory.goback.md) | ||
|
||
## ScopedHistory.goBack property | ||
|
||
Send the user one location back in the history stack. Equivalent to calling [ScopedHistory.go(-1)](./kibana-plugin-public.scopedhistory.go.md)<!-- -->. If no more entries are available backwards, this is a no-op. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
goBack: () => void; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.goforward.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [goForward](./kibana-plugin-public.scopedhistory.goforward.md) | ||
|
||
## ScopedHistory.goForward property | ||
|
||
Send the user one location forward in the history stack. Equivalent to calling [ScopedHistory.go(1)](./kibana-plugin-public.scopedhistory.go.md)<!-- -->. If no more entries are available forwards, this is a no-op. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
goForward: () => void; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.length.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [length](./kibana-plugin-public.scopedhistory.length.md) | ||
|
||
## ScopedHistory.length property | ||
|
||
The number of entries in the history stack, including all entries forwards and backwards from the current location. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
get length(): number; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.listen.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [listen](./kibana-plugin-public.scopedhistory.listen.md) | ||
|
||
## ScopedHistory.listen property | ||
|
||
Adds a listener for location updates. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
listen: (listener: (location: Location<HistoryLocationState>, action: Action) => void) => UnregisterCallback; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.location.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [location](./kibana-plugin-public.scopedhistory.location.md) | ||
|
||
## ScopedHistory.location property | ||
|
||
The current location of the history stack. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
get location(): Location<HistoryLocationState>; | ||
``` |
41 changes: 41 additions & 0 deletions
41
docs/development/core/public/kibana-plugin-public.scopedhistory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) | ||
|
||
## ScopedHistory class | ||
|
||
A wrapper around a `History` instance that is scoped to a particular base path of the history stack. Behaves similarly to the `basename` option except that this wrapper hides any history stack entries from outside the scope of this base path. | ||
|
||
This wrapper also allows Core and Plugins to share a single underlying global `History` instance without exposing the history of other applications. | ||
|
||
The [createSubHistory](./kibana-plugin-public.scopedhistory.createsubhistory.md) method is particularly useful for applications that contain any number of "sub-apps" which should not have access to the main application's history or basePath. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare class ScopedHistory<HistoryLocationState = unknown> implements History<HistoryLocationState> | ||
``` | ||
## Constructors | ||
| Constructor | Modifiers | Description | | ||
| --- | --- | --- | | ||
| [(constructor)(parentHistory, basePath)](./kibana-plugin-public.scopedhistory._constructor_.md) | | Constructs a new instance of the <code>ScopedHistory</code> class | | ||
## Properties | ||
| Property | Modifiers | Type | Description | | ||
| --- | --- | --- | --- | | ||
| [action](./kibana-plugin-public.scopedhistory.action.md) | | <code>Action</code> | The last action dispatched on the history stack. | | ||
| [block](./kibana-plugin-public.scopedhistory.block.md) | | <code>(prompt?: string | boolean | History.TransitionPromptHook<HistoryLocationState> | undefined) => UnregisterCallback</code> | Not supported. Use [AppMountParameters.onAppLeave](./kibana-plugin-public.appmountparameters.onappleave.md)<!-- -->. | | ||
| [createHref](./kibana-plugin-public.scopedhistory.createhref.md) | | <code>(location: LocationDescriptorObject<HistoryLocationState>) => string</code> | Creates an href (string) to the location. | | ||
| [createSubHistory](./kibana-plugin-public.scopedhistory.createsubhistory.md) | | <code><SubHistoryLocationState = unknown>(basePath: string) => ScopedHistory<SubHistoryLocationState></code> | Creates a <code>ScopedHistory</code> for a subpath of this <code>ScopedHistory</code>. Useful for applications that may have sub-apps that do not need access to the containing application's history. | | ||
| [go](./kibana-plugin-public.scopedhistory.go.md) | | <code>(n: number) => void</code> | Send the user forward or backwards in the history stack. | | ||
| [goBack](./kibana-plugin-public.scopedhistory.goback.md) | | <code>() => void</code> | Send the user one location back in the history stack. Equivalent to calling [ScopedHistory.go(-1)](./kibana-plugin-public.scopedhistory.go.md)<!-- -->. If no more entries are available backwards, this is a no-op. | | ||
| [goForward](./kibana-plugin-public.scopedhistory.goforward.md) | | <code>() => void</code> | Send the user one location forward in the history stack. Equivalent to calling [ScopedHistory.go(1)](./kibana-plugin-public.scopedhistory.go.md)<!-- -->. If no more entries are available forwards, this is a no-op. | | ||
| [length](./kibana-plugin-public.scopedhistory.length.md) | | <code>number</code> | The number of entries in the history stack, including all entries forwards and backwards from the current location. | | ||
| [listen](./kibana-plugin-public.scopedhistory.listen.md) | | <code>(listener: (location: Location<HistoryLocationState>, action: Action) => void) => UnregisterCallback</code> | Adds a listener for location updates. | | ||
| [location](./kibana-plugin-public.scopedhistory.location.md) | | <code>Location<HistoryLocationState></code> | The current location of the history stack. | | ||
| [push](./kibana-plugin-public.scopedhistory.push.md) | | <code>(pathOrLocation: string | LocationDescriptorObject<HistoryLocationState>, state?: HistoryLocationState | undefined) => void</code> | Pushes a new location onto the history stack. If there are forward entries in the stack, they will be removed. | | ||
| [replace](./kibana-plugin-public.scopedhistory.replace.md) | | <code>(pathOrLocation: string | LocationDescriptorObject<HistoryLocationState>, state?: HistoryLocationState | undefined) => void</code> | Replaces the current location in the history stack. Does not remove forward or backward entries. | | ||
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.scopedhistory.push.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ScopedHistory](./kibana-plugin-public.scopedhistory.md) > [push](./kibana-plugin-public.scopedhistory.push.md) | ||
|
||
## ScopedHistory.push property | ||
|
||
Pushes a new location onto the history stack. If there are forward entries in the stack, they will be removed. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
push: (pathOrLocation: string | LocationDescriptorObject<HistoryLocationState>, state?: HistoryLocationState | undefined) => void; | ||
``` |
Oops, something went wrong.