diff --git a/package.json b/package.json index 5c102c960db692..30aa3c178ae00f 100644 --- a/package.json +++ b/package.json @@ -173,11 +173,12 @@ "react-color": "2.11.7", "react-dom": "15.6.1", "react-input-autosize": "1.1.0", + "react-input-range": "1.2.1", "react-markdown": "2.4.2", "react-redux": "4.4.5", "react-router": "2.0.0", "react-router-redux": "4.0.4", - "react-select": "1.0.0-rc.1", + "react-select": "1.0.0-rc.5", "react-sortable": "1.1.0", "react-toggle": "3.0.1", "reactcss": "1.0.7", diff --git a/src/core_plugins/input_control_vis/index.js b/src/core_plugins/input_control_vis/index.js new file mode 100644 index 00000000000000..f7d56fced8ab42 --- /dev/null +++ b/src/core_plugins/input_control_vis/index.js @@ -0,0 +1,9 @@ +export default function (kibana) { + return new kibana.Plugin({ + uiExports: { + visTypes: [ + 'plugins/input_control_vis/register_vis' + ] + } + }); +} diff --git a/src/core_plugins/input_control_vis/package.json b/src/core_plugins/input_control_vis/package.json new file mode 100644 index 00000000000000..0d52be412f2fdb --- /dev/null +++ b/src/core_plugins/input_control_vis/package.json @@ -0,0 +1,4 @@ +{ + "name": "input_control_vis", + "version": "kibana" +} diff --git a/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/controls_tab.test.js.snap b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/controls_tab.test.js.snap new file mode 100644 index 00000000000000..ef492095b2dd7a --- /dev/null +++ b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/controls_tab.test.js.snap @@ -0,0 +1,95 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders ControlsTab 1`] = ` +
+ + +
+
+ +
+ + } + onClick={[Function]} + type="button" + > + Add + +
+
+`; diff --git a/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/list_control_editor.test.js.snap b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/list_control_editor.test.js.snap new file mode 100644 index 00000000000000..803263077bf4f1 --- /dev/null +++ b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/list_control_editor.test.js.snap @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders ListControlEditor 1`] = ` +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+`; diff --git a/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/options_tab.test.js.snap b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/options_tab.test.js.snap new file mode 100644 index 00000000000000..3728ea07e8cfeb --- /dev/null +++ b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/options_tab.test.js.snap @@ -0,0 +1,32 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders OptionsTab 1`] = ` +
+
+
+ + + + + +
+
+
+`; diff --git a/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/range_control_editor.test.js.snap b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/range_control_editor.test.js.snap new file mode 100644 index 00000000000000..0c640431ca64cb --- /dev/null +++ b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/range_control_editor.test.js.snap @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders RangeControlEditor 1`] = ` +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+`; diff --git a/src/core_plugins/input_control_vis/public/components/editor/control_editor.js b/src/core_plugins/input_control_vis/public/components/editor/control_editor.js new file mode 100644 index 00000000000000..5f373c12defe04 --- /dev/null +++ b/src/core_plugins/input_control_vis/public/components/editor/control_editor.js @@ -0,0 +1,170 @@ +import classNames from 'classnames'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { RangeControlEditor } from './range_control_editor'; +import { ListControlEditor } from './list_control_editor'; +import { getTitle } from '../../editor_utils'; + +export class ControlEditor extends Component { + + state = { + isEditorCollapsed: true + } + + handleToggleControlVisibility = () => { + this.setState(prevState => ( + { isEditorCollapsed: !prevState.isEditorCollapsed } + )); + } + + changeLabel = (evt) => { + this.props.handleLabelChange(this.props.controlIndex, evt); + } + + removeControl = () => { + this.props.handleRemoveControl(this.props.controlIndex); + } + + moveUpControl = () => { + this.props.moveControl(this.props.controlIndex, -1); + } + + moveDownControl = () => { + this.props.moveControl(this.props.controlIndex, 1); + } + + changeIndexPattern = (evt) => { + this.props.handleIndexPatternChange(this.props.controlIndex, evt); + } + + changeFieldName = (evt) => { + this.props.handleFieldNameChange(this.props.controlIndex, evt); + } + + renderEditor() { + let controlEditor = null; + switch (this.props.controlParams.type) { + case 'list': + controlEditor = ( + + ); + break; + case 'range': + controlEditor = ( + + ); + break; + default: + throw new Error(`Unhandled control editor type ${this.props.controlParams.type}`); + } + + const labelId = `controlLabel${this.props.controlIndex}`; + return ( +
+
+ +
+ +
+
+ + {controlEditor} +
+ ); + } + + render() { + const visibilityToggleClasses = classNames('fa', { + 'fa-caret-right': !this.state.isEditorCollapsed, + 'fa-caret-down': this.state.isEditorCollapsed + }); + + return ( +
+
+