diff --git a/docs/development/core/public/kibana-plugin-public.ianonymouspaths.isanonymous.md b/docs/development/core/public/kibana-plugin-public.ianonymouspaths.isanonymous.md index 92a87668b6ef0..d6be78e1e725b 100644 --- a/docs/development/core/public/kibana-plugin-public.ianonymouspaths.isanonymous.md +++ b/docs/development/core/public/kibana-plugin-public.ianonymouspaths.isanonymous.md @@ -4,7 +4,7 @@ ## IAnonymousPaths.isAnonymous() method -Determines whether the provided path doesn't require authentication +Determines whether the provided path doesn't require authentication. `path` should include the current basePath. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.ianonymouspaths.md b/docs/development/core/public/kibana-plugin-public.ianonymouspaths.md index 3e5caf49695c2..1290df28780cf 100644 --- a/docs/development/core/public/kibana-plugin-public.ianonymouspaths.md +++ b/docs/development/core/public/kibana-plugin-public.ianonymouspaths.md @@ -16,6 +16,6 @@ export interface IAnonymousPaths | Method | Description | | --- | --- | -| [isAnonymous(path)](./kibana-plugin-public.ianonymouspaths.isanonymous.md) | Determines whether the provided path doesn't require authentication | -| [register(path)](./kibana-plugin-public.ianonymouspaths.register.md) | Register path as not requiring authentication | +| [isAnonymous(path)](./kibana-plugin-public.ianonymouspaths.isanonymous.md) | Determines whether the provided path doesn't require authentication. path should include the current basePath. | +| [register(path)](./kibana-plugin-public.ianonymouspaths.register.md) | Register path as not requiring authentication. path should not include the current basePath. | diff --git a/docs/development/core/public/kibana-plugin-public.ianonymouspaths.register.md b/docs/development/core/public/kibana-plugin-public.ianonymouspaths.register.md index 88c615da05155..3ab9bf438aa16 100644 --- a/docs/development/core/public/kibana-plugin-public.ianonymouspaths.register.md +++ b/docs/development/core/public/kibana-plugin-public.ianonymouspaths.register.md @@ -4,7 +4,7 @@ ## IAnonymousPaths.register() method -Register `path` as not requiring authentication +Register `path` as not requiring authentication. `path` should not include the current basePath. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.md b/docs/development/core/public/kibana-plugin-public.md index 253e50f0f2c2e..df0b963e2b627 100644 --- a/docs/development/core/public/kibana-plugin-public.md +++ b/docs/development/core/public/kibana-plugin-public.md @@ -121,5 +121,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) | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.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) | diff --git a/docs/development/core/public/kibana-plugin-public.uisettingsclient.getall.md b/docs/development/core/public/kibana-plugin-public.uisettingsclient.getall.md index 5eaf06e7dd682..06daf8e8151cd 100644 --- a/docs/development/core/public/kibana-plugin-public.uisettingsclient.getall.md +++ b/docs/development/core/public/kibana-plugin-public.uisettingsclient.getall.md @@ -9,9 +9,9 @@ Gets the metadata about all uiSettings, including the type, default value, and u Signature: ```typescript -getAll(): UiSettingsState; +getAll(): Record>; ``` Returns: -`UiSettingsState` +`Record>` diff --git a/docs/development/core/public/kibana-plugin-public.uisettingsclientcontract.md b/docs/development/core/public/kibana-plugin-public.uisettingsclientcontract.md index 6eda1fd3274c6..7173386d88265 100644 --- a/docs/development/core/public/kibana-plugin-public.uisettingsclientcontract.md +++ b/docs/development/core/public/kibana-plugin-public.uisettingsclientcontract.md @@ -4,7 +4,7 @@ ## UiSettingsClientContract type -[UiSettingsClient](./kibana-plugin-public.uisettingsclient.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) Signature: diff --git a/docs/development/core/server/kibana-plugin-server.iuisettingsclient.getuserprovided.md b/docs/development/core/server/kibana-plugin-server.iuisettingsclient.getuserprovided.md index 9a449b64ed5d0..134039cfa91f3 100644 --- a/docs/development/core/server/kibana-plugin-server.iuisettingsclient.getuserprovided.md +++ b/docs/development/core/server/kibana-plugin-server.iuisettingsclient.getuserprovided.md @@ -9,8 +9,5 @@ Retrieves a set of all uiSettings values set by the user. Signature: ```typescript -getUserProvided: () => Promise>; +getUserProvided: () => Promise>>; ``` diff --git a/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md b/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md index b0b5e908139ad..a4697ddbbb85e 100644 --- a/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md +++ b/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md @@ -4,7 +4,7 @@ ## IUiSettingsClient interface -Client that provides access to the UiSettings stored in elasticsearch. +Server-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. Signature: @@ -19,7 +19,7 @@ export interface IUiSettingsClient | [get](./kibana-plugin-server.iuisettingsclient.get.md) | <T extends SavedObjectAttribute = any>(key: string) => Promise<T> | Retrieves uiSettings values set by the user with fallbacks to default values if not specified. | | [getAll](./kibana-plugin-server.iuisettingsclient.getall.md) | <T extends SavedObjectAttribute = any>() => Promise<Record<string, T>> | 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) | () => Readonly<Record<string, UiSettingsParams>> | Returns registered uiSettings values [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) | -| [getUserProvided](./kibana-plugin-server.iuisettingsclient.getuserprovided.md) | <T extends SavedObjectAttribute = any>() => Promise<Record<string, {
userValue?: T;
isOverridden?: boolean;
}>> | Retrieves a set of all uiSettings values set by the user. | +| [getUserProvided](./kibana-plugin-server.iuisettingsclient.getuserprovided.md) | <T extends SavedObjectAttribute = any>() => Promise<Record<string, UserProvidedValues<T>>> | Retrieves a set of all uiSettings values set by the user. | | [isOverridden](./kibana-plugin-server.iuisettingsclient.isoverridden.md) | (key: string) => boolean | Shows whether the uiSettings value set by the user. | | [remove](./kibana-plugin-server.iuisettingsclient.remove.md) | (key: string) => Promise<void> | Removes uiSettings value by key. | | [removeMany](./kibana-plugin-server.iuisettingsclient.removemany.md) | (keys: string[]) => Promise<void> | Removes multiple uiSettings values by keys. | diff --git a/docs/development/core/server/kibana-plugin-server.md b/docs/development/core/server/kibana-plugin-server.md index e14991484746d..9907750b8742f 100644 --- a/docs/development/core/server/kibana-plugin-server.md +++ b/docs/development/core/server/kibana-plugin-server.md @@ -63,7 +63,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [IKibanaSocket](./kibana-plugin-server.ikibanasocket.md) | A tiny abstraction for TCP socket. | | [IndexSettingsDeprecationInfo](./kibana-plugin-server.indexsettingsdeprecationinfo.md) | | | [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. | -| [IUiSettingsClient](./kibana-plugin-server.iuisettingsclient.md) | Client that provides access to the UiSettings stored in elasticsearch. | +| [IUiSettingsClient](./kibana-plugin-server.iuisettingsclient.md) | Server-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. | | [KibanaRequestRoute](./kibana-plugin-server.kibanarequestroute.md) | Request specific route information exposed to a handler. | | [LegacyRequest](./kibana-plugin-server.legacyrequest.md) | | | [LegacyServiceSetupDeps](./kibana-plugin-server.legacyservicesetupdeps.md) | | @@ -119,6 +119,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | SessionStorage factory to bind one to an incoming request | | [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) | UiSettings parameters defined by the plugins. | | [UiSettingsServiceSetup](./kibana-plugin-server.uisettingsservicesetup.md) | | +| [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) | Describes the values explicitly set by user. | ## Variables diff --git a/docs/development/core/server/kibana-plugin-server.uisettingsparams.category.md b/docs/development/core/server/kibana-plugin-server.uisettingsparams.category.md index 47aedbfbf2810..6bf1b17dc947a 100644 --- a/docs/development/core/server/kibana-plugin-server.uisettingsparams.category.md +++ b/docs/development/core/server/kibana-plugin-server.uisettingsparams.category.md @@ -9,5 +9,5 @@ used to group the configured setting in the UI Signature: ```typescript -category: string[]; +category?: string[]; ``` diff --git a/docs/development/core/server/kibana-plugin-server.uisettingsparams.description.md b/docs/development/core/server/kibana-plugin-server.uisettingsparams.description.md index 8d8887285ae2e..6a203629f5425 100644 --- a/docs/development/core/server/kibana-plugin-server.uisettingsparams.description.md +++ b/docs/development/core/server/kibana-plugin-server.uisettingsparams.description.md @@ -9,5 +9,5 @@ description provided to a user in UI Signature: ```typescript -description: string; +description?: string; ``` diff --git a/docs/development/core/server/kibana-plugin-server.uisettingsparams.md b/docs/development/core/server/kibana-plugin-server.uisettingsparams.md index 275111c05eff9..a38499e8f37dd 100644 --- a/docs/development/core/server/kibana-plugin-server.uisettingsparams.md +++ b/docs/development/core/server/kibana-plugin-server.uisettingsparams.md @@ -20,7 +20,7 @@ export interface UiSettingsParams | [description](./kibana-plugin-server.uisettingsparams.description.md) | string | description provided to a user in UI | | [name](./kibana-plugin-server.uisettingsparams.name.md) | string | title in the UI | | [optionLabels](./kibana-plugin-server.uisettingsparams.optionlabels.md) | Record<string, string> | text labels for 'select' type UI element | -| [options](./kibana-plugin-server.uisettingsparams.options.md) | string[] | a range of valid values | +| [options](./kibana-plugin-server.uisettingsparams.options.md) | string[] | array of permitted values for this setting | | [readonly](./kibana-plugin-server.uisettingsparams.readonly.md) | boolean | a flag indicating that value cannot be changed | | [requiresPageReload](./kibana-plugin-server.uisettingsparams.requirespagereload.md) | boolean | a flag indicating whether new value applying requires page reloading | | [type](./kibana-plugin-server.uisettingsparams.type.md) | UiSettingsType | defines a type of UI element [UiSettingsType](./kibana-plugin-server.uisettingstype.md) | diff --git a/docs/development/core/server/kibana-plugin-server.uisettingsparams.name.md b/docs/development/core/server/kibana-plugin-server.uisettingsparams.name.md index 2b414eefffed2..07905ca7de20a 100644 --- a/docs/development/core/server/kibana-plugin-server.uisettingsparams.name.md +++ b/docs/development/core/server/kibana-plugin-server.uisettingsparams.name.md @@ -9,5 +9,5 @@ title in the UI Signature: ```typescript -name: string; +name?: string; ``` diff --git a/docs/development/core/server/kibana-plugin-server.uisettingsparams.options.md b/docs/development/core/server/kibana-plugin-server.uisettingsparams.options.md index 71eecdfabc4a0..2220feab74ffd 100644 --- a/docs/development/core/server/kibana-plugin-server.uisettingsparams.options.md +++ b/docs/development/core/server/kibana-plugin-server.uisettingsparams.options.md @@ -4,7 +4,7 @@ ## UiSettingsParams.options property -a range of valid values +array of permitted values for this setting Signature: diff --git a/docs/development/core/server/kibana-plugin-server.uisettingsparams.value.md b/docs/development/core/server/kibana-plugin-server.uisettingsparams.value.md index 455756899ecfc..397498ccf5c11 100644 --- a/docs/development/core/server/kibana-plugin-server.uisettingsparams.value.md +++ b/docs/development/core/server/kibana-plugin-server.uisettingsparams.value.md @@ -9,5 +9,5 @@ default value to fall back to if a user doesn't provide any Signature: ```typescript -value: SavedObjectAttribute; +value?: SavedObjectAttribute; ``` diff --git a/docs/development/core/server/kibana-plugin-server.uisettingsservicesetup.register.md b/docs/development/core/server/kibana-plugin-server.uisettingsservicesetup.register.md index e758814520092..8091a7cec44aa 100644 --- a/docs/development/core/server/kibana-plugin-server.uisettingsservicesetup.register.md +++ b/docs/development/core/server/kibana-plugin-server.uisettingsservicesetup.register.md @@ -22,3 +22,7 @@ register(settings: Record): void; `void` +## Example + +setup(core: CoreSetup){ core.uiSettings.register(\[{ foo: { name: i18n.translate('my foo settings'), value: true, description: 'add some awesomeness', }, }\]); } + diff --git a/docs/development/core/server/kibana-plugin-server.userprovidedvalues.isoverridden.md b/docs/development/core/server/kibana-plugin-server.userprovidedvalues.isoverridden.md new file mode 100644 index 0000000000000..01e04b490595d --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.userprovidedvalues.isoverridden.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) > [isOverridden](./kibana-plugin-server.userprovidedvalues.isoverridden.md) + +## UserProvidedValues.isOverridden property + +Signature: + +```typescript +isOverridden?: boolean; +``` diff --git a/docs/development/core/server/kibana-plugin-server.userprovidedvalues.md b/docs/development/core/server/kibana-plugin-server.userprovidedvalues.md new file mode 100644 index 0000000000000..7b2114404d7f2 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.userprovidedvalues.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) + +## UserProvidedValues interface + +Describes the values explicitly set by user. + +Signature: + +```typescript +export interface UserProvidedValues +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [isOverridden](./kibana-plugin-server.userprovidedvalues.isoverridden.md) | boolean | | +| [userValue](./kibana-plugin-server.userprovidedvalues.uservalue.md) | T | | + diff --git a/docs/development/core/server/kibana-plugin-server.userprovidedvalues.uservalue.md b/docs/development/core/server/kibana-plugin-server.userprovidedvalues.uservalue.md new file mode 100644 index 0000000000000..59d25651b7697 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.userprovidedvalues.uservalue.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) > [userValue](./kibana-plugin-server.userprovidedvalues.uservalue.md) + +## UserProvidedValues.userValue property + +Signature: + +```typescript +userValue?: T; +``` diff --git a/src/core/MIGRATION.md b/src/core/MIGRATION.md index 018a91be4c3d1..7b062b20c7415 100644 --- a/src/core/MIGRATION.md +++ b/src/core/MIGRATION.md @@ -1198,7 +1198,7 @@ This table shows where these uiExports have moved to in the New Platform. In mos | `styleSheetPaths` | | | | `taskDefinitions` | | Should be an API on the taskManager plugin. | | `uiCapabilities` | [`core.application.register`](/docs/development/core/public/kibana-plugin-public.applicationsetup.register.md) | | -| `uiSettingDefaults` | | Most likely part of server-side UiSettingsService. | +| `uiSettingDefaults` | [`core.uiSettings.register`](docs/development/core/server/kibana-plugin-server.uisettingsservicesetup.md) | | | `validations` | | Part of SavedObjects, see [#33587](https://github.com/elastic/kibana/issues/33587) | | `visEditorTypes` | | | | `visTypeEnhancers` | | | diff --git a/src/core/public/injected_metadata/injected_metadata_service.ts b/src/core/public/injected_metadata/injected_metadata_service.ts index 478285a70771e..a5342aaa48b72 100644 --- a/src/core/public/injected_metadata/injected_metadata_service.ts +++ b/src/core/public/injected_metadata/injected_metadata_service.ts @@ -19,8 +19,12 @@ import { get } from 'lodash'; import { DiscoveredPlugin, PluginName } from '../../server'; -import { EnvironmentMode, PackageInfo } from '../../server/types'; -import { UiSettingsState } from '../ui_settings'; +import { + EnvironmentMode, + PackageInfo, + UiSettingsParams, + UserProvidedValues, +} from '../../server/types'; import { deepFreeze } from '../../utils/'; import { Capabilities } from '..'; @@ -69,8 +73,8 @@ export interface InjectedMetadataParams { serverName: string; devMode: boolean; uiSettings: { - defaults: UiSettingsState; - user?: UiSettingsState; + defaults: Record; + user?: Record; }; }; }; @@ -179,8 +183,8 @@ export interface InjectedMetadataSetup { serverName: string; devMode: boolean; uiSettings: { - defaults: UiSettingsState; - user?: UiSettingsState | undefined; + defaults: Record; + user?: Record | undefined; }; }; getInjectedVar: (name: string, defaultValue?: any) => unknown; diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 416fb13cbb73e..a596ea394abda 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -11,6 +11,8 @@ import React from 'react'; import * as Rx from 'rxjs'; import { ShallowPromise } from '@kbn/utility-types'; import { EuiGlobalToastListToast as Toast } from '@elastic/eui'; +import { UiSettingsParams as UiSettingsParams_2 } from 'src/core/server/types'; +import { UserProvidedValues as UserProvidedValues_2 } from 'src/core/server/types'; // @public export interface App extends AppBase { @@ -957,7 +959,7 @@ export class UiSettingsClient { constructor(params: UiSettingsClientParams); get$(key: string, defaultOverride?: any): Rx.Observable; get(key: string, defaultOverride?: any): any; - getAll(): UiSettingsState; + getAll(): Record>; getSaved$(): Rx.Observable<{ key: string; newValue: any; @@ -979,16 +981,13 @@ export class UiSettingsClient { stop(): void; } -// @public (undocumented) +// @public export type UiSettingsClientContract = PublicMethodsOf; // @public (undocumented) export interface UiSettingsState { - // Warning: (ae-forgotten-export) The symbol "InjectedUiSettingsDefault" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "InjectedUiSettingsUser" needs to be exported by the entry point index.d.ts - // // (undocumented) - [key: string]: InjectedUiSettingsDefault & InjectedUiSettingsUser; + [key: string]: UiSettingsParams_2 & UserProvidedValues_2; } diff --git a/src/core/public/ui_settings/types.ts b/src/core/public/ui_settings/types.ts index d1cf25c3e9e6f..24e87eb04f026 100644 --- a/src/core/public/ui_settings/types.ts +++ b/src/core/public/ui_settings/types.ts @@ -17,28 +17,9 @@ * under the License. */ -// properties that come from legacyInjectedMetadata.uiSettings.defaults -interface InjectedUiSettingsDefault { - name?: string; - value?: any; - description?: string; - category?: string[]; - type?: string; - readOnly?: boolean; - options?: string[] | { [key: string]: any }; - /** - * Whether a change in that setting will only take affect after a page reload. - */ - requiresPageReload?: boolean; -} - -// properties that come from legacyInjectedMetadata.uiSettings.user -interface InjectedUiSettingsUser { - userValue?: any; - isOverridden?: boolean; -} +import { UiSettingsParams, UserProvidedValues } from 'src/core/server/types'; /** @public */ export interface UiSettingsState { - [key: string]: InjectedUiSettingsDefault & InjectedUiSettingsUser; + [key: string]: UiSettingsParams & UserProvidedValues; } diff --git a/src/core/public/ui_settings/ui_settings_client.ts b/src/core/public/ui_settings/ui_settings_client.ts index 3083851dd453d..c3190847130d5 100644 --- a/src/core/public/ui_settings/ui_settings_client.ts +++ b/src/core/public/ui_settings/ui_settings_client.ts @@ -21,18 +21,25 @@ import { cloneDeep, defaultsDeep } from 'lodash'; import * as Rx from 'rxjs'; import { filter, map } from 'rxjs/operators'; +import { UiSettingsParams, UserProvidedValues } from 'src/core/server/types'; import { UiSettingsState } from './types'; + import { UiSettingsApi } from './ui_settings_api'; /** @public */ interface UiSettingsClientParams { api: UiSettingsApi; - defaults: UiSettingsState; + defaults: Record; initialSettings?: UiSettingsState; } /** + * 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; @@ -44,8 +51,8 @@ export class UiSettingsClient { private readonly updateErrors$ = new Rx.Subject(); private readonly api: UiSettingsApi; - private readonly defaults: UiSettingsState; - private cache: UiSettingsState; + private readonly defaults: Record; + private cache: Record; constructor(params: UiSettingsClientParams) { this.api = params.api; diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 24989b9d5da6a..35e83da4ef30c 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -180,6 +180,7 @@ export { InternalUiSettingsServiceSetup, UiSettingsType, UiSettingsServiceSetup, + UserProvidedValues, } from './ui_settings'; export { RecursiveReadonly } from '../utils'; diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 380524930774f..14943fc96f268 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -766,10 +766,7 @@ export interface IUiSettingsClient { get: (key: string) => Promise; getAll: () => Promise>; getRegistered: () => Readonly>; - getUserProvided: () => Promise>; + getUserProvided: () => Promise>>; isOverridden: (key: string) => boolean; remove: (key: string) => Promise; removeMany: (keys: string[]) => Promise; @@ -1615,15 +1612,15 @@ export interface SessionStorageFactory { // @public export interface UiSettingsParams { - category: string[]; - description: string; - name: string; + category?: string[]; + description?: string; + name?: string; optionLabels?: Record; options?: string[]; readonly?: boolean; requiresPageReload?: boolean; type?: UiSettingsType; - value: SavedObjectAttribute; + value?: SavedObjectAttribute; } // @public (undocumented) @@ -1634,6 +1631,14 @@ export interface UiSettingsServiceSetup { // @public export type UiSettingsType = 'json' | 'markdown' | 'number' | 'select' | 'boolean' | 'string'; +// @public +export interface UserProvidedValues { + // (undocumented) + isOverridden?: boolean; + // (undocumented) + userValue?: T; +} + // Warnings were encountered during analysis: // diff --git a/src/core/server/types.ts b/src/core/server/types.ts index 46c70a91721b5..4878fb9ccae19 100644 --- a/src/core/server/types.ts +++ b/src/core/server/types.ts @@ -20,4 +20,5 @@ /** This module is intended for consumption by public to avoid import issues with server-side code */ export { PluginOpaqueId } from './plugins/types'; export * from './saved_objects/types'; +export * from './ui_settings/types'; export { EnvironmentMode, PackageInfo } from './config/types'; diff --git a/src/core/server/ui_settings/create_or_upgrade_saved_config/get_upgradeable_config.test.ts b/src/core/server/ui_settings/create_or_upgrade_saved_config/get_upgradeable_config.test.ts index 53eb6d62c6578..5e3307386bcff 100644 --- a/src/core/server/ui_settings/create_or_upgrade_saved_config/get_upgradeable_config.test.ts +++ b/src/core/server/ui_settings/create_or_upgrade_saved_config/get_upgradeable_config.test.ts @@ -17,11 +17,11 @@ * under the License. */ import { getUpgradeableConfig } from './get_upgradeable_config'; -import { SavedObjectsClientMock } from '../../saved_objects/service/saved_objects_client.mock'; +import { savedObjectsClientMock } from '../../saved_objects/service/saved_objects_client.mock'; describe('getUpgradeableConfig', () => { it('finds saved objects with type "config"', async () => { - const savedObjectsClient = SavedObjectsClientMock.create(); + const savedObjectsClient = savedObjectsClientMock.create(); savedObjectsClient.find.mockResolvedValue({ saved_objects: [{ id: '7.5.0' }], } as any); @@ -32,7 +32,7 @@ describe('getUpgradeableConfig', () => { it('finds saved config with version < than Kibana version', async () => { const savedConfig = { id: '7.4.0' }; - const savedObjectsClient = SavedObjectsClientMock.create(); + const savedObjectsClient = savedObjectsClientMock.create(); savedObjectsClient.find.mockResolvedValue({ saved_objects: [savedConfig], } as any); @@ -43,7 +43,7 @@ describe('getUpgradeableConfig', () => { it('finds saved config with RC version === Kibana version', async () => { const savedConfig = { id: '7.5.0-rc1' }; - const savedObjectsClient = SavedObjectsClientMock.create(); + const savedObjectsClient = savedObjectsClientMock.create(); savedObjectsClient.find.mockResolvedValue({ saved_objects: [savedConfig], } as any); @@ -54,7 +54,7 @@ describe('getUpgradeableConfig', () => { it('does not find saved config with version === Kibana version', async () => { const savedConfig = { id: '7.5.0' }; - const savedObjectsClient = SavedObjectsClientMock.create(); + const savedObjectsClient = savedObjectsClientMock.create(); savedObjectsClient.find.mockResolvedValue({ saved_objects: [savedConfig], } as any); @@ -65,7 +65,7 @@ describe('getUpgradeableConfig', () => { it('does not find saved config with version > Kibana version', async () => { const savedConfig = { id: '7.6.0' }; - const savedObjectsClient = SavedObjectsClientMock.create(); + const savedObjectsClient = savedObjectsClientMock.create(); savedObjectsClient.find.mockResolvedValue({ saved_objects: [savedConfig], } as any); @@ -75,7 +75,7 @@ describe('getUpgradeableConfig', () => { }); it('handles empty config', async () => { - const savedObjectsClient = SavedObjectsClientMock.create(); + const savedObjectsClient = savedObjectsClientMock.create(); savedObjectsClient.find.mockResolvedValue({ saved_objects: [], } as any); diff --git a/src/core/server/ui_settings/index.ts b/src/core/server/ui_settings/index.ts index 52701bd7a6dff..fd0a21bed4e12 100644 --- a/src/core/server/ui_settings/index.ts +++ b/src/core/server/ui_settings/index.ts @@ -28,4 +28,5 @@ export { UiSettingsParams, InternalUiSettingsServiceSetup, UiSettingsType, + UserProvidedValues, } from './types'; diff --git a/src/core/server/ui_settings/types.ts b/src/core/server/ui_settings/types.ts index ad76461ab4e14..0fa6b3702af24 100644 --- a/src/core/server/ui_settings/types.ts +++ b/src/core/server/ui_settings/types.ts @@ -18,7 +18,10 @@ */ import { SavedObjectsClientContract, SavedObjectAttribute } from '../saved_objects/types'; /** - * Client that provides access to the UiSettings stored in elasticsearch. + * Server-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. * * @public */ @@ -39,7 +42,7 @@ export interface IUiSettingsClient { * Retrieves a set of all uiSettings values set by the user. */ getUserProvided: () => Promise< - Record + Record> >; /** * Writes multiple uiSettings values and marks them as set by the user. @@ -63,6 +66,15 @@ export interface IUiSettingsClient { isOverridden: (key: string) => boolean; } +/** + * Describes the values explicitly set by user. + * @public + * */ +export interface UserProvidedValues { + userValue?: T; + isOverridden?: boolean; +} + /** * UI element type to represent the settings. * @public @@ -75,14 +87,14 @@ export type UiSettingsType = 'json' | 'markdown' | 'number' | 'select' | 'boolea * */ export interface UiSettingsParams { /** title in the UI */ - name: string; + name?: string; /** default value to fall back to if a user doesn't provide any */ - value: SavedObjectAttribute; + value?: SavedObjectAttribute; /** description provided to a user in UI */ - description: string; + description?: string; /** used to group the configured setting in the UI */ - category: string[]; - /** a range of valid values */ + category?: string[]; + /** array of permitted values for this setting */ options?: string[]; /** text labels for 'select' type UI element */ optionLabels?: Record; @@ -113,6 +125,17 @@ export interface UiSettingsServiceSetup { /** * Sets settings with default values for the uiSettings. * @param settings + * + * @example + * setup(core: CoreSetup){ + * core.uiSettings.register([{ + * foo: { + * name: i18n.translate('my foo settings'), + * value: true, + * description: 'add some awesomeness', + * }, + * }]); + * } */ register(settings: Record): void; }