Skip to content

Commit

Permalink
Add code editor suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
asimonok committed Feb 5, 2024
1 parent 2964774 commit 19ff7da
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/components/EchartsEditor/EchartsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const EchartsEditor: React.FC<Props> = ({ value, onChange, context, item
});

if (item.id === Editor.VISUALCODE) {
return [...CODE_EDITOR_SUGGESTIONS, ...VISUAL_CODE_EDITOR_SUGGESTIONS, ...suggestions];
return [...VISUAL_CODE_EDITOR_SUGGESTIONS, ...suggestions];
}

return [...CODE_EDITOR_SUGGESTIONS, ...suggestions];
Expand Down
131 changes: 96 additions & 35 deletions src/constants/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,89 @@ export const FORMAT_OPTIONS = [
{ value: Format.NONE, label: 'Disabled' },
];

/**
* Editor Base Context Suggestions
*/
const EDITOR_BASE_CONTEXT_SUGGESTIONS: CodeEditorSuggestionItem[] = [
{
label: 'context',
kind: CodeEditorSuggestionItemKind.Constant,
detail: 'All passed possible properties and methods.',
},

/**
* Panel
*/
{
label: 'context.panel',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Panel instance properties.',
},
{
label: 'context.panel.data',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Panel data.',
},
{
label: 'context.panel.chart',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'ECharts instance.',
},

/**
* Grafana
*/
{
label: 'context.grafana',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Grafana properties and methods.',
},
{
label: 'context.grafana.theme',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Grafana theme.',
},
{
label: 'context.grafana.replaceVariables',
kind: CodeEditorSuggestionItemKind.Method,
detail: 'Interpolate variables.',
},
{
label: 'context.grafana.eventBus',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Panels events.',
},
{
label: 'context.grafana.locationService',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Location service.',
},
{
label: 'context.grafana.notifySuccess',
kind: CodeEditorSuggestionItemKind.Method,
detail: 'Show success notification.',
},
{
label: 'context.grafana.notifyError',
kind: CodeEditorSuggestionItemKind.Method,
detail: 'Show error notification.',
},

/**
* Echarts
*/
{
label: 'context.echarts',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'ECharts library.',
},
{
label: 'context.ecStat',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'A statistical and data mining tool.',
},
];

/**
* Suggestions
*/
Expand Down Expand Up @@ -103,47 +186,25 @@ export const CODE_EDITOR_SUGGESTIONS: CodeEditorSuggestionItem[] = [
kind: CodeEditorSuggestionItemKind.Method,
detail: 'Display error notification.',
},
{
label: 'context',
kind: CodeEditorSuggestionItemKind.Constant,
detail: 'All passed possible properties and methods.',
},
{
label: 'context.panel',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Panel instance properties.',
},
{
label: 'context.panel.data',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Panel data.',
},
{
label: 'context.panel.chart',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'ECharts instance.',
},
{
label: 'context.grafana',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'Grafana properties and methods.',
},
{
label: 'context.echarts',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'ECharts library.',
},
{
label: 'context.ecStat',
kind: CodeEditorSuggestionItemKind.Property,
detail: 'A statistical and data mining tool.',
},

/**
* Context
*/
...EDITOR_BASE_CONTEXT_SUGGESTIONS,
];

/**
* Visual Code Editor Suggestions
*/
export const VISUAL_CODE_EDITOR_SUGGESTIONS: CodeEditorSuggestionItem[] = [
/**
* Context
*/
...EDITOR_BASE_CONTEXT_SUGGESTIONS,

/**
* Visual Editor
*/
{
label: 'context.editor',
kind: CodeEditorSuggestionItemKind.Property,
Expand Down

0 comments on commit 19ff7da

Please sign in to comment.