Skip to content

Commit

Permalink
Update Code suggestions (#293)
Browse files Browse the repository at this point in the history
* suggestions updated

* Update CHANGELOG.md

* Update suggestions

---------

Co-authored-by: Mikhail Volkov <[email protected]>
  • Loading branch information
vitPinchuk and mikhail-vl authored May 23, 2024
1 parent 89d5aa7 commit cb75185
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 63 deletions.
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

0 comments on commit cb75185

Please sign in to comment.