Skip to content

Commit 708ccae

Browse files
Expose fatalErrors API from the Start contract (elastic#55300)
* Expose FatalErrors from the Start contract. This API is intended to be used for runtime as well. * update docs * update data plugin snapshot to fix tests * address comments Co-authored-by: Elastic Machine <[email protected]>
1 parent 5122ac3 commit 708ccae

16 files changed

+123
-35
lines changed
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2-
3-
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [ChromeNavLinks](./kibana-plugin-public.chromenavlinks.md) &gt; [update](./kibana-plugin-public.chromenavlinks.update.md)
4-
5-
## ChromeNavLinks.update() method
6-
7-
> Warning: This API is now obsolete.
8-
>
9-
> Uses the [AppBase.updater$](./kibana-plugin-public.appbase.updater_.md) property when registering your application with [ApplicationSetup.register()](./kibana-plugin-public.applicationsetup.register.md) instead.
10-
>
11-
12-
Update the navlink for the given id with the updated attributes. Returns the updated navlink or `undefined` if it does not exist.
13-
14-
<b>Signature:</b>
15-
16-
```typescript
17-
update(id: string, values: ChromeNavLinkUpdateableFields): ChromeNavLink | undefined;
18-
```
19-
20-
## Parameters
21-
22-
| Parameter | Type | Description |
23-
| --- | --- | --- |
24-
| id | <code>string</code> | |
25-
| values | <code>ChromeNavLinkUpdateableFields</code> | |
26-
27-
<b>Returns:</b>
28-
29-
`ChromeNavLink | undefined`
30-
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [ChromeNavLinks](./kibana-plugin-public.chromenavlinks.md) &gt; [update](./kibana-plugin-public.chromenavlinks.update.md)
4+
5+
## ChromeNavLinks.update() method
6+
7+
> Warning: This API is now obsolete.
8+
>
9+
> Uses the [AppBase.updater$](./kibana-plugin-public.appbase.updater_.md) property when registering your application with [ApplicationSetup.register()](./kibana-plugin-public.applicationsetup.register.md) instead.
10+
>
11+
12+
Update the navlink for the given id with the updated attributes. Returns the updated navlink or `undefined` if it does not exist.
13+
14+
<b>Signature:</b>
15+
16+
```typescript
17+
update(id: string, values: ChromeNavLinkUpdateableFields): ChromeNavLink | undefined;
18+
```
19+
20+
## Parameters
21+
22+
| Parameter | Type | Description |
23+
| --- | --- | --- |
24+
| id | <code>string</code> | |
25+
| values | <code>ChromeNavLinkUpdateableFields</code> | |
26+
27+
<b>Returns:</b>
28+
29+
`ChromeNavLink | undefined`
30+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [CoreStart](./kibana-plugin-public.corestart.md) &gt; [fatalErrors](./kibana-plugin-public.corestart.fatalerrors.md)
4+
5+
## CoreStart.fatalErrors property
6+
7+
[FatalErrorsStart](./kibana-plugin-public.fatalerrorsstart.md)
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
fatalErrors: FatalErrorsStart;
13+
```

docs/development/core/public/kibana-plugin-public.corestart.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface CoreStart
1919
| [application](./kibana-plugin-public.corestart.application.md) | <code>ApplicationStart</code> | [ApplicationStart](./kibana-plugin-public.applicationstart.md) |
2020
| [chrome](./kibana-plugin-public.corestart.chrome.md) | <code>ChromeStart</code> | [ChromeStart](./kibana-plugin-public.chromestart.md) |
2121
| [docLinks](./kibana-plugin-public.corestart.doclinks.md) | <code>DocLinksStart</code> | [DocLinksStart](./kibana-plugin-public.doclinksstart.md) |
22+
| [fatalErrors](./kibana-plugin-public.corestart.fatalerrors.md) | <code>FatalErrorsStart</code> | [FatalErrorsStart](./kibana-plugin-public.fatalerrorsstart.md) |
2223
| [http](./kibana-plugin-public.corestart.http.md) | <code>HttpStart</code> | [HttpStart](./kibana-plugin-public.httpstart.md) |
2324
| [i18n](./kibana-plugin-public.corestart.i18n.md) | <code>I18nStart</code> | [I18nStart](./kibana-plugin-public.i18nstart.md) |
2425
| [injectedMetadata](./kibana-plugin-public.corestart.injectedmetadata.md) | <code>{</code><br/><code> getInjectedVar: (name: string, defaultValue?: any) =&gt; unknown;</code><br/><code> }</code> | exposed temporarily until https://github.com/elastic/kibana/issues/41990 done use \*only\* to retrieve config values. There is no way to set injected values in the new platform. Use the legacy platform API instead. |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [FatalErrorsStart](./kibana-plugin-public.fatalerrorsstart.md)
4+
5+
## FatalErrorsStart type
6+
7+
FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
export declare type FatalErrorsStart = FatalErrorsSetup;
13+
```

docs/development/core/public/kibana-plugin-public.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
129129
| [ChromeHelpExtensionMenuGitHubLink](./kibana-plugin-public.chromehelpextensionmenugithublink.md) | |
130130
| [ChromeHelpExtensionMenuLink](./kibana-plugin-public.chromehelpextensionmenulink.md) | |
131131
| [ChromeNavLinkUpdateableFields](./kibana-plugin-public.chromenavlinkupdateablefields.md) | |
132+
| [FatalErrorsStart](./kibana-plugin-public.fatalerrorsstart.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. |
132133
| [HandlerContextType](./kibana-plugin-public.handlercontexttype.md) | Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-public.handlerfunction.md) to represent the type of the context. |
133134
| [HandlerFunction](./kibana-plugin-public.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-public.icontextcontainer.md) |
134135
| [HandlerParameters](./kibana-plugin-public.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-public.handlerfunction.md)<!-- -->, excluding the [HandlerContextType](./kibana-plugin-public.handlercontexttype.md)<!-- -->. |

src/core/public/core_system.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export class CoreSystem {
214214
const http = await this.http.start({ injectedMetadata, fatalErrors: this.fatalErrorsSetup! });
215215
const savedObjects = await this.savedObjects.start({ http });
216216
const i18n = await this.i18n.start();
217+
const fatalErrors = await this.fatalErrors.start();
217218
await this.integrations.start({ uiSettings });
218219

219220
const coreUiTargetDomElement = document.createElement('div');
@@ -271,6 +272,7 @@ export class CoreSystem {
271272
notifications,
272273
overlays,
273274
uiSettings,
275+
fatalErrors,
274276
};
275277

276278
const plugins = await this.plugins.start(core);

src/core/public/fatal_errors/fatal_errors_service.mock.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,22 @@ const createSetupContractMock = () => {
2626

2727
return setupContract;
2828
};
29+
const createStartContractMock = createSetupContractMock;
2930

3031
type FatalErrorsServiceContract = PublicMethodsOf<FatalErrorsService>;
3132
const createMock = () => {
3233
const mocked: jest.Mocked<FatalErrorsServiceContract> = {
3334
setup: jest.fn(),
35+
start: jest.fn(),
3436
};
3537

3638
mocked.setup.mockReturnValue(createSetupContractMock());
39+
mocked.start.mockReturnValue(createStartContractMock());
3740
return mocked;
3841
};
3942

4043
export const fatalErrorsServiceMock = {
4144
create: createMock,
4245
createSetupContract: createSetupContractMock,
46+
createStartContract: createStartContractMock,
4347
};

src/core/public/fatal_errors/fatal_errors_service.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ export interface FatalErrorsSetup {
5454
get$: () => Rx.Observable<FatalErrorInfo>;
5555
}
5656

57+
/**
58+
* FatalErrors stop the Kibana Public Core and displays a fatal error screen
59+
* with details about the Kibana build and the error.
60+
*
61+
* @public
62+
*/
63+
export type FatalErrorsStart = FatalErrorsSetup;
64+
5765
/** @interal */
5866
export class FatalErrorsService {
5967
private readonly errorInfo$ = new Rx.ReplaySubject<FatalErrorInfo>();
68+
private fatalErrors?: FatalErrorsSetup;
6069

6170
/**
6271
*
@@ -82,7 +91,7 @@ export class FatalErrorsService {
8291
},
8392
});
8493

85-
const fatalErrorsSetup: FatalErrorsSetup = {
94+
this.fatalErrors = {
8695
add: (error, source?) => {
8796
const errorInfo = getErrorInfo(error, source);
8897

@@ -101,9 +110,17 @@ export class FatalErrorsService {
101110
},
102111
};
103112

104-
this.setupGlobalErrorHandlers(fatalErrorsSetup);
113+
this.setupGlobalErrorHandlers(this.fatalErrors!);
105114

106-
return fatalErrorsSetup;
115+
return this.fatalErrors!;
116+
}
117+
118+
public start() {
119+
const { fatalErrors } = this;
120+
if (!fatalErrors) {
121+
throw new Error('FatalErrorsService#setup() must be invoked before start.');
122+
}
123+
return fatalErrors;
107124
}
108125

109126
private renderError(injectedMetadata: InjectedMetadataSetup, i18n: I18nStart) {

src/core/public/fatal_errors/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
* under the License.
1818
*/
1919

20-
export { FatalErrorsSetup, FatalErrorsService } from './fatal_errors_service';
20+
export { FatalErrorsSetup, FatalErrorsStart, FatalErrorsService } from './fatal_errors_service';
2121
export { FatalErrorInfo } from './get_error_info';

src/core/public/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import {
5555
ChromeRecentlyAccessed,
5656
ChromeRecentlyAccessedHistoryItem,
5757
} from './chrome';
58-
import { FatalErrorsSetup, FatalErrorInfo } from './fatal_errors';
58+
import { FatalErrorsSetup, FatalErrorsStart, FatalErrorInfo } from './fatal_errors';
5959
import { HttpSetup, HttpStart } from './http';
6060
import { I18nStart } from './i18n';
6161
import { InjectedMetadataSetup, InjectedMetadataStart, LegacyNavLink } from './injected_metadata';
@@ -233,6 +233,8 @@ export interface CoreStart {
233233
overlays: OverlayStart;
234234
/** {@link IUiSettingsClient} */
235235
uiSettings: IUiSettingsClient;
236+
/** {@link FatalErrorsStart} */
237+
fatalErrors: FatalErrorsStart;
236238
/**
237239
* exposed temporarily until https://github.com/elastic/kibana/issues/41990 done
238240
* use *only* to retrieve config values. There is no way to set injected values
@@ -303,6 +305,7 @@ export {
303305
DocLinksStart,
304306
FatalErrorInfo,
305307
FatalErrorsSetup,
308+
FatalErrorsStart,
306309
HttpSetup,
307310
HttpStart,
308311
I18nStart,

0 commit comments

Comments
 (0)