GET _search
diff --git a/src/legacy/core_plugins/console/public/src/console_menu.js b/src/legacy/core_plugins/console/public/src/console_menu.js
new file mode 100644
index 0000000000000..3ab05556f643e
--- /dev/null
+++ b/src/legacy/core_plugins/console/public/src/console_menu.js
@@ -0,0 +1,157 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import PropTypes from 'prop-types';
+
+import React, {
+ Component,
+} from 'react';
+
+import {
+ EuiButtonIcon,
+ EuiContextMenuPanel,
+ EuiContextMenuItem,
+ EuiPopover,
+} from '@elastic/eui';
+
+import { FormattedMessage } from '@kbn/i18n/react';
+
+export class ConsoleMenu extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ curlCode: '',
+ isPopoverOpen: false,
+ };
+ }
+
+ mouseEnter = () => {
+ if (this.state.isPopoverOpen) return;
+ this.props.getCurl(text => {
+ this.setState({ curlCode: text });
+ });
+ }
+
+ copyAsCurl() {
+ this.copyText(this.state.curlCode);
+ }
+
+ copyText(text) {
+ const textField = document.createElement('textarea');
+ textField.innerText = text;
+ document.body.appendChild(textField);
+ textField.select();
+ document.execCommand('copy');
+ textField.remove();
+ }
+
+ onButtonClick = () => {
+ this.setState(prevState => ({
+ isPopoverOpen: !prevState.isPopoverOpen,
+ }));
+ };
+
+ closePopover = () => {
+ this.setState({
+ isPopoverOpen: false,
+ });
+ };
+
+ openDocs = () => {
+ this.closePopover();
+ this.props.getDocumentation();
+ this.props.openDocumentation();
+ }
+
+ render() {
+ const button = (
+
+ }
+ />
+ );
+
+ const items = [
+ (
+ { this.closePopover(); this.copyAsCurl(); }}
+ >
+
+
+ ), (
+ { this.openDocs(); }}
+ >
+
+
+ ), (
+ { this.closePopover(); this.props.autoIndent(event); }}
+ >
+
+
+ )
+ ];
+
+ return (
+
+
+
+
+
+ );
+ }
+}
+
+ConsoleMenu.propTypes = {
+ getCurl: PropTypes.func.isRequired,
+ openDocumentation: PropTypes.func.isRequired,
+ getDocumentation: PropTypes.func.isRequired,
+ autoIndent: PropTypes.func.isRequired,
+};
diff --git a/src/legacy/core_plugins/console/public/src/controllers/sense_controller.js b/src/legacy/core_plugins/console/public/src/controllers/sense_controller.js
index 9f1c9be68f9cc..4d3757be9a6ac 100644
--- a/src/legacy/core_plugins/console/public/src/controllers/sense_controller.js
+++ b/src/legacy/core_plugins/console/public/src/controllers/sense_controller.js
@@ -53,6 +53,9 @@ module.controller('SenseController', function SenseController(Private, $scope, $
$scope.getDocumentation();
});
$scope.getDocumentation();
+
+ // expose method for React Consumption
+ $scope.getRequestsAsCURL = input.getRequestsAsCURL;
});
$scope.getDocumentation = () => {
input.getRequestsInRange(function (requests) {
diff --git a/src/legacy/core_plugins/console/public/src/directives/console_menu_directive.js b/src/legacy/core_plugins/console/public/src/directives/console_menu_directive.js
new file mode 100644
index 0000000000000..32c1bcd278072
--- /dev/null
+++ b/src/legacy/core_plugins/console/public/src/directives/console_menu_directive.js
@@ -0,0 +1,34 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import 'ngreact';
+
+import { wrapInI18nContext } from 'ui/i18n';
+import { uiModules } from 'ui/modules';
+const module = uiModules.get('apps/sense', ['react']);
+
+import { ConsoleMenu } from '../console_menu';
+
+module.directive('consoleMenu', function (reactDirective) {
+ return reactDirective(
+ wrapInI18nContext(ConsoleMenu),
+ undefined,
+ { restrict: 'E' }
+ );
+});
diff --git a/src/legacy/core_plugins/console/public/src/input.js b/src/legacy/core_plugins/console/public/src/input.js
index 68b54ab9ecda1..64cb27b51e7f7 100644
--- a/src/legacy/core_plugins/console/public/src/input.js
+++ b/src/legacy/core_plugins/console/public/src/input.js
@@ -17,7 +17,6 @@
* under the License.
*/
-const $ = require('jquery');
require('brace');
require('brace/ext/searchbox');
import Autocomplete from './autocomplete';
@@ -66,37 +65,6 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu
}
});
-
- /**
- * COPY AS CURL
- */
- (function setupClipboard() {
- function copyText(text) {
- const node = $(` {
- copyText($copyAsCurlEl.attr('data-clipboard-text'));
- });
-
- input.$actions.on('mouseenter', function () {
- if ($(this).hasClass('open')) return;
- input.getRequestsAsCURL(text => {
- $copyAsCurlEl.attr('data-clipboard-text', text);
- });
- });
- }());
-
/**
* Setup the "send" shortcut
*/
diff --git a/src/legacy/core_plugins/vega/public/help_menus/vega_action_menu.js b/src/legacy/core_plugins/vega/public/help_menus/vega_action_menu.js
new file mode 100644
index 0000000000000..f09f2f6f42370
--- /dev/null
+++ b/src/legacy/core_plugins/vega/public/help_menus/vega_action_menu.js
@@ -0,0 +1,114 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import PropTypes from 'prop-types';
+
+import React, {
+ Component,
+} from 'react';
+
+import {
+ EuiButtonIcon,
+ EuiContextMenuPanel,
+ EuiContextMenuItem,
+ EuiPopover,
+} from '@elastic/eui';
+
+import { FormattedMessage } from '@kbn/i18n/react';
+
+export class VegaActionsMenu extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ isPopoverOpen: false,
+ };
+ }
+
+ onButtonClick = () => {
+ this.setState(prevState => ({
+ isPopoverOpen: !prevState.isPopoverOpen,
+ }));
+ };
+
+ closePopover = () => {
+ this.setState({
+ isPopoverOpen: false,
+ });
+ };
+
+ render() {
+ const button = (
+
+ }
+ />
+ );
+
+ const items = [
+ (
+ { this.closePopover(); this.props.formatHJson(event); }}
+ >
+
+
+ ), (
+ { this.closePopover(); this.props.formatJson(event); }}
+ >
+
+
+ )
+ ];
+
+ return (
+
+
+
+ );
+ }
+}
+
+VegaActionsMenu.propTypes = {
+ formatHJson: PropTypes.func.isRequired,
+ formatJson: PropTypes.func.isRequired,
+};
diff --git a/src/legacy/core_plugins/vega/public/help_menus/vega_help_menu.js b/src/legacy/core_plugins/vega/public/help_menus/vega_help_menu.js
new file mode 100644
index 0000000000000..06fe096fec98f
--- /dev/null
+++ b/src/legacy/core_plugins/vega/public/help_menus/vega_help_menu.js
@@ -0,0 +1,126 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React, {
+ Component,
+} from 'react';
+
+import {
+ EuiButtonIcon,
+ EuiContextMenuPanel,
+ EuiContextMenuItem,
+ EuiPopover,
+} from '@elastic/eui';
+
+import { FormattedMessage } from '@kbn/i18n/react';
+
+export class VegaHelpMenu extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ isPopoverOpen: false,
+ };
+ }
+
+ onButtonClick = () => {
+ this.setState(prevState => ({
+ isPopoverOpen: !prevState.isPopoverOpen,
+ }));
+ };
+
+ closePopover = () => {
+ this.setState({
+ isPopoverOpen: false,
+ });
+ };
+
+ render() {
+ const button = (
+
+ }
+ />
+ );
+
+ const items = [
+ (
+ { this.closePopover(); }}
+ >
+
+
+ ), (
+ { this.closePopover(); }}
+ >
+
+
+ ), (
+ { this.closePopover(); }}
+ >
+
+
+ )
+ ];
+
+ return (
+
+
+
+ );
+ }
+}
diff --git a/src/legacy/core_plugins/vega/public/help_menus/vega_help_menu_directives.js b/src/legacy/core_plugins/vega/public/help_menus/vega_help_menu_directives.js
new file mode 100644
index 0000000000000..46a9263691a3f
--- /dev/null
+++ b/src/legacy/core_plugins/vega/public/help_menus/vega_help_menu_directives.js
@@ -0,0 +1,44 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import 'ngreact';
+
+import { wrapInI18nContext } from 'ui/i18n';
+import { uiModules } from 'ui/modules';
+const module = uiModules.get('kibana/vega', ['react']);
+
+import { VegaHelpMenu } from './vega_help_menu';
+import { VegaActionsMenu } from './vega_action_menu';
+
+module.directive('vegaActionsMenu', function (reactDirective) {
+ return reactDirective(
+ wrapInI18nContext(VegaActionsMenu),
+ undefined,
+ { restrict: 'E' }
+ );
+});
+
+module.directive('vegaHelpMenu', function (reactDirective) {
+ return reactDirective(
+ wrapInI18nContext(VegaHelpMenu),
+ undefined,
+ { restrict: 'E' }
+ );
+});
diff --git a/src/legacy/core_plugins/vega/public/vega_editor_template.html b/src/legacy/core_plugins/vega/public/vega_editor_template.html
index f1ffe3552eed1..498fa7c91ff53 100644
--- a/src/legacy/core_plugins/vega/public/vega_editor_template.html
+++ b/src/legacy/core_plugins/vega/public/vega_editor_template.html
@@ -19,79 +19,13 @@
>