mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SplitOpen: Update API to accept multiple queries (#62245)
* SplitOpen: Update API to accept multiple queries * Explore: Deprecate query in SplitOpenOptions and add queries * Use queries in log samples * Fix test
This commit is contained in:
parent
c66ab3a9e4
commit
b9bbb4e1fb
@ -24,7 +24,9 @@ export interface ExploreTracePanelState {
|
|||||||
|
|
||||||
export interface SplitOpenOptions<T> {
|
export interface SplitOpenOptions<T> {
|
||||||
datasourceUid: string;
|
datasourceUid: string;
|
||||||
query: T;
|
/** @deprecated Will be removed in a future version. Use queries instead. */
|
||||||
|
query?: T;
|
||||||
|
queries?: T[];
|
||||||
range?: TimeRange;
|
range?: TimeRange;
|
||||||
panelsState?: ExplorePanelsState;
|
panelsState?: ExplorePanelsState;
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,6 @@ describe('LogsSamplePanel', () => {
|
|||||||
expect(splitButton).toBeInTheDocument();
|
expect(splitButton).toBeInTheDocument();
|
||||||
|
|
||||||
await userEvent.click(splitButton);
|
await userEvent.click(splitButton);
|
||||||
expect(splitOpen).toHaveBeenCalledWith({ datasourceUid: 'test_uid', query: { refId: 'test_refid' } });
|
expect(splitOpen).toHaveBeenCalledWith({ datasourceUid: 'test_uid', queries: [{ refId: 'test_refid' }] });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -58,7 +58,7 @@ export function LogsSamplePanel(props: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSplitOpen = () => {
|
const onSplitOpen = () => {
|
||||||
splitOpen({ query: logSampleQueries[0], datasourceUid: datasourceInstance.uid });
|
splitOpen({ queries: logSampleQueries, datasourceUid: datasourceInstance.uid });
|
||||||
reportInteraction('grafana_explore_logs_sample_split_button_clicked', {
|
reportInteraction('grafana_explore_logs_sample_split_button_clicked', {
|
||||||
datasourceType: datasourceInstance?.type ?? 'unknown',
|
datasourceType: datasourceInstance?.type ?? 'unknown',
|
||||||
queriesCount: logSampleQueries.length,
|
queriesCount: logSampleQueries.length,
|
||||||
|
@ -108,9 +108,11 @@ export const splitOpen = <T extends DataQuery = DataQuery>(options?: SplitOpenOp
|
|||||||
let rightUrlState: ExploreUrlState = leftUrlState;
|
let rightUrlState: ExploreUrlState = leftUrlState;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
|
const { query, queries } = options;
|
||||||
|
|
||||||
rightUrlState = {
|
rightUrlState = {
|
||||||
datasource: options.datasourceUid,
|
datasource: options.datasourceUid,
|
||||||
queries: [options.query],
|
queries: queries ?? (query ? [query] : []),
|
||||||
range: options.range || leftState.range,
|
range: options.range || leftState.range,
|
||||||
panelsState: options.panelsState,
|
panelsState: options.panelsState,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user