diff --git a/src/components/EchartsEditor/EchartsEditor.tsx b/src/components/EchartsEditor/EchartsEditor.tsx index 74de773..c0e9248 100644 --- a/src/components/EchartsEditor/EchartsEditor.tsx +++ b/src/components/EchartsEditor/EchartsEditor.tsx @@ -57,7 +57,7 @@ export const EchartsEditor: React.FC = ({ 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]; diff --git a/src/constants/editor.ts b/src/constants/editor.ts index b10dfac..db7bf90 100644 --- a/src/constants/editor.ts +++ b/src/constants/editor.ts @@ -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 */ @@ -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,