From 82c6850f22dc4579bf06239f2fc79028e94eff9b Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 10:07:25 -0700 Subject: [PATCH] Fix reporting discover (#190) (#192) (cherry picked from commit 2d643cc4ee10e2d6ccc16b3317ae4ab5859c20bf) Signed-off-by: Derek Ho Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- public/components/context_menu/context_menu.js | 1 + public/components/context_menu/context_menu_helpers.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/public/components/context_menu/context_menu.js b/public/components/context_menu/context_menu.js index 36cc142f..f587ab6e 100644 --- a/public/components/context_menu/context_menu.js +++ b/public/components/context_menu/context_menu.js @@ -336,6 +336,7 @@ window.onpopstate = history.onpushstate = () => { }; const getApiPath = () => { + if (window.location.href.includes('/data-explorer/discover/')) return '../../../api' if (window.location.href.includes('/data-explorer/discover')) return '../../api' return '../api' } diff --git a/public/components/context_menu/context_menu_helpers.js b/public/components/context_menu/context_menu_helpers.js index 3ebe5d76..1a1e9959 100644 --- a/public/components/context_menu/context_menu_helpers.js +++ b/public/components/context_menu/context_menu_helpers.js @@ -26,7 +26,7 @@ export const contextMenuViewReports = () => export const getTimeFieldsFromUrl = () => { const url = unhashUrl(window.location.href); - let [, fromDateString, toDateString] = url.match(timeRangeMatcher); + let [, fromDateString, toDateString] = url.match(timeRangeMatcher) ?? ["", "now-15m", "now"]; fromDateString = decodeURIComponent(fromDateString.replace(/[']+/g, '')); // convert time range to from date format in case time range is relative const fromDateFormat = dateMath.parse(fromDateString);