mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -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> {
|
||||
onChangeDatasource = async (option: { value: any }) => {
|
||||
this.props.changeDatasource(this.props.exploreId, option.value);
|
||||
this.props.changeDatasource(this.props.exploreId, option.value, { importQueries: true });
|
||||
};
|
||||
|
||||
onClearAll = () => {
|
||||
|
@ -163,7 +163,7 @@ export function RichHistoryCard(props: Props) {
|
||||
const onRunQuery = async () => {
|
||||
const queriesToRun = query.queries;
|
||||
if (query.datasourceName !== datasourceInstance?.name) {
|
||||
await changeDatasource(exploreId, query.datasourceName);
|
||||
await changeDatasource(exploreId, query.datasourceName, { importQueries: true });
|
||||
setQueries(exploreId, queriesToRun);
|
||||
} else {
|
||||
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.
|
||||
*/
|
||||
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) => {
|
||||
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) {
|
||||
dispatch(changeRefreshInterval(exploreId, RefreshPicker.offOption.value));
|
||||
@ -268,7 +274,7 @@ export function loadExploreDatasourcesAndSetDatasource(
|
||||
const exploreDatasources = getExploreDatasources();
|
||||
|
||||
if (exploreDatasources.length >= 1) {
|
||||
await dispatch(changeDatasource(exploreId, datasourceName));
|
||||
await dispatch(changeDatasource(exploreId, datasourceName, { importQueries: true }));
|
||||
dispatch(runQueries(exploreId));
|
||||
} else {
|
||||
dispatch(loadDatasourceMissingAction({ exploreId }));
|
||||
@ -729,6 +735,7 @@ export function splitOpen<T extends DataQuery = any>(options?: { datasourceUid:
|
||||
const dataSourceSettings = getDatasourceSrv().getDataSourceSettingsByUid(options.datasourceUid);
|
||||
await dispatch(changeDatasource(ExploreId.right, dataSourceSettings.name));
|
||||
await dispatch(setQueriesAction({ exploreId: ExploreId.right, queries }));
|
||||
await dispatch(runQueries(ExploreId.right));
|
||||
} else {
|
||||
rightState.queries = leftState.queries.slice();
|
||||
rightState.urlState = urlState;
|
||||
|
Loading…
Reference in New Issue
Block a user