Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Backport Context Menu fix to 7.9.1 #300

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions kibana-reports/public/components/context_menu/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,34 @@ $(function () {
locationHashChanged();
});

const isDiscoverNavMenu = (navMenu) => {
return navMenu[0].children.length === 5 &&
($('[data-test-subj="breadcrumb first"]').prop('title') === 'Discover' ||
$('[data-test-subj="breadcrumb first last"]').prop('title') === 'Discover')
}

const isDashboardNavMenu = (navMenu) => {
return (navMenu[0].children.length === 4 || navMenu[0].children.length === 6) &&
($('[data-test-subj="breadcrumb first"]').prop('title') === 'Dashboard')
}

const isVisualizationNavMenu = (navMenu) => {
return navMenu[0].children.length === 3
&& ($('[data-test-subj="breadcrumb first"]').prop('title') === 'Visualize')
}



function locationHashChanged() {
const observer = new MutationObserver(function (mutations) {
const navMenu = document.querySelectorAll(
'span.kbnTopNavMenu__wrapper > div.euiFlexGroup'
);
if (navMenu && navMenu.length && navMenu[0].children.length > 1) {
if (navMenu && navMenu.length && (
isDiscoverNavMenu(navMenu) ||
isDashboardNavMenu(navMenu) ||
isVisualizationNavMenu(navMenu))
) {
try {
if ($('#downloadReport').length) {
return;
Expand Down Expand Up @@ -263,9 +285,9 @@ const getUuidFromUrl = () =>
);
const isDiscover = () => window.location.href.includes('discover');

window.onhashchange = function () {
$(window).one('hashchange', function( e ) {
locationHashChanged();
};
});
/**
* for navigating to tabs from Kibana sidebar, it uses history.pushState, which doesn't trigger onHashchange.
* https://stackoverflow.com/questions/4570093/how-to-get-notified-about-changes-of-the-history-via-history-pushstate/4585031
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const popoverMenuDiscover = (savedObjectAvailable) => {
</div>
<div data-focus-lock-disabled="disabled">
<div class="euiPanel euiPopover__panel euiPopover__panel--bottom euiPopover__panel-isOpen euiPopover__panel-withTitle" aria-live="assertive" role="dialog" aria-modal="true" aria-describedby="i199c7fc0-f92e-11ea-a40d-395bfe9dc89a" style="top: 97px; left: 255.583px; z-index: 2000;" id="reportPopover">
<div class="euiPopover__panelArrow euiPopover__panelArrow--bottom" style="left: 15.9417px; top: 0px;">
<div class="euiPopover__panelArrow euiPopover__panelArrow--bottom" style="left: 30.9417px; top: 0px;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? I didn't see this change in your PR to dev

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah- in 7.9.1 the Discover reporting menu was not lined up over the Reporting nav menu item, it's almost not under it at all.
Screen Shot 2021-01-11 at 9 27 54 AM

</div>
<div>
<div class="euiContextMenu" data-test-subj="shareContextMenu" style="height: ${popoverHeight}; width: 235px;">
Expand Down
370 changes: 185 additions & 185 deletions kibana-reports/target/public/.kbn-optimizer-cache

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions kibana-reports/target/public/0.plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion kibana-reports/target/public/0.plugin.js.map

Large diffs are not rendered by default.

81 changes: 46 additions & 35 deletions kibana-reports/target/public/opendistro_kibana_reports.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@
/******/ ({

/***/ "../../node_modules/css-loader/dist/cjs.js?!../../node_modules/postcss-loader/src/index.js?!../../node_modules/resolve-url-loader/index.js?!../../node_modules/sass-loader/dist/cjs.js?!./public/index.scss?v7dark":
/*!***********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-0-1!/Users/szhongna/Desktop/reporting/kibana/node_modules/postcss-loader/src??ref--6-oneOf-0-2!/Users/szhongna/Desktop/reporting/kibana/node_modules/resolve-url-loader??ref--6-oneOf-0-3!/Users/szhongna/Desktop/reporting/kibana/node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-0-4!./public/index.scss?v7dark ***!
\***********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/*!*******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-0-1!/Users/davidcui/kibana-master/kibana/node_modules/postcss-loader/src??ref--6-oneOf-0-2!/Users/davidcui/kibana-master/kibana/node_modules/resolve-url-loader??ref--6-oneOf-0-3!/Users/davidcui/kibana-master/kibana/node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-0-4!./public/index.scss?v7dark ***!
\*******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

Expand All @@ -220,9 +220,9 @@ module.exports = exports;
/***/ }),

/***/ "../../node_modules/css-loader/dist/cjs.js?!../../node_modules/postcss-loader/src/index.js?!../../node_modules/resolve-url-loader/index.js?!../../node_modules/sass-loader/dist/cjs.js?!./public/index.scss?v7light":
/*!************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-1-1!/Users/szhongna/Desktop/reporting/kibana/node_modules/postcss-loader/src??ref--6-oneOf-1-2!/Users/szhongna/Desktop/reporting/kibana/node_modules/resolve-url-loader??ref--6-oneOf-1-3!/Users/szhongna/Desktop/reporting/kibana/node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-1-4!./public/index.scss?v7light ***!
\************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/*!********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-1-1!/Users/davidcui/kibana-master/kibana/node_modules/postcss-loader/src??ref--6-oneOf-1-2!/Users/davidcui/kibana-master/kibana/node_modules/resolve-url-loader??ref--6-oneOf-1-3!/Users/davidcui/kibana-master/kibana/node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-1-4!./public/index.scss?v7light ***!
\********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

Expand All @@ -238,9 +238,9 @@ module.exports = exports;
/***/ }),

/***/ "../../node_modules/css-loader/dist/runtime/api.js":
/*!********************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/css-loader/dist/runtime/api.js ***!
\********************************************************************************************/
/*!****************************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/css-loader/dist/runtime/api.js ***!
\****************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

Expand Down Expand Up @@ -343,9 +343,9 @@ function toComment(sourceMap) {
/***/ }),

/***/ "../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
/*!*******************************************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
\*******************************************************************************************************************/
/*!***************************************************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
\***************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

Expand Down Expand Up @@ -623,9 +623,9 @@ module.exports = function (list, options) {
/***/ }),

