mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* introduce IUiSettingsClient on the client * switch uiSettings service to IUiSettingsClient * update uiSettings service tests * all plugins should use IUiSettingsClient * stop is not public methods anymore * remove savedobject attribute type references * regen docs * remove all references to UiSettingsClient class * regen docs * add migration example for uiSettings * update consumer types and tests * address comments
This commit is contained in:
parent
f39c8d4f11
commit
51947b006a
123 changed files with 739 additions and 1092 deletions
|
@ -17,7 +17,7 @@ core: {
|
|||
i18n: I18nStart;
|
||||
notifications: NotificationsStart;
|
||||
overlays: OverlayStart;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
injectedMetadata: {
|
||||
getInjectedVar: (name: string, defaultValue?: any) => unknown;
|
||||
};
|
||||
|
|
|
@ -16,5 +16,5 @@ export interface AppMountContext
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [core](./kibana-plugin-public.appmountcontext.core.md) | <code>{</code><br/><code> application: Pick<ApplicationStart, 'capabilities' | 'navigateToApp'>;</code><br/><code> chrome: ChromeStart;</code><br/><code> docLinks: DocLinksStart;</code><br/><code> http: HttpStart;</code><br/><code> i18n: I18nStart;</code><br/><code> notifications: NotificationsStart;</code><br/><code> overlays: OverlayStart;</code><br/><code> uiSettings: UiSettingsClientContract;</code><br/><code> injectedMetadata: {</code><br/><code> getInjectedVar: (name: string, defaultValue?: any) => unknown;</code><br/><code> };</code><br/><code> }</code> | Core service APIs available to mounted applications. |
|
||||
| [core](./kibana-plugin-public.appmountcontext.core.md) | <code>{</code><br/><code> application: Pick<ApplicationStart, 'capabilities' | 'navigateToApp'>;</code><br/><code> chrome: ChromeStart;</code><br/><code> docLinks: DocLinksStart;</code><br/><code> http: HttpStart;</code><br/><code> i18n: I18nStart;</code><br/><code> notifications: NotificationsStart;</code><br/><code> overlays: OverlayStart;</code><br/><code> uiSettings: IUiSettingsClient;</code><br/><code> injectedMetadata: {</code><br/><code> getInjectedVar: (name: string, defaultValue?: any) => unknown;</code><br/><code> };</code><br/><code> }</code> | Core service APIs available to mounted applications. |
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ Say we're creating a plugin for rendering visualizations that allows new renderi
|
|||
export interface VizRenderContext {
|
||||
core: {
|
||||
i18n: I18nStart;
|
||||
uiSettings: UISettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
[contextName: string]: unknown;
|
||||
}
|
||||
|
|
|
@ -22,5 +22,5 @@ export interface CoreSetup
|
|||
| [http](./kibana-plugin-public.coresetup.http.md) | <code>HttpSetup</code> | [HttpSetup](./kibana-plugin-public.httpsetup.md) |
|
||||
| [injectedMetadata](./kibana-plugin-public.coresetup.injectedmetadata.md) | <code>{</code><br/><code> getInjectedVar: (name: string, defaultValue?: any) => 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. |
|
||||
| [notifications](./kibana-plugin-public.coresetup.notifications.md) | <code>NotificationsSetup</code> | [NotificationsSetup](./kibana-plugin-public.notificationssetup.md) |
|
||||
| [uiSettings](./kibana-plugin-public.coresetup.uisettings.md) | <code>UiSettingsClientContract</code> | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) |
|
||||
| [uiSettings](./kibana-plugin-public.coresetup.uisettings.md) | <code>IUiSettingsClient</code> | [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) |
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
## CoreSetup.uiSettings property
|
||||
|
||||
[UiSettingsClient](./kibana-plugin-public.uisettingsclient.md)
|
||||
[IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md)
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
```
|
||||
|
|
|
@ -25,5 +25,5 @@ export interface CoreStart
|
|||
| [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) |
|
||||
| [savedObjects](./kibana-plugin-public.corestart.savedobjects.md) | <code>SavedObjectsStart</code> | [SavedObjectsStart](./kibana-plugin-public.savedobjectsstart.md) |
|
||||
| [uiSettings](./kibana-plugin-public.corestart.uisettings.md) | <code>UiSettingsClientContract</code> | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) |
|
||||
| [uiSettings](./kibana-plugin-public.corestart.uisettings.md) | <code>IUiSettingsClient</code> | [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) |
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
## CoreStart.uiSettings property
|
||||
|
||||
[UiSettingsClient](./kibana-plugin-public.uisettingsclient.md)
|
||||
[IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md)
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
```
|
||||
|
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [get](./kibana-plugin-public.iuisettingsclient.get.md)
|
||||
|
||||
## IUiSettingsClient.get property
|
||||
|
||||
Gets the value for a specific uiSetting. If this setting has no user-defined value then the `defaultOverride` parameter is returned (and parsed if setting is of type "json" or "number). If the parameter is not defined and the key is not registered by any plugin then an error is thrown, otherwise reads the default value defined by a plugin.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
get: <T = any>(key: string, defaultOverride?: T) => T;
|
||||
```
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [get$](./kibana-plugin-public.iuisettingsclient.get_.md)
|
||||
|
||||
## IUiSettingsClient.get$ property
|
||||
|
||||
Gets an observable of the current value for a config key, and all updates to that config key in the future. Providing a `defaultOverride` argument behaves the same as it does in \#get()
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
get$: <T = any>(key: string, defaultOverride?: T) => Observable<T>;
|
||||
```
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [getAll](./kibana-plugin-public.iuisettingsclient.getall.md)
|
||||
|
||||
## IUiSettingsClient.getAll property
|
||||
|
||||
Gets the metadata about all uiSettings, including the type, default value, and user value for each key.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getAll: () => Readonly<Record<string, UiSettingsParams & UserProvidedValues>>;
|
||||
```
|
|
@ -0,0 +1,17 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [getSaved$](./kibana-plugin-public.iuisettingsclient.getsaved_.md)
|
||||
|
||||
## IUiSettingsClient.getSaved$ property
|
||||
|
||||
Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getSaved$: <T = any>() => Observable<{
|
||||
key: string;
|
||||
newValue: T;
|
||||
oldValue: T;
|
||||
}>;
|
||||
```
|
|
@ -0,0 +1,17 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [getUpdate$](./kibana-plugin-public.iuisettingsclient.getupdate_.md)
|
||||
|
||||
## IUiSettingsClient.getUpdate$ property
|
||||
|
||||
Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getUpdate$: <T = any>() => Observable<{
|
||||
key: string;
|
||||
newValue: T;
|
||||
oldValue: T;
|
||||
}>;
|
||||
```
|
|
@ -1,17 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [getUpdateErrors$](./kibana-plugin-public.uisettingsclient.getupdateerrors_.md)
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [getUpdateErrors$](./kibana-plugin-public.iuisettingsclient.getupdateerrors_.md)
|
||||
|
||||
## UiSettingsClient.getUpdateErrors$() method
|
||||
## IUiSettingsClient.getUpdateErrors$ property
|
||||
|
||||
Returns an Observable that notifies subscribers of each error while trying to update the settings, containing the actual Error class.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getUpdateErrors$(): Rx.Observable<Error>;
|
||||
getUpdateErrors$: () => Observable<Error>;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
`Rx.Observable<Error>`
|
||||
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [isCustom](./kibana-plugin-public.iuisettingsclient.iscustom.md)
|
||||
|
||||
## IUiSettingsClient.isCustom property
|
||||
|
||||
Returns true if the setting wasn't registered by any plugin, but was either added directly via `set()`<!-- -->, or is an unknown setting found in the uiSettings saved object
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isCustom: (key: string) => boolean;
|
||||
```
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [isDeclared](./kibana-plugin-public.iuisettingsclient.isdeclared.md)
|
||||
|
||||
## IUiSettingsClient.isDeclared property
|
||||
|
||||
Returns true if the key is a "known" uiSetting, meaning it is either registered by any plugin or was previously added as a custom setting via the `set()` method.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isDeclared: (key: string) => boolean;
|
||||
```
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [isDefault](./kibana-plugin-public.iuisettingsclient.isdefault.md)
|
||||
|
||||
## IUiSettingsClient.isDefault property
|
||||
|
||||
Returns true if the setting has no user-defined value or is unknown
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isDefault: (key: string) => boolean;
|
||||
```
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [isOverridden](./kibana-plugin-public.iuisettingsclient.isoverridden.md)
|
||||
|
||||
## IUiSettingsClient.isOverridden property
|
||||
|
||||
Shows whether the uiSettings value set by the user.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isOverridden: (key: string) => boolean;
|
||||
```
|
|
@ -0,0 +1,32 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md)
|
||||
|
||||
## IUiSettingsClient interface
|
||||
|
||||
Client-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md)
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface IUiSettingsClient
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [get](./kibana-plugin-public.iuisettingsclient.get.md) | <code><T = any>(key: string, defaultOverride?: T) => T</code> | Gets the value for a specific uiSetting. If this setting has no user-defined value then the <code>defaultOverride</code> parameter is returned (and parsed if setting is of type "json" or "number). If the parameter is not defined and the key is not registered by any plugin then an error is thrown, otherwise reads the default value defined by a plugin. |
|
||||
| [get$](./kibana-plugin-public.iuisettingsclient.get_.md) | <code><T = any>(key: string, defaultOverride?: T) => Observable<T></code> | Gets an observable of the current value for a config key, and all updates to that config key in the future. Providing a <code>defaultOverride</code> argument behaves the same as it does in \#get() |
|
||||
| [getAll](./kibana-plugin-public.iuisettingsclient.getall.md) | <code>() => Readonly<Record<string, UiSettingsParams & UserProvidedValues>></code> | Gets the metadata about all uiSettings, including the type, default value, and user value for each key. |
|
||||
| [getSaved$](./kibana-plugin-public.iuisettingsclient.getsaved_.md) | <code><T = any>() => Observable<{</code><br/><code> key: string;</code><br/><code> newValue: T;</code><br/><code> oldValue: T;</code><br/><code> }></code> | Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed. |
|
||||
| [getUpdate$](./kibana-plugin-public.iuisettingsclient.getupdate_.md) | <code><T = any>() => Observable<{</code><br/><code> key: string;</code><br/><code> newValue: T;</code><br/><code> oldValue: T;</code><br/><code> }></code> | Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed. |
|
||||
| [getUpdateErrors$](./kibana-plugin-public.iuisettingsclient.getupdateerrors_.md) | <code>() => Observable<Error></code> | Returns an Observable that notifies subscribers of each error while trying to update the settings, containing the actual Error class. |
|
||||
| [isCustom](./kibana-plugin-public.iuisettingsclient.iscustom.md) | <code>(key: string) => boolean</code> | Returns true if the setting wasn't registered by any plugin, but was either added directly via <code>set()</code>, or is an unknown setting found in the uiSettings saved object |
|
||||
| [isDeclared](./kibana-plugin-public.iuisettingsclient.isdeclared.md) | <code>(key: string) => boolean</code> | Returns true if the key is a "known" uiSetting, meaning it is either registered by any plugin or was previously added as a custom setting via the <code>set()</code> method. |
|
||||
| [isDefault](./kibana-plugin-public.iuisettingsclient.isdefault.md) | <code>(key: string) => boolean</code> | Returns true if the setting has no user-defined value or is unknown |
|
||||
| [isOverridden](./kibana-plugin-public.iuisettingsclient.isoverridden.md) | <code>(key: string) => boolean</code> | Shows whether the uiSettings value set by the user. |
|
||||
| [overrideLocalDefault](./kibana-plugin-public.iuisettingsclient.overridelocaldefault.md) | <code>(key: string, newDefault: any) => void</code> | Overrides the default value for a setting in this specific browser tab. If the page is reloaded the default override is lost. |
|
||||
| [remove](./kibana-plugin-public.iuisettingsclient.remove.md) | <code>(key: string) => Promise<boolean></code> | Removes the user-defined value for a setting, causing it to revert to the default. This method behaves the same as calling <code>set(key, null)</code>, including the synchronization, custom setting, and error behavior of that method. |
|
||||
| [set](./kibana-plugin-public.iuisettingsclient.set.md) | <code>(key: string, value: any) => Promise<boolean></code> | Sets the value for a uiSetting. If the setting is not registered by any plugin it will be stored as a custom setting. The new value will be synchronously available via the <code>get()</code> method and sent to the server in the background. If the request to the server fails then a updateErrors$ will be notified and the setting will be reverted to its value before <code>set()</code> was called. |
|
||||
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [overrideLocalDefault](./kibana-plugin-public.iuisettingsclient.overridelocaldefault.md)
|
||||
|
||||
## IUiSettingsClient.overrideLocalDefault property
|
||||
|
||||
Overrides the default value for a setting in this specific browser tab. If the page is reloaded the default override is lost.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
overrideLocalDefault: (key: string, newDefault: any) => void;
|
||||
```
|
|
@ -1,24 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [remove](./kibana-plugin-public.uisettingsclient.remove.md)
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [remove](./kibana-plugin-public.iuisettingsclient.remove.md)
|
||||
|
||||
## UiSettingsClient.remove() method
|
||||
## IUiSettingsClient.remove property
|
||||
|
||||
Removes the user-defined value for a setting, causing it to revert to the default. This method behaves the same as calling `set(key, null)`<!-- -->, including the synchronization, custom setting, and error behavior of that method.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
remove(key: string): Promise<boolean>;
|
||||
remove: (key: string) => Promise<boolean>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`Promise<boolean>`
|
||||
|
|
@ -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) > [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) > [set](./kibana-plugin-public.iuisettingsclient.set.md)
|
||||
|
||||
## IUiSettingsClient.set property
|
||||
|
||||
Sets the value for a uiSetting. If the setting is not registered by any plugin it will be stored as a custom setting. The new value will be synchronously available via the `get()` method and sent to the server in the background. If the request to the server fails then a updateErrors$ will be notified and the setting will be reverted to its value before `set()` was called.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
set: (key: string, value: any) => Promise<boolean>;
|
||||
```
|
|
@ -17,7 +17,6 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state. The client-side SavedObjectsClient is a thin convenience library around the SavedObjects HTTP API for interacting with Saved Objects. |
|
||||
| [SimpleSavedObject](./kibana-plugin-public.simplesavedobject.md) | This class is a very simple wrapper for SavedObjects loaded from the server with the [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md)<!-- -->.<!-- -->It provides basic functionality for creating/saving/deleting saved objects, but doesn't include any type-specific implementations. |
|
||||
| [ToastsApi](./kibana-plugin-public.toastsapi.md) | Methods for adding and removing global toast messages. |
|
||||
| [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) | |
|
||||
|
||||
## Interfaces
|
||||
|
||||
|
@ -65,6 +64,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) | |
|
||||
| [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md) | Used to halt a request Promise chain in a [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md)<!-- -->. |
|
||||
| [InterceptedHttpResponse](./kibana-plugin-public.interceptedhttpresponse.md) | |
|
||||
| [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) | Client-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. [IUiSettingsClient](./kibana-plugin-public.iuisettingsclient.md) |
|
||||
| [LegacyCoreSetup](./kibana-plugin-public.legacycoresetup.md) | Setup interface exposed to the legacy platform via the <code>ui/new_platform</code> module. |
|
||||
| [LegacyCoreStart](./kibana-plugin-public.legacycorestart.md) | Start interface exposed to the legacy platform via the <code>ui/new_platform</code> module. |
|
||||
| [LegacyNavLink](./kibana-plugin-public.legacynavlink.md) | |
|
||||
|
@ -126,6 +126,5 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
|
|||
| [ToastInputFields](./kibana-plugin-public.toastinputfields.md) | Allowed fields for [ToastInput](./kibana-plugin-public.toastinput.md)<!-- -->. |
|
||||
| [ToastsSetup](./kibana-plugin-public.toastssetup.md) | [IToasts](./kibana-plugin-public.itoasts.md) |
|
||||
| [ToastsStart](./kibana-plugin-public.toastsstart.md) | [IToasts](./kibana-plugin-public.itoasts.md) |
|
||||
| [UiSettingsClientContract](./kibana-plugin-public.uisettingsclientcontract.md) | Client-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) |
|
||||
| [UnmountCallback](./kibana-plugin-public.unmountcallback.md) | A function that will unmount the element previously mounted by the associated [MountPoint](./kibana-plugin-public.mountpoint.md) |
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ Constructs a new instance of the `ToastsApi` class
|
|||
|
||||
```typescript
|
||||
constructor(deps: {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
});
|
||||
```
|
||||
|
||||
|
@ -18,5 +18,5 @@ constructor(deps: {
|
|||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| deps | <code>{</code><br/><code> uiSettings: UiSettingsClientContract;</code><br/><code> }</code> | |
|
||||
| deps | <code>{</code><br/><code> uiSettings: IUiSettingsClient;</code><br/><code> }</code> | |
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [(constructor)](./kibana-plugin-public.uisettingsclient._constructor_.md)
|
||||
|
||||
## UiSettingsClient.(constructor)
|
||||
|
||||
Constructs a new instance of the `UiSettingsClient` class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(params: UiSettingsClientParams);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| params | <code>UiSettingsClientParams</code> | |
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [get](./kibana-plugin-public.uisettingsclient.get.md)
|
||||
|
||||
## UiSettingsClient.get() method
|
||||
|
||||
Gets the value for a specific uiSetting. If this setting has no user-defined value then the `defaultOverride` parameter is returned (and parsed if setting is of type "json" or "number). If the parameter is not defined and the key is not defined by a uiSettingDefaults then an error is thrown, otherwise the default is read from the uiSettingDefaults.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
get(key: string, defaultOverride?: any): any;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
| defaultOverride | <code>any</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`any`
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [get$](./kibana-plugin-public.uisettingsclient.get_.md)
|
||||
|
||||
## UiSettingsClient.get$() method
|
||||
|
||||
Gets an observable of the current value for a config key, and all updates to that config key in the future. Providing a `defaultOverride` argument behaves the same as it does in \#get()
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
get$(key: string, defaultOverride?: any): Rx.Observable<any>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
| defaultOverride | <code>any</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`Rx.Observable<any>`
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [getAll](./kibana-plugin-public.uisettingsclient.getall.md)
|
||||
|
||||
## UiSettingsClient.getAll() method
|
||||
|
||||
Gets the metadata about all uiSettings, including the type, default value, and user value for each key.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getAll(): Record<string, UiSettingsParams & UserProvidedValues<any>>;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
`Record<string, UiSettingsParams & UserProvidedValues<any>>`
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [getSaved$](./kibana-plugin-public.uisettingsclient.getsaved_.md)
|
||||
|
||||
## UiSettingsClient.getSaved$() method
|
||||
|
||||
Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getSaved$(): Rx.Observable<{
|
||||
key: string;
|
||||
newValue: any;
|
||||
oldValue: any;
|
||||
}>;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
`Rx.Observable<{
|
||||
key: string;
|
||||
newValue: any;
|
||||
oldValue: any;
|
||||
}>`
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [getUpdate$](./kibana-plugin-public.uisettingsclient.getupdate_.md)
|
||||
|
||||
## UiSettingsClient.getUpdate$() method
|
||||
|
||||
Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getUpdate$(): Rx.Observable<{
|
||||
key: string;
|
||||
newValue: any;
|
||||
oldValue: any;
|
||||
}>;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
`Rx.Observable<{
|
||||
key: string;
|
||||
newValue: any;
|
||||
oldValue: any;
|
||||
}>`
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [isCustom](./kibana-plugin-public.uisettingsclient.iscustom.md)
|
||||
|
||||
## UiSettingsClient.isCustom() method
|
||||
|
||||
Returns true if the setting is not a part of the uiSettingDefaults, but was either added directly via `set()`<!-- -->, or is an unknown setting found in the uiSettings saved object
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isCustom(key: string): boolean;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`boolean`
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [isDeclared](./kibana-plugin-public.uisettingsclient.isdeclared.md)
|
||||
|
||||
## UiSettingsClient.isDeclared() method
|
||||
|
||||
Returns true if the key is a "known" uiSetting, meaning it is either defined in the uiSettingDefaults or was previously added as a custom setting via the `set()` method.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isDeclared(key: string): boolean;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`boolean`
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [isDefault](./kibana-plugin-public.uisettingsclient.isdefault.md)
|
||||
|
||||
## UiSettingsClient.isDefault() method
|
||||
|
||||
Returns true if the setting has no user-defined value or is unknown
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isDefault(key: string): boolean;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`boolean`
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [isOverridden](./kibana-plugin-public.uisettingsclient.isoverridden.md)
|
||||
|
||||
## UiSettingsClient.isOverridden() method
|
||||
|
||||
Returns true if a settings value is overridden by the server. When a setting is overridden its value can not be changed via `set()` or `remove()`<!-- -->.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isOverridden(key: string): boolean;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`boolean`
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md)
|
||||
|
||||
## UiSettingsClient class
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class UiSettingsClient
|
||||
```
|
||||
|
||||
## Constructors
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(params)](./kibana-plugin-public.uisettingsclient._constructor_.md) | | Constructs a new instance of the <code>UiSettingsClient</code> class |
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [get(key, defaultOverride)](./kibana-plugin-public.uisettingsclient.get.md) | | Gets the value for a specific uiSetting. If this setting has no user-defined value then the <code>defaultOverride</code> parameter is returned (and parsed if setting is of type "json" or "number). If the parameter is not defined and the key is not defined by a uiSettingDefaults then an error is thrown, otherwise the default is read from the uiSettingDefaults. |
|
||||
| [get$(key, defaultOverride)](./kibana-plugin-public.uisettingsclient.get_.md) | | Gets an observable of the current value for a config key, and all updates to that config key in the future. Providing a <code>defaultOverride</code> argument behaves the same as it does in \#get() |
|
||||
| [getAll()](./kibana-plugin-public.uisettingsclient.getall.md) | | Gets the metadata about all uiSettings, including the type, default value, and user value for each key. |
|
||||
| [getSaved$()](./kibana-plugin-public.uisettingsclient.getsaved_.md) | | Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed. |
|
||||
| [getUpdate$()](./kibana-plugin-public.uisettingsclient.getupdate_.md) | | Returns an Observable that notifies subscribers of each update to the uiSettings, including the key, newValue, and oldValue of the setting that changed. |
|
||||
| [getUpdateErrors$()](./kibana-plugin-public.uisettingsclient.getupdateerrors_.md) | | Returns an Observable that notifies subscribers of each error while trying to update the settings, containing the actual Error class. |
|
||||
| [isCustom(key)](./kibana-plugin-public.uisettingsclient.iscustom.md) | | Returns true if the setting is not a part of the uiSettingDefaults, but was either added directly via <code>set()</code>, or is an unknown setting found in the uiSettings saved object |
|
||||
| [isDeclared(key)](./kibana-plugin-public.uisettingsclient.isdeclared.md) | | Returns true if the key is a "known" uiSetting, meaning it is either defined in the uiSettingDefaults or was previously added as a custom setting via the <code>set()</code> method. |
|
||||
| [isDefault(key)](./kibana-plugin-public.uisettingsclient.isdefault.md) | | Returns true if the setting has no user-defined value or is unknown |
|
||||
| [isOverridden(key)](./kibana-plugin-public.uisettingsclient.isoverridden.md) | | Returns true if a settings value is overridden by the server. When a setting is overridden its value can not be changed via <code>set()</code> or <code>remove()</code>. |
|
||||
| [overrideLocalDefault(key, newDefault)](./kibana-plugin-public.uisettingsclient.overridelocaldefault.md) | | Overrides the default value for a setting in this specific browser tab. If the page is reloaded the default override is lost. |
|
||||
| [remove(key)](./kibana-plugin-public.uisettingsclient.remove.md) | | Removes the user-defined value for a setting, causing it to revert to the default. This method behaves the same as calling <code>set(key, null)</code>, including the synchronization, custom setting, and error behavior of that method. |
|
||||
| [set(key, val)](./kibana-plugin-public.uisettingsclient.set.md) | | Sets the value for a uiSetting. If the setting is not defined in the uiSettingDefaults it will be stored as a custom setting. The new value will be synchronously available via the <code>get()</code> method and sent to the server in the background. If the request to the server fails then a toast notification will be displayed and the setting will be reverted it its value before <code>set()</code> was called. |
|
||||
| [stop()](./kibana-plugin-public.uisettingsclient.stop.md) | | Prepares the uiSettingsClient to be discarded, completing any update$ observables that have been created. |
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [overrideLocalDefault](./kibana-plugin-public.uisettingsclient.overridelocaldefault.md)
|
||||
|
||||
## UiSettingsClient.overrideLocalDefault() method
|
||||
|
||||
Overrides the default value for a setting in this specific browser tab. If the page is reloaded the default override is lost.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
overrideLocalDefault(key: string, newDefault: any): void;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
| newDefault | <code>any</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`void`
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [set](./kibana-plugin-public.uisettingsclient.set.md)
|
||||
|
||||
## UiSettingsClient.set() method
|
||||
|
||||
Sets the value for a uiSetting. If the setting is not defined in the uiSettingDefaults it will be stored as a custom setting. The new value will be synchronously available via the `get()` method and sent to the server in the background. If the request to the server fails then a toast notification will be displayed and the setting will be reverted it its value before `set()` was called.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
set(key: string, val: any): Promise<boolean>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| key | <code>string</code> | |
|
||||
| val | <code>any</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`Promise<boolean>`
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) > [stop](./kibana-plugin-public.uisettingsclient.stop.md)
|
||||
|
||||
## UiSettingsClient.stop() method
|
||||
|
||||
Prepares the uiSettingsClient to be discarded, completing any update$ observables that have been created.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
stop(): void;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
`void`
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [UiSettingsClientContract](./kibana-plugin-public.uisettingsclientcontract.md)
|
||||
|
||||
## UiSettingsClientContract type
|
||||
|
||||
Client-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md)
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type UiSettingsClientContract = PublicMethodsOf<UiSettingsClient>;
|
||||
```
|
|
@ -85,7 +85,7 @@ Say we're creating a plugin for rendering visualizations that allows new renderi
|
|||
export interface VizRenderContext {
|
||||
core: {
|
||||
i18n: I18nStart;
|
||||
uiSettings: UISettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
[contextName: string]: unknown;
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ Retrieves uiSettings values set by the user with fallbacks to default values if
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
get: <T extends SavedObjectAttribute = any>(key: string) => Promise<T>;
|
||||
get: <T = any>(key: string) => Promise<T>;
|
||||
```
|
||||
|
|
|
@ -9,5 +9,5 @@ Retrieves a set of all uiSettings values set by the user with fallbacks to defau
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getAll: <T extends SavedObjectAttribute = any>() => Promise<Record<string, T>>;
|
||||
getAll: <T = any>() => Promise<Record<string, T>>;
|
||||
```
|
||||
|
|
|
@ -9,5 +9,5 @@ Retrieves a set of all uiSettings values set by the user.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getUserProvided: <T extends SavedObjectAttribute = any>() => Promise<Record<string, UserProvidedValues<T>>>;
|
||||
getUserProvided: <T = any>() => Promise<Record<string, UserProvidedValues<T>>>;
|
||||
```
|
||||
|
|
|
@ -16,13 +16,13 @@ export interface IUiSettingsClient
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [get](./kibana-plugin-server.iuisettingsclient.get.md) | <code><T extends SavedObjectAttribute = any>(key: string) => Promise<T></code> | Retrieves uiSettings values set by the user with fallbacks to default values if not specified. |
|
||||
| [getAll](./kibana-plugin-server.iuisettingsclient.getall.md) | <code><T extends SavedObjectAttribute = any>() => Promise<Record<string, T>></code> | Retrieves a set of all uiSettings values set by the user with fallbacks to default values if not specified. |
|
||||
| [get](./kibana-plugin-server.iuisettingsclient.get.md) | <code><T = any>(key: string) => Promise<T></code> | Retrieves uiSettings values set by the user with fallbacks to default values if not specified. |
|
||||
| [getAll](./kibana-plugin-server.iuisettingsclient.getall.md) | <code><T = any>() => Promise<Record<string, T>></code> | Retrieves a set of all uiSettings values set by the user with fallbacks to default values if not specified. |
|
||||
| [getRegistered](./kibana-plugin-server.iuisettingsclient.getregistered.md) | <code>() => Readonly<Record<string, UiSettingsParams>></code> | Returns registered uiSettings values [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) |
|
||||
| [getUserProvided](./kibana-plugin-server.iuisettingsclient.getuserprovided.md) | <code><T extends SavedObjectAttribute = any>() => Promise<Record<string, UserProvidedValues<T>>></code> | Retrieves a set of all uiSettings values set by the user. |
|
||||
| [getUserProvided](./kibana-plugin-server.iuisettingsclient.getuserprovided.md) | <code><T = any>() => Promise<Record<string, UserProvidedValues<T>>></code> | Retrieves a set of all uiSettings values set by the user. |
|
||||
| [isOverridden](./kibana-plugin-server.iuisettingsclient.isoverridden.md) | <code>(key: string) => boolean</code> | Shows whether the uiSettings value set by the user. |
|
||||
| [remove](./kibana-plugin-server.iuisettingsclient.remove.md) | <code>(key: string) => Promise<void></code> | Removes uiSettings value by key. |
|
||||
| [removeMany](./kibana-plugin-server.iuisettingsclient.removemany.md) | <code>(keys: string[]) => Promise<void></code> | Removes multiple uiSettings values by keys. |
|
||||
| [set](./kibana-plugin-server.iuisettingsclient.set.md) | <code><T extends SavedObjectAttribute = any>(key: string, value: T) => Promise<void></code> | Writes uiSettings value and marks it as set by the user. |
|
||||
| [setMany](./kibana-plugin-server.iuisettingsclient.setmany.md) | <code><T extends SavedObjectAttribute = any>(changes: Record<string, T>) => Promise<void></code> | Writes multiple uiSettings values and marks them as set by the user. |
|
||||
| [set](./kibana-plugin-server.iuisettingsclient.set.md) | <code>(key: string, value: any) => Promise<void></code> | Writes uiSettings value and marks it as set by the user. |
|
||||
| [setMany](./kibana-plugin-server.iuisettingsclient.setmany.md) | <code>(changes: Record<string, any>) => Promise<void></code> | Writes multiple uiSettings values and marks them as set by the user. |
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ Writes uiSettings value and marks it as set by the user.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
set: <T extends SavedObjectAttribute = any>(key: string, value: T) => Promise<void>;
|
||||
set: (key: string, value: any) => Promise<void>;
|
||||
```
|
||||
|
|
|
@ -9,5 +9,5 @@ Writes multiple uiSettings values and marks them as set by the user.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
setMany: <T extends SavedObjectAttribute = any>(changes: Record<string, T>) => Promise<void>;
|
||||
setMany: (changes: Record<string, any>) => Promise<void>;
|
||||
```
|
||||
|
|
|
@ -9,7 +9,7 @@ Describes the values explicitly set by user.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface UserProvidedValues<T extends SavedObjectAttribute = any>
|
||||
export interface UserProvidedValues<T = any>
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
|
|
@ -1248,6 +1248,38 @@ This table shows where these uiExports have moved to in the New Platform. In mos
|
|||
| `visTypes` | | |
|
||||
| `visualize` | | |
|
||||
|
||||
Examples:
|
||||
|
||||
- **uiSettingDefaults**
|
||||
|
||||
Before:
|
||||
```js
|
||||
uiExports: {
|
||||
uiSettingDefaults: {
|
||||
'my-plugin:my-setting': {
|
||||
name: 'just-work',
|
||||
value: true,
|
||||
description: 'make it work',
|
||||
category: ['my-category'],
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
After:
|
||||
```ts
|
||||
// src/plugins/my-plugin/server/plugin.ts
|
||||
setup(core: CoreSetup){
|
||||
core.uiSettings.register({
|
||||
'my-plugin:my-setting': {
|
||||
name: 'just-work',
|
||||
value: true,
|
||||
description: 'make it work',
|
||||
category: ['my-category'],
|
||||
},
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## How to
|
||||
|
||||
### Configure plugin
|
||||
|
|
|
@ -28,7 +28,7 @@ import { I18nStart } from '../i18n';
|
|||
import { NotificationsStart } from '../notifications';
|
||||
import { OverlayStart } from '../overlays';
|
||||
import { PluginOpaqueId } from '../plugins';
|
||||
import { UiSettingsClientContract } from '../ui_settings';
|
||||
import { IUiSettingsClient } from '../ui_settings';
|
||||
import { RecursiveReadonly } from '../../utils';
|
||||
|
||||
/** @public */
|
||||
|
@ -118,8 +118,8 @@ export interface AppMountContext {
|
|||
notifications: NotificationsStart;
|
||||
/** {@link OverlayStart} */
|
||||
overlays: OverlayStart;
|
||||
/** {@link UiSettingsClient} */
|
||||
uiSettings: UiSettingsClientContract;
|
||||
/** {@link IUiSettingsClient} */
|
||||
uiSettings: IUiSettingsClient;
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -47,7 +47,7 @@ export class ContextService {
|
|||
* export interface VizRenderContext {
|
||||
* core: {
|
||||
* i18n: I18nStart;
|
||||
* uiSettings: UISettingsClientContract;
|
||||
* uiSettings: IUiSettingsClient;
|
||||
* }
|
||||
* [contextName: string]: unknown;
|
||||
* }
|
||||
|
|
|
@ -62,7 +62,7 @@ import { InjectedMetadataSetup, InjectedMetadataStart, LegacyNavLink } from './i
|
|||
import { NotificationsSetup, NotificationsStart } from './notifications';
|
||||
import { OverlayStart } from './overlays';
|
||||
import { Plugin, PluginInitializer, PluginInitializerContext, PluginOpaqueId } from './plugins';
|
||||
import { UiSettingsClient, UiSettingsState, UiSettingsClientContract } from './ui_settings';
|
||||
import { UiSettingsState, IUiSettingsClient } from './ui_settings';
|
||||
import { ApplicationSetup, Capabilities, ApplicationStart } from './application';
|
||||
import { DocLinksStart } from './doc_links';
|
||||
import { SavedObjectsStart } from './saved_objects';
|
||||
|
@ -158,8 +158,8 @@ export interface CoreSetup {
|
|||
http: HttpSetup;
|
||||
/** {@link NotificationsSetup} */
|
||||
notifications: NotificationsSetup;
|
||||
/** {@link UiSettingsClient} */
|
||||
uiSettings: UiSettingsClientContract;
|
||||
/** {@link IUiSettingsClient} */
|
||||
uiSettings: IUiSettingsClient;
|
||||
/**
|
||||
* 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
|
||||
|
@ -197,8 +197,8 @@ export interface CoreStart {
|
|||
notifications: NotificationsStart;
|
||||
/** {@link OverlayStart} */
|
||||
overlays: OverlayStart;
|
||||
/** {@link UiSettingsClient} */
|
||||
uiSettings: UiSettingsClientContract;
|
||||
/** {@link IUiSettingsClient} */
|
||||
uiSettings: IUiSettingsClient;
|
||||
/**
|
||||
* 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
|
||||
|
@ -282,7 +282,6 @@ export {
|
|||
PluginInitializerContext,
|
||||
SavedObjectsStart,
|
||||
PluginOpaqueId,
|
||||
UiSettingsClient,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
UiSettingsState,
|
||||
};
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { UiSettingsClientContract } from '../ui_settings';
|
||||
import { IUiSettingsClient } from '../ui_settings';
|
||||
import { CoreService } from '../../types';
|
||||
|
||||
import { MomentService } from './moment';
|
||||
import { StylesService } from './styles';
|
||||
|
||||
interface Deps {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -21,11 +21,11 @@ import moment from 'moment-timezone';
|
|||
import { merge, Subscription } from 'rxjs';
|
||||
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { UiSettingsClientContract } from '../../ui_settings';
|
||||
import { IUiSettingsClient } from '../../ui_settings';
|
||||
import { CoreService } from '../../../types';
|
||||
|
||||
interface StartDeps {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
import { UiSettingsClientContract } from '../../ui_settings';
|
||||
import { IUiSettingsClient } from '../../ui_settings';
|
||||
import { CoreService } from '../../../types';
|
||||
// @ts-ignore
|
||||
import disableAnimationsCss from '!!raw-loader!./disable_animations.css';
|
||||
|
||||
interface StartDeps {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -22,11 +22,11 @@ import { i18n } from '@kbn/i18n';
|
|||
import { Subscription } from 'rxjs';
|
||||
import { I18nStart } from '../i18n';
|
||||
import { ToastsService, ToastsSetup, ToastsStart } from './toasts';
|
||||
import { UiSettingsClientContract } from '../ui_settings';
|
||||
import { IUiSettingsClient } from '../ui_settings';
|
||||
import { OverlayStart } from '../overlays';
|
||||
|
||||
interface SetupDeps {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
interface StartDeps {
|
||||
|
|
|
@ -24,7 +24,7 @@ import * as Rx from 'rxjs';
|
|||
import { ErrorToast } from './error_toast';
|
||||
import { MountPoint } from '../../types';
|
||||
import { mountReactNode } from '../../utils';
|
||||
import { UiSettingsClientContract } from '../../ui_settings';
|
||||
import { IUiSettingsClient } from '../../ui_settings';
|
||||
import { OverlayStart } from '../../overlays';
|
||||
import { I18nStart } from '../../i18n';
|
||||
|
||||
|
@ -94,12 +94,12 @@ export type IToasts = Pick<
|
|||
export class ToastsApi implements IToasts {
|
||||
private toasts$ = new Rx.BehaviorSubject<Toast[]>([]);
|
||||
private idCounter = 0;
|
||||
private uiSettings: UiSettingsClientContract;
|
||||
private uiSettings: IUiSettingsClient;
|
||||
|
||||
private overlays?: OverlayStart;
|
||||
private i18n?: I18nStart;
|
||||
|
||||
constructor(deps: { uiSettings: UiSettingsClientContract }) {
|
||||
constructor(deps: { uiSettings: IUiSettingsClient }) {
|
||||
this.uiSettings = deps.uiSettings;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ import React from 'react';
|
|||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
|
||||
import { I18nStart } from '../../i18n';
|
||||
import { UiSettingsClientContract } from '../../ui_settings';
|
||||
import { IUiSettingsClient } from '../../ui_settings';
|
||||
import { GlobalToastList } from './global_toast_list';
|
||||
import { ToastsApi, IToasts } from './toasts_api';
|
||||
import { OverlayStart } from '../../overlays';
|
||||
|
||||
interface SetupDeps {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
interface StartDeps {
|
||||
|
|
|
@ -23,7 +23,7 @@ import { map } from 'rxjs/operators';
|
|||
|
||||
import { PriorityMap } from './priority_map';
|
||||
import { BannersList } from './banners_list';
|
||||
import { UiSettingsClientContract } from '../../ui_settings';
|
||||
import { IUiSettingsClient } from '../../ui_settings';
|
||||
import { I18nStart } from '../../i18n';
|
||||
import { MountPoint } from '../../types';
|
||||
import { UserBannerService } from './user_banner_service';
|
||||
|
@ -73,7 +73,7 @@ export interface OverlayBanner {
|
|||
|
||||
interface StartDeps {
|
||||
i18n: I18nStart;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -27,13 +27,13 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
import { EuiCallOut, EuiButton } from '@elastic/eui';
|
||||
|
||||
import { I18nStart } from '../../i18n';
|
||||
import { UiSettingsClientContract } from '../../ui_settings';
|
||||
import { IUiSettingsClient } from '../../ui_settings';
|
||||
import { OverlayBannersStart } from './banners_service';
|
||||
|
||||
interface StartDeps {
|
||||
banners: OverlayBannersStart;
|
||||
i18n: I18nStart;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { I18nStart } from '../i18n';
|
||||
import { UiSettingsClientContract } from '../ui_settings';
|
||||
import { IUiSettingsClient } from '../ui_settings';
|
||||
import { OverlayBannersStart, OverlayBannersService } from './banners';
|
||||
import { FlyoutService, OverlayFlyoutStart } from './flyout';
|
||||
import { ModalService, OverlayModalStart } from './modal';
|
||||
|
@ -26,7 +26,7 @@ import { ModalService, OverlayModalStart } from './modal';
|
|||
interface StartDeps {
|
||||
i18n: I18nStart;
|
||||
targetDomElement: HTMLElement;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -63,7 +63,7 @@ export interface AppMountContext {
|
|||
i18n: I18nStart;
|
||||
notifications: NotificationsStart;
|
||||
overlays: OverlayStart;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
injectedMetadata: {
|
||||
getInjectedVar: (name: string, defaultValue?: any) => unknown;
|
||||
};
|
||||
|
@ -289,7 +289,7 @@ export interface CoreSetup {
|
|||
// (undocumented)
|
||||
notifications: NotificationsSetup;
|
||||
// (undocumented)
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -315,7 +315,7 @@ export interface CoreStart {
|
|||
// (undocumented)
|
||||
savedObjects: SavedObjectsStart;
|
||||
// (undocumented)
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
// @internal
|
||||
|
@ -621,6 +621,31 @@ export interface InterceptedHttpResponse {
|
|||
// @public
|
||||
export type IToasts = Pick<ToastsApi, 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError'>;
|
||||
|
||||
// @public
|
||||
export interface IUiSettingsClient {
|
||||
get$: <T = any>(key: string, defaultOverride?: T) => Observable<T>;
|
||||
get: <T = any>(key: string, defaultOverride?: T) => T;
|
||||
getAll: () => Readonly<Record<string, UiSettingsParams_2 & UserProvidedValues_2>>;
|
||||
getSaved$: <T = any>() => Observable<{
|
||||
key: string;
|
||||
newValue: T;
|
||||
oldValue: T;
|
||||
}>;
|
||||
getUpdate$: <T = any>() => Observable<{
|
||||
key: string;
|
||||
newValue: T;
|
||||
oldValue: T;
|
||||
}>;
|
||||
getUpdateErrors$: () => Observable<Error>;
|
||||
isCustom: (key: string) => boolean;
|
||||
isDeclared: (key: string) => boolean;
|
||||
isDefault: (key: string) => boolean;
|
||||
isOverridden: (key: string) => boolean;
|
||||
overrideLocalDefault: (key: string, newDefault: any) => void;
|
||||
remove: (key: string) => Promise<boolean>;
|
||||
set: (key: string, value: any) => Promise<boolean>;
|
||||
}
|
||||
|
||||
// @public @deprecated
|
||||
export interface LegacyCoreSetup extends CoreSetup {
|
||||
// Warning: (ae-forgotten-export) The symbol "InjectedMetadataSetup" needs to be exported by the entry point index.d.ts
|
||||
|
@ -968,7 +993,7 @@ export type ToastInputFields = Pick<EuiGlobalToastListToast, Exclude<keyof EuiGl
|
|||
// @public
|
||||
export class ToastsApi implements IToasts {
|
||||
constructor(deps: {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
});
|
||||
add(toastOrTitle: ToastInput): Toast;
|
||||
addDanger(toastOrTitle: ToastInput): Toast;
|
||||
|
@ -990,37 +1015,6 @@ export type ToastsSetup = IToasts;
|
|||
// @public (undocumented)
|
||||
export type ToastsStart = IToasts;
|
||||
|
||||
// @public (undocumented)
|
||||
export class UiSettingsClient {
|
||||
// Warning: (ae-forgotten-export) The symbol "UiSettingsClientParams" needs to be exported by the entry point index.d.ts
|
||||
constructor(params: UiSettingsClientParams);
|
||||
get$(key: string, defaultOverride?: any): Rx.Observable<any>;
|
||||
get(key: string, defaultOverride?: any): any;
|
||||
getAll(): Record<string, UiSettingsParams_2 & UserProvidedValues_2<any>>;
|
||||
getSaved$(): Rx.Observable<{
|
||||
key: string;
|
||||
newValue: any;
|
||||
oldValue: any;
|
||||
}>;
|
||||
getUpdate$(): Rx.Observable<{
|
||||
key: string;
|
||||
newValue: any;
|
||||
oldValue: any;
|
||||
}>;
|
||||
getUpdateErrors$(): Rx.Observable<Error>;
|
||||
isCustom(key: string): boolean;
|
||||
isDeclared(key: string): boolean;
|
||||
isDefault(key: string): boolean;
|
||||
isOverridden(key: string): boolean;
|
||||
overrideLocalDefault(key: string, newDefault: any): void;
|
||||
remove(key: string): Promise<boolean>;
|
||||
set(key: string, val: any): Promise<boolean>;
|
||||
stop(): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type UiSettingsClientContract = PublicMethodsOf<UiSettingsClient>;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface UiSettingsState {
|
||||
// (undocumented)
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`#get after a get for an unknown property, the property is not persisted 1`] = `
|
||||
"Unexpected \`config.get(\\"obscureProperty2\\")\` call on unrecognized configuration setting \\"obscureProperty2\\".
|
||||
Setting an initial value via \`config.set(\\"obscureProperty2\\", value)\` before attempting to retrieve
|
||||
"Unexpected \`IUiSettingsClient.get(\\"obscureProperty2\\")\` call on unrecognized configuration setting \\"obscureProperty2\\".
|
||||
Setting an initial value via \`IUiSettingsClient.set(\\"obscureProperty2\\", value)\` before attempting to retrieve
|
||||
any custom setting value for \\"obscureProperty2\\" may fix this issue.
|
||||
You can use \`config.get(\\"obscureProperty2\\", defaultValue)\`, which will just return
|
||||
You can use \`IUiSettingsClient.get(\\"obscureProperty2\\", defaultValue)\`, which will just return
|
||||
\`defaultValue\` when the key is unrecognized."
|
||||
`;
|
||||
|
||||
exports[`#get gives access to config values 1`] = `"Browser"`;
|
||||
exports[`#get gives access to uiSettings values 1`] = `"Browser"`;
|
||||
|
||||
exports[`#get supports the default value overload 1`] = `"default"`;
|
||||
|
||||
exports[`#get throws on unknown properties that don't have a value yet. 1`] = `
|
||||
"Unexpected \`config.get(\\"throwableProperty\\")\` call on unrecognized configuration setting \\"throwableProperty\\".
|
||||
Setting an initial value via \`config.set(\\"throwableProperty\\", value)\` before attempting to retrieve
|
||||
"Unexpected \`IUiSettingsClient.get(\\"throwableProperty\\")\` call on unrecognized configuration setting \\"throwableProperty\\".
|
||||
Setting an initial value via \`IUiSettingsClient.set(\\"throwableProperty\\", value)\` before attempting to retrieve
|
||||
any custom setting value for \\"throwableProperty\\" may fix this issue.
|
||||
You can use \`config.get(\\"throwableProperty\\", defaultValue)\`, which will just return
|
||||
You can use \`IUiSettingsClient.get(\\"throwableProperty\\", defaultValue)\`, which will just return
|
||||
\`defaultValue\` when the key is unrecognized."
|
||||
`;
|
||||
|
||||
exports[`#getUpdate$ sends { key, newValue, oldValue } notifications when config changes 1`] = `
|
||||
exports[`#getUpdate$ sends { key, newValue, oldValue } notifications when client changes 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
|
@ -32,7 +32,7 @@ Array [
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`#getUpdate$ sends { key, newValue, oldValue } notifications when config changes 2`] = `
|
||||
exports[`#getUpdate$ sends { key, newValue, oldValue } notifications when client changes 2`] = `
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`#setup constructs UiSettingsClient and UiSettingsApi: UiSettingsApi args 1`] = `
|
||||
[MockFunction MockUiSettingsApi] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Object {
|
||||
"addLoadingCount": [MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Object {
|
||||
"loadingCountObservable": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": undefined,
|
||||
},
|
||||
],
|
||||
},
|
||||
"anonymousPaths": AnonymousPaths {
|
||||
"basePath": BasePath {
|
||||
"basePath": "",
|
||||
"get": [Function],
|
||||
"prepend": [Function],
|
||||
"remove": [Function],
|
||||
},
|
||||
"paths": Set {},
|
||||
},
|
||||
"basePath": BasePath {
|
||||
"basePath": "",
|
||||
"get": [Function],
|
||||
"prepend": [Function],
|
||||
"remove": [Function],
|
||||
},
|
||||
"delete": [MockFunction],
|
||||
"fetch": [MockFunction],
|
||||
"get": [MockFunction],
|
||||
"getLoadingCount$": [MockFunction],
|
||||
"head": [MockFunction],
|
||||
"intercept": [MockFunction],
|
||||
"options": [MockFunction],
|
||||
"patch": [MockFunction],
|
||||
"post": [MockFunction],
|
||||
"put": [MockFunction],
|
||||
"removeAllInterceptors": [MockFunction],
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": undefined,
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#setup constructs UiSettingsClient and UiSettingsApi: UiSettingsClient args 1`] = `
|
||||
[MockFunction MockUiSettingsClient] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Object {
|
||||
"api": MockUiSettingsApi {
|
||||
"getLoadingCount$": [MockFunction] {
|
||||
"calls": Array [
|
||||
Array [],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": Object {
|
||||
"loadingCountObservable": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
"defaults": Object {
|
||||
"legacyInjectedUiSettingDefaults": true,
|
||||
},
|
||||
"initialSettings": Object {
|
||||
"legacyInjectedUiSettingUserValues": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": undefined,
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#setup passes the uiSettings loading count to the loading count api: http.addLoadingCount calls 1`] = `
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
Object {
|
||||
"loadingCountObservable": true,
|
||||
},
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": undefined,
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
|
@ -18,5 +18,5 @@
|
|||
*/
|
||||
|
||||
export { UiSettingsService } from './ui_settings_service';
|
||||
export { UiSettingsClient, UiSettingsClientContract } from './ui_settings_client';
|
||||
export { UiSettingsState } from './types';
|
||||
export { UiSettingsClient } from './ui_settings_client';
|
||||
export { UiSettingsState, IUiSettingsClient } from './types';
|
||||
|
|
|
@ -17,9 +17,112 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { UiSettingsParams, UserProvidedValues } from 'src/core/server/types';
|
||||
|
||||
/** @public */
|
||||
export interface UiSettingsState {
|
||||
[key: string]: UiSettingsParams & UserProvidedValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-side client that provides access to the advanced settings stored in elasticsearch.
|
||||
* The settings provide control over the behavior of the Kibana application.
|
||||
* For example, a user can specify how to display numeric or date fields.
|
||||
* Users can adjust the settings via Management UI.
|
||||
* {@link IUiSettingsClient}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IUiSettingsClient {
|
||||
/**
|
||||
* Gets the value for a specific uiSetting. If this setting has no user-defined value
|
||||
* then the `defaultOverride` parameter is returned (and parsed if setting is of type
|
||||
* "json" or "number). If the parameter is not defined and the key is not registered
|
||||
* by any plugin then an error is thrown, otherwise reads the default value defined by a plugin.
|
||||
*/
|
||||
get: <T = any>(key: string, defaultOverride?: T) => T;
|
||||
|
||||
/**
|
||||
* Gets an observable of the current value for a config key, and all updates to that config
|
||||
* key in the future. Providing a `defaultOverride` argument behaves the same as it does in #get()
|
||||
*/
|
||||
get$: <T = any>(key: string, defaultOverride?: T) => Observable<T>;
|
||||
|
||||
/**
|
||||
* Gets the metadata about all uiSettings, including the type, default value, and user value
|
||||
* for each key.
|
||||
*/
|
||||
getAll: () => Readonly<Record<string, UiSettingsParams & UserProvidedValues>>;
|
||||
|
||||
/**
|
||||
* Sets the value for a uiSetting. If the setting is not registered by any plugin
|
||||
* it will be stored as a custom setting. The new value will be synchronously available via
|
||||
* the `get()` method and sent to the server in the background. If the request to the
|
||||
* server fails then a updateErrors$ will be notified and the setting will be
|
||||
* reverted to its value before `set()` was called.
|
||||
*/
|
||||
set: (key: string, value: any) => Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Overrides the default value for a setting in this specific browser tab. If the page
|
||||
* is reloaded the default override is lost.
|
||||
*/
|
||||
overrideLocalDefault: (key: string, newDefault: any) => void;
|
||||
|
||||
/**
|
||||
* Removes the user-defined value for a setting, causing it to revert to the default. This
|
||||
* method behaves the same as calling `set(key, null)`, including the synchronization, custom
|
||||
* setting, and error behavior of that method.
|
||||
*/
|
||||
remove: (key: string) => Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Returns true if the key is a "known" uiSetting, meaning it is either registered
|
||||
* by any plugin or was previously added as a custom setting via the `set()` method.
|
||||
*/
|
||||
isDeclared: (key: string) => boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the setting has no user-defined value or is unknown
|
||||
*/
|
||||
isDefault: (key: string) => boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the setting wasn't registered by any plugin, but was either
|
||||
* added directly via `set()`, or is an unknown setting found in the uiSettings saved
|
||||
* object
|
||||
*/
|
||||
isCustom: (key: string) => boolean;
|
||||
|
||||
/**
|
||||
* Shows whether the uiSettings value set by the user.
|
||||
*/
|
||||
isOverridden: (key: string) => boolean;
|
||||
|
||||
/**
|
||||
* Returns an Observable that notifies subscribers of each update to the uiSettings,
|
||||
* including the key, newValue, and oldValue of the setting that changed.
|
||||
*/
|
||||
getUpdate$: <T = any>() => Observable<{
|
||||
key: string;
|
||||
newValue: T;
|
||||
oldValue: T;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Returns an Observable that notifies subscribers of each update to the uiSettings,
|
||||
* including the key, newValue, and oldValue of the setting that changed.
|
||||
*/
|
||||
getSaved$: <T = any>() => Observable<{
|
||||
key: string;
|
||||
newValue: T;
|
||||
oldValue: T;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Returns an Observable that notifies subscribers of each error while trying to update
|
||||
* the settings, containing the actual Error class.
|
||||
*/
|
||||
getUpdateErrors$: () => Observable<Error>;
|
||||
}
|
||||
|
|
|
@ -16,72 +16,79 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Subject } from 'rxjs';
|
||||
import { materialize, take, toArray } from 'rxjs/operators';
|
||||
|
||||
import { UiSettingsClient } from './ui_settings_client';
|
||||
|
||||
let done$: Subject<unknown>;
|
||||
|
||||
function setup(options: { defaults?: any; initialSettings?: any } = {}) {
|
||||
const { defaults = { dateFormat: { value: 'Browser' } }, initialSettings = {} } = options;
|
||||
|
||||
const batchSet = jest.fn(() => ({
|
||||
settings: {},
|
||||
}));
|
||||
|
||||
const config = new UiSettingsClient({
|
||||
done$ = new Subject();
|
||||
const client = new UiSettingsClient({
|
||||
defaults,
|
||||
initialSettings,
|
||||
api: {
|
||||
batchSet,
|
||||
} as any,
|
||||
done$,
|
||||
});
|
||||
|
||||
return { config, batchSet };
|
||||
return { client, batchSet };
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
done$.complete();
|
||||
});
|
||||
|
||||
describe('#get', () => {
|
||||
it('gives access to config values', () => {
|
||||
const { config } = setup();
|
||||
expect(config.get('dateFormat')).toMatchSnapshot();
|
||||
it('gives access to uiSettings values', () => {
|
||||
const { client } = setup();
|
||||
expect(client.get('dateFormat')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('supports the default value overload', () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
// default values are consumed and returned atomically
|
||||
expect(config.get('obscureProperty1', 'default')).toMatchSnapshot();
|
||||
expect(client.get('obscureProperty1', 'default')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('after a get for an unknown property, the property is not persisted', () => {
|
||||
const { config } = setup();
|
||||
config.get('obscureProperty2', 'default');
|
||||
const { client } = setup();
|
||||
client.get('obscureProperty2', 'default');
|
||||
|
||||
// after a get, default values are NOT persisted
|
||||
expect(() => config.get('obscureProperty2')).toThrowErrorMatchingSnapshot();
|
||||
expect(() => client.get('obscureProperty2')).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
|
||||
it('honors the default parameter for unset options that are exported', () => {
|
||||
const { config } = setup();
|
||||
// if you are hitting this error, then a test is setting this config value globally and not unsetting it!
|
||||
expect(config.isDefault('dateFormat')).toBe(true);
|
||||
const { client } = setup();
|
||||
// if you are hitting this error, then a test is setting this client value globally and not unsetting it!
|
||||
expect(client.isDefault('dateFormat')).toBe(true);
|
||||
|
||||
const defaultDateFormat = config.get('dateFormat');
|
||||
const defaultDateFormat = client.get('dateFormat');
|
||||
|
||||
expect(config.get('dateFormat', 'xyz')).toBe('xyz');
|
||||
expect(client.get('dateFormat', 'xyz')).toBe('xyz');
|
||||
// shouldn't change other usages
|
||||
expect(config.get('dateFormat')).toBe(defaultDateFormat);
|
||||
expect(config.get('dataFormat', defaultDateFormat)).toBe(defaultDateFormat);
|
||||
expect(client.get('dateFormat')).toBe(defaultDateFormat);
|
||||
expect(client.get('dataFormat', defaultDateFormat)).toBe(defaultDateFormat);
|
||||
});
|
||||
|
||||
it("throws on unknown properties that don't have a value yet.", () => {
|
||||
const { config } = setup();
|
||||
expect(() => config.get('throwableProperty')).toThrowErrorMatchingSnapshot();
|
||||
const { client } = setup();
|
||||
expect(() => client.get('throwableProperty')).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#get$', () => {
|
||||
it('emits the current value when called', async () => {
|
||||
const { config } = setup();
|
||||
const values = await config
|
||||
const { client } = setup();
|
||||
const values = await client
|
||||
.get$('dateFormat')
|
||||
.pipe(take(1), toArray())
|
||||
.toPromise();
|
||||
|
@ -90,18 +97,18 @@ describe('#get$', () => {
|
|||
});
|
||||
|
||||
it('emits an error notification if the key is unknown', async () => {
|
||||
const { config } = setup();
|
||||
const values = await config
|
||||
const { client } = setup();
|
||||
const values = await client
|
||||
.get$('unknown key')
|
||||
.pipe(materialize())
|
||||
.toPromise();
|
||||
|
||||
expect(values).toMatchInlineSnapshot(`
|
||||
Notification {
|
||||
"error": [Error: Unexpected \`config.get("unknown key")\` call on unrecognized configuration setting "unknown key".
|
||||
Setting an initial value via \`config.set("unknown key", value)\` before attempting to retrieve
|
||||
"error": [Error: Unexpected \`IUiSettingsClient.get("unknown key")\` call on unrecognized configuration setting "unknown key".
|
||||
Setting an initial value via \`IUiSettingsClient.set("unknown key", value)\` before attempting to retrieve
|
||||
any custom setting value for "unknown key" may fix this issue.
|
||||
You can use \`config.get("unknown key", defaultValue)\`, which will just return
|
||||
You can use \`IUiSettingsClient.get("unknown key", defaultValue)\`, which will just return
|
||||
\`defaultValue\` when the key is unrecognized.],
|
||||
"hasValue": false,
|
||||
"kind": "E",
|
||||
|
@ -111,13 +118,13 @@ You can use \`config.get("unknown key", defaultValue)\`, which will just return
|
|||
});
|
||||
|
||||
it('emits the new value when it changes', async () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
setTimeout(() => {
|
||||
config.set('dateFormat', 'new format');
|
||||
client.set('dateFormat', 'new format');
|
||||
}, 10);
|
||||
|
||||
const values = await config
|
||||
const values = await client
|
||||
.get$('dateFormat')
|
||||
.pipe(take(2), toArray())
|
||||
.toPromise();
|
||||
|
@ -126,17 +133,17 @@ You can use \`config.get("unknown key", defaultValue)\`, which will just return
|
|||
});
|
||||
|
||||
it('emits the default override if no value is set, or if the value is removed', async () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
setTimeout(() => {
|
||||
config.set('dateFormat', 'new format');
|
||||
client.set('dateFormat', 'new format');
|
||||
}, 10);
|
||||
|
||||
setTimeout(() => {
|
||||
config.remove('dateFormat');
|
||||
client.remove('dateFormat');
|
||||
}, 20);
|
||||
|
||||
const values = await config
|
||||
const values = await client
|
||||
.get$('dateFormat', 'my default')
|
||||
.pipe(take(3), toArray())
|
||||
.toPromise();
|
||||
|
@ -146,37 +153,37 @@ You can use \`config.get("unknown key", defaultValue)\`, which will just return
|
|||
});
|
||||
|
||||
describe('#set', () => {
|
||||
it('stores a value in the config val set', () => {
|
||||
const { config } = setup();
|
||||
const original = config.get('dateFormat');
|
||||
config.set('dateFormat', 'notaformat');
|
||||
expect(config.get('dateFormat')).toBe('notaformat');
|
||||
config.set('dateFormat', original);
|
||||
it('stores a value in the client val set', () => {
|
||||
const { client } = setup();
|
||||
const original = client.get('dateFormat');
|
||||
client.set('dateFormat', 'notaformat');
|
||||
expect(client.get('dateFormat')).toBe('notaformat');
|
||||
client.set('dateFormat', original);
|
||||
});
|
||||
|
||||
it('stores a value in a previously unknown config key', () => {
|
||||
const { config } = setup();
|
||||
expect(() => config.set('unrecognizedProperty', 'somevalue')).not.toThrowError();
|
||||
expect(config.get('unrecognizedProperty')).toBe('somevalue');
|
||||
it('stores a value in a previously unknown client key', () => {
|
||||
const { client } = setup();
|
||||
expect(() => client.set('unrecognizedProperty', 'somevalue')).not.toThrowError();
|
||||
expect(client.get('unrecognizedProperty')).toBe('somevalue');
|
||||
});
|
||||
|
||||
it('resolves to true on success', async () => {
|
||||
const { config } = setup();
|
||||
await expect(config.set('foo', 'bar')).resolves.toBe(true);
|
||||
const { client } = setup();
|
||||
await expect(client.set('foo', 'bar')).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it('resolves to false on failure', async () => {
|
||||
const { config, batchSet } = setup();
|
||||
const { client, batchSet } = setup();
|
||||
|
||||
batchSet.mockImplementation(() => {
|
||||
throw new Error('Error in request');
|
||||
});
|
||||
|
||||
await expect(config.set('foo', 'bar')).resolves.toBe(false);
|
||||
await expect(client.set('foo', 'bar')).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it('throws an error if key is overridden', async () => {
|
||||
const { config } = setup({
|
||||
const { client } = setup({
|
||||
initialSettings: {
|
||||
foo: {
|
||||
isOverridden: true,
|
||||
|
@ -184,28 +191,28 @@ describe('#set', () => {
|
|||
},
|
||||
},
|
||||
});
|
||||
await expect(config.set('foo', true)).rejects.toThrowErrorMatchingSnapshot();
|
||||
await expect(client.set('foo', true)).rejects.toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#remove', () => {
|
||||
it('resolves to true on success', async () => {
|
||||
const { config } = setup();
|
||||
await expect(config.remove('dateFormat')).resolves.toBe(true);
|
||||
const { client } = setup();
|
||||
await expect(client.remove('dateFormat')).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it('resolves to false on failure', async () => {
|
||||
const { config, batchSet } = setup();
|
||||
const { client, batchSet } = setup();
|
||||
|
||||
batchSet.mockImplementation(() => {
|
||||
throw new Error('Error in request');
|
||||
});
|
||||
|
||||
await expect(config.remove('dateFormat')).resolves.toBe(false);
|
||||
await expect(client.remove('dateFormat')).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it('throws an error if key is overridden', async () => {
|
||||
const { config } = setup({
|
||||
const { client } = setup({
|
||||
initialSettings: {
|
||||
bar: {
|
||||
isOverridden: true,
|
||||
|
@ -213,81 +220,81 @@ describe('#remove', () => {
|
|||
},
|
||||
},
|
||||
});
|
||||
await expect(config.remove('bar')).rejects.toThrowErrorMatchingSnapshot();
|
||||
await expect(client.remove('bar')).rejects.toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isDeclared', () => {
|
||||
it('returns true if name is know', () => {
|
||||
const { config } = setup();
|
||||
expect(config.isDeclared('dateFormat')).toBe(true);
|
||||
const { client } = setup();
|
||||
expect(client.isDeclared('dateFormat')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false if name is not known', () => {
|
||||
const { config } = setup();
|
||||
expect(config.isDeclared('dateFormat')).toBe(true);
|
||||
const { client } = setup();
|
||||
expect(client.isDeclared('dateFormat')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isDefault', () => {
|
||||
it('returns true if value is default', () => {
|
||||
const { config } = setup();
|
||||
expect(config.isDefault('dateFormat')).toBe(true);
|
||||
const { client } = setup();
|
||||
expect(client.isDefault('dateFormat')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false if name is not known', () => {
|
||||
const { config } = setup();
|
||||
config.set('dateFormat', 'foo');
|
||||
expect(config.isDefault('dateFormat')).toBe(false);
|
||||
const { client } = setup();
|
||||
client.set('dateFormat', 'foo');
|
||||
expect(client.isDefault('dateFormat')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isCustom', () => {
|
||||
it('returns false if name is in from defaults', () => {
|
||||
const { config } = setup();
|
||||
expect(config.isCustom('dateFormat')).toBe(false);
|
||||
const { client } = setup();
|
||||
expect(client.isCustom('dateFormat')).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false for unknown name', () => {
|
||||
const { config } = setup();
|
||||
expect(config.isCustom('foo')).toBe(false);
|
||||
const { client } = setup();
|
||||
expect(client.isCustom('foo')).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true if name is from unknown set()', () => {
|
||||
const { config } = setup();
|
||||
config.set('foo', 'bar');
|
||||
expect(config.isCustom('foo')).toBe(true);
|
||||
const { client } = setup();
|
||||
client.set('foo', 'bar');
|
||||
expect(client.isCustom('foo')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getUpdate$', () => {
|
||||
it('sends { key, newValue, oldValue } notifications when config changes', () => {
|
||||
it('sends { key, newValue, oldValue } notifications when client changes', () => {
|
||||
const handler = jest.fn();
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
config.getUpdate$().subscribe(handler);
|
||||
client.getUpdate$().subscribe(handler);
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
|
||||
config.set('foo', 'bar');
|
||||
client.set('foo', 'bar');
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
expect(handler.mock.calls).toMatchSnapshot();
|
||||
handler.mockClear();
|
||||
|
||||
config.set('foo', 'baz');
|
||||
client.set('foo', 'baz');
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
expect(handler.mock.calls).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('observables complete when client is stopped', () => {
|
||||
const onComplete = jest.fn();
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
config.getUpdate$().subscribe({
|
||||
client.getUpdate$().subscribe({
|
||||
complete: onComplete,
|
||||
});
|
||||
|
||||
expect(onComplete).not.toHaveBeenCalled();
|
||||
config.stop();
|
||||
done$.complete();
|
||||
expect(onComplete).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -295,84 +302,84 @@ describe('#getUpdate$', () => {
|
|||
describe('#overrideLocalDefault', () => {
|
||||
describe('key has no user value', () => {
|
||||
it('synchronously modifies the default value returned by get()', () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
expect(config.get('dateFormat')).toMatchSnapshot('get before override');
|
||||
config.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(config.get('dateFormat')).toMatchSnapshot('get after override');
|
||||
expect(client.get('dateFormat')).toMatchSnapshot('get before override');
|
||||
client.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(client.get('dateFormat')).toMatchSnapshot('get after override');
|
||||
});
|
||||
|
||||
it('synchronously modifies the value returned by getAll()', () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
expect(config.getAll()).toMatchSnapshot('getAll before override');
|
||||
config.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(config.getAll()).toMatchSnapshot('getAll after override');
|
||||
expect(client.getAll()).toMatchSnapshot('getAll before override');
|
||||
client.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(client.getAll()).toMatchSnapshot('getAll after override');
|
||||
});
|
||||
|
||||
it('calls subscriber with new and previous value', () => {
|
||||
const handler = jest.fn();
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
config.getUpdate$().subscribe(handler);
|
||||
config.overrideLocalDefault('dateFormat', 'bar');
|
||||
client.getUpdate$().subscribe(handler);
|
||||
client.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(handler.mock.calls).toMatchSnapshot('single subscriber call');
|
||||
});
|
||||
});
|
||||
|
||||
describe('key with user value', () => {
|
||||
it('does not modify the return value of get', () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
config.set('dateFormat', 'foo');
|
||||
expect(config.get('dateFormat')).toMatchSnapshot('get before override');
|
||||
config.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(config.get('dateFormat')).toMatchSnapshot('get after override');
|
||||
client.set('dateFormat', 'foo');
|
||||
expect(client.get('dateFormat')).toMatchSnapshot('get before override');
|
||||
client.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(client.get('dateFormat')).toMatchSnapshot('get after override');
|
||||
});
|
||||
|
||||
it('is included in the return value of getAll', () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
config.set('dateFormat', 'foo');
|
||||
expect(config.getAll()).toMatchSnapshot('getAll before override');
|
||||
config.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(config.getAll()).toMatchSnapshot('getAll after override');
|
||||
client.set('dateFormat', 'foo');
|
||||
expect(client.getAll()).toMatchSnapshot('getAll before override');
|
||||
client.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(client.getAll()).toMatchSnapshot('getAll after override');
|
||||
});
|
||||
|
||||
it('does not call subscriber', () => {
|
||||
const handler = jest.fn();
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
config.set('dateFormat', 'foo');
|
||||
config.getUpdate$().subscribe(handler);
|
||||
config.overrideLocalDefault('dateFormat', 'bar');
|
||||
client.set('dateFormat', 'foo');
|
||||
client.getUpdate$().subscribe(handler);
|
||||
client.overrideLocalDefault('dateFormat', 'bar');
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('returns default override when setting removed', () => {
|
||||
const { config } = setup();
|
||||
const { client } = setup();
|
||||
|
||||
config.set('dateFormat', 'foo');
|
||||
config.overrideLocalDefault('dateFormat', 'bar');
|
||||
client.set('dateFormat', 'foo');
|
||||
client.overrideLocalDefault('dateFormat', 'bar');
|
||||
|
||||
expect(config.get('dateFormat')).toMatchSnapshot('get before override');
|
||||
expect(config.getAll()).toMatchSnapshot('getAll before override');
|
||||
expect(client.get('dateFormat')).toMatchSnapshot('get before override');
|
||||
expect(client.getAll()).toMatchSnapshot('getAll before override');
|
||||
|
||||
config.remove('dateFormat');
|
||||
client.remove('dateFormat');
|
||||
|
||||
expect(config.get('dateFormat')).toMatchSnapshot('get after override');
|
||||
expect(config.getAll()).toMatchSnapshot('getAll after override');
|
||||
expect(client.get('dateFormat')).toMatchSnapshot('get after override');
|
||||
expect(client.getAll()).toMatchSnapshot('getAll after override');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isOverridden()', () => {
|
||||
it('returns false if key is unknown', () => {
|
||||
const { config } = setup();
|
||||
expect(config.isOverridden('foo')).toBe(false);
|
||||
const { client } = setup();
|
||||
expect(client.isOverridden('foo')).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false if key is no overridden', () => {
|
||||
const { config } = setup({
|
||||
const { client } = setup({
|
||||
initialSettings: {
|
||||
foo: {
|
||||
userValue: 1,
|
||||
|
@ -383,11 +390,11 @@ describe('#overrideLocalDefault', () => {
|
|||
},
|
||||
},
|
||||
});
|
||||
expect(config.isOverridden('foo')).toBe(false);
|
||||
expect(client.isOverridden('foo')).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when key is overridden', () => {
|
||||
const { config } = setup({
|
||||
const { client } = setup({
|
||||
initialSettings: {
|
||||
foo: {
|
||||
userValue: 1,
|
||||
|
@ -398,12 +405,12 @@ describe('#overrideLocalDefault', () => {
|
|||
},
|
||||
},
|
||||
});
|
||||
expect(config.isOverridden('bar')).toBe(true);
|
||||
expect(client.isOverridden('bar')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false for object prototype properties', () => {
|
||||
const { config } = setup();
|
||||
expect(config.isOverridden('hasOwnProperty')).toBe(false);
|
||||
const { client } = setup();
|
||||
expect(client.isOverridden('hasOwnProperty')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,37 +18,25 @@
|
|||
*/
|
||||
|
||||
import { cloneDeep, defaultsDeep } from 'lodash';
|
||||
import * as Rx from 'rxjs';
|
||||
import { Observable, Subject, concat, defer, of } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
|
||||
import { UiSettingsParams, UserProvidedValues } from 'src/core/server/types';
|
||||
import { UiSettingsState } from './types';
|
||||
import { IUiSettingsClient, UiSettingsState } from './types';
|
||||
|
||||
import { UiSettingsApi } from './ui_settings_api';
|
||||
|
||||
/** @public */
|
||||
interface UiSettingsClientParams {
|
||||
api: UiSettingsApi;
|
||||
defaults: Record<string, UiSettingsParams>;
|
||||
initialSettings?: UiSettingsState;
|
||||
done$: Observable<unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-side client that provides access to the advanced settings stored in elasticsearch.
|
||||
* The settings provide control over the behavior of the Kibana application.
|
||||
* For example, a user can specify how to display numeric or date fields.
|
||||
* Users can adjust the settings via Management UI.
|
||||
* {@link UiSettingsClient}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type UiSettingsClientContract = PublicMethodsOf<UiSettingsClient>;
|
||||
|
||||
/** @public */
|
||||
export class UiSettingsClient {
|
||||
private readonly update$ = new Rx.Subject<{ key: string; newValue: any; oldValue: any }>();
|
||||
private readonly saved$ = new Rx.Subject<{ key: string; newValue: any; oldValue: any }>();
|
||||
private readonly updateErrors$ = new Rx.Subject<Error>();
|
||||
export class UiSettingsClient implements IUiSettingsClient {
|
||||
private readonly update$ = new Subject<{ key: string; newValue: any; oldValue: any }>();
|
||||
private readonly saved$ = new Subject<{ key: string; newValue: any; oldValue: any }>();
|
||||
private readonly updateErrors$ = new Subject<Error>();
|
||||
|
||||
private readonly api: UiSettingsApi;
|
||||
private readonly defaults: Record<string, UiSettingsParams>;
|
||||
|
@ -58,24 +46,21 @@ export class UiSettingsClient {
|
|||
this.api = params.api;
|
||||
this.defaults = cloneDeep(params.defaults);
|
||||
this.cache = defaultsDeep({}, this.defaults, cloneDeep(params.initialSettings));
|
||||
|
||||
params.done$.subscribe({
|
||||
complete: () => {
|
||||
this.update$.complete();
|
||||
this.saved$.complete();
|
||||
this.updateErrors$.complete();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata about all uiSettings, including the type, default value, and user value
|
||||
* for each key.
|
||||
*/
|
||||
public getAll() {
|
||||
getAll() {
|
||||
return cloneDeep(this.cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value for a specific uiSetting. If this setting has no user-defined value
|
||||
* then the `defaultOverride` parameter is returned (and parsed if setting is of type
|
||||
* "json" or "number). If the parameter is not defined and the key is not defined by a
|
||||
* uiSettingDefaults then an error is thrown, otherwise the default is read
|
||||
* from the uiSettingDefaults.
|
||||
*/
|
||||
public get(key: string, defaultOverride?: any) {
|
||||
get<T = any>(key: string, defaultOverride?: T) {
|
||||
const declared = this.isDeclared(key);
|
||||
|
||||
if (!declared && defaultOverride !== undefined) {
|
||||
|
@ -84,10 +69,10 @@ export class UiSettingsClient {
|
|||
|
||||
if (!declared) {
|
||||
throw new Error(
|
||||
`Unexpected \`config.get("${key}")\` call on unrecognized configuration setting "${key}".
|
||||
Setting an initial value via \`config.set("${key}", value)\` before attempting to retrieve
|
||||
`Unexpected \`IUiSettingsClient.get("${key}")\` call on unrecognized configuration setting "${key}".
|
||||
Setting an initial value via \`IUiSettingsClient.set("${key}", value)\` before attempting to retrieve
|
||||
any custom setting value for "${key}" may fix this issue.
|
||||
You can use \`config.get("${key}", defaultValue)\`, which will just return
|
||||
You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just return
|
||||
\`defaultValue\` when the key is unrecognized.`
|
||||
);
|
||||
}
|
||||
|
@ -108,13 +93,9 @@ You can use \`config.get("${key}", defaultValue)\`, which will just return
|
|||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an observable of the current value for a config key, and all updates to that config
|
||||
* key in the future. Providing a `defaultOverride` argument behaves the same as it does in #get()
|
||||
*/
|
||||
public get$(key: string, defaultOverride?: any) {
|
||||
return Rx.concat(
|
||||
Rx.defer(() => Rx.of(this.get(key, defaultOverride))),
|
||||
get$<T = any>(key: string, defaultOverride?: T) {
|
||||
return concat(
|
||||
defer(() => of(this.get(key, defaultOverride))),
|
||||
this.update$.pipe(
|
||||
filter(update => update.key === key),
|
||||
map(() => this.get(key, defaultOverride))
|
||||
|
@ -122,63 +103,31 @@ You can use \`config.get("${key}", defaultValue)\`, which will just return
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value for a uiSetting. If the setting is not defined in the uiSettingDefaults
|
||||
* it will be stored as a custom setting. The new value will be synchronously available via
|
||||
* the `get()` method and sent to the server in the background. If the request to the
|
||||
* server fails then a toast notification will be displayed and the setting will be
|
||||
* reverted it its value before `set()` was called.
|
||||
*/
|
||||
public async set(key: string, val: any) {
|
||||
return await this.update(key, val);
|
||||
async set(key: string, value: any) {
|
||||
return await this.update(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the user-defined value for a setting, causing it to revert to the default. This
|
||||
* method behaves the same as calling `set(key, null)`, including the synchronization, custom
|
||||
* setting, and error behavior of that method.
|
||||
*/
|
||||
public async remove(key: string) {
|
||||
async remove(key: string) {
|
||||
return await this.update(key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the key is a "known" uiSetting, meaning it is either defined in the
|
||||
* uiSettingDefaults or was previously added as a custom setting via the `set()` method.
|
||||
*/
|
||||
public isDeclared(key: string) {
|
||||
isDeclared(key: string) {
|
||||
return key in this.cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the setting has no user-defined value or is unknown
|
||||
*/
|
||||
public isDefault(key: string) {
|
||||
isDefault(key: string) {
|
||||
return !this.isDeclared(key) || this.cache[key].userValue == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the setting is not a part of the uiSettingDefaults, but was either
|
||||
* added directly via `set()`, or is an unknown setting found in the uiSettings saved
|
||||
* object
|
||||
*/
|
||||
public isCustom(key: string) {
|
||||
isCustom(key: string) {
|
||||
return this.isDeclared(key) && !('value' in this.cache[key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a settings value is overridden by the server. When a setting is overridden
|
||||
* its value can not be changed via `set()` or `remove()`.
|
||||
*/
|
||||
public isOverridden(key: string) {
|
||||
isOverridden(key: string) {
|
||||
return this.isDeclared(key) && Boolean(this.cache[key].isOverridden);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default value for a setting in this specific browser tab. If the page
|
||||
* is reloaded the default override is lost.
|
||||
*/
|
||||
public overrideLocalDefault(key: string, newDefault: any) {
|
||||
overrideLocalDefault(key: string, newDefault: any) {
|
||||
// capture the previous value
|
||||
const prevDefault = this.defaults[key] ? this.defaults[key].value : undefined;
|
||||
|
||||
|
@ -201,39 +150,18 @@ You can use \`config.get("${key}", defaultValue)\`, which will just return
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Observable that notifies subscribers of each update to the uiSettings,
|
||||
* including the key, newValue, and oldValue of the setting that changed.
|
||||
*/
|
||||
public getUpdate$() {
|
||||
getUpdate$() {
|
||||
return this.update$.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Observable that notifies subscribers of each update to the uiSettings,
|
||||
* including the key, newValue, and oldValue of the setting that changed.
|
||||
*/
|
||||
public getSaved$() {
|
||||
getSaved$() {
|
||||
return this.saved$.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Observable that notifies subscribers of each error while trying to update
|
||||
* the settings, containing the actual Error class.
|
||||
*/
|
||||
public getUpdateErrors$() {
|
||||
getUpdateErrors$() {
|
||||
return this.updateErrors$.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the uiSettingsClient to be discarded, completing any update$ observables
|
||||
* that have been created.
|
||||
*/
|
||||
public stop() {
|
||||
this.update$.complete();
|
||||
this.saved$.complete();
|
||||
}
|
||||
|
||||
private assertUpdateAllowed(key: string) {
|
||||
if (this.isOverridden(key)) {
|
||||
throw new Error(
|
||||
|
@ -242,7 +170,7 @@ You can use \`config.get("${key}", defaultValue)\`, which will just return
|
|||
}
|
||||
}
|
||||
|
||||
private async update(key: string, newVal: any) {
|
||||
private async update(key: string, newVal: any): Promise<boolean> {
|
||||
this.assertUpdateAllowed(key);
|
||||
|
||||
const declared = this.isDeclared(key);
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
import * as Rx from 'rxjs';
|
||||
import { UiSettingsService, UiSettingsClientContract } from './';
|
||||
import { UiSettingsService } from './';
|
||||
import { IUiSettingsClient } from './types';
|
||||
|
||||
const createSetupContractMock = () => {
|
||||
const setupContract: jest.Mocked<UiSettingsClientContract> = {
|
||||
const setupContract: jest.Mocked<IUiSettingsClient> = {
|
||||
getAll: jest.fn(),
|
||||
get: jest.fn(),
|
||||
get$: jest.fn(),
|
||||
|
@ -34,7 +35,6 @@ const createSetupContractMock = () => {
|
|||
getUpdate$: jest.fn(),
|
||||
getSaved$: jest.fn(),
|
||||
getUpdateErrors$: jest.fn(),
|
||||
stop: jest.fn(),
|
||||
};
|
||||
setupContract.get$.mockReturnValue(new Rx.Subject<any>());
|
||||
setupContract.getUpdate$.mockReturnValue(new Rx.Subject<any>());
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function mockClass<T>(
|
||||
module: string,
|
||||
Class: new (...args: any[]) => T,
|
||||
setup: (instance: any, args: any[]) => void
|
||||
) {
|
||||
const MockClass = jest.fn(function(this: any, ...args: any[]) {
|
||||
setup(this, args);
|
||||
});
|
||||
|
||||
// define the mock name which is used in some snapshots
|
||||
MockClass.mockName(`Mock${Class.name}`);
|
||||
|
||||
// define the class name for the MockClass which is used in other snapshots
|
||||
Object.defineProperty(MockClass, 'name', {
|
||||
value: `Mock${Class.name}`,
|
||||
});
|
||||
|
||||
jest.doMock(module, () => ({
|
||||
[Class.name]: MockClass,
|
||||
}));
|
||||
|
||||
return MockClass;
|
||||
}
|
||||
|
||||
// Mock the UiSettingsApi class
|
||||
import { UiSettingsApi } from './ui_settings_api';
|
||||
export const MockUiSettingsApi = mockClass('./ui_settings_api', UiSettingsApi, inst => {
|
||||
inst.stop = jest.fn();
|
||||
inst.getLoadingCount$ = jest.fn().mockReturnValue({
|
||||
loadingCountObservable: true,
|
||||
});
|
||||
});
|
||||
|
||||
// Mock the UiSettingsClient class
|
||||
import { UiSettingsClient } from './ui_settings_client';
|
||||
export const MockUiSettingsClient = mockClass('./ui_settings_client', UiSettingsClient, inst => {
|
||||
inst.stop = jest.fn();
|
||||
});
|
|
@ -16,8 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { MockUiSettingsApi, MockUiSettingsClient } from './ui_settings_service.test.mocks';
|
||||
import * as Rx from 'rxjs';
|
||||
|
||||
import { httpServiceMock } from '../http/http_service.mock';
|
||||
import { injectedMetadataServiceMock } from '../injected_metadata/injected_metadata_service.mock';
|
||||
|
@ -30,53 +29,27 @@ const defaultDeps = {
|
|||
injectedMetadata: injectedMetadataServiceMock.createSetupContract(),
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('#setup', () => {
|
||||
it('returns an instance of UiSettingsClient', () => {
|
||||
const setup = new UiSettingsService().setup(defaultDeps);
|
||||
expect(setup).toBeInstanceOf(MockUiSettingsClient);
|
||||
});
|
||||
|
||||
it('constructs UiSettingsClient and UiSettingsApi', () => {
|
||||
new UiSettingsService().setup(defaultDeps);
|
||||
|
||||
expect(MockUiSettingsApi).toMatchSnapshot('UiSettingsApi args');
|
||||
expect(MockUiSettingsClient).toMatchSnapshot('UiSettingsClient args');
|
||||
});
|
||||
|
||||
it('passes the uiSettings loading count to the loading count api', () => {
|
||||
new UiSettingsService().setup(defaultDeps);
|
||||
|
||||
expect(httpSetup.addLoadingCount).toMatchSnapshot('http.addLoadingCount calls');
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
expect(() => service.stop()).not.toThrowError();
|
||||
});
|
||||
|
||||
it('stops the uiSettingsClient and uiSettingsApi', () => {
|
||||
it('stops the uiSettingsClient and uiSettingsApi', async () => {
|
||||
const service = new UiSettingsService();
|
||||
let loadingCount$: Rx.Observable<unknown>;
|
||||
defaultDeps.http.addLoadingCount.mockImplementation(obs$ => (loadingCount$ = obs$));
|
||||
const client = service.setup(defaultDeps);
|
||||
const [[{ api }]] = MockUiSettingsClient.mock.calls;
|
||||
jest.spyOn(client, 'stop');
|
||||
jest.spyOn(api, 'stop');
|
||||
|
||||
service.stop();
|
||||
expect(api.stop).toHaveBeenCalledTimes(1);
|
||||
expect(client.stop).toHaveBeenCalledTimes(1);
|
||||
|
||||
await expect(
|
||||
Rx.combineLatest(
|
||||
client.getUpdate$(),
|
||||
client.getSaved$(),
|
||||
client.getUpdateErrors$(),
|
||||
loadingCount$!
|
||||
).toPromise()
|
||||
).resolves.toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,12 +16,14 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import { HttpSetup } from '../http';
|
||||
import { InjectedMetadataSetup } from '../injected_metadata';
|
||||
|
||||
import { UiSettingsApi } from './ui_settings_api';
|
||||
import { UiSettingsClient, UiSettingsClientContract } from './ui_settings_client';
|
||||
import { UiSettingsClient } from './ui_settings_client';
|
||||
import { IUiSettingsClient } from './types';
|
||||
|
||||
interface UiSettingsServiceDeps {
|
||||
http: HttpSetup;
|
||||
|
@ -32,8 +34,9 @@ interface UiSettingsServiceDeps {
|
|||
export class UiSettingsService {
|
||||
private uiSettingsApi?: UiSettingsApi;
|
||||
private uiSettingsClient?: UiSettingsClient;
|
||||
private done$ = new Subject();
|
||||
|
||||
public setup({ http, injectedMetadata }: UiSettingsServiceDeps): UiSettingsClientContract {
|
||||
public setup({ http, injectedMetadata }: UiSettingsServiceDeps): IUiSettingsClient {
|
||||
this.uiSettingsApi = new UiSettingsApi(http);
|
||||
http.addLoadingCount(this.uiSettingsApi.getLoadingCount$());
|
||||
|
||||
|
@ -44,19 +47,18 @@ export class UiSettingsService {
|
|||
api: this.uiSettingsApi,
|
||||
defaults: legacyMetadata.uiSettings.defaults,
|
||||
initialSettings: legacyMetadata.uiSettings.user,
|
||||
done$: this.done$,
|
||||
});
|
||||
|
||||
return this.uiSettingsClient;
|
||||
}
|
||||
|
||||
public start(): UiSettingsClientContract {
|
||||
public start(): IUiSettingsClient {
|
||||
return this.uiSettingsClient!;
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.uiSettingsClient) {
|
||||
this.uiSettingsClient.stop();
|
||||
}
|
||||
this.done$.complete();
|
||||
|
||||
if (this.uiSettingsApi) {
|
||||
this.uiSettingsApi.stop();
|
||||
|
|
|
@ -48,7 +48,7 @@ export class ContextService {
|
|||
* export interface VizRenderContext {
|
||||
* core: {
|
||||
* i18n: I18nStart;
|
||||
* uiSettings: UISettingsClientContract;
|
||||
* uiSettings: IUiSettingsClient;
|
||||
* }
|
||||
* [contextName: string]: unknown;
|
||||
* }
|
||||
|
|
|
@ -735,15 +735,15 @@ export type IScopedClusterClient = Pick<ScopedClusterClient, 'callAsCurrentUser'
|
|||
|
||||
// @public
|
||||
export interface IUiSettingsClient {
|
||||
get: <T extends SavedObjectAttribute = any>(key: string) => Promise<T>;
|
||||
getAll: <T extends SavedObjectAttribute = any>() => Promise<Record<string, T>>;
|
||||
get: <T = any>(key: string) => Promise<T>;
|
||||
getAll: <T = any>() => Promise<Record<string, T>>;
|
||||
getRegistered: () => Readonly<Record<string, UiSettingsParams>>;
|
||||
getUserProvided: <T extends SavedObjectAttribute = any>() => Promise<Record<string, UserProvidedValues<T>>>;
|
||||
getUserProvided: <T = any>() => Promise<Record<string, UserProvidedValues<T>>>;
|
||||
isOverridden: (key: string) => boolean;
|
||||
remove: (key: string) => Promise<void>;
|
||||
removeMany: (keys: string[]) => Promise<void>;
|
||||
set: <T extends SavedObjectAttribute = any>(key: string, value: T) => Promise<void>;
|
||||
setMany: <T extends SavedObjectAttribute = any>(changes: Record<string, T>) => Promise<void>;
|
||||
set: (key: string, value: any) => Promise<void>;
|
||||
setMany: (changes: Record<string, any>) => Promise<void>;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -1650,7 +1650,7 @@ export interface UiSettingsServiceSetup {
|
|||
export type UiSettingsType = 'json' | 'markdown' | 'number' | 'select' | 'boolean' | 'string';
|
||||
|
||||
// @public
|
||||
export interface UserProvidedValues<T extends SavedObjectAttribute = any> {
|
||||
export interface UserProvidedValues<T = any> {
|
||||
// (undocumented)
|
||||
isOverridden?: boolean;
|
||||
// (undocumented)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { defaults } from 'lodash';
|
||||
|
||||
import { SavedObjectsClientContract, SavedObjectAttribute } from '../../saved_objects/types';
|
||||
import { SavedObjectsClientContract } from '../../saved_objects/types';
|
||||
import { SavedObjectsErrorHelpers } from '../../saved_objects/';
|
||||
import { Logger } from '../../logging';
|
||||
|
||||
|
@ -33,9 +33,9 @@ interface Options {
|
|||
handleWriteErrors: boolean;
|
||||
}
|
||||
|
||||
export async function createOrUpgradeSavedConfig<T extends SavedObjectAttribute = any>(
|
||||
export async function createOrUpgradeSavedConfig(
|
||||
options: Options
|
||||
): Promise<Record<string, T> | undefined> {
|
||||
): Promise<Record<string, any> | undefined> {
|
||||
const { savedObjectsClient, version, buildNum, log, handleWriteErrors } = options;
|
||||
|
||||
// try to find an older config we can upgrade
|
||||
|
|
|
@ -33,25 +33,23 @@ export interface IUiSettingsClient {
|
|||
/**
|
||||
* Retrieves uiSettings values set by the user with fallbacks to default values if not specified.
|
||||
*/
|
||||
get: <T extends SavedObjectAttribute = any>(key: string) => Promise<T>;
|
||||
get: <T = any>(key: string) => Promise<T>;
|
||||
/**
|
||||
* Retrieves a set of all uiSettings values set by the user with fallbacks to default values if not specified.
|
||||
*/
|
||||
getAll: <T extends SavedObjectAttribute = any>() => Promise<Record<string, T>>;
|
||||
getAll: <T = any>() => Promise<Record<string, T>>;
|
||||
/**
|
||||
* Retrieves a set of all uiSettings values set by the user.
|
||||
*/
|
||||
getUserProvided: <T extends SavedObjectAttribute = any>() => Promise<
|
||||
Record<string, UserProvidedValues<T>>
|
||||
>;
|
||||
getUserProvided: <T = any>() => Promise<Record<string, UserProvidedValues<T>>>;
|
||||
/**
|
||||
* Writes multiple uiSettings values and marks them as set by the user.
|
||||
*/
|
||||
setMany: <T extends SavedObjectAttribute = any>(changes: Record<string, T>) => Promise<void>;
|
||||
setMany: (changes: Record<string, any>) => Promise<void>;
|
||||
/**
|
||||
* Writes uiSettings value and marks it as set by the user.
|
||||
*/
|
||||
set: <T extends SavedObjectAttribute = any>(key: string, value: T) => Promise<void>;
|
||||
set: (key: string, value: any) => Promise<void>;
|
||||
/**
|
||||
* Removes uiSettings value by key.
|
||||
*/
|
||||
|
@ -70,7 +68,7 @@ export interface IUiSettingsClient {
|
|||
* Describes the values explicitly set by user.
|
||||
* @public
|
||||
* */
|
||||
export interface UserProvidedValues<T extends SavedObjectAttribute = any> {
|
||||
export interface UserProvidedValues<T = any> {
|
||||
userValue?: T;
|
||||
isOverridden?: boolean;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import { defaultsDeep } from 'lodash';
|
||||
|
||||
import { SavedObjectsErrorHelpers } from '../saved_objects';
|
||||
import { SavedObjectsClientContract, SavedObjectAttribute } from '../saved_objects/types';
|
||||
import { SavedObjectsClientContract } from '../saved_objects/types';
|
||||
import { Logger } from '../logging';
|
||||
import { createOrUpgradeSavedConfig } from './create_or_upgrade_saved_config';
|
||||
import { IUiSettingsClient, UiSettingsParams } from './types';
|
||||
|
@ -30,7 +30,7 @@ export interface UiSettingsServiceOptions {
|
|||
id: string;
|
||||
buildNum: number;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
overrides?: Record<string, SavedObjectAttribute>;
|
||||
overrides?: Record<string, any>;
|
||||
defaults?: Record<string, UiSettingsParams>;
|
||||
log: Logger;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ interface ReadOptions {
|
|||
autoCreateOrUpgradeIfMissing?: boolean;
|
||||
}
|
||||
|
||||
interface UserProvidedValue<T extends SavedObjectAttribute = any> {
|
||||
interface UserProvidedValue<T = any> {
|
||||
userValue?: T;
|
||||
isOverridden?: boolean;
|
||||
}
|
||||
|
||||
type UiSettingsRawValue = UiSettingsParams & UserProvidedValue;
|
||||
|
||||
type UserProvided<T extends SavedObjectAttribute = any> = Record<string, UserProvidedValue<T>>;
|
||||
type UserProvided<T = any> = Record<string, UserProvidedValue<T>>;
|
||||
type UiSettingsRaw = Record<string, UiSettingsRawValue>;
|
||||
|
||||
export class UiSettingsClient implements IUiSettingsClient {
|
||||
|
@ -75,12 +75,12 @@ export class UiSettingsClient implements IUiSettingsClient {
|
|||
return this.defaults;
|
||||
}
|
||||
|
||||
async get<T extends SavedObjectAttribute = any>(key: string): Promise<T> {
|
||||
async get<T = any>(key: string): Promise<T> {
|
||||
const all = await this.getAll();
|
||||
return all[key];
|
||||
}
|
||||
|
||||
async getAll<T extends SavedObjectAttribute = any>() {
|
||||
async getAll<T = any>() {
|
||||
const raw = await this.getRaw();
|
||||
|
||||
return Object.keys(raw).reduce((all, key) => {
|
||||
|
@ -90,7 +90,7 @@ export class UiSettingsClient implements IUiSettingsClient {
|
|||
}, {} as Record<string, T>);
|
||||
}
|
||||
|
||||
async getUserProvided<T extends SavedObjectAttribute = any>(): Promise<UserProvided<T>> {
|
||||
async getUserProvided<T = any>(): Promise<UserProvided<T>> {
|
||||
const userProvided: UserProvided = {};
|
||||
|
||||
// write the userValue for each key stored in the saved object that is not overridden
|
||||
|
@ -112,11 +112,11 @@ export class UiSettingsClient implements IUiSettingsClient {
|
|||
return userProvided;
|
||||
}
|
||||
|
||||
async setMany<T extends SavedObjectAttribute = any>(changes: Record<string, T>) {
|
||||
async setMany(changes: Record<string, any>) {
|
||||
await this.write({ changes });
|
||||
}
|
||||
|
||||
async set<T extends SavedObjectAttribute = any>(key: string, value: T) {
|
||||
async set(key: string, value: any) {
|
||||
await this.setMany({ [key]: value });
|
||||
}
|
||||
|
||||
|
@ -147,11 +147,11 @@ export class UiSettingsClient implements IUiSettingsClient {
|
|||
return defaultsDeep(userProvided, this.defaults);
|
||||
}
|
||||
|
||||
private async write<T extends SavedObjectAttribute = any>({
|
||||
private async write({
|
||||
changes,
|
||||
autoCreateOrUpgradeIfMissing = true,
|
||||
}: {
|
||||
changes: Record<string, T>;
|
||||
changes: Record<string, any>;
|
||||
autoCreateOrUpgradeIfMissing?: boolean;
|
||||
}) {
|
||||
for (const key of Object.keys(changes)) {
|
||||
|
@ -180,16 +180,16 @@ export class UiSettingsClient implements IUiSettingsClient {
|
|||
}
|
||||
}
|
||||
|
||||
private async read<T extends SavedObjectAttribute>({
|
||||
private async read({
|
||||
ignore401Errors = false,
|
||||
autoCreateOrUpgradeIfMissing = true,
|
||||
}: ReadOptions = {}): Promise<Record<string, T>> {
|
||||
}: ReadOptions = {}): Promise<Record<string, any>> {
|
||||
try {
|
||||
const resp = await this.savedObjectsClient.get(this.type, this.id);
|
||||
return resp.attributes;
|
||||
} catch (error) {
|
||||
if (SavedObjectsErrorHelpers.isNotFoundError(error) && autoCreateOrUpgradeIfMissing) {
|
||||
const failedUpgradeAttributes = await createOrUpgradeSavedConfig<T>({
|
||||
const failedUpgradeAttributes = await createOrUpgradeSavedConfig({
|
||||
savedObjectsClient: this.savedObjectsClient,
|
||||
version: this.id,
|
||||
buildNum: this.buildNum,
|
||||
|
|
|
@ -23,7 +23,7 @@ import { CoreService } from '../../types';
|
|||
import { CoreContext } from '../core_context';
|
||||
import { Logger } from '../logging';
|
||||
|
||||
import { SavedObjectsClientContract, SavedObjectAttribute } from '../saved_objects/types';
|
||||
import { SavedObjectsClientContract } from '../saved_objects/types';
|
||||
import { InternalHttpServiceSetup } from '../http';
|
||||
import { UiSettingsConfigType } from './ui_settings_config';
|
||||
import { UiSettingsClient } from './ui_settings_client';
|
||||
|
@ -84,7 +84,7 @@ export class UiSettingsService implements CoreService<InternalUiSettingsServiceS
|
|||
|
||||
private async getOverrides(deps: SetupDeps) {
|
||||
const config = await this.config$.pipe(first()).toPromise();
|
||||
const overrides: Record<string, SavedObjectAttribute> = config.overrides;
|
||||
const overrides: Record<string, any> = config.overrides;
|
||||
// manually implemented deprecation until New platform Config service
|
||||
// supports them https://github.com/elastic/kibana/issues/40255
|
||||
if (typeof deps.http.config.defaultRoute !== 'undefined') {
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
|
||||
// eslint-disable-next-line max-classes-per-file
|
||||
import { IndexPatterns } from './index_patterns';
|
||||
import {
|
||||
SavedObjectsClientContract,
|
||||
UiSettingsClientContract,
|
||||
HttpServiceBase,
|
||||
} from 'kibana/public';
|
||||
import { SavedObjectsClientContract, IUiSettingsClient, HttpServiceBase } from 'kibana/public';
|
||||
|
||||
jest.mock('./index_pattern', () => {
|
||||
class IndexPattern {
|
||||
|
@ -52,7 +48,7 @@ describe('IndexPatterns', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
const savedObjectsClient = {} as SavedObjectsClientContract;
|
||||
const uiSettings = {} as UiSettingsClientContract;
|
||||
const uiSettings = {} as IUiSettingsClient;
|
||||
const http = {} as HttpServiceBase;
|
||||
|
||||
indexPatterns = new IndexPatterns(uiSettings, savedObjectsClient, http);
|
||||
|
|
|
@ -21,7 +21,7 @@ import { idx } from '@kbn/elastic-idx';
|
|||
import {
|
||||
SavedObjectsClientContract,
|
||||
SimpleSavedObject,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
HttpServiceBase,
|
||||
} from 'src/core/public';
|
||||
|
||||
|
@ -32,13 +32,13 @@ import { IndexPatternsApiClient, GetFieldsOptions } from './index_patterns_api_c
|
|||
const indexPatternCache = createIndexPatternCache();
|
||||
|
||||
export class IndexPatterns {
|
||||
private config: UiSettingsClientContract;
|
||||
private config: IUiSettingsClient;
|
||||
private savedObjectsClient: SavedObjectsClientContract;
|
||||
private savedObjectsCache?: Array<SimpleSavedObject<Record<string, any>>> | null;
|
||||
private apiClient: IndexPatternsApiClient;
|
||||
|
||||
constructor(
|
||||
config: UiSettingsClientContract,
|
||||
config: IUiSettingsClient,
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
http: HttpServiceBase
|
||||
) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
SavedObjectsClientContract,
|
||||
HttpServiceBase,
|
||||
NotificationsStart,
|
||||
|
@ -36,7 +36,7 @@ import {
|
|||
} from './index_patterns';
|
||||
|
||||
export interface IndexPatternDependencies {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
http: HttpServiceBase;
|
||||
notifications: NotificationsStart;
|
||||
|
|
|
@ -344,7 +344,6 @@ exports[`QueryStringInput Should disable autoFocus on EuiFieldText when disableA
|
|||
"overrideLocalDefault": [MockFunction],
|
||||
"remove": [MockFunction],
|
||||
"set": [MockFunction],
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -907,7 +906,6 @@ exports[`QueryStringInput Should disable autoFocus on EuiFieldText when disableA
|
|||
"overrideLocalDefault": [MockFunction],
|
||||
"remove": [MockFunction],
|
||||
"set": [MockFunction],
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1458,7 +1456,6 @@ exports[`QueryStringInput Should pass the query language to the language switche
|
|||
"overrideLocalDefault": [MockFunction],
|
||||
"remove": [MockFunction],
|
||||
"set": [MockFunction],
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -2018,7 +2015,6 @@ exports[`QueryStringInput Should pass the query language to the language switche
|
|||
"overrideLocalDefault": [MockFunction],
|
||||
"remove": [MockFunction],
|
||||
"set": [MockFunction],
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -2569,7 +2565,6 @@ exports[`QueryStringInput Should render the given query 1`] = `
|
|||
"overrideLocalDefault": [MockFunction],
|
||||
"remove": [MockFunction],
|
||||
"set": [MockFunction],
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -3129,7 +3124,6 @@ exports[`QueryStringInput Should render the given query 1`] = `
|
|||
"overrideLocalDefault": [MockFunction],
|
||||
"remove": [MockFunction],
|
||||
"set": [MockFunction],
|
||||
"stop": [MockFunction],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { isEmpty } from 'lodash';
|
||||
import { UiSettingsClientContract, SavedObjectsClientContract } from 'src/core/public';
|
||||
import { IUiSettingsClient, SavedObjectsClientContract } from 'src/core/public';
|
||||
import { getFromSavedObject } from '../../../index_patterns';
|
||||
|
||||
export async function fetchIndexPatterns(
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
indexPatternStrings: string[],
|
||||
uiSettings: UiSettingsClientContract
|
||||
uiSettings: IUiSettingsClient
|
||||
) {
|
||||
if (!indexPatternStrings || isEmpty(indexPatternStrings)) {
|
||||
return [];
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
ChromeStart,
|
||||
LegacyCoreStart,
|
||||
SavedObjectsClientContract,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
} from 'kibana/public';
|
||||
import { Storage } from '../../../../../plugins/kibana_utils/public';
|
||||
import {
|
||||
|
@ -64,7 +64,7 @@ export interface RenderDeps {
|
|||
dashboardConfig: any;
|
||||
savedDashboards: any;
|
||||
dashboardCapabilities: any;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
chrome: ChromeStart;
|
||||
addBasePath: (path: string) => string;
|
||||
savedQueryService: NpDataStart['query']['savedQueries'];
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
NotificationsSetup,
|
||||
OverlayStart,
|
||||
SavedObjectsClientContract,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
UiSettingsState,
|
||||
} from 'kibana/public';
|
||||
import { UiStatsMetricType } from '@kbn/analytics';
|
||||
|
@ -50,7 +50,7 @@ export interface HomeKibanaServices {
|
|||
getInjected: (name: string, defaultValue?: any) => unknown;
|
||||
chrome: ChromeStart;
|
||||
telemetryOptInProvider: any;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
http: HttpStart;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
toastNotifications: NotificationsSetup['toasts'];
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
CoreStart,
|
||||
Plugin,
|
||||
PluginInitializerContext,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
} from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
|
@ -35,7 +35,7 @@ import { createRegionMapTypeDefinition } from './region_map_type';
|
|||
|
||||
/** @private */
|
||||
interface RegionMapVisualizationDependencies extends LegacyDependenciesPluginSetup {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
CoreStart,
|
||||
Plugin,
|
||||
PluginInitializerContext,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
} from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
|
@ -35,7 +35,7 @@ import { createTileMapTypeDefinition } from './tile_map_type';
|
|||
|
||||
/** @private */
|
||||
interface TileMapVisualizationDependencies extends LegacyDependenciesPluginSetup {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
CoreStart,
|
||||
Plugin,
|
||||
PluginInitializerContext,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
HttpSetup,
|
||||
} from 'kibana/public';
|
||||
import { Plugin as ExpressionsPlugin } from 'src/plugins/expressions/public';
|
||||
|
@ -35,7 +35,7 @@ import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim'
|
|||
|
||||
/** @internal */
|
||||
export interface TimelionVisualizationDependencies extends LegacyDependenciesPluginSetup {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
http: HttpSetup;
|
||||
timelionPanels: Map<string, Panel>;
|
||||
timefilter: TimefilterContract;
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { UiSettingsClientContract, SavedObjectsClientContract } from 'src/core/public';
|
||||
import { IUiSettingsClient, SavedObjectsClientContract } from 'src/core/public';
|
||||
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
|
||||
|
||||
export interface ICoreStartContext {
|
||||
appName: string;
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
storage: IStorageWrapper;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
CoreStart,
|
||||
Plugin,
|
||||
SavedObjectsClientContract,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
} from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
|
@ -37,7 +37,7 @@ export interface MetricsPluginSetupDependencies {
|
|||
visualizations: VisualizationsSetup;
|
||||
}
|
||||
export interface MetricsVisualizationDependencies {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { I18nStart, SavedObjectsStart, UiSettingsClientContract } from 'src/core/public';
|
||||
import { I18nStart, SavedObjectsStart, IUiSettingsClient } from 'src/core/public';
|
||||
import { createGetterSetter } from '../../../../plugins/kibana_utils/public';
|
||||
|
||||
export const [getUISettings, setUISettings] = createGetterSetter<UiSettingsClientContract>(
|
||||
'UISettings'
|
||||
);
|
||||
export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');
|
||||
|
||||
export const [getSavedObjectsClient, setSavedObjectsClient] = createGetterSetter<SavedObjectsStart>(
|
||||
'SavedObjectsClient'
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
CoreSetup,
|
||||
CoreStart,
|
||||
Plugin,
|
||||
UiSettingsClientContract,
|
||||
IUiSettingsClient,
|
||||
} from '../../../../core/public';
|
||||
import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
|
@ -32,7 +32,7 @@ import { createVegaTypeDefinition } from './vega_type';
|
|||
|
||||
/** @internal */
|
||||
export interface VegaVisualizationDependencies extends LegacyDependenciesPluginSetup {
|
||||
uiSettings: UiSettingsClientContract;
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -17,13 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { I18nStart, UiSettingsClientContract } from 'src/core/public';
|
||||
import { I18nStart, IUiSettingsClient } from 'src/core/public';
|
||||
import { TypesStart } from './types';
|
||||
import { createGetterSetter } from '../../../../../../plugins/kibana_utils/public';
|
||||
|
||||
export const [getUISettings, setUISettings] = createGetterSetter<UiSettingsClientContract>(
|
||||
'UISettings'
|
||||
);
|
||||
export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');
|
||||
|
||||
export const [getTypes, setTypes] = createGetterSetter<TypesStart>('Types');
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ describe('date_range params', () => {
|
|||
});
|
||||
|
||||
it('should use the Kibana time_zone if no parameter specified', () => {
|
||||
npStart.core.uiSettings.get = jest.fn(() => 'kibanaTimeZone');
|
||||
npStart.core.uiSettings.get = jest.fn(() => 'kibanaTimeZone' as any);
|
||||
|
||||
const aggConfigs = getAggConfigs(
|
||||
{
|
||||
|
|
|
@ -159,7 +159,7 @@ describe('Histogram Agg', () => {
|
|||
}
|
||||
|
||||
// mock histogram:maxBars value;
|
||||
npStart.core.uiSettings.get = jest.fn(() => maxBars);
|
||||
npStart.core.uiSettings.get = jest.fn(() => maxBars as any);
|
||||
|
||||
return aggConfig.write(aggConfigs).params;
|
||||
};
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
import { fetchSoon } from './fetch_soon';
|
||||
import { callClient } from './call_client';
|
||||
import { UiSettingsClientContract } from '../../../../../core/public';
|
||||
import { IUiSettingsClient } from '../../../../../core/public';
|
||||
import { FetchHandlers, FetchOptions } from './types';
|
||||
import { SearchRequest, SearchResponse } from '../types';
|
||||
|
||||
function getConfigStub(config: any = {}) {
|
||||
return {
|
||||
get: key => config[key],
|
||||
} as UiSettingsClientContract;
|
||||
} as IUiSettingsClient;
|
||||
}
|
||||
|
||||
const mockResponses: Record<string, SearchResponse> = {
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
|
||||
import { getMSearchParams, getSearchParams } from './get_search_params';
|
||||
import { UiSettingsClientContract } from '../../../../../core/public';
|
||||
import { IUiSettingsClient } from '../../../../../core/public';
|
||||
|
||||
function getConfigStub(config: any = {}) {
|
||||
return {
|
||||
get: key => config[key],
|
||||
} as UiSettingsClientContract;
|
||||
} as IUiSettingsClient;
|
||||
}
|
||||
|
||||
describe('getMSearchParams', () => {
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { UiSettingsClientContract } from '../../../../../core/public';
|
||||
import { IUiSettingsClient } from '../../../../../core/public';
|
||||
|
||||
const sessionId = Date.now();
|
||||
|
||||
export function getMSearchParams(config: UiSettingsClientContract) {
|
||||
export function getMSearchParams(config: IUiSettingsClient) {
|
||||
return {
|
||||
rest_total_hits_as_int: true,
|
||||
ignore_throttled: getIgnoreThrottled(config),
|
||||
|
@ -29,7 +29,7 @@ export function getMSearchParams(config: UiSettingsClientContract) {
|
|||
};
|
||||
}
|
||||
|
||||
export function getSearchParams(config: UiSettingsClientContract, esShardTimeout: number = 0) {
|
||||
export function getSearchParams(config: IUiSettingsClient, esShardTimeout: number = 0) {
|
||||
return {
|
||||
rest_total_hits_as_int: true,
|
||||
ignore_unavailable: true,
|
||||
|
@ -40,16 +40,16 @@ export function getSearchParams(config: UiSettingsClientContract, esShardTimeout
|
|||
};
|
||||
}
|
||||
|
||||
export function getIgnoreThrottled(config: UiSettingsClientContract) {
|
||||
export function getIgnoreThrottled(config: IUiSettingsClient) {
|
||||
return !config.get('search:includeFrozen');
|
||||
}
|
||||
|
||||
export function getMaxConcurrentShardRequests(config: UiSettingsClientContract) {
|
||||
export function getMaxConcurrentShardRequests(config: IUiSettingsClient) {
|
||||
const maxConcurrentShardRequests = config.get('courier:maxConcurrentShardRequests');
|
||||
return maxConcurrentShardRequests > 0 ? maxConcurrentShardRequests : undefined;
|
||||
}
|
||||
|
||||
export function getPreference(config: UiSettingsClientContract) {
|
||||
export function getPreference(config: IUiSettingsClient) {
|
||||
const setRequestPreference = config.get('courier:setRequestPreference');
|
||||
if (setRequestPreference === 'sessionId') return sessionId;
|
||||
return setRequestPreference === 'custom'
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { UiSettingsClientContract } from '../../../../../core/public';
|
||||
import { IUiSettingsClient } from '../../../../../core/public';
|
||||
import { SearchRequest, SearchResponse } from '../types';
|
||||
|
||||
export interface ApiCaller {
|
||||
|
@ -36,6 +36,6 @@ export interface FetchOptions {
|
|||
|
||||
export interface FetchHandlers {
|
||||
es: ApiCaller;
|
||||
config: UiSettingsClientContract;
|
||||
config: IUiSettingsClient;
|
||||
esShardTimeout: number;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { defaultSearchStrategy } from './default_search_strategy';
|
||||
import { UiSettingsClientContract } from '../../../../../core/public';
|
||||
import { IUiSettingsClient } from '../../../../../core/public';
|
||||
import { SearchStrategySearchParams } from './types';
|
||||
|
||||
const { search } = defaultSearchStrategy;
|
||||
|
@ -26,7 +26,7 @@ const { search } = defaultSearchStrategy;
|
|||
function getConfigStub(config: any = {}) {
|
||||
return {
|
||||
get: key => config[key],
|
||||
} as UiSettingsClientContract;
|
||||
} as IUiSettingsClient;
|
||||
}
|
||||
|
||||
const msearchMockResponse: any = Promise.resolve([]);
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
import chrome from '../chrome';
|
||||
|
||||
import { parse as parseUrl } from 'url';
|
||||
import { Subject } from 'rxjs';
|
||||
import sinon from 'sinon';
|
||||
import { metadata } from '../metadata';
|
||||
import { UiSettingsClient } from '../../../../core/public';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { UiSettingsClient } from '../../../../core/public/ui_settings';
|
||||
|
||||
import './test_harness.css';
|
||||
import 'ng_mock';
|
||||
|
@ -46,10 +48,12 @@ before(() => {
|
|||
});
|
||||
|
||||
let stubUiSettings;
|
||||
let done$;
|
||||
function createStubUiSettings() {
|
||||
if (stubUiSettings) {
|
||||
stubUiSettings.stop();
|
||||
done$.complete();
|
||||
}
|
||||
done$ = new Subject();
|
||||
|
||||
stubUiSettings = new UiSettingsClient({
|
||||
api: {
|
||||
|
@ -60,6 +64,7 @@ function createStubUiSettings() {
|
|||
onUpdateError: () => {},
|
||||
defaults: metadata.uiSettings.defaults,
|
||||
initialSettings: {},
|
||||
done$,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
import { get } from 'lodash';
|
||||
import { getEsQueryConfig } from './get_es_query_config';
|
||||
import { UiSettingsClientContract } from 'kibana/public';
|
||||
import { IUiSettingsClient } from 'kibana/public';
|
||||
|
||||
const config = ({
|
||||
get(item: string) {
|
||||
|
@ -36,7 +36,7 @@ const config = ({
|
|||
'dateFormat:tz': {
|
||||
dateFormatTZ: 'Browser',
|
||||
},
|
||||
} as unknown) as UiSettingsClientContract;
|
||||
} as unknown) as IUiSettingsClient;
|
||||
|
||||
describe('getEsQueryConfig', () => {
|
||||
test('should return the parameters of an Elasticsearch query config requested', () => {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue