-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Reporting/Dashboard] Update integration to use v2 reports #108553
Changes from 20 commits
40ab51f
56985bd
47ec77a
1cb0766
adee42b
3a93a16
9eacc30
06ef623
6cd42ba
99b7479
db13ecd
7c4260c
27d86a7
c9d09e7
8261f76
a002d5c
6116fc3
f69d78f
e3e7f7e
9d97c06
566851e
d302131
84cbc7b
c3a8f4f
4f2b82d
2ad676a
cb39ce9
30978d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,9 @@ import { | |
DashboardRedirect, | ||
DashboardState, | ||
} from '../../types'; | ||
import { DashboardAppLocatorParams } from '../../locator'; | ||
import { | ||
loadDashboardHistoryLocationState, | ||
tryDestroyDashboardContainer, | ||
syncDashboardContainerInput, | ||
savedObjectToDashboardState, | ||
|
@@ -88,6 +90,7 @@ export const useDashboardAppState = ({ | |
savedObjectsTagging, | ||
dashboardCapabilities, | ||
dashboardSessionStorage, | ||
scopedHistory, | ||
} = services; | ||
const { docTitle } = chrome; | ||
const { notifications } = core; | ||
|
@@ -149,10 +152,15 @@ export const useDashboardAppState = ({ | |
*/ | ||
const dashboardSessionStorageState = dashboardSessionStorage.getState(savedDashboardId) || {}; | ||
const dashboardURLState = loadDashboardUrlState(dashboardBuildContext); | ||
const forwardedAppState = loadDashboardHistoryLocationState( | ||
scopedHistory()?.location?.state as undefined | DashboardAppLocatorParams | ||
); | ||
|
||
const initialDashboardState = { | ||
...savedDashboardState, | ||
...dashboardSessionStorageState, | ||
...dashboardURLState, | ||
...forwardedAppState, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we add the state from |
||
|
||
// if there is an incoming embeddable, dashboard always needs to be in edit mode to receive it. | ||
...(incomingEmbeddable ? { viewMode: ViewMode.EDIT } : {}), | ||
|
@@ -312,6 +320,7 @@ export const useDashboardAppState = ({ | |
getStateTransfer, | ||
savedDashboards, | ||
usageCollection, | ||
scopedHistory, | ||
notifications, | ||
indexPatterns, | ||
kibanaVersion, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { convertSavedDashboardPanelToPanelState } from '../../../common/embeddable/embeddable_saved_object_converters'; | ||
import { ForwardedDashboardState } from '../../locator'; | ||
import { DashboardPanelMap, DashboardState } from '../../types'; | ||
|
||
export const loadDashboardHistoryLocationState = ( | ||
state?: ForwardedDashboardState | ||
): Partial<DashboardState> => { | ||
if (!state) { | ||
return {}; | ||
} | ||
|
||
const { panels, ...restOfState } = state; | ||
if (!panels?.length) { | ||
return restOfState; | ||
} | ||
|
||
const panelsMap: DashboardPanelMap = {}; | ||
panels!.forEach((panel, idx) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very similar to the code in I wonder if we should have a common method for |
||
panelsMap![panel.panelIndex ?? String(idx)] = convertSavedDashboardPanelToPanelState(panel); | ||
}); | ||
|
||
return { | ||
...restOfState, | ||
...{ panels: panelsMap }, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -6,16 +6,20 @@ | |||
* Side Public License, v 1. | ||||
*/ | ||||
|
||||
import { Capabilities } from 'src/core/public'; | ||||
import { EuiCheckboxGroup } from '@elastic/eui'; | ||||
import React from 'react'; | ||||
import { ReactElement, useState } from 'react'; | ||||
import { i18n } from '@kbn/i18n'; | ||||
import moment from 'moment'; | ||||
import React, { ReactElement, useState } from 'react'; | ||||
import type { Capabilities } from 'src/core/public'; | ||||
import { DashboardSavedObject } from '../..'; | ||||
import { shareModalStrings } from '../../dashboard_strings'; | ||||
import { DashboardAppLocatorParams, DASHBOARD_APP_LOCATOR } from '../../locator'; | ||||
import { TimeRange } from '../../services/data'; | ||||
import { ViewMode } from '../../services/embeddable'; | ||||
import { setStateToKbnUrl, unhashUrl } from '../../services/kibana_utils'; | ||||
import { SharePluginStart } from '../../services/share'; | ||||
import { dashboardUrlParams } from '../dashboard_router'; | ||||
import { shareModalStrings } from '../../dashboard_strings'; | ||||
import { DashboardAppCapabilities, DashboardState } from '../../types'; | ||||
import { dashboardUrlParams } from '../dashboard_router'; | ||||
import { stateToRawDashboardState } from '../lib/convert_dashboard_state'; | ||||
|
||||
const showFilterBarId = 'showFilterBar'; | ||||
|
@@ -28,6 +32,7 @@ interface ShowShareModalProps { | |||
savedDashboard: DashboardSavedObject; | ||||
currentDashboardState: DashboardState; | ||||
dashboardCapabilities: DashboardAppCapabilities; | ||||
timeRange: TimeRange; | ||||
} | ||||
|
||||
export const showPublicUrlSwitch = (anonymousUserCapabilities: Capabilities) => { | ||||
|
@@ -46,6 +51,7 @@ export function ShowShareModal({ | |||
savedDashboard, | ||||
dashboardCapabilities, | ||||
currentDashboardState, | ||||
timeRange, | ||||
}: ShowShareModalProps) { | ||||
const EmbedUrlParamExtension = ({ | ||||
setParamValue, | ||||
|
@@ -104,21 +110,49 @@ export function ShowShareModal({ | |||
); | ||||
}; | ||||
|
||||
const rawDashboardState = stateToRawDashboardState({ | ||||
state: currentDashboardState, | ||||
version: kibanaVersion, | ||||
}); | ||||
|
||||
const locatorParams: DashboardAppLocatorParams = { | ||||
dashboardId: savedDashboard.id, | ||||
filters: rawDashboardState.filters, | ||||
preserveSavedFilters: true, | ||||
query: rawDashboardState.query, | ||||
savedQuery: rawDashboardState.savedQuery, | ||||
useHash: false, | ||||
panels: rawDashboardState.panels, | ||||
timeRange, | ||||
viewMode: ViewMode.VIEW, // For share locators we always load the dashboard in view mode | ||||
refreshInterval: undefined, // We don't share refresh interval externally | ||||
}; | ||||
|
||||
share.toggleShareContextMenu({ | ||||
isDirty, | ||||
anchorElement, | ||||
allowEmbed: true, | ||||
allowShortUrl: dashboardCapabilities.createShortUrl, | ||||
shareableUrl: setStateToKbnUrl( | ||||
'_a', | ||||
stateToRawDashboardState({ state: currentDashboardState, version: kibanaVersion }), | ||||
rawDashboardState, | ||||
{ useHash: false, storeInHashQuery: true }, | ||||
unhashUrl(window.location.href) | ||||
), | ||||
objectId: savedDashboard.id, | ||||
objectType: 'dashboard', | ||||
sharingData: { | ||||
title: savedDashboard.title, | ||||
title: | ||||
savedDashboard.title || | ||||
i18n.translate('dashboard.share.defaultDashboardTitle', { | ||||
defaultMessage: 'Dashboard [{date}]', | ||||
values: { date: moment().toISOString(true) }, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this date string need to be converted to the user's timezone and formatted per the time format in Advanced Settings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whether we issue a request for v1 or v2 reports depends on the I decided to keep it this way because I was not sure whether other parts of Kibana (like Canvas and visualize) still depend on v1 report types based on the params they pass in. Once they've all been updated we should remove this funcitonality - and probably send out a message that Reports now requires locators. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this date string need to be converted to the user's timezone and formatted per the time format in Advanced Settings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a great point @tsullivan ! Do you mind if I address this in a follow up PR as I did this same thing in discover kibana/src/plugins/discover/public/application/apps/main/components/top_nav/get_top_nav_links.ts Line 129 in f0bf877
|
||||
}), | ||||
locatorParams: { | ||||
id: DASHBOARD_APP_LOCATOR, | ||||
version: kibanaVersion, | ||||
params: locatorParams, | ||||
}, | ||||
}, | ||||
embedUrlParamExtensions: [ | ||||
{ | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done to address issues with emebedding this type inside of a
SerializableRecord
type. There are issues with index types not being present ininterface
definitions, these are not an issue withtype
definitions as they are more permissive (it seems). Otherwise we run into what I think is: microsoft/TypeScript#1889