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