mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 07:35:45 -06:00
Run query on splitOpen action
This commit is contained in:
parent
cace879c96
commit
3559b6c573
@ -91,7 +91,7 @@ type Props = StateProps & DispatchProps & OwnProps;
|
|||||||
|
|
||||||
export class UnConnectedExploreToolbar extends PureComponent<Props> {
|
export class UnConnectedExploreToolbar extends PureComponent<Props> {
|
||||||
onChangeDatasource = async (option: { value: any }) => {
|
onChangeDatasource = async (option: { value: any }) => {
|
||||||
this.props.changeDatasource(this.props.exploreId, option.value);
|
this.props.changeDatasource(this.props.exploreId, option.value, { importQueries: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
onClearAll = () => {
|
onClearAll = () => {
|
||||||
|
@ -163,7 +163,7 @@ export function RichHistoryCard(props: Props) {
|
|||||||
const onRunQuery = async () => {
|
const onRunQuery = async () => {
|
||||||
const queriesToRun = query.queries;
|
const queriesToRun = query.queries;
|
||||||
if (query.datasourceName !== datasourceInstance?.name) {
|
if (query.datasourceName !== datasourceInstance?.name) {
|
||||||
await changeDatasource(exploreId, query.datasourceName);
|
await changeDatasource(exploreId, query.datasourceName, { importQueries: true });
|
||||||
setQueries(exploreId, queriesToRun);
|
setQueries(exploreId, queriesToRun);
|
||||||
} else {
|
} else {
|
||||||
setQueries(exploreId, queriesToRun);
|
setQueries(exploreId, queriesToRun);
|
||||||
|
@ -122,7 +122,11 @@ export function addQueryRow(exploreId: ExploreId, index: number): ThunkResult<vo
|
|||||||
/**
|
/**
|
||||||
* Loads a new datasource identified by the given name.
|
* Loads a new datasource identified by the given name.
|
||||||
*/
|
*/
|
||||||
export function changeDatasource(exploreId: ExploreId, datasourceName: string): ThunkResult<void> {
|
export function changeDatasource(
|
||||||
|
exploreId: ExploreId,
|
||||||
|
datasourceName: string,
|
||||||
|
options?: { importQueries: boolean }
|
||||||
|
): ThunkResult<void> {
|
||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
let newDataSourceInstance: DataSourceApi;
|
let newDataSourceInstance: DataSourceApi;
|
||||||
|
|
||||||
@ -150,7 +154,9 @@ export function changeDatasource(exploreId: ExploreId, datasourceName: string):
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
await dispatch(importQueries(exploreId, queries, currentDataSourceInstance, newDataSourceInstance));
|
if (options?.importQueries) {
|
||||||
|
await dispatch(importQueries(exploreId, queries, currentDataSourceInstance, newDataSourceInstance));
|
||||||
|
}
|
||||||
|
|
||||||
if (getState().explore[exploreId].isLive) {
|
if (getState().explore[exploreId].isLive) {
|
||||||
dispatch(changeRefreshInterval(exploreId, RefreshPicker.offOption.value));
|
dispatch(changeRefreshInterval(exploreId, RefreshPicker.offOption.value));
|
||||||
@ -268,7 +274,7 @@ export function loadExploreDatasourcesAndSetDatasource(
|
|||||||
const exploreDatasources = getExploreDatasources();
|
const exploreDatasources = getExploreDatasources();
|
||||||
|
|
||||||
if (exploreDatasources.length >= 1) {
|
if (exploreDatasources.length >= 1) {
|
||||||
await dispatch(changeDatasource(exploreId, datasourceName));
|
await dispatch(changeDatasource(exploreId, datasourceName, { importQueries: true }));
|
||||||
dispatch(runQueries(exploreId));
|
dispatch(runQueries(exploreId));
|
||||||
} else {
|
} else {
|
||||||
dispatch(loadDatasourceMissingAction({ exploreId }));
|
dispatch(loadDatasourceMissingAction({ exploreId }));
|
||||||
@ -729,6 +735,7 @@ export function splitOpen<T extends DataQuery = any>(options?: { datasourceUid:
|
|||||||
const dataSourceSettings = getDatasourceSrv().getDataSourceSettingsByUid(options.datasourceUid);
|
const dataSourceSettings = getDatasourceSrv().getDataSourceSettingsByUid(options.datasourceUid);
|
||||||
await dispatch(changeDatasource(ExploreId.right, dataSourceSettings.name));
|
await dispatch(changeDatasource(ExploreId.right, dataSourceSettings.name));
|
||||||
await dispatch(setQueriesAction({ exploreId: ExploreId.right, queries }));
|
await dispatch(setQueriesAction({ exploreId: ExploreId.right, queries }));
|
||||||
|
await dispatch(runQueries(ExploreId.right));
|
||||||
} else {
|
} else {
|
||||||
rightState.queries = leftState.queries.slice();
|
rightState.queries = leftState.queries.slice();
|
||||||
rightState.urlState = urlState;
|
rightState.urlState = urlState;
|
||||||
|
Loading…
Reference in New Issue
Block a user