Skip to content

Commit

Permalink
fixup! support reporting for new discover
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuali925 committed Sep 15, 2023
1 parent ce029eb commit 11b8fb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 9 additions & 4 deletions public/components/context_menu/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const generateInContextReport = async (
reportSource = 'Dashboard';
} else if (/\/app\/visualize/.test(baseUrl)) {
reportSource = 'Visualization';
} else if (/\/app\/discover/.test(baseUrl)) {
} else if (/\/app\/(discover|data-explorer)/.test(baseUrl)) {
reportSource = 'Saved search';
}

Expand Down Expand Up @@ -87,7 +87,7 @@ const generateInContextReport = async (
};

fetch(
`../api/reporting/generateReport?${new URLSearchParams(
`${getApiPath()}/reporting/generateReport?${new URLSearchParams(
uiSettingsService.getSearchParams()
)}`,
{
Expand Down Expand Up @@ -254,7 +254,7 @@ const checkURLParams = async () => {

const isDiscoverNavMenu = (navMenu) => {
return (
navMenu[0].children.length === 5 &&
navMenu[0].children.length === 6 &&
($('[data-test-subj="breadcrumb first"]').prop('title') === 'Discover' ||
$('[data-test-subj="breadcrumb first last"]').prop('title') ===
'Discover')
Expand Down Expand Up @@ -335,8 +335,13 @@ window.onpopstate = history.onpushstate = () => {
locationHashChanged();
};

const getApiPath = () => {
if (window.location.href.includes('/data-explorer/discover')) return '../../api'
return '../api'
}

async function getTenantInfoIfExists() {
const res = await fetch(`../api/v1/multitenancy/tenant`, {
const res = await fetch(`${getApiPath()}/v1/multitenancy/tenant`, {
headers: {
'Content-Type': 'application/json',
'osd-xsrf': 'reporting',
Expand Down
4 changes: 4 additions & 0 deletions server/utils/__tests__/validationHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ describe('test input validation', () => {
'/app/data-explorer/discover/#/view/571aaf70-4c88-11e8-b3d7-01146121b73d',
true,
],
[
'/app/data-explorer/discover?security_tenant=private#/view/571aaf70-4c88-11e8-b3d7-01146121b73d',
true,
],
[
'/app/discoverLegacy#/view/571aaf70-4c88-11e8-b3d7-01146121b73d',
true,
Expand Down
2 changes: 1 addition & 1 deletion server/utils/validationHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const isValidRelativeUrl = (relativeUrl: string) => {
export const regexDuration = /^(-?)P(?=\d|T\d)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)([DW]))?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;
export const regexEmailAddress = /\S+@\S+\.\S+/;
export const regexReportName = /^[\w\-\s\(\)\[\]\,\_\-+]+$/;
export const regexRelativeUrl = /^\/(_plugin\/kibana\/|_dashboards\/)?app\/(dashboards|visualize|discover|discoverLegacy|data-explorer\/discover\/|observability-dashboards|observability-notebooks|notebooks-dashboards\?view=output_only(&security_tenant=.+)?)(\?security_tenant=.+)?#\/(notebooks\/|view\/|edit\/)?[^\/]+$/;
export const regexRelativeUrl = /^\/(_plugin\/kibana\/|_dashboards\/)?app\/(dashboards|visualize|discover|discoverLegacy|data-explorer\/discover\/?|observability-dashboards|observability-notebooks|notebooks-dashboards\?view=output_only(&security_tenant=.+)?)(\?security_tenant=.+)?#\/(notebooks\/|view\/|edit\/)?[^\/]+$/;

export const validateReport = async (
client: ILegacyScopedClusterClient,
Expand Down

0 comments on commit 11b8fb2

Please sign in to comment.