mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
## Summary Fixes: https://github.com/elastic/kibana/issues/149347 This PR replaces deprecated `uiSettings` client with `settings.client` in `useUiSetting` hook. As a result, all consumers of the hook need to provide `settings` service to Kibana context. The majority of this PR is providing the `settings` as a dependency to affected plugins. It would be great if sometime in the future we could get rid of `uiSettings` entirely. `CodeEditor` is one of the components relying on this hook, which caused a lot of the changes in this PR. If you have been tagged for review it means your code is using `useUiSetting` hook directly, or is consuming `CodeEditor` component. I have been focused on updating plugins that had failing functional tests, but would appreciate a manual pass on this as well. xoxo ### Checklist Delete any items that are not applicable to this PR. ~ [ ] 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~ - [X] [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 ~- [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))~ ~- [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~ ~- [ ] 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 renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~ ~- [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)~ ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Maja Grubic <maja.grubic@elastic.co> Co-authored-by: Patryk Kopyciński <contact@patrykkopycinski.com>
100 lines
2.9 KiB
TypeScript
100 lines
2.9 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import { firstValueFrom } from 'rxjs';
|
|
import { i18n } from '@kbn/i18n';
|
|
import { Plugin, CoreSetup } from '@kbn/core/public';
|
|
|
|
import { ILicense } from '@kbn/licensing-plugin/common/types';
|
|
import { PLUGIN } from '../common/constants';
|
|
|
|
import { PluginDependencies } from './types';
|
|
import { getLinks } from './links';
|
|
|
|
const checkLicenseStatus = (license: ILicense) => {
|
|
const { state, message } = license.check(PLUGIN.id, PLUGIN.minimumLicenseType);
|
|
return state === 'valid' ? { valid: true } : { valid: false, message };
|
|
};
|
|
|
|
export class PainlessLabUIPlugin implements Plugin<void, void, PluginDependencies> {
|
|
public setup(
|
|
{ http, getStartServices, uiSettings }: CoreSetup,
|
|
{ devTools, home, licensing }: PluginDependencies
|
|
) {
|
|
home.featureCatalogue.register({
|
|
id: PLUGIN.id,
|
|
title: i18n.translate('xpack.painlessLab.registryProviderTitle', {
|
|
defaultMessage: 'Painless Lab (beta)',
|
|
}),
|
|
description: i18n.translate('xpack.painlessLab.registryProviderDescription', {
|
|
defaultMessage: 'Simulate and debug painless code.',
|
|
}),
|
|
icon: 'empty',
|
|
path: '/app/dev_tools#/painless_lab',
|
|
showOnHomePage: false,
|
|
category: 'admin',
|
|
});
|
|
|
|
const devTool = devTools.register({
|
|
id: 'painless_lab',
|
|
order: 7,
|
|
isBeta: true,
|
|
title: i18n.translate('xpack.painlessLab.displayName', {
|
|
defaultMessage: 'Painless Lab',
|
|
}),
|
|
enableRouting: false,
|
|
disabled: false,
|
|
mount: async ({ element, theme$ }) => {
|
|
const [core] = await getStartServices();
|
|
|
|
const {
|
|
i18n: { Context: I18nContext },
|
|
notifications,
|
|
docLinks,
|
|
chrome,
|
|
settings,
|
|
} = core;
|
|
|
|
const license = await firstValueFrom(licensing.license$);
|
|
const licenseStatus = checkLicenseStatus(license);
|
|
|
|
if (!licenseStatus.valid) {
|
|
notifications.toasts.addDanger(licenseStatus.message!);
|
|
window.location.hash = '/dev_tools';
|
|
return () => {};
|
|
}
|
|
|
|
const { renderApp } = await import('./application');
|
|
const tearDownApp = renderApp(element, {
|
|
I18nContext,
|
|
http,
|
|
uiSettings,
|
|
links: getLinks(docLinks),
|
|
chrome,
|
|
theme$,
|
|
settings,
|
|
});
|
|
|
|
return () => {
|
|
tearDownApp();
|
|
};
|
|
},
|
|
});
|
|
|
|
licensing.license$.subscribe((license) => {
|
|
if (!checkLicenseStatus(license).valid && !devTool.isDisabled()) {
|
|
devTool.disable();
|
|
} else if (devTool.isDisabled()) {
|
|
devTool.enable();
|
|
}
|
|
});
|
|
}
|
|
|
|
public start() {}
|
|
|
|
public stop() {}
|
|
}
|