-
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
[Lens] Duplicated datatable available as inspector data for Heatmap chart #126786
Changes from 6 commits
dcd108a
94cb3b6
cf4cb83
2f8ce6f
36a4e91
4b82de8
ed6967f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { TablesAdapter } from '../../../../../src/plugins/expressions'; | ||
import type { Datatable } from '../../../../../src/plugins/expressions'; | ||
|
||
export const logDataTable = ( | ||
tableAdapter: TablesAdapter, | ||
datatables: Record<string, Datatable> = {} | ||
) => { | ||
Object.entries(datatables).forEach(([key, table]) => tableAdapter.logDatatable(key, table)); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ import { | |
getUnknownVisualizationTypeError, | ||
} from '../../error_helper'; | ||
import { getMissingIndexPattern, validateDatasourceAndVisualization } from '../state_helpers'; | ||
import { DefaultInspectorAdapters } from '../../../../../../../src/plugins/expressions/common'; | ||
import type { DefaultInspectorAdapters } from '../../../../../../../src/plugins/expressions/common'; | ||
import { | ||
onActiveDataChange, | ||
useLensDispatch, | ||
|
@@ -68,10 +68,12 @@ import { | |
selectSearchSessionId, | ||
selectAutoApplyEnabled, | ||
selectTriggerApplyChanges, | ||
selectDatasourceLayers, | ||
} from '../../../state_management'; | ||
import type { LensInspector } from '../../../lens_inspector_service'; | ||
import { inferTimeField } from '../../../utils'; | ||
import { setChangesApplied } from '../../../state_management/lens_slice'; | ||
import type { Datatable } from '../../../../../../../src/plugins/expressions/public'; | ||
|
||
export interface WorkspacePanelProps { | ||
visualizationMap: VisualizationMap; | ||
|
@@ -381,6 +383,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ | |
if (localState.expressionToRender === null) { | ||
return renderEmptyWorkspace(); | ||
} | ||
|
||
return ( | ||
<VisualizationWrapper | ||
expression={localState.expressionToRender} | ||
|
@@ -391,6 +394,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ | |
localState={{ ...localState, configurationValidationError, missingRefsErrors }} | ||
ExpressionRendererComponent={ExpressionRendererComponent} | ||
application={core.application} | ||
datasourceMap={datasourceMap} | ||
activeDatasourceId={activeDatasourceId} | ||
/> | ||
); | ||
|
@@ -455,6 +459,7 @@ export const VisualizationWrapper = ({ | |
ExpressionRendererComponent, | ||
application, | ||
activeDatasourceId, | ||
datasourceMap, | ||
}: { | ||
expression: string | null | undefined; | ||
framePublicAPI: FramePublicAPI; | ||
|
@@ -473,6 +478,7 @@ export const VisualizationWrapper = ({ | |
ExpressionRendererComponent: ReactExpressionRendererType; | ||
application: ApplicationStart; | ||
activeDatasourceId: string | null; | ||
datasourceMap: DatasourceMap; | ||
}) => { | ||
const context = useLensSelector(selectExecutionContext); | ||
const searchContext: ExecutionContextSearch = useMemo( | ||
|
@@ -487,16 +493,27 @@ export const VisualizationWrapper = ({ | |
[context] | ||
); | ||
const searchSessionId = useLensSelector(selectSearchSessionId); | ||
|
||
const datasourceLayers = useLensSelector((state) => selectDatasourceLayers(state, datasourceMap)); | ||
const dispatchLens = useLensDispatch(); | ||
|
||
const onData$ = useCallback( | ||
(data: unknown, adapters?: Partial<DefaultInspectorAdapters>) => { | ||
if (adapters && adapters.tables) { | ||
dispatchLens(onActiveDataChange({ ...adapters.tables.tables })); | ||
const [defaultLayerId] = Object.keys(datasourceLayers); | ||
|
||
dispatchLens( | ||
onActiveDataChange( | ||
Object.entries(adapters.tables?.tables).reduce<Record<string, Datatable>>( | ||
(acc, [key, value], index, tables) => ({ | ||
[tables.length === 1 ? defaultLayerId : key]: value, | ||
}), | ||
{} | ||
) | ||
) | ||
); | ||
} | ||
}, | ||
[dispatchLens] | ||
[datasourceLayers, dispatchLens] | ||
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 will cause a lot of re-evaluations of this callback as |
||
); | ||
|
||
function renderFixAction( | ||
|
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.
Note to @andrewctate We need to do something similar on your PR which brings "show underlying data" to the dashboard as a panel action - otherwise it won't have the required active data around in all cases