Skip to content

Commit

Permalink
Add UiSettings validation & Kibana default route redirection (#59694) (
Browse files Browse the repository at this point in the history
…#60257)

* add schema to ui settings params

* add validation for defaults and overrides

* validate in ui settings client

* ui settings routes validation

* clean up tests

* use schema for defaultRoutes

* move URL redirection to NP

* fix spaces test

* update docs

* update kbn pm

* fix karma test

* fix tests

* address comments

* get rid of getDEfaultRoute

* regen docs

* fix tests

* fix enter-spaces test

* validate on relative url format

* update i18n

* fix enter-spoace test

* move relative url validation to utils

* add CoreApp containing application logic

* extract public uiSettings params in a separate type

* make schema required

* update docs
  • Loading branch information
mshustov authored Mar 16, 2020
1 parent 8775546 commit 80b58a5
Show file tree
Hide file tree
Showing 63 changed files with 1,311 additions and 362 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [IUiSettingsClient](./kibana-plugin-core-public.iuisettingsclient.md) &gt; [getAll](./kibana-plugin-core-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, PublicUiSettingsParams & UserProvidedValues>>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [IUiSettingsClient](./kibana-plugin-core-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-core-public.iuisettingsclient.md)

<b>Signature:</b>

```typescript
export interface IUiSettingsClient
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [get](./kibana-plugin-core-public.iuisettingsclient.get.md) | <code>&lt;T = any&gt;(key: string, defaultOverride?: T) =&gt; 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-core-public.iuisettingsclient.get_.md) | <code>&lt;T = any&gt;(key: string, defaultOverride?: T) =&gt; Observable&lt;T&gt;</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-core-public.iuisettingsclient.getall.md) | <code>() =&gt; Readonly&lt;Record&lt;string, PublicUiSettingsParams &amp; UserProvidedValues&gt;&gt;</code> | Gets the metadata about all uiSettings, including the type, default value, and user value for each key. |
| [getSaved$](./kibana-plugin-core-public.iuisettingsclient.getsaved_.md) | <code>&lt;T = any&gt;() =&gt; Observable&lt;{</code><br/><code> key: string;</code><br/><code> newValue: T;</code><br/><code> oldValue: T;</code><br/><code> }&gt;</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-core-public.iuisettingsclient.getupdate_.md) | <code>&lt;T = any&gt;() =&gt; Observable&lt;{</code><br/><code> key: string;</code><br/><code> newValue: T;</code><br/><code> oldValue: T;</code><br/><code> }&gt;</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-core-public.iuisettingsclient.getupdateerrors_.md) | <code>() =&gt; Observable&lt;Error&gt;</code> | Returns an Observable that notifies subscribers of each error while trying to update the settings, containing the actual Error class. |
| [isCustom](./kibana-plugin-core-public.iuisettingsclient.iscustom.md) | <code>(key: string) =&gt; 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-core-public.iuisettingsclient.isdeclared.md) | <code>(key: string) =&gt; 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-core-public.iuisettingsclient.isdefault.md) | <code>(key: string) =&gt; boolean</code> | Returns true if the setting has no user-defined value or is unknown |
| [isOverridden](./kibana-plugin-core-public.iuisettingsclient.isoverridden.md) | <code>(key: string) =&gt; boolean</code> | Shows whether the uiSettings value set by the user. |
| [overrideLocalDefault](./kibana-plugin-core-public.iuisettingsclient.overridelocaldefault.md) | <code>(key: string, newDefault: any) =&gt; 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-core-public.iuisettingsclient.remove.md) | <code>(key: string) =&gt; Promise&lt;boolean&gt;</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-core-public.iuisettingsclient.set.md) | <code>(key: string, value: any) =&gt; Promise&lt;boolean&gt;</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. |

Loading

0 comments on commit 80b58a5

Please sign in to comment.