Skip to content

Commit c5e9fbb

Browse files
committed
Merge branch 'master' into siem_ui_new_platform_services
2 parents ad83050 + 28e05e7 commit c5e9fbb

23 files changed

Lines changed: 211 additions & 88 deletions

File tree

src/plugins/kibana_react/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ export * from './overlays';
2525
export * from './ui_settings';
2626
export * from './field_icon';
2727
export * from './table_list_view';
28-
export { toMountPoint, useShallowCompareEffect } from './util';
28+
export { toMountPoint, useObservable, useShallowCompareEffect } from './util';

x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ export class ServiceIntegrations extends React.Component<Props, State> {
148148
panels={[
149149
{
150150
id: 0,
151-
items: this.getPanelItems(license.features.ml?.is_available)
151+
items: this.getPanelItems(
152+
license?.getFeature('ml').isAvailable
153+
)
152154
}
153155
]}
154156
/>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import React from 'react';
8+
import {
9+
EuiEmptyPrompt,
10+
EuiButton,
11+
EuiPanel,
12+
EuiFlexGroup,
13+
EuiFlexItem
14+
} from '@elastic/eui';
15+
import { i18n } from '@kbn/i18n';
16+
import { useKibanaUrl } from '../../../hooks/useKibanaUrl';
17+
18+
export function PlatinumLicensePrompt() {
19+
// Set the height to give it some top margin
20+
const style = { height: '60vh' };
21+
22+
const licensePageUrl = useKibanaUrl(
23+
'/app/kibana',
24+
'/management/elasticsearch/license_management/home'
25+
);
26+
27+
return (
28+
<EuiFlexGroup
29+
alignItems="center"
30+
justifyContent="spaceAround"
31+
style={style}
32+
>
33+
<EuiFlexItem grow={false}>
34+
<EuiPanel grow={false} hasShadow={true}>
35+
<EuiEmptyPrompt
36+
actions={[
37+
<EuiButton fill={true} href={licensePageUrl}>
38+
{i18n.translate(
39+
'xpack.apm.serviceMap.licensePromptButtonText',
40+
{
41+
defaultMessage: 'Start 30-day Platinum trial'
42+
}
43+
)}
44+
</EuiButton>
45+
]}
46+
body={
47+
<p>
48+
{i18n.translate('xpack.apm.serviceMap.licensePromptBody', {
49+
defaultMessage:
50+
"In order to access Service Maps, you must be subscribed to an Elastic Platinum license. With it, you'll have the ability to visualize your entire application stack along with your APM data."
51+
})}
52+
</p>
53+
}
54+
title={
55+
<h2>
56+
{i18n.translate('xpack.apm.serviceMap.licensePromptTitle', {
57+
defaultMessage: 'Service maps is available in Platinum.'
58+
})}
59+
</h2>
60+
}
61+
/>
62+
</EuiPanel>
63+
</EuiFlexItem>
64+
</EuiFlexGroup>
65+
);
66+
}

x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import React from 'react';
87
import theme from '@elastic/eui/dist/eui_theme_light.json';
9-
import { useUrlParams } from '../../../hooks/useUrlParams';
8+
import React from 'react';
109
import { useFetcher } from '../../../hooks/useFetcher';
11-
import { Cytoscape } from './Cytoscape';
10+
import { useLicense } from '../../../hooks/useLicense';
11+
import { useUrlParams } from '../../../hooks/useUrlParams';
1212
import { Controls } from './Controls';
13+
import { Cytoscape } from './Cytoscape';
14+
import { PlatinumLicensePrompt } from './PlatinumLicensePrompt';
1315

1416
interface ServiceMapProps {
1517
serviceName?: string;
@@ -53,14 +55,19 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
5355
);
5456

5557
const elements = Array.isArray(data) ? data : [];
58+
const license = useLicense();
59+
const isValidPlatinumLicense =
60+
license?.isActive && license?.type === 'platinum';
5661

57-
return (
62+
return isValidPlatinumLicense ? (
5863
<Cytoscape
5964
elements={elements}
6065
serviceName={serviceName}
6166
style={cytoscapeDivStyle}
6267
>
6368
<Controls />
6469
</Cytoscape>
70+
) : (
71+
<PlatinumLicensePrompt />
6572
);
6673
}

x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class TransactionCharts extends Component<TransactionChartProps> {
170170
</EuiFlexItem>
171171
<LicenseContext.Consumer>
172172
{license =>
173-
this.renderMLHeader(license.features.ml?.is_available)
173+
this.renderMLHeader(license?.getFeature('ml').isAvailable)
174174
}
175175
</LicenseContext.Consumer>
176176
</EuiFlexGroup>

x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,27 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6+
67
import React from 'react';
7-
import { FETCH_STATUS, useFetcher } from '../../hooks/useFetcher';
8-
import { loadLicense, LicenseApiResponse } from '../../services/rest/xpack';
9-
import { InvalidLicenseNotification } from './InvalidLicenseNotification';
8+
import { useObservable } from '../../../../../../../src/plugins/kibana_react/public';
9+
import { ILicense } from '../../../../../../plugins/licensing/public';
1010
import { useApmPluginContext } from '../../hooks/useApmPluginContext';
11+
import { InvalidLicenseNotification } from './InvalidLicenseNotification';
1112

12-
const initialLicense: LicenseApiResponse = {
13-
features: {},
14-
license: {
15-
is_active: false
16-
}
17-
};
18-
export const LicenseContext = React.createContext(initialLicense);
13+
export const LicenseContext = React.createContext<ILicense | undefined>(
14+
undefined
15+
);
1916

20-
export const LicenseProvider: React.FC = ({ children }) => {
21-
const { http } = useApmPluginContext().core;
22-
const { data = initialLicense, status } = useFetcher(
23-
() => loadLicense(http),
24-
[http]
25-
);
26-
const hasValidLicense = data.license.is_active;
17+
export function LicenseProvider({ children }: { children: React.ReactChild }) {
18+
const { license$ } = useApmPluginContext().plugins.licensing;
19+
const license = useObservable(license$);
20+
const hasInvalidLicense = !license?.isActive;
2721

2822
// if license is invalid show an error message
29-
if (status === FETCH_STATUS.SUCCESS && !hasValidLicense) {
23+
if (hasInvalidLicense) {
3024
return <InvalidLicenseNotification />;
3125
}
3226

3327
// render rest of application and pass down license via context
34-
return <LicenseContext.Provider value={data} children={children} />;
35-
};
28+
return <LicenseContext.Provider value={license} children={children} />;
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import url from 'url';
8+
import { useApmPluginContext } from './useApmPluginContext';
9+
10+
export function useKibanaUrl(
11+
/** The path to the plugin */ path: string,
12+
/** The hash path */ hash: string
13+
) {
14+
const { core } = useApmPluginContext();
15+
return url.format({
16+
pathname: core.http.basePath.prepend(path),
17+
hash
18+
});
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { useContext } from 'react';
8+
import { LicenseContext } from '../context/LicenseContext';
9+
10+
export function useLicense() {
11+
return useContext(LicenseContext);
12+
}

x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,36 @@
66

77
import React from 'react';
88
import ReactDOM from 'react-dom';
9-
import { Router, Route, Switch } from 'react-router-dom';
9+
import { Route, Router, Switch } from 'react-router-dom';
1010
import styled from 'styled-components';
1111
import { metadata } from 'ui/metadata';
12-
import { HomePublicPluginSetup } from '../../../../../../src/plugins/home/public';
1312
import {
13+
CoreSetup,
1414
CoreStart,
15+
PackageInfo,
1516
Plugin,
16-
CoreSetup,
17-
PluginInitializerContext,
18-
PackageInfo
17+
PluginInitializerContext
1918
} from '../../../../../../src/core/public';
2019
import { DataPublicPluginSetup } from '../../../../../../src/plugins/data/public';
21-
import { history } from '../utils/history';
22-
import { LocationProvider } from '../context/LocationContext';
23-
import { UrlParamsProvider } from '../context/UrlParamsContext';
24-
import { px, unit, units } from '../style/variables';
25-
import { LoadingIndicatorProvider } from '../context/LoadingIndicatorContext';
26-
import { LicenseProvider } from '../context/LicenseContext';
27-
import { UpdateBreadcrumbs } from '../components/app/Main/UpdateBreadcrumbs';
20+
import { HomePublicPluginSetup } from '../../../../../../src/plugins/home/public';
21+
import { LicensingPluginSetup } from '../../../../../plugins/licensing/public';
2822
import { routes } from '../components/app/Main/route_config';
2923
import { ScrollToTopOnPathChange } from '../components/app/Main/ScrollToTopOnPathChange';
24+
import { UpdateBreadcrumbs } from '../components/app/Main/UpdateBreadcrumbs';
25+
import { ApmPluginContext } from '../context/ApmPluginContext';
26+
import { LicenseProvider } from '../context/LicenseContext';
27+
import { LoadingIndicatorProvider } from '../context/LoadingIndicatorContext';
28+
import { LocationProvider } from '../context/LocationContext';
3029
import { MatchedRouteProvider } from '../context/MatchedRouteContext';
30+
import { UrlParamsProvider } from '../context/UrlParamsContext';
3131
import { createStaticIndexPattern } from '../services/rest/index_pattern';
32-
import { setHelpExtension } from './setHelpExtension';
33-
import { setReadonlyBadge } from './updateBadge';
32+
import { px, unit, units } from '../style/variables';
33+
import { history } from '../utils/history';
3434
import { featureCatalogueEntry } from './featureCatalogueEntry';
3535
import { getConfigFromInjectedMetadata } from './getConfigFromInjectedMetadata';
36+
import { setHelpExtension } from './setHelpExtension';
3637
import { toggleAppLinkInNav } from './toggleAppLinkInNav';
37-
import { ApmPluginContext } from '../context/ApmPluginContext';
38+
import { setReadonlyBadge } from './updateBadge';
3839

3940
export const REACT_APP_ROOT_ID = 'react-apm-root';
4041

@@ -64,6 +65,7 @@ export type ApmPluginStart = void;
6465
export interface ApmPluginSetupDeps {
6566
data: DataPublicPluginSetup;
6667
home: HomePublicPluginSetup;
68+
licensing: LicensingPluginSetup;
6769
}
6870

6971
export interface ConfigSchema {

x-pack/legacy/plugins/apm/public/services/rest/xpack.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)