in dashboards-reports/public/components/context_menu/context_menu.js [247:284]
function locationHashChanged() {
const observer = new MutationObserver(function (mutations) {
const navMenu = document.querySelectorAll(
'span.osdTopNavMenu__wrapper > nav.euiHeaderLinks > div.euiHeaderLinks__list'
);
if (
navMenu &&
navMenu.length &&
(isDiscoverNavMenu(navMenu) ||
isDashboardNavMenu(navMenu) ||
isVisualizationNavMenu(navMenu))
) {
try {
if ($('#downloadReport').length) {
return;
}
const menuItem = document.createElement('div');
menuItem.innerHTML = getMenuItem(
i18n.translate('opensearch.reports.menu.name', {
defaultMessage: 'Reporting',
})
);
navMenu[0].insertBefore(menuItem.children[0], navMenu[0].lastChild);
} catch (e) {
console.log(e);
} finally {
observer.disconnect();
}
}
});
// Start observing
observer.observe(document.body, {
//document.body is node target to observe
childList: true, //This is a must have for the observer with subtree
subtree: true, //Set to true if changes must also be observed in descendants.
});
}