|
@@ -4,7 +4,20 @@ import Kusto from './kusto/kusto';
|
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
|
import coreModule from 'app/core/core_module';
|
|
import coreModule from 'app/core/core_module';
|
|
|
|
|
|
|
|
-class Editor extends Component<any, any> {
|
|
|
|
|
|
|
+interface EditorProps {
|
|
|
|
|
+ index: number;
|
|
|
|
|
+ placeholder?: string;
|
|
|
|
|
+ change: (value: string, index: number) => void;
|
|
|
|
|
+ variables: () => string[] | string[];
|
|
|
|
|
+ getSchema?: () => Promise<any>;
|
|
|
|
|
+ execute?: () => void;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class Editor extends Component<EditorProps, any> {
|
|
|
|
|
+ static defaultProps = {
|
|
|
|
|
+ placeholder: 'Enter a query'
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
this.state = {
|
|
this.state = {
|
|
@@ -31,7 +44,7 @@ class Editor extends Component<any, any> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- const { request, variables, getSchema } = this.props;
|
|
|
|
|
|
|
+ const { variables, getSchema, placeholder } = this.props;
|
|
|
const { edited, query } = this.state;
|
|
const { edited, query } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -42,8 +55,7 @@ class Editor extends Component<any, any> {
|
|
|
onQueryChange={this.onChangeQuery}
|
|
onQueryChange={this.onChangeQuery}
|
|
|
prismLanguage="kusto"
|
|
prismLanguage="kusto"
|
|
|
prismDefinition={Kusto}
|
|
prismDefinition={Kusto}
|
|
|
- placeholder="Enter a query"
|
|
|
|
|
- request={request}
|
|
|
|
|
|
|
+ placeholder={placeholder}
|
|
|
templateVariables={variables}
|
|
templateVariables={variables}
|
|
|
getSchema={getSchema}
|
|
getSchema={getSchema}
|
|
|
/>
|
|
/>
|
|
@@ -56,7 +68,7 @@ coreModule.directive('kustoEditor', [
|
|
|
'reactDirective',
|
|
'reactDirective',
|
|
|
reactDirective => {
|
|
reactDirective => {
|
|
|
return reactDirective(Editor, [
|
|
return reactDirective(Editor, [
|
|
|
- 'change', 'database', 'execute', 'query', 'request', 'variables',
|
|
|
|
|
|
|
+ 'change', 'database', 'execute', 'query', 'variables', 'placeholder',
|
|
|
['getSchema', { watchDepth: 'reference' }]
|
|
['getSchema', { watchDepth: 'reference' }]
|
|
|
]);
|
|
]);
|
|
|
},
|
|
},
|