Skip to content

Commit

Permalink
fixed ci issues by:
Browse files Browse the repository at this point in the history
- moving readOnly badge, and help extension setup to occure only
  when apm app is mounted
- registering saved object types
- also moved createStaticIndexPattern from a react useEffect on the
  APM home screen to when the app is mounted
  • Loading branch information
ogupte committed Apr 30, 2020
1 parent 269f089 commit c47f3b3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
11 changes: 1 addition & 10 deletions x-pack/plugins/apm/public/components/app/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
EuiTitle
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useEffect } from 'react';
import React from 'react';
import { $ElementType } from 'utility-types';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
import { ApmHeader } from '../../shared/ApmHeader';
Expand All @@ -25,7 +25,6 @@ import { SetupInstructionsLink } from '../../shared/Links/SetupInstructionsLink'
import { ServiceMap } from '../ServiceMap';
import { ServiceOverview } from '../ServiceOverview';
import { TraceOverview } from '../TraceOverview';
import { createStaticIndexPattern } from '../../../services/rest/index_pattern';

function getHomeTabs({
serviceMapEnabled = true
Expand Down Expand Up @@ -88,14 +87,6 @@ export function Home({ tab }: Props) {
homeTab => homeTab.name === tab
) as $ElementType<typeof homeTabs, number>;

useEffect(() => {
// Automatically creates static index pattern and stores as saved object
createStaticIndexPattern().catch(e => {
// eslint-disable-next-line no-console
console.log('Error creating static index pattern', e);
});
}, []);

return (
<div>
<ApmHeader>
Expand Down
15 changes: 12 additions & 3 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { TransactionDurationAlertTrigger } from './components/shared/Transaction
import { setHelpExtension } from './setHelpExtension';
import { toggleAppLinkInNav } from './toggleAppLinkInNav';
import { setReadonlyBadge } from './updateBadge';
import { createStaticIndexPattern } from './services/rest/index_pattern';

export type ApmPluginSetup = void;
export type ApmPluginStart = void;
Expand Down Expand Up @@ -85,16 +86,24 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
const { renderApp } = await import('./application');
// Get start services
const [coreStart] = await core.getStartServices();

// render APM feedback link in global help menu
setHelpExtension(coreStart);
setReadonlyBadge(coreStart);

// Automatically creates static index pattern and stores as saved object
createStaticIndexPattern().catch(e => {
// eslint-disable-next-line no-console
console.log('Error creating static index pattern', e);
});

return renderApp(coreStart, pluginSetupDeps, params, config);
}
});
}
public start(core: CoreStart, plugins: ApmPluginStartDeps) {
createCallApmApi(core.http);

// render APM feedback link in global help menu
setHelpExtension(core);
setReadonlyBadge(core);
toggleAppLinkInNav(core, this.initializerContext.config.get());

plugins.triggers_actions_ui.alertTypeRegistry.register({
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/apm/public/updateBadge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CoreStart } from 'kibana/public';
export function setReadonlyBadge({ application, chrome }: CoreStart) {
const canSave = application.capabilities.apm.save;
const { setBadge } = chrome;

setBadge(
!canSave
? {
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { registerApmAlerts } from './lib/alerts/register_apm_alerts';
import { createApmTelemetry } from './lib/apm_telemetry';
import { PluginSetupContract as FeaturesPluginSetup } from '../../../plugins/features/server';
import { APM_FEATURE } from './feature';
import { apmIndices, apmTelemetry } from './saved_objects';

export interface APMPluginSetup {
config$: Observable<APMConfig>;
Expand Down Expand Up @@ -64,6 +65,9 @@ export class APMPlugin implements Plugin<APMPluginSetup> {
map(([apmOssConfig, apmConfig]) => mergeConfigs(apmOssConfig, apmConfig))
);

core.savedObjects.registerType(apmIndices);
core.savedObjects.registerType(apmTelemetry);

if (plugins.actions && plugins.alerting) {
registerApmAlerts({
alerting: plugins.alerting,
Expand Down

0 comments on commit c47f3b3

Please sign in to comment.