/***/ "../../node_modules/uuid/lib/bytesToUuid.js":
/*!*************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/uuid/lib/bytesToUuid.js ***!
\*************************************************************************************/
/*!*********************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/uuid/lib/bytesToUuid.js ***!
\*********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {

Expand Down Expand Up @@ -658,9 +658,9 @@ module.exports = bytesToUuid;
/***/ }),

/***/ "../../node_modules/uuid/lib/rng-browser.js":
/*!*************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/uuid/lib/rng-browser.js ***!
\*************************************************************************************/
/*!*********************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/uuid/lib/rng-browser.js ***!
\*********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {

Expand Down Expand Up @@ -703,9 +703,9 @@ if (getRandomValues) {
/***/ }),

/***/ "../../node_modules/uuid/v4.js":
/*!************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/uuid/v4.js ***!
\************************************************************************/
/*!********************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/uuid/v4.js ***!
\********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

Expand Down Expand Up @@ -743,9 +743,9 @@ module.exports = v4;
/***/ }),

/***/ "../../node_modules/val-loader/dist/cjs.js?key=opendistro_kibana_reports!../../packages/kbn-ui-shared-deps/public_path_module_creator.js":
/*!*********************************************************************************************************************************************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/node_modules/val-loader/dist/cjs.js?key=opendistro_kibana_reports!/Users/szhongna/Desktop/reporting/kibana/packages/kbn-ui-shared-deps/public_path_module_creator.js ***!
\*********************************************************************************************************************************************************************************************************************/
/*!*************************************************************************************************************************************************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/node_modules/val-loader/dist/cjs.js?key=opendistro_kibana_reports!/Users/davidcui/kibana-master/kibana/packages/kbn-ui-shared-deps/public_path_module_creator.js ***!
\*************************************************************************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

Expand Down Expand Up @@ -785,9 +785,9 @@ module.exports = g;
/***/ }),

