Skip to content

Commit 287416e

Browse files
committed
Merge branch 'master' of github.com:elastic/kibana into fix-ftue-with-apm
2 parents 4f5b60a + 27a4fe2 commit 287416e

File tree

37 files changed

+463
-174
lines changed

37 files changed

+463
-174
lines changed

src/plugins/console/server/lib/elasticsearch_proxy_config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import _ from 'lodash';
2121
import http from 'http';
2222
import https from 'https';
2323
import url from 'url';
24-
import { Duration } from 'moment';
2524

26-
const createAgent = (legacyConfig: any) => {
25+
import { ESConfigForProxy } from '../types';
26+
27+
const createAgent = (legacyConfig: ESConfigForProxy) => {
2728
const target = url.parse(_.head(legacyConfig.hosts));
2829
if (!/^https/.test(target.protocol || '')) return new http.Agent();
2930

@@ -59,7 +60,7 @@ const createAgent = (legacyConfig: any) => {
5960
return new https.Agent(agentOptions);
6061
};
6162

62-
export const getElasticsearchProxyConfig = (legacyConfig: { requestTimeout: Duration }) => {
63+
export const getElasticsearchProxyConfig = (legacyConfig: ESConfigForProxy) => {
6364
return {
6465
timeout: legacyConfig.requestTimeout.asMilliseconds(),
6566
agent: createAgent(legacyConfig),

src/plugins/console/server/plugin.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ export class ConsoleServerPlugin implements Plugin<ConsoleSetup> {
6060
const legacyConfig = readLegacyEsConfig();
6161
return {
6262
...elasticsearch,
63-
hosts: legacyConfig.hosts,
64-
requestHeadersWhitelist: legacyConfig.requestHeadersWhitelist,
65-
customHeaders: legacyConfig.customHeaders,
63+
...legacyConfig,
6664
};
6765
},
6866
pathFilters: proxyPathFilters,

src/plugins/console/server/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,12 @@ export interface ESConfigForProxy {
3131
requestHeadersWhitelist: string[];
3232
customHeaders: Record<string, any>;
3333
requestTimeout: Duration;
34+
ssl?: {
35+
verificationMode: 'none' | 'certificate' | 'full';
36+
certificateAuthorities: string[] | string;
37+
alwaysPresentCertificate: boolean;
38+
certificate?: string;
39+
key?: string;
40+
keyPassphrase?: string;
41+
};
3442
}
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 {
8+
EuiFlexGroup,
9+
EuiFlexItem,
10+
EuiHorizontalRule,
11+
EuiTitle
12+
} from '@elastic/eui';
13+
import cytoscape from 'cytoscape';
14+
import React from 'react';
15+
import { Buttons } from './Buttons';
16+
import { Info } from './Info';
17+
import { ServiceMetricList } from './ServiceMetricList';
18+
19+
const popoverMinWidth = 280;
20+
21+
interface ContentsProps {
22+
focusedServiceName?: string;
23+
isService: boolean;
24+
label: string;
25+
onFocusClick: () => void;
26+
selectedNodeData: cytoscape.NodeDataDefinition;
27+
selectedNodeServiceName: string;
28+
}
29+
30+
export function Contents({
31+
selectedNodeData,
32+
focusedServiceName,
33+
isService,
34+
label,
35+
onFocusClick,
36+
selectedNodeServiceName
37+
}: ContentsProps) {
38+
return (
39+
<EuiFlexGroup
40+
direction="column"
41+
gutterSize="s"
42+
style={{ minWidth: popoverMinWidth }}
43+
>
44+
<EuiFlexItem>
45+
<EuiTitle size="xxs">
46+
<h3>{label}</h3>
47+
</EuiTitle>
48+
<EuiHorizontalRule margin="xs" />
49+
</EuiFlexItem>
50+
<EuiFlexItem>
51+
{isService ? (
52+
<ServiceMetricList serviceName={selectedNodeServiceName} />
53+
) : (
54+
<Info {...selectedNodeData} />
55+
)}
56+
</EuiFlexItem>
57+
{isService && (
58+
<Buttons
59+
focusedServiceName={focusedServiceName}
60+
onFocusClick={onFocusClick}
61+
selectedNodeServiceName={selectedNodeServiceName}
62+
/>
63+
)}
64+
</EuiFlexGroup>
65+
);
66+
}

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

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

7-
import React from 'react';
7+
import lightTheme from '@elastic/eui/dist/eui_theme_light.json';
88
import { i18n } from '@kbn/i18n';
9+
import cytoscape from 'cytoscape';
10+
import React from 'react';
911
import styled from 'styled-components';
10-
import lightTheme from '@elastic/eui/dist/eui_theme_light.json';
1112

1213
const ItemRow = styled.div`
1314
line-height: 2;
@@ -19,8 +20,8 @@ const ItemTitle = styled.dt`
1920

2021
const ItemDescription = styled.dd``;
2122

22-
interface InfoProps {
23-
type: string;
23+
interface InfoProps extends cytoscape.NodeDataDefinition {
24+
type?: string;
2425
subtype?: string;
2526
}
2627

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 { storiesOf } from '@storybook/react';
8+
import React from 'react';
9+
import {
10+
ApmPluginContext,
11+
ApmPluginContextValue
12+
} from '../../../../context/ApmPluginContext';
13+
import { Contents } from './Contents';
14+
15+
const selectedNodeData = {
16+
id: 'opbeans-node',
17+
label: 'opbeans-node',
18+
href:
19+
'#/services/opbeans-node/service-map?rangeFrom=now-24h&rangeTo=now&refreshPaused=true&refreshInterval=0',
20+
agentName: 'nodejs',
21+
type: 'service'
22+
};
23+
24+
storiesOf('app/ServiceMap/Popover/Contents', module).add(
25+
'example',
26+
() => {
27+
return (
28+
<ApmPluginContext.Provider
29+
value={
30+
({ core: { notifications: {} } } as unknown) as ApmPluginContextValue
31+
}
32+
>
33+
<Contents
34+
selectedNodeData={selectedNodeData}
35+
isService={true}
36+
label="opbeans-node"
37+
onFocusClick={() => {}}
38+
selectedNodeServiceName="opbeans-node"
39+
/>
40+
</ApmPluginContext.Provider>
41+
);
42+
},
43+
{
44+
info: {
45+
propTablesExclude: [ApmPluginContext.Provider],
46+
source: false
47+
}
48+
}
49+
);

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

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

7-
import {
8-
EuiFlexGroup,
9-
EuiFlexItem,
10-
EuiHorizontalRule,
11-
EuiPopover,
12-
EuiTitle
13-
} from '@elastic/eui';
7+
import { EuiPopover } from '@elastic/eui';
148
import cytoscape from 'cytoscape';
159
import React, {
1610
CSSProperties,
11+
useCallback,
1712
useContext,
1813
useEffect,
19-
useState,
20-
useCallback
14+
useRef,
15+
useState
2116
} from 'react';
2217
import { CytoscapeContext } from '../Cytoscape';
23-
import { Buttons } from './Buttons';
24-
import { Info } from './Info';
25-
import { ServiceMetricList } from './ServiceMetricList';
26-
27-
const popoverMinWidth = 280;
18+
import { Contents } from './Contents';
2819

2920
interface PopoverProps {
3021
focusedServiceName?: string;
@@ -35,92 +26,79 @@ export function Popover({ focusedServiceName }: PopoverProps) {
3526
const [selectedNode, setSelectedNode] = useState<
3627
cytoscape.NodeSingular | undefined
3728
>(undefined);
38-
const onFocusClick = useCallback(() => setSelectedNode(undefined), [
29+
const deselect = useCallback(() => setSelectedNode(undefined), [
3930
setSelectedNode
4031
]);
41-
42-
useEffect(() => {
43-
const selectHandler: cytoscape.EventHandler = event => {
44-
setSelectedNode(event.target);
45-
};
46-
const unselectHandler: cytoscape.EventHandler = () => {
47-
setSelectedNode(undefined);
48-
};
49-
50-
if (cy) {
51-
cy.on('select', 'node', selectHandler);
52-
cy.on('unselect', 'node', unselectHandler);
53-
cy.on('data viewport', unselectHandler);
54-
}
55-
56-
return () => {
57-
if (cy) {
58-
cy.removeListener('select', 'node', selectHandler);
59-
cy.removeListener('unselect', 'node', unselectHandler);
60-
cy.removeListener('data viewport', undefined, unselectHandler);
61-
}
62-
};
63-
}, [cy]);
64-
6532
const renderedHeight = selectedNode?.renderedHeight() ?? 0;
6633
const renderedWidth = selectedNode?.renderedWidth() ?? 0;
6734
const { x, y } = selectedNode?.renderedPosition() ?? { x: 0, y: 0 };
6835
const isOpen = !!selectedNode;
69-
const selectedNodeServiceName: string = selectedNode?.data('id');
7036
const isService = selectedNode?.data('type') === 'service';
7137
const triggerStyle: CSSProperties = {
7238
background: 'transparent',
7339
height: renderedHeight,
7440
position: 'absolute',
75-
width: renderedWidth
41+
width: renderedWidth,
42+
border: '3px dotted red'
7643
};
77-
const trigger = <div className="trigger" style={triggerStyle} />;
78-
44+
const trigger = <div style={triggerStyle} />;
7945
const zoom = cy?.zoom() ?? 1;
8046
const height = selectedNode?.height() ?? 0;
81-
const translateY = y - (zoom + 1) * (height / 2);
47+
const translateY = y - ((zoom + 1) * height) / 4;
8248
const popoverStyle: CSSProperties = {
8349
position: 'absolute',
8450
transform: `translate(${x}px, ${translateY}px)`
8551
};
86-
const data = selectedNode?.data() ?? {};
87-
const label = data.label || selectedNodeServiceName;
52+
const selectedNodeData = selectedNode?.data() ?? {};
53+
const selectedNodeServiceName = selectedNodeData.id;
54+
const label = selectedNodeData.label || selectedNodeServiceName;
55+
const popoverRef = useRef<EuiPopover>(null);
56+
57+
// Set up Cytoscape event handlers
58+
useEffect(() => {
59+
const selectHandler: cytoscape.EventHandler = event => {
60+
setSelectedNode(event.target);
61+
};
62+
63+
if (cy) {
64+
cy.on('select', 'node', selectHandler);
65+
cy.on('unselect', 'node', deselect);
66+
cy.on('data viewport', deselect);
67+
}
68+
69+
return () => {
70+
if (cy) {
71+
cy.removeListener('select', 'node', selectHandler);
72+
cy.removeListener('unselect', 'node', deselect);
73+
cy.removeListener('data viewport', undefined, deselect);
74+
}
75+
};
76+
}, [cy, deselect]);
77+
78+
// Handle positioning of popover. This makes it so the popover positions
79+
// itself correctly and the arrows are always pointing to where they should.
80+
useEffect(() => {
81+
if (popoverRef.current) {
82+
popoverRef.current.positionPopoverFluid();
83+
}
84+
}, [popoverRef, x, y]);
8885

8986
return (
9087
<EuiPopover
9188
anchorPosition={'upCenter'}
9289
button={trigger}
9390
closePopover={() => {}}
9491
isOpen={isOpen}
92+
ref={popoverRef}
9593
style={popoverStyle}
9694
>
97-
<EuiFlexGroup
98-
direction="column"
99-
gutterSize="s"
100-
style={{ minWidth: popoverMinWidth }}
101-
>
102-
<EuiFlexItem>
103-
<EuiTitle size="xxs">
104-
<h3>{label}</h3>
105-
</EuiTitle>
106-
<EuiHorizontalRule margin="xs" />
107-
</EuiFlexItem>
108-
109-
<EuiFlexItem>
110-
{isService ? (
111-
<ServiceMetricList serviceName={selectedNodeServiceName} />
112-
) : (
113-
<Info {...data} />
114-
)}
115-
</EuiFlexItem>
116-
{isService && (
117-
<Buttons
118-
focusedServiceName={focusedServiceName}
119-
onFocusClick={onFocusClick}
120-
selectedNodeServiceName={selectedNodeServiceName}
121-
/>
122-
)}
123-
</EuiFlexGroup>
95+
<Contents
96+
selectedNodeData={selectedNodeData}
97+
isService={isService}
98+
label={label}
99+
onFocusClick={deselect}
100+
selectedNodeServiceName={selectedNodeServiceName}
101+
/>
124102
</EuiPopover>
125103
);
126104
}

x-pack/legacy/plugins/encrypted_saved_objects/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export const encryptedSavedObjects = (kibana: {
2121
// Some legacy plugins still use `enabled` config key, so we keep it here, but the rest of the
2222
// keys is handled by the New Platform plugin.
2323
config: (Joi: Root) =>
24-
Joi.object({ enabled: Joi.boolean().default(true) })
24+
Joi.object({
25+
enabled: Joi.boolean().default(true),
26+
})
2527
.unknown(true)
2628
.default(),
2729

x-pack/legacy/plugins/siem/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { i18n } from '@kbn/i18n';
8+
import { get } from 'lodash/fp';
89
import { resolve } from 'path';
910
import { Server } from 'hapi';
1011
import { Root } from 'joi';
@@ -155,6 +156,9 @@ export const siem = (kibana: any) => {
155156
const initializerContext = { ...coreContext, env } as PluginInitializerContext;
156157
const serverFacade = {
157158
config,
159+
usingEphemeralEncryptionKey:
160+
get('usingEphemeralEncryptionKey', newPlatform.setup.plugins.encryptedSavedObjects) ??
161+
false,
158162
plugins: {
159163
alerting: plugins.alerting,
160164
actions: newPlatform.start.plugins.actions,

0 commit comments

Comments
 (0)