mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* feat: 🎸 add uiSettings service in "start" Core * test: 💍 add test for uiSettings#start() lifecycle * fix: 🐛 add uiSettings to plugin context * docs: ✏️ update Core API docs * fix: 🐛 fix TypeScript type check errors
This commit is contained in:
parent
900f48cc5f
commit
7f8b424e2f
15 changed files with 66 additions and 2 deletions
|
@ -22,4 +22,5 @@ export interface CoreStart
|
|||
| [i18n](./kibana-plugin-public.corestart.i18n.md) | <code>I18nStart</code> | [I18nStart](./kibana-plugin-public.i18nstart.md) |
|
||||
| [notifications](./kibana-plugin-public.corestart.notifications.md) | <code>NotificationsStart</code> | [NotificationsStart](./kibana-plugin-public.notificationsstart.md) |
|
||||
| [overlays](./kibana-plugin-public.corestart.overlays.md) | <code>OverlayStart</code> | [OverlayStart](./kibana-plugin-public.overlaystart.md) |
|
||||
| [uiSettings](./kibana-plugin-public.corestart.uisettings.md) | <code>UiSettingsStart</code> | [UiSettingsStart](./kibana-plugin-public.uisettingsstart.md) |
|
||||
|
||||
|
|
|
@ -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) > [CoreStart](./kibana-plugin-public.corestart.md) > [uiSettings](./kibana-plugin-public.corestart.uisettings.md)
|
||||
|
||||
## CoreStart.uiSettings property
|
||||
|
||||
[UiSettingsStart](./kibana-plugin-public.uisettingsstart.md)
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
uiSettings: UiSettingsStart;
|
||||
```
|
|
@ -57,4 +57,5 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [RecursiveReadonly](./kibana-plugin-public.recursivereadonly.md) | |
|
||||
| [ToastInput](./kibana-plugin-public.toastinput.md) | |
|
||||
| [UiSettingsSetup](./kibana-plugin-public.uisettingssetup.md) | |
|
||||
| [UiSettingsStart](./kibana-plugin-public.uisettingsstart.md) | |
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsStart](./kibana-plugin-public.uisettingsstart.md)
|
||||
|
||||
## UiSettingsStart type
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type UiSettingsStart = UiSettingsClient;
|
||||
```
|
|
@ -210,6 +210,11 @@ describe('#start()', () => {
|
|||
expect(MockApplicationService.start).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('calls uiSettings#start()', async () => {
|
||||
await startCore();
|
||||
expect(MockUiSettingsService.start).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('calls i18n#start()', async () => {
|
||||
await startCore();
|
||||
expect(MockI18nService.start).toHaveBeenCalledTimes(1);
|
||||
|
|
|
@ -176,6 +176,7 @@ export class CoreSystem {
|
|||
injectedMetadata,
|
||||
notifications,
|
||||
});
|
||||
const uiSettings = await this.uiSettings.start();
|
||||
|
||||
const core: InternalCoreStart = {
|
||||
application,
|
||||
|
@ -185,6 +186,7 @@ export class CoreSystem {
|
|||
injectedMetadata,
|
||||
notifications,
|
||||
overlays,
|
||||
uiSettings,
|
||||
};
|
||||
|
||||
const plugins = await this.plugins.start(core);
|
||||
|
|
|
@ -57,7 +57,7 @@ import {
|
|||
} from './notifications';
|
||||
import { OverlayRef, OverlayStart } from './overlays';
|
||||
import { Plugin, PluginInitializer, PluginInitializerContext } from './plugins';
|
||||
import { UiSettingsClient, UiSettingsSetup, UiSettingsState } from './ui_settings';
|
||||
import { UiSettingsClient, UiSettingsSetup, UiSettingsStart, UiSettingsState } from './ui_settings';
|
||||
import { ApplicationSetup, Capabilities, ApplicationStart } from './application';
|
||||
|
||||
/** @interal */
|
||||
|
@ -106,6 +106,8 @@ export interface CoreStart {
|
|||
notifications: NotificationsStart;
|
||||
/** {@link OverlayStart} */
|
||||
overlays: OverlayStart;
|
||||
/** {@link UiSettingsStart} */
|
||||
uiSettings: UiSettingsStart;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
@ -152,4 +154,5 @@ export {
|
|||
UiSettingsClient,
|
||||
UiSettingsState,
|
||||
UiSettingsSetup,
|
||||
UiSettingsStart,
|
||||
};
|
||||
|
|
|
@ -90,6 +90,7 @@ const i18nStart = i18nServiceMock.createStartContract();
|
|||
const injectedMetadataStart = injectedMetadataServiceMock.createStartContract();
|
||||
const notificationsStart = notificationServiceMock.createStartContract();
|
||||
const overlayStart = overlayServiceMock.createStartContract();
|
||||
const uiSettingsStart = uiSettingsServiceMock.createStartContract();
|
||||
|
||||
const defaultStartDeps = {
|
||||
core: {
|
||||
|
@ -100,6 +101,7 @@ const defaultStartDeps = {
|
|||
injectedMetadata: injectedMetadataStart,
|
||||
notifications: notificationsStart,
|
||||
overlays: overlayStart,
|
||||
uiSettings: uiSettingsStart,
|
||||
},
|
||||
targetDomElement: document.createElement('div'),
|
||||
plugins: {},
|
||||
|
|
|
@ -93,5 +93,6 @@ export function createPluginStartContext<TSetup, TStart, TPluginsSetup, TPlugins
|
|||
i18n: deps.i18n,
|
||||
notifications: deps.notifications,
|
||||
overlays: deps.overlays,
|
||||
uiSettings: deps.uiSettings,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ beforeEach(() => {
|
|||
injectedMetadata: injectedMetadataServiceMock.createStartContract(),
|
||||
notifications: notificationServiceMock.createStartContract(),
|
||||
overlays: overlayServiceMock.createStartContract(),
|
||||
uiSettings: uiSettingsServiceMock.createStartContract() as jest.Mocked<UiSettingsClient>,
|
||||
};
|
||||
mockStartContext = {
|
||||
...omit(mockStartDeps, 'injectedMetadata'),
|
||||
|
|
|
@ -127,6 +127,8 @@ export interface CoreStart {
|
|||
notifications: NotificationsStart;
|
||||
// (undocumented)
|
||||
overlays: OverlayStart;
|
||||
// (undocumented)
|
||||
uiSettings: UiSettingsStart;
|
||||
}
|
||||
|
||||
// @internal
|
||||
|
@ -395,6 +397,9 @@ export class UiSettingsClient {
|
|||
// @public (undocumented)
|
||||
export type UiSettingsSetup = UiSettingsClient;
|
||||
|
||||
// @public (undocumented)
|
||||
export type UiSettingsStart = UiSettingsClient;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface UiSettingsState {
|
||||
// Warning: (ae-forgotten-export) The symbol "InjectedUiSettingsDefault" needs to be exported by the entry point index.d.ts
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { UiSettingsService, UiSettingsSetup } from './ui_settings_service';
|
||||
export { UiSettingsService, UiSettingsSetup, UiSettingsStart } from './ui_settings_service';
|
||||
export { UiSettingsClient } from './ui_settings_client';
|
||||
export { UiSettingsState } from './types';
|
||||
|
|
|
@ -43,6 +43,7 @@ type UiSettingsServiceContract = PublicMethodsOf<UiSettingsService>;
|
|||
const createMock = () => {
|
||||
const mocked: jest.Mocked<UiSettingsServiceContract> = {
|
||||
setup: jest.fn(),
|
||||
start: jest.fn(),
|
||||
stop: jest.fn(),
|
||||
};
|
||||
|
||||
|
@ -53,4 +54,5 @@ const createMock = () => {
|
|||
export const uiSettingsServiceMock = {
|
||||
create: createMock,
|
||||
createSetupContract: createSetupContractMock,
|
||||
createStartContract: createSetupContractMock,
|
||||
};
|
||||
|
|
|
@ -54,6 +54,15 @@ describe('#setup', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#start', () => {
|
||||
it('returns an instance of UiSettingsClient', () => {
|
||||
const uiSettings = new UiSettingsService();
|
||||
uiSettings.setup(defaultDeps);
|
||||
const start = uiSettings.start();
|
||||
expect(start).toBeInstanceOf(MockUiSettingsClient);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#stop', () => {
|
||||
it('runs fine if service never set up', () => {
|
||||
const service = new UiSettingsService();
|
||||
|
|
|
@ -49,6 +49,10 @@ export class UiSettingsService {
|
|||
return this.uiSettingsClient;
|
||||
}
|
||||
|
||||
public start(): UiSettingsStart {
|
||||
return this.uiSettingsClient!;
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.uiSettingsClient) {
|
||||
this.uiSettingsClient.stop();
|
||||
|
@ -62,3 +66,6 @@ export class UiSettingsService {
|
|||
|
||||
/** @public */
|
||||
export type UiSettingsSetup = UiSettingsClient;
|
||||
|
||||
/** @public */
|
||||
export type UiSettingsStart = UiSettingsClient;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue