[v10.2.x] Explore: Fix support for angular based datasource editors (#77505)
Explore: Fix support for angular based datasource editors (#77486)
(cherry picked from commit 7737226786)
Co-authored-by: Giordano Ricci <me@giordanoricci.com>
This commit is contained in:
co-authored by
Giordano Ricci
parent
819a0c1c7e
commit
c32d98a530
@@ -1,7 +1,7 @@
|
||||
import { identity, isEmpty, isEqual, isObject, mapValues, omitBy } from 'lodash';
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
import { CoreApp, ExploreUrlState, DataSourceApi, toURLRange } from '@grafana/data';
|
||||
import { CoreApp, ExploreUrlState, DataSourceApi, toURLRange, EventBusSrv } from '@grafana/data';
|
||||
import { DataQuery, DataSourceRef } from '@grafana/schema';
|
||||
import { useGrafana } from 'app/core/context/GrafanaContext';
|
||||
import { clearQueryKeys, getLastUsedDatasourceUID } from 'app/core/utils/explore';
|
||||
@@ -142,6 +142,7 @@ export function useStateSync(params: ExploreQueryParams) {
|
||||
range: fromURLRange(range),
|
||||
panelsState,
|
||||
position: i,
|
||||
eventBridge: new EventBusSrv(),
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -209,6 +210,7 @@ export function useStateSync(params: ExploreQueryParams) {
|
||||
queries,
|
||||
range: fromURLRange(range),
|
||||
panelsState,
|
||||
eventBridge: new EventBusSrv(),
|
||||
})
|
||||
).unwrap();
|
||||
})
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
PreferredVisualisationType,
|
||||
RawTimeRange,
|
||||
ExploreCorrelationHelperData,
|
||||
EventBusExtended,
|
||||
} from '@grafana/data';
|
||||
import { DataQuery, DataSourceRef } from '@grafana/schema';
|
||||
import { getQueryKeys } from 'app/core/utils/explore';
|
||||
@@ -98,6 +99,7 @@ interface InitializeExplorePayload {
|
||||
range: TimeRange;
|
||||
history: HistoryItem[];
|
||||
datasourceInstance?: DataSourceApi;
|
||||
eventBridge: EventBusExtended;
|
||||
}
|
||||
const initializeExploreAction = createAction<InitializeExplorePayload>('explore/initializeExploreAction');
|
||||
|
||||
@@ -128,6 +130,7 @@ export interface InitializeExploreOptions {
|
||||
panelsState?: ExplorePanelsState;
|
||||
correlationHelperData?: ExploreCorrelationHelperData;
|
||||
position?: number;
|
||||
eventBridge: EventBusExtended;
|
||||
}
|
||||
/**
|
||||
* Initialize Explore state with state from the URL and the React component.
|
||||
@@ -140,7 +143,15 @@ export interface InitializeExploreOptions {
|
||||
export const initializeExplore = createAsyncThunk(
|
||||
'explore/initializeExplore',
|
||||
async (
|
||||
{ exploreId, datasource, queries, range, panelsState, correlationHelperData }: InitializeExploreOptions,
|
||||
{
|
||||
exploreId,
|
||||
datasource,
|
||||
queries,
|
||||
range,
|
||||
panelsState,
|
||||
correlationHelperData,
|
||||
eventBridge,
|
||||
}: InitializeExploreOptions,
|
||||
{ dispatch, getState, fulfillWithValue }
|
||||
) => {
|
||||
let instance = undefined;
|
||||
@@ -160,6 +171,7 @@ export const initializeExplore = createAsyncThunk(
|
||||
range: getRange(range, getTimeZone(getState().user)),
|
||||
datasourceInstance: instance,
|
||||
history,
|
||||
eventBridge,
|
||||
})
|
||||
);
|
||||
if (panelsState !== undefined) {
|
||||
@@ -244,13 +256,14 @@ export const paneReducer = (state: ExploreItemState = makeExplorePaneState(), ac
|
||||
}
|
||||
|
||||
if (initializeExploreAction.match(action)) {
|
||||
const { queries, range, datasourceInstance, history } = action.payload;
|
||||
const { queries, range, datasourceInstance, history, eventBridge } = action.payload;
|
||||
|
||||
return {
|
||||
...state,
|
||||
range,
|
||||
queries,
|
||||
initialized: true,
|
||||
eventBridge,
|
||||
queryKeys: getQueryKeys(queries),
|
||||
datasourceInstance,
|
||||
history,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
import { AnyAction } from 'redux';
|
||||
|
||||
import { SplitOpenOptions, TimeRange } from '@grafana/data';
|
||||
import { SplitOpenOptions, TimeRange, EventBusSrv } from '@grafana/data';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { generateExploreId, GetExploreUrlArguments } from 'app/core/utils/explore';
|
||||
import { PanelModel } from 'app/features/dashboard/state';
|
||||
@@ -84,6 +84,7 @@ export const splitOpen = createAsyncThunk(
|
||||
range: options?.range || originState?.range.raw || DEFAULT_RANGE,
|
||||
panelsState: options?.panelsState || originState?.panelsState,
|
||||
correlationHelperData: options?.correlationHelperData,
|
||||
eventBridge: new EventBusSrv(),
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user