44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import { EuiButton } from '@elastic/eui' ;
87import theme from '@elastic/eui/dist/eui_theme_light.json' ;
98import { i18n } from '@kbn/i18n' ;
109import { ElementDefinition } from 'cytoscape' ;
@@ -16,7 +15,6 @@ import React, {
1615 useRef ,
1716 useState
1817} from 'react' ;
19- import { toMountPoint } from '../../../../../../../../src/plugins/kibana_react/public' ;
2018import { isValidPlatinumLicense } from '../../../../../../../plugins/apm/common/service_map' ;
2119// eslint-disable-next-line @kbn/eslint/no-restricted-paths
2220import { ServiceMapAPIResponse } from '../../../../../../../plugins/apm/server/lib/service_map/get_service_map' ;
@@ -78,7 +76,6 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
7876 } ) ;
7977
8078 const renderedElements = useRef < ElementDefinition [ ] > ( [ ] ) ;
81- const openToast = useRef < string | null > ( null ) ;
8279
8380 const [ responses , setResponses ] = useState < ServiceMapAPIResponse [ ] > ( [ ] ) ;
8481
@@ -160,41 +157,11 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
160157 return ! find ( renderedElements . current , el => isEqual ( el , element ) ) ;
161158 } ) ;
162159
163- const updateMap = ( ) => {
160+ if ( newElements . length > 0 && renderedElements . current . length > 0 ) {
164161 renderedElements . current = elements ;
165- if ( openToast . current ) {
166- notifications . toasts . remove ( openToast . current ) ;
167- }
168162 forceUpdate ( ) ;
169- } ;
170-
171- if ( newElements . length > 0 && renderedElements . current . length > 0 ) {
172- openToast . current = notifications . toasts . add ( {
173- title : i18n . translate ( 'xpack.apm.newServiceMapData' , {
174- defaultMessage : `Newly discovered connections are available.`
175- } ) ,
176- onClose : ( ) => {
177- openToast . current = null ;
178- } ,
179- toastLifeTimeMs : 24 * 60 * 60 * 1000 ,
180- text : toMountPoint (
181- < EuiButton onClick = { updateMap } >
182- { i18n . translate ( 'xpack.apm.updateServiceMap' , {
183- defaultMessage : 'Update map'
184- } ) }
185- </ EuiButton >
186- )
187- } ) . id ;
188163 }
189-
190- return ( ) => {
191- if ( openToast . current ) {
192- notifications . toasts . remove ( openToast . current ) ;
193- }
194- } ;
195-
196- // eslint-disable-next-line react-hooks/exhaustive-deps
197- } , [ elements ] ) ;
164+ } , [ elements , forceUpdate ] ) ;
198165
199166 const { ref : wrapperRef , width, height } = useRefDimensions ( ) ;
200167
0 commit comments