Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
dashboard
/
components
/
PanelEditor
/
File Content:
getVisualizationOptions.test.ts
import { EventBusSrv, FieldType, getDefaultTimeRange, LoadingState, toDataFrame } from '@grafana/data'; import { getStandardEditorContext } from './getVisualizationOptions'; describe('getStandardEditorContext', () => { it('defaults the series data to an empty array', () => { const editorContext = getStandardEditorContext({ data: undefined, replaceVariables: jest.fn(), options: {}, eventBus: new EventBusSrv(), instanceState: {}, }); expect(editorContext.data).toEqual([]); }); it('returns suggestions for empty data', () => { const editorContext = getStandardEditorContext({ data: undefined, replaceVariables: jest.fn(), options: {}, eventBus: new EventBusSrv(), instanceState: {}, }); expect(editorContext.getSuggestions).toBeDefined(); expect(editorContext.getSuggestions?.()).toEqual([ { documentation: 'Name of the series', label: 'Name', origin: 'series', value: '__series.name', }, { documentation: 'Field name of the clicked datapoint (in ms epoch)', label: 'Name', origin: 'field', value: '__field.name', }, { documentation: 'Adds current variables', label: 'All variables', origin: 'template', value: '__all_variables', }, { documentation: 'Adds current time range', label: 'Time range', origin: 'built-in', value: '__url_time_range', }, { documentation: "Adds current time range's from value", label: 'Time range: from', origin: 'built-in', value: '__from', }, { documentation: "Adds current time range's to value", label: 'Time range: to', origin: 'built-in', value: '__to', }, ]); }); it('returns suggestions for non-empty data', () => { const series = [ toDataFrame({ fields: [ { name: 'time', type: FieldType.time }, { name: 'score', type: FieldType.number }, ], }), ]; const panelData = { series, timeRange: getDefaultTimeRange(), state: LoadingState.Done, }; const editorContext = getStandardEditorContext({ data: panelData, replaceVariables: jest.fn(), options: {}, eventBus: new EventBusSrv(), instanceState: {}, }); expect(editorContext.getSuggestions).toBeDefined(); expect(editorContext.getSuggestions?.()).toEqual([ { documentation: 'Name of the series', label: 'Name', origin: 'series', value: '__series.name', }, { documentation: 'Field name of the clicked datapoint (in ms epoch)', label: 'Name', origin: 'field', value: '__field.name', }, { documentation: 'Formatted value for time on the same row', label: 'time', origin: 'fields', value: '__data.fields.time', }, { documentation: 'Formatted value for score on the same row', label: 'score', origin: 'fields', value: '__data.fields.score', }, { documentation: 'Enter the field order', label: 'Select by index', origin: 'fields', value: '__data.fields[0]', }, { documentation: 'the numeric field value', label: 'Show numeric value', origin: 'fields', value: '__data.fields.score.numeric', }, { documentation: 'the text value', label: 'Show text value', origin: 'fields', value: '__data.fields.score.text', }, { documentation: 'Adds current variables', label: 'All variables', origin: 'template', value: '__all_variables', }, { documentation: 'Adds current time range', label: 'Time range', origin: 'built-in', value: '__url_time_range', }, { documentation: "Adds current time range's from value", label: 'Time range: from', origin: 'built-in', value: '__from', }, { documentation: "Adds current time range's to value", label: 'Time range: to', origin: 'built-in', value: '__to', }, ]); }); });
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
state
---
0755
AngularPanelOptions.tsx
3907 bytes
0644
DynamicConfigValueEditor.tsx
3678 bytes
0644
OptionsPane.tsx
2615 bytes
0644
OptionsPaneCategory.tsx
5759 bytes
0644
OptionsPaneCategoryDescriptor.tsx
1835 bytes
0644
OptionsPaneItemDescriptor.tsx
3584 bytes
0644
OptionsPaneItemOverrides.tsx
1208 bytes
0644
OptionsPaneOptions.test.tsx
9120 bytes
0644
OptionsPaneOptions.tsx
7812 bytes
0644
OverrideCategoryTitle.tsx
2069 bytes
0644
PanelEditor.tsx
16794 bytes
0644
PanelEditorQueries.tsx
4139 bytes
0644
PanelEditorTableView.test.tsx
7264 bytes
0644
PanelEditorTableView.tsx
2203 bytes
0644
PanelEditorTabs.tsx
4931 bytes
0644
PanelHeaderCorner.test.tsx
708 bytes
0644
PanelHeaderCorner.tsx
3489 bytes
0644
PanelNotSupported.test.tsx
1398 bytes
0644
PanelNotSupported.tsx
849 bytes
0644
VisualizationButton.tsx
2277 bytes
0644
VisualizationSelectPane.tsx
6512 bytes
0644
getFieldOverrideElements.tsx
8273 bytes
0644
getLibraryPanelOptions.tsx
1704 bytes
0644
getPanelFrameOptions.tsx
11327 bytes
0644
getVisualizationOptions.test.ts
4366 bytes
0644
getVisualizationOptions.tsx
9787 bytes
0644
types.ts
1823 bytes
0644
usePanelLatestData.ts
2206 bytes
0644
utils.test.ts
5250 bytes
0644
utils.ts
2895 bytes
0644
N4ST4R_ID | Naxtarrr