Skip to content

Commit

Permalink
Set service map cursors (#80920)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
smith authored Oct 19, 2020
1 parent f4c596d commit dd33002
Show file tree
Hide file tree
Showing 9 changed files with 362 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useUrlParams } from '../../../hooks/useUrlParams';
import { getAPMHref } from '../../shared/Links/apm/APMLink';
import { APMQueryParams } from '../../shared/Links/url_helpers';
import { CytoscapeContext } from './Cytoscape';
import { getAnimationOptions, getNodeHeight } from './cytoscapeOptions';
import { getAnimationOptions, getNodeHeight } from './cytoscape_options';

const ControlsContainer = styled('div')`
left: ${({ theme }) => theme.eui.gutterTypes.gutterMedium};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import React, {
useState,
} from 'react';
import { useTheme } from '../../../hooks/useTheme';
import { getCytoscapeOptions } from './cytoscapeOptions';
import { getCytoscapeOptions } from './cytoscape_options';
import { useCytoscapeEventHandlers } from './use_cytoscape_event_handlers';

cytoscape.use(dagre);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useTheme } from '../../../../hooks/useTheme';
import { fontSize, px } from '../../../../style/variables';
import { asInteger, asDuration } from '../../../../../common/utils/formatters';
import { MLJobLink } from '../../../shared/Links/MachineLearningLinks/MLJobLink';
import { popoverWidth } from '../cytoscapeOptions';
import { popoverWidth } from '../cytoscape_options';
import { TRANSACTION_REQUEST } from '../../../../../common/transaction_types';
import {
getSeverity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import React, { MouseEvent } from 'react';
import { Buttons } from './Buttons';
import { Info } from './Info';
import { ServiceStatsFetcher } from './ServiceStatsFetcher';
import { popoverWidth } from '../cytoscapeOptions';
import { popoverWidth } from '../cytoscape_options';

interface ContentsProps {
isService: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import cytoscape from 'cytoscape';
import { useTheme } from '../../../../hooks/useTheme';
import { SERVICE_NAME } from '../../../../../common/elasticsearch_fieldnames';
import { CytoscapeContext } from '../Cytoscape';
import { getAnimationOptions } from '../cytoscapeOptions';
import { getAnimationOptions } from '../cytoscape_options';
import { Contents } from './Contents';

interface PopoverProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
*/
import cytoscape from 'cytoscape';
import { CSSProperties } from 'react';
import {
getServiceHealthStatusColor,
ServiceHealthStatus,
} from '../../../../common/service_health_status';
import { EuiTheme } from '../../../../../observability/public';
import { ServiceAnomalyStats } from '../../../../common/anomaly_detection';
import {
SERVICE_NAME,
SPAN_DESTINATION_SERVICE_RESOURCE,
} from '../../../../common/elasticsearch_fieldnames';
import { EuiTheme } from '../../../../../observability/public';
import {
getServiceHealthStatusColor,
ServiceHealthStatus,
} from '../../../../common/service_health_status';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
import { defaultIcon, iconForNode } from './icons';
import { ServiceAnomalyStats } from '../../../../common/anomaly_detection';

export const popoverWidth = 280;

Expand Down Expand Up @@ -104,6 +105,11 @@ function isService(el: cytoscape.NodeSingular) {
const getStyle = (theme: EuiTheme): cytoscape.Stylesheet[] => {
const lineColor = theme.eui.euiColorMediumShade;
return [
{
selector: 'core',
// @ts-expect-error DefinitelyTyped does not recognize 'active-bg-opacity'
style: { 'active-bg-opacity': 0 },
},
{
selector: 'node',
style: {
Expand Down Expand Up @@ -226,7 +232,10 @@ const getStyle = (theme: EuiTheme): cytoscape.Stylesheet[] => {

// The CSS styles for the div containing the cytoscape element. Makes a
// background grid of dots.
export const getCytoscapeDivStyle = (theme: EuiTheme): CSSProperties => ({
export const getCytoscapeDivStyle = (
theme: EuiTheme,
status: FETCH_STATUS
): CSSProperties => ({
background: `linear-gradient(
90deg,
${theme.eui.euiPageBackgroundColor}
Expand All @@ -242,6 +251,7 @@ linear-gradient(
center,
${theme.eui.euiColorLightShade}`,
backgroundSize: `${theme.eui.euiSizeL} ${theme.eui.euiSizeL}`,
cursor: `${status === FETCH_STATUS.LOADING ? 'wait' : 'grab'}`,
margin: `-${theme.eui.gutterTypes.gutterLarge}`,
marginTop: 0,
});
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { callApmApi } from '../../../services/rest/createCallApmApi';
import { LicensePrompt } from '../../shared/LicensePrompt';
import { Controls } from './Controls';
import { Cytoscape } from './Cytoscape';
import { getCytoscapeDivStyle } from './cytoscapeOptions';
import { getCytoscapeDivStyle } from './cytoscape_options';
import { EmptyBanner } from './EmptyBanner';
import { EmptyPrompt } from './empty_prompt';
import { Popover } from './Popover';
Expand Down Expand Up @@ -121,7 +121,7 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
elements={data.elements}
height={height}
serviceName={serviceName}
style={getCytoscapeDivStyle(theme)}
style={getCytoscapeDivStyle(theme, status)}
>
<Controls />
{serviceName && <EmptyBanner />}
Expand Down
Loading

0 comments on commit dd33002

Please sign in to comment.