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

Optimize selectors for DOM operation to reduce possible version compatibility issue #244

Merged
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
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