mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Remove legend formatting when switching from panel to Explore (#25848)
* Remove legend formatting when switching from panel to explore * Add test coverage
This commit is contained in:
parent
75a714aa51
commit
6c7a452726
@ -11,6 +11,8 @@ import {
|
|||||||
sortLogsResult,
|
sortLogsResult,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
updateHistory,
|
updateHistory,
|
||||||
|
getExploreUrl,
|
||||||
|
GetExploreUrlArguments,
|
||||||
} from './explore';
|
} from './explore';
|
||||||
import store from 'app/core/store';
|
import store from 'app/core/store';
|
||||||
import {
|
import {
|
||||||
@ -174,6 +176,32 @@ describe('state functions', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getExploreUrl', () => {
|
||||||
|
const args = ({
|
||||||
|
panel: {
|
||||||
|
getSavedId: () => 1,
|
||||||
|
},
|
||||||
|
panelTargets: [{ refId: 'A', expr: 'query1', legendFormat: 'legendFormat1' }],
|
||||||
|
panelDatasource: {
|
||||||
|
name: 'testDataSource',
|
||||||
|
meta: {
|
||||||
|
id: '1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
datasourceSrv: {
|
||||||
|
get: jest.fn(),
|
||||||
|
getDataSourceById: jest.fn(),
|
||||||
|
},
|
||||||
|
timeSrv: {
|
||||||
|
timeRangeForUrl: () => '1',
|
||||||
|
},
|
||||||
|
} as unknown) as GetExploreUrlArguments;
|
||||||
|
|
||||||
|
it('should omit legendFormat in explore url', () => {
|
||||||
|
expect(getExploreUrl(args).then(data => expect(data).not.toMatch(/legendFormat1/g)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('updateHistory()', () => {
|
describe('updateHistory()', () => {
|
||||||
const datasourceId = 'myDatasource';
|
const datasourceId = 'myDatasource';
|
||||||
const key = `grafana.explore.history.${datasourceId}`;
|
const key = `grafana.explore.history.${datasourceId}`;
|
||||||
|
@ -70,7 +70,11 @@ export interface GetExploreUrlArguments {
|
|||||||
export async function getExploreUrl(args: GetExploreUrlArguments): Promise<string | undefined> {
|
export async function getExploreUrl(args: GetExploreUrlArguments): Promise<string | undefined> {
|
||||||
const { panel, panelTargets, panelDatasource, datasourceSrv, timeSrv } = args;
|
const { panel, panelTargets, panelDatasource, datasourceSrv, timeSrv } = args;
|
||||||
let exploreDatasource = panelDatasource;
|
let exploreDatasource = panelDatasource;
|
||||||
let exploreTargets: DataQuery[] = panelTargets;
|
|
||||||
|
/** In Explore, we don't have legend formatter and we don't want to keep
|
||||||
|
* legend formatting as we can't change it
|
||||||
|
*/
|
||||||
|
let exploreTargets: DataQuery[] = panelTargets.map(t => _.omit(t, 'legendFormat'));
|
||||||
let url: string | undefined;
|
let url: string | undefined;
|
||||||
|
|
||||||
// Mixed datasources need to choose only one datasource
|
// Mixed datasources need to choose only one datasource
|
||||||
|
Loading…
Reference in New Issue
Block a user