mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 19:13:14 -04:00
## Summary This PR aims at relocating some of the Kibana modules (plugins and packages) into a new folder structure, according to the _Sustainable Kibana Architecture_ initiative. > [!IMPORTANT] > * We kindly ask you to: > * Manually fix the errors in the error section below (if there are any). > * Search for the `packages[\/\\]` and `plugins[\/\\]` patterns in the source code (Babel and Eslint config files), and update them appropriately. > * Manually review `.buildkite/scripts/pipelines/pull_request/pipeline.ts` to ensure that any CI pipeline customizations continue to be correctly applied after the changed path names > * Review all of the updated files, specially the `.ts` and `.js` files listed in the sections below, as some of them contain relative paths that have been updated. > * Think of potential impact of the move, including tooling and configuration files that can be pointing to the relocated modules. E.g.: > * customised eslint rules > * docs pointing to source code > [!NOTE] > * This PR has been auto-generated. > * Any manual contributions will be lost if the 'relocate' script is re-run. > * Try to obtain the missing reviews / approvals before applying manual fixes, and/or keep your changes in a .patch / git stash. > * Please use [#sustainable_kibana_architecture](https://elastic.slack.com/archives/C07TCKTA22E) Slack channel for feedback. Are you trying to rebase this PR to solve merge conflicts? Please follow the steps describe [here](https://elastic.slack.com/archives/C07TCKTA22E/p1734019532879269?thread_ts=1734019339.935419&cid=C07TCKTA22E). #### 13 packages(s) are going to be relocated: | Id | Target folder | | -- | ------------- | | `@kbn/core-chrome-browser-internal` | `src/core/packages/chrome/browser-internal` | | `@kbn/core-custom-branding-browser` | `src/core/packages/custom-branding/browser` | | `@kbn/core-custom-branding-browser-internal` | `src/core/packages/custom-branding/browser-internal` | | `@kbn/core-custom-branding-browser-mocks` | `src/core/packages/custom-branding/browser-mocks` | | `@kbn/core-custom-branding-common` | `src/core/packages/custom-branding/common` | | `@kbn/core-custom-branding-server` | `src/core/packages/custom-branding/server` | | `@kbn/core-custom-branding-server-internal` | `src/core/packages/custom-branding/server-internal` | | `@kbn/core-custom-branding-server-mocks` | `src/core/packages/custom-branding/server-mocks` | | `@kbn/core-ui-settings-browser` | `src/core/packages/ui-settings/browser` | | `@kbn/core-ui-settings-browser-internal` | `src/core/packages/ui-settings/browser-internal` | | `@kbn/core-ui-settings-common` | `src/core/packages/ui-settings/common` | | `@kbn/core-ui-settings-server` | `src/core/packages/ui-settings/server` | | `@kbn/core-ui-settings-server-internal` | `src/core/packages/ui-settings/server-internal` | <details > <summary>Updated references</summary> ``` ./docs/developer/architecture/core/patterns-scoped-services.asciidoc ./docs/developer/architecture/core/uisettings-service.asciidoc ./package.json ./packages/core/custom-branding/core-custom-branding-common/index.ts ./packages/kbn-ts-projects/config-paths.json ./src/core/packages/chrome/browser-internal/jest.config.js ./src/core/packages/custom-branding/browser-internal/jest.config.js ./src/core/packages/custom-branding/browser-mocks/jest.config.js ./src/core/packages/custom-branding/server-internal/jest.config.js ./src/core/packages/custom-branding/server-mocks/jest.config.js ./src/core/packages/ui-settings/browser-internal/jest.config.js ./src/core/packages/ui-settings/browser/jest.config.js ./src/core/packages/ui-settings/common/jest.config.js ./src/core/packages/ui-settings/server-internal/jest.config.js ./src/core/packages/ui-settings/server/jest.config.js ./src/platform/packages/private/kbn-repo-packages/package-map.json ./tsconfig.base.json ./x-pack/platform/plugins/private/transform/public/app/common/time_zone_utils.ts ./yarn.lock .github/CODEOWNERS ``` </details><details > <summary>Updated relative paths</summary> ``` src/core/packages/chrome/browser-internal/jest.config.js:12 src/core/packages/chrome/browser-internal/tsconfig.json:2 src/core/packages/custom-branding/browser-internal/jest.config.js:12 src/core/packages/custom-branding/browser-internal/tsconfig.json:2 src/core/packages/custom-branding/browser-mocks/jest.config.js:12 src/core/packages/custom-branding/browser-mocks/tsconfig.json:2 src/core/packages/custom-branding/browser/tsconfig.json:2 src/core/packages/custom-branding/common/tsconfig.json:2 src/core/packages/custom-branding/server-internal/jest.config.js:12 src/core/packages/custom-branding/server-internal/tsconfig.json:2 src/core/packages/custom-branding/server-mocks/jest.config.js:12 src/core/packages/custom-branding/server-mocks/tsconfig.json:2 src/core/packages/custom-branding/server/tsconfig.json:2 src/core/packages/ui-settings/browser-internal/jest.config.js:12 src/core/packages/ui-settings/browser-internal/tsconfig.json:2 src/core/packages/ui-settings/browser/jest.config.js:12 src/core/packages/ui-settings/browser/tsconfig.json:2 src/core/packages/ui-settings/common/jest.config.js:12 src/core/packages/ui-settings/common/tsconfig.json:2 src/core/packages/ui-settings/server-internal/jest.config.js:12 src/core/packages/ui-settings/server-internal/tsconfig.json:2 src/core/packages/ui-settings/server/jest.config.js:12 src/core/packages/ui-settings/server/tsconfig.json:2 ``` </details> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
173 lines
6.4 KiB
Text
173 lines
6.4 KiB
Text
[[ui-settings-service]]
|
|
== UI settings service
|
|
|
|
NOTE: The UI settings service is available both server and client side.
|
|
|
|
=== Overview
|
|
|
|
UI settings are configurable from the Advanced Settings page in Management and control the behavior of {kib}. uiSettings are stored in a config saved object and, as such, conform to the same conditions as other <<saved-objects-service, Saved Objects>>.
|
|
|
|
There are several ways to configure an advanced setting:
|
|
|
|
- <<advanced-settings-ui, Through the Advanced Settings UI>>
|
|
- <<uisettings-overrides, Locked via kibana.yml's uiSettings.overrides>>
|
|
- <<client-side-usage, Through the client-side uiSettings Service>>
|
|
- <<server-side-usage, Through the server-side uiSettings Service>>
|
|
|
|
Keep in mind that once you add a new advanced setting, you cannot change or remove it without <<uisettings-migrations, registering a migration in core>>.
|
|
|
|
[[advanced-settings-ui]]
|
|
=== Configuration with Advanced Settings UI
|
|
The uiSettings service is the programmatic interface to Kibana's Advanced Settings UI. Kibana plugins use the service to extend Kibana UI Settings Management with custom settings for their plugin.
|
|
|
|
Configuration through the Advanced Settings UI is restricted to users authorised to acces the Advanced Settings page. Users who don't have permissions to change these values default to using the settings configured to the space they are in. Config saved objects can be shared between spaces.
|
|
|
|
[[uisettings-overrides]]
|
|
=== Configuration with UI settings overrides
|
|
experimental[] When a setting is configured as an override in kibana.yml, it will override any other value stored in the config saved object. If an override is misconfigured, it will fail config validation and prevent Kibana from starting up. The override applies to Kibana as a whole for all spaces and users and the option will be disabled in the Advanced Settings page. We refer to these as "global" overrides.
|
|
|
|
Use the top-level `uiSettings` key for this, for example:
|
|
|
|
[source,yaml]
|
|
----
|
|
# Display times in UTC
|
|
uiSettings:
|
|
overrides:
|
|
"dateFormat:tz": "UTC"
|
|
----
|
|
|
|
[[client-side-usage]]
|
|
=== Client side usage
|
|
On the client, the `uiSettings` service is exposed directly from `core` and the {kib-repo}/blob/8.9/src/core/packages/ui-settings/server/src/ui_settings_client.ts[client]
|
|
provides plugins access to the `config` entries stored in {es}.
|
|
|
|
In the interest of performance, `uiSettings` are cached. Any changes that require cache refreshes should register an instruction to reload the page when settings are configured in Advanced Settings using the `requiresPageReload` {kib-repo}/blob/8.9/src/core/packages/ui-settings/common/src/ui_settings.ts[parameter].
|
|
|
|
[source,typescript]
|
|
----
|
|
import { CoreSetup, Plugin } from 'src/core/public';
|
|
|
|
export class MyPlugin implements Plugin<MyPluginSetup, MyPluginStart> {
|
|
public setup(core: CoreSetup): MyPluginSetup {
|
|
…
|
|
core.uiSettings.getUpdate$().subscribe(({ key, newValue }) => {
|
|
if (key === 'custom') {
|
|
// do something with changes...
|
|
myPluginService.register({
|
|
…
|
|
})
|
|
}
|
|
});
|
|
…
|
|
}
|
|
|
|
public start(core: CoreStart): MyPluginStart {
|
|
return {
|
|
…
|
|
settings: {
|
|
getCustomValue: () => core.uiSettings.get('custom'),
|
|
…
|
|
},
|
|
};
|
|
}
|
|
}
|
|
|
|
----
|
|
|
|
[[server-side-usage]]
|
|
=== Server side usage
|
|
On the server, `uiSettings` are exposed directly from `core`.
|
|
|
|
The following example shows how to register a new `custom` setting with a default value of '42'. When registering a new setting, you must provide a schema against which validations are performed on read and write. All the other {kib-repo}/blob/8.9/src/core/packages/ui-settings/common/src/ui_settings.ts[parameters] are optional.
|
|
|
|
[source,typescript]
|
|
----
|
|
import { schema } from '@kbn/config-schema';
|
|
import type { CoreSetup,Plugin } from '@kbn/core/server';
|
|
|
|
export class MyPlugin implements Plugin {
|
|
public setup(core: CoreSetup) {
|
|
core.uiSettings.register({
|
|
custom: {
|
|
value: '42',
|
|
schema: schema.string(),
|
|
},
|
|
});
|
|
const router = core.http.createRouter();
|
|
router.get({
|
|
path: 'my_plugin/{id}',
|
|
validate: …,
|
|
},
|
|
async (context, request, response) => {
|
|
const customSetting = await context.uiSettings.client.get('custom');
|
|
…
|
|
});
|
|
}
|
|
}
|
|
|
|
----
|
|
|
|
[[uisettings-migrations]]
|
|
=== Migrations
|
|
|
|
[IMPORTANT]
|
|
==============================================
|
|
Migrations for 3rd party plugin advanced settings are not currently supported. If a 3rd party plugin registers an advanced setting, the setting is essentially permanent and cannot be fixed without manual intervention.
|
|
==============================================
|
|
|
|
To change or remove a `uiSetting`, the whole `config` Saved Object needs to be migrated.
|
|
|
|
For example, if we wanted to remove a `custom` setting, or rename `my_setting:fourtyTwo` to `my_other_setting:fourtyTwo`, we'd need two migration entries, one for each change targeting the version in which these changes apply:
|
|
|
|
[source,typescript]
|
|
----
|
|
export const migrations = {
|
|
...
|
|
'8.1.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
|
|
...doc,
|
|
...(doc.attributes && {
|
|
attributes: Object.keys(doc.attributes).reduce(
|
|
(acc, key) =>
|
|
[
|
|
// other settings to remove for 8.1.0...
|
|
'custom',
|
|
].includes(key)
|
|
? {
|
|
...acc,
|
|
}
|
|
: {
|
|
...acc,
|
|
[key]: doc.attributes[key],
|
|
},
|
|
{}
|
|
),
|
|
}),
|
|
references: doc.references || [],
|
|
}),
|
|
'8.2.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
|
|
...doc,
|
|
...(doc.attributes && {
|
|
attributes: Object.keys(doc.attributes).reduce(
|
|
(acc, key) =>
|
|
key.startsWith('my_setting:')
|
|
? {
|
|
...acc,
|
|
[key.replace('my_setting', 'my_other_setting')]: doc.attributes[key],
|
|
}
|
|
: {
|
|
...acc,
|
|
[key]: doc.attributes[key],
|
|
},
|
|
{}
|
|
),
|
|
}),
|
|
references: doc.references || [],
|
|
}),
|
|
…
|
|
}
|
|
----
|
|
|
|
[TIP]
|
|
==============================================
|
|
Plugins can leverage the optional deprecation parameter on registration for handling deprecation notices and renames. The deprecation warnings are rendered in the Advanced Settings UI and should also be added to the <<settings,Configure Kibana>> guide.
|
|
==============================================
|