/***/ "../../packages/elastic-datemath/target/index.js":
/*!******************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/packages/elastic-datemath/target/index.js ***!
\******************************************************************************************/
/*!**************************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/packages/elastic-datemath/target/index.js ***!
\**************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

Expand Down Expand Up @@ -1039,9 +1039,9 @@ module.exports = exports.default;
/***/ }),

/***/ "../../packages/kbn-optimizer/target/worker/entry_point_creator.js":
/*!************************************************************************************************************!*\
!*** /Users/szhongna/Desktop/reporting/kibana/packages/kbn-optimizer/target/worker/entry_point_creator.js ***!
\************************************************************************************************************/
/*!********************************************************************************************************!*\
!*** /Users/davidcui/kibana-master/kibana/packages/kbn-optimizer/target/worker/entry_point_creator.js ***!
\********************************************************************************************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

Expand Down Expand Up @@ -12359,11 +12359,23 @@ jquery__WEBPACK_IMPORTED_MODULE_0___default()(function () {
locationHashChanged();
});

const isDiscoverNavMenu = navMenu => {
return navMenu[0].children.length === 5 && (jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-test-subj="breadcrumb first"]').prop('title') === 'Discover' || jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-test-subj="breadcrumb first last"]').prop('title') === 'Discover');
};

const isDashboardNavMenu = navMenu => {
return (navMenu[0].children.length === 4 || navMenu[0].children.length === 6) && jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-test-subj="breadcrumb first"]').prop('title') === 'Dashboard';
};

const isVisualizationNavMenu = navMenu => {
return navMenu[0].children.length === 3 && jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-test-subj="breadcrumb first"]').prop('title') === 'Visualize';
};

function locationHashChanged() {
const observer = new MutationObserver(function (mutations) {
const navMenu = document.querySelectorAll('span.kbnTopNavMenu__wrapper > div.euiFlexGroup');

if (navMenu && navMenu.length && navMenu[0].children.length > 1) {
if (navMenu && navMenu.length && (isDiscoverNavMenu(navMenu) || isDashboardNavMenu(navMenu) || isVisualizationNavMenu(navMenu))) {
try {
if (jquery__WEBPACK_IMPORTED_MODULE_0___default()('#downloadReport').length) {
return;
Expand Down Expand Up @@ -12394,15 +12406,14 @@ const getUuidFromUrl = () => window.location.href.match(/(\b[0-9a-f]{8}\b-[0-9a-

const isDiscover = () => window.location.href.includes('discover');

window.onhashchange = function () {
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).one('hashchange', function (e) {
locationHashChanged();
};
});
/**
* for navigating to tabs from Kibana sidebar, it uses history.pushState, which doesn't trigger onHashchange.
* https://stackoverflow.com/questions/4570093/how-to-get-notified-about-changes-of-the-history-via-history-pushstate/4585031
*/


(function (history) {
const pushState = history.pushState;

Expand Down Expand Up @@ -12698,7 +12709,7 @@ const popoverMenuDiscover = savedObjectAvailable => {
</div>
<div data-focus-lock-disabled="disabled">
<div class="euiPanel euiPopover__panel euiPopover__panel--bottom euiPopover__panel-isOpen euiPopover__panel-withTitle" aria-live="assertive" role="dialog" aria-modal="true" aria-describedby="i199c7fc0-f92e-11ea-a40d-395bfe9dc89a" style="top: 97px; left: 255.583px; z-index: 2000;" id="reportPopover">
<div class="euiPopover__panelArrow euiPopover__panelArrow--bottom" style="left: 15.9417px; top: 0px;">
<div class="euiPopover__panelArrow euiPopover__panelArrow--bottom" style="left: 30.9417px; top: 0px;">
</div>
<div>
<div class="euiContextMenu" data-test-subj="shareContextMenu" style="height: ${popoverHeight}; width: 235px;">
Expand Down

Large diffs are not rendered by default.