## Summary <!-- ### DONT MERGE, THIS PR DEPENDS ON AN UPDATE TO EUI, THAT'S IN FLIGHT --> Closes https://github.com/elastic/kibana/issues/202782 This PR reworks how custom themes used within the kibana code editor for the default visual look and ones specific to supported languages are defined to accomodate the upcoming visual refresh, the approach here leverages the `euiTheme` object value returned from the `useEuiTheme` hook, now a single theme declaration is all that is required such that using either the `colorMode `value or the `euiTheme` from the provided `UseEUITheme` value it's possible to craft a theme that's in the context of kIbana, color mode aware and the editor would be able to resolve the appropriate colors depending on the user's color mode. This required some modification to monaco itself; now when defining languages if the `CustomLanguageType` specification is being followed, a function that resolves to a standard monaco theme can be provided on the property `languageThemeResolver` which will be passed the `euiTheme` when registering this theme. It's worth mentioning that this can also be done manually by leveraging the custom method `registerLanguageThemeResolver` added on the monaco editor object, like so ```tsx monaco.editor.registerLanguageThemeResolver(LanguageID, languageThemeResolver); ``` However one should take note that when calling this method directly, the ID passed must correlate to a registered language ID, else the theme will not be available for use after Monaco is initialised, hence the theme name must equal an existing language ID if it's to be used for a specific language. ## How to test - Enable borealis, like so; - in your `kibana.dev.yml` file include the following config; ```yml uiSettings.experimental.themeSwitcherEnabled: true ``` - start kibana using the following command; `KBN_OPTIMIZER_THEMES="borealislight,borealisdark,v8light,v8dark" yarn start --run-examples` - Tryout all downstream of the code editor to ascertain the code editor colors are as should be for both Amsterdam and Borealis; downstreams include; - ES|QL editor, navigate to discover and click the "try ES|QL" button - Dev tools, on clicking the nav hamburger menu under the management menu group there's a menu item that links to all dev tools - Index Management use cases; navigate to stack management, under Index management select any existing index, then navigate to it's settings this should load up the code editor. - Saved Object use case; navigate to stack management, under saved objects attempt inspecting any saved object we'd be presented with the code editor etc. <!-- ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --> --------- Co-authored-by: ek-so <eksomail@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> |
||
---|---|---|
.. | ||
analytics/utils/analytics_collection_utils | ||
cloud | ||
content-management | ||
core | ||
deeplinks/shared | ||
home | ||
kbn-ambient-common-types | ||
kbn-ambient-ftr-types | ||
kbn-ambient-storybook-types | ||
kbn-ambient-ui-types | ||
kbn-analytics | ||
kbn-apm-config-loader | ||
kbn-apm-synthtrace | ||
kbn-apm-synthtrace-client | ||
kbn-axe-config | ||
kbn-babel-preset | ||
kbn-babel-register | ||
kbn-babel-transform | ||
kbn-bazel-runner | ||
kbn-calculate-auto | ||
kbn-calculate-width-from-char-count | ||
kbn-capture-oas-snapshot-cli | ||
kbn-chart-icons | ||
kbn-charts-theme | ||
kbn-check-mappings-update-cli | ||
kbn-check-prod-native-modules-cli | ||
kbn-ci-stats-core | ||
kbn-ci-stats-performance-metrics | ||
kbn-ci-stats-reporter | ||
kbn-ci-stats-shipper-cli | ||
kbn-cli-dev-mode | ||
kbn-code-owners | ||
kbn-coloring | ||
kbn-config | ||
kbn-config-mocks | ||
kbn-config-schema | ||
kbn-crypto | ||
kbn-crypto-browser | ||
kbn-cypress-config | ||
kbn-data-service | ||
kbn-dependency-ownership | ||
kbn-dependency-usage | ||
kbn-dev-cli-errors | ||
kbn-dev-cli-runner | ||
kbn-dev-proc-runner | ||
kbn-dev-utils | ||
kbn-docs-utils | ||
kbn-dom-drag-drop | ||
kbn-ebt-tools | ||
kbn-es | ||
kbn-es-archiver | ||
kbn-es-errors | ||
kbn-es-types | ||
kbn-eslint-config | ||
kbn-eslint-plugin-css | ||
kbn-eslint-plugin-disable | ||
kbn-eslint-plugin-eslint | ||
kbn-eslint-plugin-i18n | ||
kbn-eslint-plugin-imports | ||
kbn-eslint-plugin-telemetry | ||
kbn-event-annotation-common | ||
kbn-event-annotation-components | ||
kbn-expect | ||
kbn-failed-test-reporter-cli | ||
kbn-find-used-node-modules | ||
kbn-formatters | ||
kbn-ftr-common-functional-services | ||
kbn-ftr-common-functional-ui-services | ||
kbn-ftr-screenshot-filename | ||
kbn-gen-ai-functional-testing | ||
kbn-generate | ||
kbn-generate-console-definitions | ||
kbn-generate-csv | ||
kbn-get-repo-files | ||
kbn-grid-layout | ||
kbn-guided-onboarding | ||
kbn-handlebars | ||
kbn-hapi-mocks | ||
kbn-health-gateway-server | ||
kbn-i18n | ||
kbn-i18n-react | ||
kbn-import-locator | ||
kbn-import-resolver | ||
kbn-interpreter | ||
kbn-io-ts-utils | ||
kbn-item-buffer | ||
kbn-jest-serializers | ||
kbn-journeys | ||
kbn-json-ast | ||
kbn-kibana-manifest-schema | ||
kbn-lens-formula-docs | ||
kbn-lint-packages-cli | ||
kbn-lint-ts-projects-cli | ||
kbn-logging | ||
kbn-logging-mocks | ||
kbn-managed-content-badge | ||
kbn-managed-vscode-config | ||
kbn-managed-vscode-config-cli | ||
kbn-management | ||
kbn-manifest | ||
kbn-mock-idp-plugin | ||
kbn-mock-idp-utils | ||
kbn-monaco | ||
kbn-object-versioning | ||
kbn-object-versioning-utils | ||
kbn-openapi-bundler | ||
kbn-openapi-generator | ||
kbn-optimizer | ||
kbn-optimizer-webpack-helpers | ||
kbn-palettes | ||
kbn-peggy | ||
kbn-peggy-loader | ||
kbn-performance-testing-dataset-extractor | ||
kbn-picomatcher | ||
kbn-plugin-check | ||
kbn-plugin-generator | ||
kbn-plugin-helpers | ||
kbn-react-mute-legacy-root-warning | ||
kbn-recently-accessed | ||
kbn-relocate | ||
kbn-repo-file-maps | ||
kbn-repo-linter | ||
kbn-repo-path | ||
kbn-repo-source-classifier | ||
kbn-repo-source-classifier-cli | ||
kbn-reporting | ||
kbn-router-to-openapispec | ||
kbn-safer-lodash-set | ||
kbn-saved-objects-settings | ||
kbn-saved-search-component | ||
kbn-scout | ||
kbn-scout-info | ||
kbn-scout-reporting | ||
kbn-screenshotting-server | ||
kbn-security-hardening | ||
kbn-server-http-tools | ||
kbn-set-map | ||
kbn-shared-ux-utility | ||
kbn-some-dev-log | ||
kbn-sort-package-json | ||
kbn-sort-predicates | ||
kbn-std | ||
kbn-stdio-dev-helpers | ||
kbn-storybook | ||
kbn-telemetry-tools | ||
kbn-test | ||
kbn-test-eui-helpers | ||
kbn-test-jest-helpers | ||
kbn-test-subj-selector | ||
kbn-timelion-grammar | ||
kbn-tinymath | ||
kbn-tooling-log | ||
kbn-transpose-utils | ||
kbn-ts-projects | ||
kbn-ts-type-check-cli | ||
kbn-ui-actions-browser | ||
kbn-use-tracked-promise | ||
kbn-user-profile-components | ||
kbn-utility-types | ||
kbn-validate-next-docs-cli | ||
kbn-visualization-ui-components | ||
kbn-visualization-utils | ||
kbn-web-worker-stub | ||
kbn-whereis-pkg-cli | ||
kbn-yarn-lock-validator | ||
kbn-zod | ||
react | ||
response-ops | ||
serverless | ||
shared-ux | ||
README.md |
Kibana-related packages
This folder contains packages that are intended for use in Kibana and Kibana plugins.
tl;dr:
- Don't publish to npm registry
- Always use the
@kbn
namespace - Always set
"private": true
inpackage.json
Using these packages
We no longer publish these packages to the npm registry. Now, instead of specifying a version when including these packages, we rely on yarn workspaces, which sets up a symlink to the package.
For example if you want to use the @kbn/i18n
package in Kibana itself, you
can specify the dependency like this:
"@kbn/i18n": "1.0.0"
However, if you want to use this from a Kibana plugin, you need to use a link:
dependency and account for the relative location of the Kibana repo, so it would
instead be:
"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"
then run yarn kbn bootstrap
from the plugin directory.
Creating a new package
Run the following command from the root of the Kibana repo:
node scripts/generate package @kbn/<PACKAGE_NAME> --web --owner @elastic/<TEAM_NAME>
Unit tests for a package
Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.
Jest
A package should follow the pattern of having .test.js
files as siblings of the source code files, and these run by Jest.
A package using the .test.js
naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test
script in the root package.json
.
yarn test
runs all unit tests.yarn jest
runs all Jest tests in Kibana.
In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.
Each package can also specify its own test
script in the package's package.json
, for cases where you'd prefer to run the tests from the local package directory.