Skip to content

Commit

Permalink
Add getter function for app availability for plugins that will be int…
Browse files Browse the repository at this point in the history
…egrated with Uptime in the future. (elastic#35543) (elastic#35868)
  • Loading branch information
justinkambic authored May 1, 2019
1 parent 3b6dd3b commit 083241f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
7 changes: 7 additions & 0 deletions x-pack/plugins/uptime/common/constants/capabilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* 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.
*/

export const INTEGRATED_SOLUTIONS = ['apm', 'infrastructure', 'logs'];
1 change: 1 addition & 0 deletions x-pack/plugins/uptime/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

export { CLIENT_DEFAULTS } from './client_defaults';
export { INDEX_NAMES } from './index_names';
export { INTEGRATED_SOLUTIONS } from './capabilities';
export { PLUGIN } from './plugin';
export { QUERY } from './query';
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 { capabilities as uiCapabilities } from 'ui/capabilities';

interface IntegratedAppsAvailability {
[key: string]: boolean;
}

export const getIntegratedAppAvailability = (
integratedApps: string[]
): IntegratedAppsAvailability => {
const capabilities = uiCapabilities.get();
return integratedApps.reduce((supportedSolutions: IntegratedAppsAvailability, solutionName) => {
supportedSolutions[solutionName] =
capabilities[solutionName] && capabilities[solutionName].show === true;
return supportedSolutions;
}, {});
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import ReactDOM from 'react-dom';
import { unmountComponentAtNode } from 'react-dom';
import chrome from 'ui/chrome';
import { PLUGIN } from '../../../../common/constants';
import { PLUGIN, INTEGRATED_SOLUTIONS } from '../../../../common/constants';
import { UMBreadcrumb } from '../../../breadcrumbs';
import { BootstrapUptimeApp, UMFrameworkAdapter } from '../../lib';
import { CreateGraphQLClient } from './framework_adapter_types';
import { renderUptimeKibanaGlobalHelp } from './kibana_global_help';
import { getIntegratedAppAvailability } from './capabilities_adapter';

export class UMKibanaFrameworkAdapter implements UMFrameworkAdapter {
private uiRoutes: any;
Expand Down Expand Up @@ -85,6 +86,17 @@ export class UMKibanaFrameworkAdapter implements UMFrameworkAdapter {
return () => ReactDOM.unmountComponentAtNode(element);
});

/**
* These values will let Uptime know if the integrated solutions
* are available. If any/all of them are unavaialble, we should not show
* links/integrations to those apps.
*/
const {
apm: isApmAvailable,
infrastructure: isInfraAvailable,
logs: isLogsAvailable,
} = getIntegratedAppAvailability(INTEGRATED_SOLUTIONS);

ReactDOM.render(
renderComponent({
basePath,
Expand All @@ -95,6 +107,9 @@ export class UMKibanaFrameworkAdapter implements UMFrameworkAdapter {
routerBasename,
client: graphQLClient,
renderGlobalHelpControls,
isApmAvailable,
isInfraAvailable,
isLogsAvailable,
}),
elem
);
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/uptime/public/uptime_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export interface UptimeAppProps {
basePath: string;
darkMode: boolean;
client: UMGraphQLClient;
isApmAvailable: boolean;
isInfraAvailable: boolean;
isLogsAvailable: boolean;
kibanaBreadcrumbs: UMBreadcrumb[];
routerBasename: string;
setBreadcrumbs: UMUpdateBreadcrumbs;
Expand Down

0 comments on commit 083241f

Please sign in to comment.