Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Code suggestions #293

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Add plugin e2e tests and remove cypress (#281, #283)
- Update context parameters in Examples (#282)
- Add Business Charts video tutorial (#291)
- Provisioning for events updated (#289)
- Update panel options (#289)
- Update Code suggestions (#293)

## 6.0.0 (2024-03-24)

Expand Down
62 changes: 3 additions & 59 deletions src/constants/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeEditorSuggestionItem, CodeEditorSuggestionItemKind } from '@grafana/ui';
import { CodeEditorSuggestionItem } from '@grafana/ui';

import { codeParameters, visualCodeParameters } from '../utils';

Expand Down Expand Up @@ -52,65 +52,9 @@ export const FORMAT_OPTIONS = [
];

/**
* Suggestions
* Code Suggestions
*/
export const CODE_EDITOR_SUGGESTIONS: CodeEditorSuggestionItem[] = [
{
label: 'data',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Result set of panel queries.',
},
{
label: 'theme',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Theme object.',
},
{
label: 'echartsInstance',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Instance of the ECharts.',
},
{
label: 'echarts',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'ECharts library.',
},
{
label: 'ecStat',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'A statistical and data mining tool.',
},
{
label: 'locationService',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Browser location and history.',
},
{
label: 'eventBus',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Event bus for application events.',
},
{
label: 'replaceVariables',
kind: CodeEditorSuggestionItemKind.Method,
detail: 'Interpolate variables.',
},
{
label: 'notifySuccess',
kind: CodeEditorSuggestionItemKind.Method,
detail: 'Display successful notification.',
},
{
label: 'notifyError',
kind: CodeEditorSuggestionItemKind.Method,
detail: 'Display error notification.',
},

/**
* Context
*/
...codeParameters.suggestions,
];
export const CODE_EDITOR_SUGGESTIONS: CodeEditorSuggestionItem[] = codeParameters.suggestions;

/**
* Visual Code Editor Suggestions
Expand Down
11 changes: 7 additions & 4 deletions src/utils/code-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { LocationService } from '@grafana/runtime';
import { CodeEditorSuggestionItemKind } from '@grafana/ui';
import { CodeParameterItem, CodeParametersBuilder } from '@volkovlabs/components';
import { ECharts } from 'echarts';
import echartsStat from 'echarts-stat';

import { SeriesItem } from '../types';

Expand All @@ -28,7 +29,7 @@ const baseParametersConfig = {
'Interpolate variables.',
CodeEditorSuggestionItemKind.Method
),
theme: new CodeParameterItem<GrafanaTheme2>('Location service.'),
theme: new CodeParameterItem<GrafanaTheme2>('Theme object.'),
notifySuccess: new CodeParameterItem<(payload: AlertPayload) => void>(
'Display successful notification.',
CodeEditorSuggestionItemKind.Method
Expand All @@ -37,9 +38,11 @@ const baseParametersConfig = {
'Display error notification.',
CodeEditorSuggestionItemKind.Method
),
refresh: new CodeParameterItem<() => void>('Refresh dashboard.', CodeEditorSuggestionItemKind.Method),
refresh: new CodeParameterItem<() => void>('Refresh dashboard panels using application events.', CodeEditorSuggestionItemKind.Method),
},
},
echarts: new CodeParameterItem<typeof echarts>('Apache ECharts library.'),
ecStat: new CodeParameterItem<typeof echartsStat>('A statistical and data mining tool for Apache ECharts.'),
},
};

Expand All @@ -58,8 +61,8 @@ export const visualCodeParameters = new CodeParametersBuilder({
editor: {
detail: 'Editor properties.',
items: {
dataset: new CodeParameterItem<{ source: [string[], ...unknown[]] }>('Echarts dataset.'),
series: new CodeParameterItem<SeriesItem[]>('Echarts series.'),
dataset: new CodeParameterItem<{ source: [string[], ...unknown[]] }>('ECharts dataset.'),
series: new CodeParameterItem<SeriesItem[]>('ECharts series.'),
},
},
},
Expand Down
Loading