Skip to content

Commit

Permalink
Closes 59786 by removing the update toast (#60172)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
ogupte and elasticmachine authored Mar 17, 2020
1 parent 466da68 commit 59551e7
Showing 1 changed file with 2 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiButton } from '@elastic/eui';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import { i18n } from '@kbn/i18n';
import { ElementDefinition } from 'cytoscape';
Expand All @@ -16,7 +15,6 @@ import React, {
useRef,
useState
} from 'react';
import { toMountPoint } from '../../../../../../../../src/plugins/kibana_react/public';
import { isValidPlatinumLicense } from '../../../../../../../plugins/apm/common/service_map';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ServiceMapAPIResponse } from '../../../../../../../plugins/apm/server/lib/service_map/get_service_map';
Expand Down Expand Up @@ -78,7 +76,6 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
});

const renderedElements = useRef<ElementDefinition[]>([]);
const openToast = useRef<string | null>(null);

const [responses, setResponses] = useState<ServiceMapAPIResponse[]>([]);

Expand Down Expand Up @@ -160,41 +157,11 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
return !find(renderedElements.current, el => isEqual(el, element));
});

const updateMap = () => {
if (newElements.length > 0 && renderedElements.current.length > 0) {
renderedElements.current = elements;
if (openToast.current) {
notifications.toasts.remove(openToast.current);
}
forceUpdate();
};

if (newElements.length > 0 && renderedElements.current.length > 0) {
openToast.current = notifications.toasts.add({
title: i18n.translate('xpack.apm.newServiceMapData', {
defaultMessage: `Newly discovered connections are available.`
}),
onClose: () => {
openToast.current = null;
},
toastLifeTimeMs: 24 * 60 * 60 * 1000,
text: toMountPoint(
<EuiButton onClick={updateMap}>
{i18n.translate('xpack.apm.updateServiceMap', {
defaultMessage: 'Update map'
})}
</EuiButton>
)
}).id;
}

return () => {
if (openToast.current) {
notifications.toasts.remove(openToast.current);
}
};

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [elements]);
}, [elements, forceUpdate]);

const { ref: wrapperRef, width, height } = useRefDimensions();

Expand Down

0 comments on commit 59551e7

Please sign in to comment.