Skip to content

Commit

Permalink
Fixes to service map single node banner
Browse files Browse the repository at this point in the history
* Make the banner 95% width so it takes up the full width
* Check the actual count of cytoscape nodes to determine whether or not to show the banner
* Make the Cytoscape component able to take a function as children so we can access the cytoscape instance directly
* Update the .NET icon
  • Loading branch information
smith committed Mar 12, 2020
1 parent d46f848 commit 86b94b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
* you may not use this file except in compliance with the Elastic License.
*/

import cytoscape from 'cytoscape';
import React, {
createContext,
CSSProperties,
useState,
useRef,
useEffect,
ReactNode,
createContext,
useCallback
useCallback,
useEffect,
useRef,
useState
} from 'react';
import cytoscape from 'cytoscape';
import { isRumAgentName } from '../../../../../../../plugins/apm/common/agent_name';
import {
animationOptions,
cytoscapeOptions,
nodeHeight,
animationOptions
nodeHeight
} from './cytoscapeOptions';

export const CytoscapeContext = createContext<cytoscape.Core | undefined>(
undefined
);

interface CytoscapeProps {
children?: ReactNode;
children?: (cy?: cytoscape.Core) => ReactNode | ReactNode;
elements: cytoscape.ElementDefinition[];
height: number;
width: number;
Expand Down Expand Up @@ -175,7 +175,7 @@ export function Cytoscape({
return (
<CytoscapeContext.Provider value={cy}>
<div ref={ref} style={divStyle}>
{children}
{typeof children === 'function' ? children(cy) : children}
</div>
</CytoscapeContext.Provider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const EmptyBannerCallOut = styled(EuiCallOut)`
${lightTheme.gutterTypes.gutterExtraLarge}
);
position: absolute;
width: 95%;
z-index: 1;
`;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
if (!license) {
return null;
}

console.log({ elements, renderedElements: renderedElements.current });
return isValidPlatinumLicense(license) ? (
<div
style={{ height: height - parseInt(theme.gutterTypes.gutterLarge, 10) }}
Expand All @@ -214,11 +214,15 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
width={width}
style={cytoscapeDivStyle}
>
<Controls />
{serviceName && renderedElements.current.length === 1 && (
<EmptyBanner />
)}
<Popover focusedServiceName={serviceName} />
{cy => {
return (
<>
<Controls />
{serviceName && cy?.nodes().length === 1 && <EmptyBanner />}
<Popover focusedServiceName={serviceName} />
</>
);
}}
</Cytoscape>
</div>
) : (
Expand Down

0 comments on commit 86b94b3

Please sign in to comment.