mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Fix bug in xpackInfo in which keys were being camel-cased during refresh but not init (#29304) (#29568)
* Update Beats Management to use camelCased plugin ID to access xpackInfo.
This commit is contained in:
parent
66c0c92f82
commit
aeb6275ed9
5 changed files with 22 additions and 21 deletions
|
@ -135,22 +135,21 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
|
|||
component: React.ReactElement<any>,
|
||||
toController: 'management' | 'self' = 'self'
|
||||
) {
|
||||
const DOM_ELEMENT_NAME = this.PLUGIN_ID.replace('_', '-');
|
||||
const adapter = this;
|
||||
this.routes.when(
|
||||
`${path}${[...Array(6)].map((e, n) => `/:arg${n}?`).join('')}`, // Hack because angular 1 does not support wildcards
|
||||
{
|
||||
template:
|
||||
toController === 'self'
|
||||
? `<${DOM_ELEMENT_NAME}><div id="${DOM_ELEMENT_NAME}ReactRoot"></div></${DOM_ELEMENT_NAME}>`
|
||||
? `<${this.PLUGIN_ID}><div id="${this.PLUGIN_ID}ReactRoot"></div></${this.PLUGIN_ID}>`
|
||||
: `<kbn-management-app section="${this.PLUGIN_ID.replace('_', '-')}">
|
||||
<div id="${DOM_ELEMENT_NAME}ReactRoot" />
|
||||
<div id="${this.PLUGIN_ID}ReactRoot" />
|
||||
</kbn-management-app>`,
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
controller: ($scope: any, $route: any) => {
|
||||
try {
|
||||
$scope.$$postDigest(() => {
|
||||
const elem = document.getElementById(`${DOM_ELEMENT_NAME}ReactRoot`);
|
||||
const elem = document.getElementById(`${this.PLUGIN_ID}ReactRoot`);
|
||||
ReactDOM.render(component, elem);
|
||||
adapter.manageAngularLifecycle($scope, $route, elem);
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { camelCase } from 'lodash';
|
||||
// @ts-ignore not typed yet
|
||||
import { XPackInfoProvider } from 'plugins/xpack_main/services/xpack_info';
|
||||
import 'ui/autoload/all';
|
||||
|
@ -41,7 +42,7 @@ export function compose(): FrontendLibs {
|
|||
|
||||
const framework = new FrameworkLib(
|
||||
new KibanaFrameworkAdapter(
|
||||
PLUGIN.ID,
|
||||
camelCase(PLUGIN.ID),
|
||||
management,
|
||||
routes,
|
||||
chrome.getBasePath,
|
||||
|
|
|
@ -5,16 +5,15 @@
|
|||
*/
|
||||
// file.skip
|
||||
|
||||
// @ts-ignore
|
||||
import { esTestConfig, kbnTestConfig, OPTIMIZE_BUNDLE_DIR } from '@kbn/test';
|
||||
import { camelCase } from 'lodash';
|
||||
// @ts-ignore
|
||||
import * as kbnTestServer from '../../../../../../../../src/test_utils/kbn_server';
|
||||
// @ts-ignore
|
||||
import { xpackKbnServerConfig } from '../../../../../../../test_utils/kbn_server_config';
|
||||
import { PLUGIN } from './../../../../../common/constants/plugin';
|
||||
|
||||
import { KibanaBackendFrameworkAdapter } from './../kibana_framework_adapter';
|
||||
import { contractTests } from './test_contract';
|
||||
|
||||
let servers: any;
|
||||
contractTests('Kibana Framework Adapter', {
|
||||
async before() {
|
||||
|
@ -27,6 +26,6 @@ contractTests('Kibana Framework Adapter', {
|
|||
await servers.stop();
|
||||
},
|
||||
adapterSetup: () => {
|
||||
return new KibanaBackendFrameworkAdapter(PLUGIN.ID, servers.kbnServer.server);
|
||||
return new KibanaBackendFrameworkAdapter(camelCase(PLUGIN.ID), servers.kbnServer.server);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,27 +4,25 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { camelCase } from 'lodash';
|
||||
import { PLUGIN } from 'x-pack/plugins/beats_management/common/constants';
|
||||
import { CONFIG_PREFIX } from 'x-pack/plugins/beats_management/common/constants/plugin';
|
||||
import { ElasticsearchBeatsAdapter } from '../adapters/beats/elasticsearch_beats_adapter';
|
||||
import { DatabaseKbnESPlugin } from '../adapters/database/adapter_types';
|
||||
import { KibanaDatabaseAdapter } from '../adapters/database/kibana_database_adapter';
|
||||
import { KibanaLegacyServer } from '../adapters/framework/adapter_types';
|
||||
import { KibanaBackendFrameworkAdapter } from '../adapters/framework/kibana_framework_adapter';
|
||||
import { ElasticsearchTagsAdapter } from '../adapters/tags/elasticsearch_tags_adapter';
|
||||
import { ElasticsearchTokensAdapter } from '../adapters/tokens/elasticsearch_tokens_adapter';
|
||||
|
||||
import { KibanaBackendFrameworkAdapter } from '../adapters/framework/kibana_framework_adapter';
|
||||
import { BackendFrameworkLib } from './../framework';
|
||||
|
||||
import { CMBeatsDomain } from '../beats';
|
||||
import { CMTagsDomain } from '../tags';
|
||||
import { CMTokensDomain } from '../tokens';
|
||||
|
||||
import { PLUGIN } from 'x-pack/plugins/beats_management/common/constants';
|
||||
import { CONFIG_PREFIX } from 'x-pack/plugins/beats_management/common/constants/plugin';
|
||||
import { DatabaseKbnESPlugin } from '../adapters/database/adapter_types';
|
||||
import { KibanaLegacyServer } from '../adapters/framework/adapter_types';
|
||||
import { CMServerLibs } from '../types';
|
||||
import { BackendFrameworkLib } from './../framework';
|
||||
|
||||
export function compose(server: KibanaLegacyServer): CMServerLibs {
|
||||
const framework = new BackendFrameworkLib(
|
||||
new KibanaBackendFrameworkAdapter(PLUGIN.ID, server, CONFIG_PREFIX)
|
||||
new KibanaBackendFrameworkAdapter(camelCase(PLUGIN.ID), server, CONFIG_PREFIX)
|
||||
);
|
||||
const database = new KibanaDatabaseAdapter(server.plugins.elasticsearch as DatabaseKbnESPlugin);
|
||||
|
||||
|
|
|
@ -27,7 +27,11 @@ export function XPackInfoProvider($window, $injector, Private) {
|
|||
};
|
||||
|
||||
setAll = (updatedXPackInfo) => {
|
||||
$window.sessionStorage.setItem(XPACK_INFO_KEY, JSON.stringify(updatedXPackInfo));
|
||||
// The decision to convert kebab-case/snake-case keys to camel-case keys stemmed from an old
|
||||
// convention of using kebabe-case/snake-case in API response bodies but camel-case in JS
|
||||
// objects. See pull #29304 for more info.
|
||||
const camelCasedXPackInfo = convertKeysToCamelCaseDeep(updatedXPackInfo);
|
||||
$window.sessionStorage.setItem(XPACK_INFO_KEY, JSON.stringify(camelCasedXPackInfo));
|
||||
};
|
||||
|
||||
clear = () => {
|
||||
|
@ -52,7 +56,7 @@ export function XPackInfoProvider($window, $injector, Private) {
|
|||
throw err;
|
||||
})
|
||||
.then((xpackInfoResponse) => {
|
||||
this.setAll(convertKeysToCamelCaseDeep(xpackInfoResponse.data));
|
||||
this.setAll(xpackInfoResponse.data);
|
||||
xpackInfoSignature.set(xpackInfoResponse.headers('kbn-xpack-sig'));
|
||||
})
|
||||
.finally(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue