From 672fbc31a1ee0f385f3623df016a667d71ac7346 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 30 Jan 2020 13:31:04 -0600 Subject: [PATCH] [APM] Service map center button Add center button for service map. The fullscreen button is still there until #56351 is merged. Add fit and padding to the layout animation. Make the node labels wider so they aren't cut off. --- .../components/app/ServiceMap/Controls.tsx | 28 +++++++++++++++++-- .../app/ServiceMap/cytoscapeOptions.ts | 18 +++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx index 5b7ddc2b450d60..07ea97f442b7fa 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx @@ -4,12 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useContext, useState, useEffect } from 'react'; import { EuiButtonIcon, EuiPanel } from '@elastic/eui'; import theme from '@elastic/eui/dist/eui_theme_light.json'; -import styled from 'styled-components'; import { i18n } from '@kbn/i18n'; +import React, { useContext, useEffect, useState } from 'react'; +import styled from 'styled-components'; import { CytoscapeContext } from './Cytoscape'; +import { animationOptions, nodeHeight } from './cytoscapeOptions'; import { FullscreenPanel } from './FullscreenPanel'; const ControlsContainer = styled('div')` @@ -58,6 +59,17 @@ export function Controls() { } }, [cy]); + function center() { + if (cy) { + const eles = cy.nodes(); + cy.animate({ + ...animationOptions, + center: { eles }, + fit: { eles, padding: nodeHeight } + }); + } + } + function zoomIn() { doZoom(cy, increment); } @@ -82,6 +94,9 @@ export function Controls() { const zoomOutLabel = i18n.translate('xpack.apm.serviceMap.zoomOut', { defaultMessage: 'Zoom out' }); + const centerLabel = i18n.translate('xpack.apm.serviceMap.center', { + defaultMessage: 'Center' + }); return ( @@ -103,6 +118,15 @@ export function Controls() { title={zoomOutLabel} /> + +