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:
Ivana Huckova 2023-02-01 11:34:25 +01:00 committed by GitHub
parent c66ab3a9e4
commit b9bbb4e1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View File

@ -24,7 +24,9 @@ export interface ExploreTracePanelState {
export interface SplitOpenOptions<T> {
datasourceUid: string;
query: T;
/** @deprecated Will be removed in a future version. Use queries instead. */
query?: T;
queries?: T[];
range?: TimeRange;
panelsState?: ExplorePanelsState;
}

View File

@ -136,6 +136,6 @@ describe('LogsSamplePanel', () => {
expect(splitButton).toBeInTheDocument();
await userEvent.click(splitButton);
expect(splitOpen).toHaveBeenCalledWith({ datasourceUid: 'test_uid', query: { refId: 'test_refid' } });
expect(splitOpen).toHaveBeenCalledWith({ datasourceUid: 'test_uid', queries: [{ refId: 'test_refid' }] });
});
});

View File

@ -58,7 +58,7 @@ export function LogsSamplePanel(props: Props) {
}
const onSplitOpen = () => {
splitOpen({ query: logSampleQueries[0], datasourceUid: datasourceInstance.uid });
splitOpen({ queries: logSampleQueries, datasourceUid: datasourceInstance.uid });
reportInteraction('grafana_explore_logs_sample_split_button_clicked', {
datasourceType: datasourceInstance?.type ?? 'unknown',
queriesCount: logSampleQueries.length,

View File

@ -108,9 +108,11 @@ export const splitOpen = <T extends DataQuery = DataQuery>(options?: SplitOpenOp
let rightUrlState: ExploreUrlState = leftUrlState;
if (options) {
const { query, queries } = options;
rightUrlState = {
datasource: options.datasourceUid,
queries: [options.query],
queries: queries ?? (query ? [query] : []),
range: options.range || leftState.range,
panelsState: options.panelsState,
};