Add getter function for app availability for plugins that will be integrated with Uptime in the future. (#35543)
This commit is contained in:
parent
e76e2d910d
commit
a343899f75
7
x-pack/plugins/uptime/common/constants/capabilities.ts
Normal file
7
x-pack/plugins/uptime/common/constants/capabilities.ts
Normal file
|
@ -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'];
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
}, {});
|
||||
};
|
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -95,6 +107,9 @@ export class UMKibanaFrameworkAdapter implements UMFrameworkAdapter {
|
|||
routerBasename,
|
||||
client: graphQLClient,
|
||||
renderGlobalHelpControls,
|
||||
isApmAvailable,
|
||||
isInfraAvailable,
|
||||
isLogsAvailable,
|
||||
}),
|
||||
elem
|
||||
);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue