Skip to content

Commit dd33002

Browse files
authored
Set service map cursors (#80920)
* Set service map cursors * "pointer" when mousing over a node * "default" when mousing out * "grabbing" while dragging Sets the cursor style on the container, not on the individual element. Since the node can both be clicked (to open a popover) and dragged, I left the cursor on hover as "pointer" to indicate the clickability. Fixes #64283.
1 parent f4c596d commit dd33002

9 files changed

Lines changed: 362 additions & 32 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useUrlParams } from '../../../hooks/useUrlParams';
1414
import { getAPMHref } from '../../shared/Links/apm/APMLink';
1515
import { APMQueryParams } from '../../shared/Links/url_helpers';
1616
import { CytoscapeContext } from './Cytoscape';
17-
import { getAnimationOptions, getNodeHeight } from './cytoscapeOptions';
17+
import { getAnimationOptions, getNodeHeight } from './cytoscape_options';
1818

1919
const ControlsContainer = styled('div')`
2020
left: ${({ theme }) => theme.eui.gutterTypes.gutterMedium};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import React, {
1717
useState,
1818
} from 'react';
1919
import { useTheme } from '../../../hooks/useTheme';
20-
import { getCytoscapeOptions } from './cytoscapeOptions';
20+
import { getCytoscapeOptions } from './cytoscape_options';
2121
import { useCytoscapeEventHandlers } from './use_cytoscape_event_handlers';
2222

2323
cytoscape.use(dagre);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { useTheme } from '../../../../hooks/useTheme';
2222
import { fontSize, px } from '../../../../style/variables';
2323
import { asInteger, asDuration } from '../../../../../common/utils/formatters';
2424
import { MLJobLink } from '../../../shared/Links/MachineLearningLinks/MLJobLink';
25-
import { popoverWidth } from '../cytoscapeOptions';
25+
import { popoverWidth } from '../cytoscape_options';
2626
import { TRANSACTION_REQUEST } from '../../../../../common/transaction_types';
2727
import {
2828
getSeverity,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import React, { MouseEvent } from 'react';
1515
import { Buttons } from './Buttons';
1616
import { Info } from './Info';
1717
import { ServiceStatsFetcher } from './ServiceStatsFetcher';
18-
import { popoverWidth } from '../cytoscapeOptions';
18+
import { popoverWidth } from '../cytoscape_options';
1919

2020
interface ContentsProps {
2121
isService: boolean;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import cytoscape from 'cytoscape';
1818
import { useTheme } from '../../../../hooks/useTheme';
1919
import { SERVICE_NAME } from '../../../../../common/elasticsearch_fieldnames';
2020
import { CytoscapeContext } from '../Cytoscape';
21-
import { getAnimationOptions } from '../cytoscapeOptions';
21+
import { getAnimationOptions } from '../cytoscape_options';
2222
import { Contents } from './Contents';
2323

2424
interface PopoverProps {

x-pack/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts renamed to x-pack/plugins/apm/public/components/app/ServiceMap/cytoscape_options.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
*/
66
import cytoscape from 'cytoscape';
77
import { CSSProperties } from 'react';
8-
import {
9-
getServiceHealthStatusColor,
10-
ServiceHealthStatus,
11-
} from '../../../../common/service_health_status';
8+
import { EuiTheme } from '../../../../../observability/public';
9+
import { ServiceAnomalyStats } from '../../../../common/anomaly_detection';
1210
import {
1311
SERVICE_NAME,
1412
SPAN_DESTINATION_SERVICE_RESOURCE,
1513
} from '../../../../common/elasticsearch_fieldnames';
16-
import { EuiTheme } from '../../../../../observability/public';
14+
import {
15+
getServiceHealthStatusColor,
16+
ServiceHealthStatus,
17+
} from '../../../../common/service_health_status';
18+
import { FETCH_STATUS } from '../../../hooks/useFetcher';
1719
import { defaultIcon, iconForNode } from './icons';
18-
import { ServiceAnomalyStats } from '../../../../common/anomaly_detection';
1920

2021
export const popoverWidth = 280;
2122

@@ -104,6 +105,11 @@ function isService(el: cytoscape.NodeSingular) {
104105
const getStyle = (theme: EuiTheme): cytoscape.Stylesheet[] => {
105106
const lineColor = theme.eui.euiColorMediumShade;
106107
return [
108+
{
109+
selector: 'core',
110+
// @ts-expect-error DefinitelyTyped does not recognize 'active-bg-opacity'
111+
style: { 'active-bg-opacity': 0 },
112+
},
107113
{
108114
selector: 'node',
109115
style: {
@@ -226,7 +232,10 @@ const getStyle = (theme: EuiTheme): cytoscape.Stylesheet[] => {
226232

227233
// The CSS styles for the div containing the cytoscape element. Makes a
228234
// background grid of dots.
229-
export const getCytoscapeDivStyle = (theme: EuiTheme): CSSProperties => ({
235+
export const getCytoscapeDivStyle = (
236+
theme: EuiTheme,
237+
status: FETCH_STATUS
238+
): CSSProperties => ({
230239
background: `linear-gradient(
231240
90deg,
232241
${theme.eui.euiPageBackgroundColor}
@@ -242,6 +251,7 @@ linear-gradient(
242251
center,
243252
${theme.eui.euiColorLightShade}`,
244253
backgroundSize: `${theme.eui.euiSizeL} ${theme.eui.euiSizeL}`,
254+
cursor: `${status === FETCH_STATUS.LOADING ? 'wait' : 'grab'}`,
245255
margin: `-${theme.eui.gutterTypes.gutterLarge}`,
246256
marginTop: 0,
247257
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { callApmApi } from '../../../services/rest/createCallApmApi';
1919
import { LicensePrompt } from '../../shared/LicensePrompt';
2020
import { Controls } from './Controls';
2121
import { Cytoscape } from './Cytoscape';
22-
import { getCytoscapeDivStyle } from './cytoscapeOptions';
22+
import { getCytoscapeDivStyle } from './cytoscape_options';
2323
import { EmptyBanner } from './EmptyBanner';
2424
import { EmptyPrompt } from './empty_prompt';
2525
import { Popover } from './Popover';
@@ -121,7 +121,7 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
121121
elements={data.elements}
122122
height={height}
123123
serviceName={serviceName}
124-
style={getCytoscapeDivStyle(theme)}
124+
style={getCytoscapeDivStyle(theme, status)}
125125
>
126126
<Controls />
127127
{serviceName && <EmptyBanner />}

0 commit comments

Comments
 (0)