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

Commit

Permalink
Optimize selectors for DOM operation to reduce possible version compa…
Browse files Browse the repository at this point in the history
…tibility issue (#244)
  • Loading branch information
zhongnansu committed Dec 10, 2020
1 parent 8ff39ca commit 00c14ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion kibana-reports/server/routes/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export enum DELIVERY_TYPE {
export enum SELECTOR {
dashboard = '#dashboardViewport',
visualization = '.visEditor__content',
topNavBar = '#globalHeaderBars',
}

// https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-from-size.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const createVisualReport = async (
report_format: reportFormat,
} = coreParams;

// TODO: polish default header, maybe add a logo, depends on UX design
const window = new JSDOM('').window;
const DOMPurify = createDOMPurify(window);

Expand Down Expand Up @@ -93,16 +92,17 @@ export const createVisualReport = async (
// remove top nav bar
await page.evaluate(
/* istanbul ignore next */
(selector) => {
document.querySelector(selector)?.remove();
() => {
// remove buttons
document
.querySelectorAll("[class^='euiButton']")
.forEach((e) => e.remove());
document.querySelector(
'.coreSystemRootDomElement.euiBody--headerIsFixed'
).style.paddingTop = '0px';
},
SELECTOR.topNavBar
// remove top navBar
document
.querySelectorAll("[class^='euiHeader']")
.forEach((e) => e.remove());
document.body.style.paddingTop = '0px';
}
);
// force wait for any resize to load after the above DOM modification
await page.waitFor(1000);
Expand Down

0 comments on commit 00c14ec

Please sign in to comment.