Skip to content

Commit

Permalink
Merge branch 'master' into vega-version
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 15, 2020
2 parents a8497d1 + 437f9f6 commit 7ce8dfd
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 16 deletions.
7 changes: 4 additions & 3 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { i18n } from '@kbn/i18n';
import { lazy } from 'react';
import { ConfigSchema } from '.';
import { ObservabilityPluginSetup } from '../../observability/public';
import {
AppMountParameters,
CoreSetup,
Expand All @@ -33,10 +34,10 @@ import {
import { AlertType } from '../common/alert_types';
import { featureCatalogueEntry } from './featureCatalogueEntry';
import { createCallApmApi } from './services/rest/createCallApmApi';
import { createStaticIndexPattern } from './services/rest/index_pattern';
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 All @@ -48,6 +49,7 @@ export interface ApmPluginSetupDeps {
home: HomePublicPluginSetup;
licensing: LicensingPluginSetup;
triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup;
observability?: ObservabilityPluginSetup;
}

export interface ApmPluginStartDeps {
Expand All @@ -64,6 +66,7 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
this.initializerContext = initializerContext;
}
public setup(core: CoreSetup, plugins: ApmPluginSetupDeps) {
createCallApmApi(core.http);
const config = this.initializerContext.config.get();
const pluginSetupDeps = plugins;

Expand Down Expand Up @@ -100,8 +103,6 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
});
}
public start(core: CoreStart, plugins: ApmPluginStartDeps) {
createCallApmApi(core.http);

toggleAppLinkInNav(core, this.initializerContext.config.get());

plugins.triggers_actions_ui.alertTypeRegistry.register({
Expand Down
24 changes: 24 additions & 0 deletions x-pack/plugins/observability/public/data_handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FetchData, HasData } from './typings/data_handler';
import { ObservabilityApp } from '../typings/common';

interface DataHandler {
fetchData: FetchData;
hasData: HasData;
}

const dataHandlers: Partial<Record<ObservabilityApp, DataHandler>> = {};

export type RegisterDataHandler = (params: { appName: ObservabilityApp } & DataHandler) => void;
export const registerDataHandler: RegisterDataHandler = ({ appName, fetchData, hasData }) => {
dataHandlers[appName] = { fetchData, hasData };
};

export function getDataHandler(appName: ObservabilityApp): DataHandler | undefined {
return dataHandlers[appName];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useEffect, useMemo } from 'react';
import { METRIC_TYPE, UiStatsMetricType } from '@kbn/analytics';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
import { ObservabilityApp } from '../../typings/common';

/**
* Note: The usage_collection plugin will take care of sending this data to the telemetry server.
Expand All @@ -17,8 +18,6 @@ import { useKibana } from '../../../../../src/plugins/kibana_react/public';
* a value, which will be a counter
*/

type ObservabilityApp = 'infra_metrics' | 'infra_logs' | 'apm' | 'uptime';

interface TrackOptions {
app?: ObservabilityApp;
metricType?: UiStatsMetricType;
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/observability/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
*/

import { PluginInitializerContext, PluginInitializer } from 'kibana/public';
import { Plugin, ClientSetup, ClientStart } from './plugin';
import { Plugin, ObservabilityPluginSetup, ObservabilityPluginStart } from './plugin';

export const plugin: PluginInitializer<ClientSetup, ClientStart> = (
export const plugin: PluginInitializer<ObservabilityPluginSetup, ObservabilityPluginStart> = (
context: PluginInitializerContext
) => {
return new Plugin(context);
};

export { ObservabilityPluginSetup, ObservabilityPluginStart };

export * from './components/action_menu';

export {
Expand Down
16 changes: 12 additions & 4 deletions x-pack/plugins/observability/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import {
Plugin as PluginClass,
PluginInitializerContext,
} from '../../../../src/core/public';
import { RegisterDataHandler, registerDataHandler } from './data_handler';

export type ClientSetup = void;
export type ClientStart = void;
export interface ObservabilityPluginSetup {
dashboard: { register: RegisterDataHandler };
}

export type ObservabilityPluginStart = void;

export class Plugin implements PluginClass<ClientSetup, ClientStart> {
export class Plugin implements PluginClass<ObservabilityPluginSetup, ObservabilityPluginStart> {
constructor(context: PluginInitializerContext) {}

public setup(core: CoreSetup) {
Expand All @@ -25,7 +29,7 @@ export class Plugin implements PluginClass<ClientSetup, ClientStart> {
appRoute: '/app/observability',
category: DEFAULT_APP_CATEGORIES.observability,

async mount(params: AppMountParameters<unknown>) {
mount: async (params: AppMountParameters<unknown>) => {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services
Expand All @@ -34,6 +38,10 @@ export class Plugin implements PluginClass<ClientSetup, ClientStart> {
return renderApp(coreStart, params);
},
});

return {
dashboard: { register: registerDataHandler },
};
}
public start() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

interface Stat {
label: string;
value: string;
color?: string;
}

export interface Coordinates {
x: number;
y?: number;
}

interface Series {
label: string;
coordinates: Coordinates[];
color?: string;
key?: string;
}

interface FetchDataResponse {
title: string;
appLink: string;
stats: Stat[];
series: Series[];
}
interface FetchDataParams {
// The start timestamp in milliseconds of the queried time interval
startTime: string;
// The end timestamp in milliseconds of the queried time interval
endTime: string;
// The aggregation bucket size in milliseconds if applicable to the data source
bucketSize: string;
}

export type FetchData = (fetchDataParams: FetchDataParams) => Promise<FetchDataResponse>;

export type HasData = () => Promise<boolean>;
2 changes: 2 additions & 0 deletions x-pack/plugins/observability/typings/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

export type ObservabilityApp = 'infra_metrics' | 'infra_logs' | 'apm' | 'uptime';

export type PromiseReturnType<Func> = Func extends (...args: any[]) => Promise<infer Value>
? Value
: Func;
3 changes: 2 additions & 1 deletion x-pack/test/functional/apps/canvas/custom_elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default function canvasCustomElementTest({
const PageObjects = getPageObjects(['canvas', 'common']);
const find = getService('find');

describe('custom elements', function () {
// FLAKY: https://github.com/elastic/kibana/issues/63339
describe.skip('custom elements', function () {
this.tags('skipFirefox');

before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
describe('space with index pattern management disabled', () => {
before(async () => {
await spacesService.create({
id: 'custom_space',
name: 'custom_space',
id: 'custom_space_no_index_patterns',
name: 'custom_space_no_index_patterns',
disabledFeatures: ['indexPatterns'],
});
});

after(async () => {
await spacesService.delete('custom_space');
await spacesService.delete('custom_space_no_index_patterns');
});

it('Navigates to Kibana home rather than index pattern management when no index patterns exist', async () => {
await PageObjects.common.navigateToUrl('discover', '', {
basePath: '/s/custom_space',
basePath: '/s/custom_space_no_index_patterns',
ensureCurrentUrl: false,
});
await testSubjects.existOrFail('homeApp', { timeout: config.get('timeouts.waitFor') });
Expand Down

0 comments on commit 7ce8dfd

Please sign in to comment.