mirror of https://github.com/grafana/grafana
DataLinks: Add internal links in table and allow custom query (#25613)
* Add internal links in table and with custom query * Add specific types for internal and external link * Change the datalink types to be more backward compatible * Refactor the link utils for explore * Add internal linking to table panels * Fix derived field condition * Prettify * Add and fix tests * Prettify * Fix imports and tests * Remove unused type * Update packages/grafana-data/src/types/explore.ts Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> * Update packages/grafana-data/src/types/explore.ts Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>pull/25942/head
parent
463e8ffd92
commit
81d7cb1773
@ -0,0 +1,22 @@ |
||||
import { ExploreMode } from './datasource'; |
||||
import { RawTimeRange } from './time'; |
||||
import { LogsDedupStrategy } from './logs'; |
||||
|
||||
/** @internal */ |
||||
export interface ExploreUrlState { |
||||
datasource: string; |
||||
queries: any[]; // Should be a DataQuery, but we're going to strip refIds, so typing makes less sense
|
||||
mode: ExploreMode; |
||||
range: RawTimeRange; |
||||
ui: ExploreUIState; |
||||
originPanelId?: number; |
||||
context?: string; |
||||
} |
||||
|
||||
/** @internal */ |
||||
export interface ExploreUIState { |
||||
showingTable: boolean; |
||||
showingGraph: boolean; |
||||
showingLogs: boolean; |
||||
dedupStrategy?: LogsDedupStrategy; |
||||
} |
@ -0,0 +1,39 @@ |
||||
import { mapInternalLinkToExplore } from './dataLinks'; |
||||
import { FieldType } from '../types'; |
||||
import { ArrayVector } from '../vector'; |
||||
|
||||
describe('mapInternalLinkToExplore', () => { |
||||
it('creates internal link', () => { |
||||
const link = mapInternalLinkToExplore( |
||||
{ |
||||
url: '', |
||||
title: '', |
||||
internal: { |
||||
datasourceUid: 'uid', |
||||
query: { query: '12344' }, |
||||
}, |
||||
}, |
||||
{}, |
||||
{} as any, |
||||
{ |
||||
name: 'test', |
||||
type: FieldType.number, |
||||
config: {}, |
||||
values: new ArrayVector([2]), |
||||
}, |
||||
{ |
||||
replaceVariables: val => val, |
||||
getDataSourceSettingsByUid: uid => ({ name: 'testDS' } as any), |
||||
} |
||||
); |
||||
|
||||
expect(link).toEqual( |
||||
expect.objectContaining({ |
||||
title: 'testDS', |
||||
href: |
||||
'/explore?left={"datasource":"testDS","queries":[{"query":"12344"}],"mode":"Metrics","ui":{"showingGraph":true,"showingTable":true,"showingLogs":true}}', |
||||
onClick: undefined, |
||||
}) |
||||
); |
||||
}); |
||||
}); |
Loading…
Reference in new issue