Skip to content

Commit

Permalink
Merge pull request #1 from elastic/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
Nox911 authored Sep 24, 2018
2 parents 7991a38 + 594d447 commit c7ec189
Show file tree
Hide file tree
Showing 47 changed files with 1,001 additions and 514 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
"@kbn/eslint-plugin-license-header": "link:packages/kbn-eslint-plugin-license-header",
"@kbn/plugin-generator": "link:packages/kbn-plugin-generator",
"@kbn/test": "link:packages/kbn-test",
"@octokit/rest": "^15.10.0",
"@types/angular": "^1.6.45",
"@types/babel-core": "^6.25.5",
"@types/bluebird": "^3.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ exports[`renders ControlsTab 1`] = `
}
}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
handleCheckboxOptionChange={[Function]}
handleFieldNameChange={[Function]}
handleIndexPatternChange={[Function]}
Expand Down Expand Up @@ -54,7 +53,6 @@ exports[`renders ControlsTab 1`] = `
}
}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
handleCheckboxOptionChange={[Function]}
handleFieldNameChange={[Function]}
handleIndexPatternChange={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

exports[`renders dynamic options should display disabled dynamic options with tooltip for non-string fields 1`] = `
<div>
<InjectIntl(IndexPatternSelectUi)
<InjectIntl(IndexPatternSelectFormRowUi)
controlIndex={0}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
indexPatternId="mockIndexPattern"
onChange={[Function]}
/>
Expand Down Expand Up @@ -72,10 +70,8 @@ exports[`renders dynamic options should display disabled dynamic options with to

exports[`renders dynamic options should display dynamic options for string fields 1`] = `
<div>
<InjectIntl(IndexPatternSelectUi)
<InjectIntl(IndexPatternSelectFormRowUi)
controlIndex={0}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
indexPatternId="mockIndexPattern"
onChange={[Function]}
/>
Expand Down Expand Up @@ -123,10 +119,8 @@ exports[`renders dynamic options should display dynamic options for string field

exports[`renders dynamic options should display size field when dynamic options is disabled 1`] = `
<div>
<InjectIntl(IndexPatternSelectUi)
<InjectIntl(IndexPatternSelectFormRowUi)
controlIndex={0}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
indexPatternId="mockIndexPattern"
onChange={[Function]}
/>
Expand Down Expand Up @@ -193,10 +187,8 @@ exports[`renders dynamic options should display size field when dynamic options

exports[`renders should display chaining input when parents are provided 1`] = `
<div>
<InjectIntl(IndexPatternSelectUi)
<InjectIntl(IndexPatternSelectFormRowUi)
controlIndex={0}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
indexPatternId="indexPattern1"
onChange={[Function]}
/>
Expand Down Expand Up @@ -296,10 +288,8 @@ exports[`renders should display chaining input when parents are provided 1`] = `

exports[`renders should not display any options until field is selected 1`] = `
<div>
<InjectIntl(IndexPatternSelectUi)
<InjectIntl(IndexPatternSelectFormRowUi)
controlIndex={0}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
indexPatternId="mockIndexPattern"
onChange={[Function]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

exports[`renders RangeControlEditor 1`] = `
<div>
<InjectIntl(IndexPatternSelectUi)
<InjectIntl(IndexPatternSelectFormRowUi)
controlIndex={0}
getIndexPattern={[Function]}
getIndexPatterns={[Function]}
indexPatternId="indexPattern1"
onChange={[Function]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class ControlEditorUi extends Component {
controlParams={this.props.controlParams}
handleIndexPatternChange={this.changeIndexPattern}
handleFieldNameChange={this.changeFieldName}
getIndexPatterns={this.props.getIndexPatterns}
getIndexPattern={this.props.getIndexPattern}
handleNumberOptionChange={this.props.handleNumberOptionChange}
handleCheckboxOptionChange={this.props.handleCheckboxOptionChange}
Expand All @@ -87,7 +86,6 @@ class ControlEditorUi extends Component {
controlParams={this.props.controlParams}
handleIndexPatternChange={this.changeIndexPattern}
handleFieldNameChange={this.changeFieldName}
getIndexPatterns={this.props.getIndexPatterns}
getIndexPattern={this.props.getIndexPattern}
handleNumberOptionChange={this.props.handleNumberOptionChange}
/>
Expand Down Expand Up @@ -179,7 +177,6 @@ ControlEditorUi.propTypes = {
handleRemoveControl: PropTypes.func.isRequired,
handleIndexPatternChange: PropTypes.func.isRequired,
handleFieldNameChange: PropTypes.func.isRequired,
getIndexPatterns: PropTypes.func.isRequired,
getIndexPattern: PropTypes.func.isRequired,
handleCheckboxOptionChange: PropTypes.func.isRequired,
handleNumberOptionChange: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ class ControlsTabUi extends Component {
type: 'list'
}

getIndexPatterns = async (search) => {
const resp = await this.props.scope.vis.API.savedObjectsClient.find({
type: 'index-pattern',
fields: ['title'],
search: `${search}*`,
search_fields: ['title'],
perPage: 100
});
return resp.savedObjects;
}

getIndexPattern = async (indexPatternId) => {
return await this.props.scope.vis.API.indexPatterns.get(indexPatternId);
}
Expand Down Expand Up @@ -127,7 +116,6 @@ class ControlsTabUi extends Component {
handleRemoveControl={this.handleRemoveControl}
handleIndexPatternChange={this.handleIndexPatternChange}
handleFieldNameChange={this.handleFieldNameChange}
getIndexPatterns={this.getIndexPatterns}
getIndexPattern={this.getIndexPattern}
handleCheckboxOptionChange={this.handleCheckboxOptionChange}
handleNumberOptionChange={this.handleNumberOptionChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,12 @@ import {
ControlsTab,
} from './controls_tab';

const savedObjectsClientMock = {
find: () => {
return Promise.resolve({
savedObjects: [
{
id: 'indexPattern1',
attributes: {
title: 'title1'
}
}
]
});
}
};
const indexPatternsMock = {
get: getIndexPatternMock
};
const scopeMock = {
vis: {
API: {
savedObjectsClient: savedObjectsClientMock,
indexPatterns: indexPatternsMock
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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 from 'react';
import { injectI18n } from '@kbn/i18n/react';
import { IndexPatternSelect } from 'ui/index_patterns/components/index_pattern_select';

import {
EuiFormRow,
} from '@elastic/eui';

function IndexPatternSelectFormRowUi(props) {
const {
controlIndex,
indexPatternId,
intl,
onChange,
} = props;
const selectId = `indexPatternSelect-${controlIndex}`;

return (
<EuiFormRow
id={selectId}
label={intl.formatMessage({
id: 'inputControl.editor.indexPatternSelect.patternLabel',
defaultMessage: 'Index Pattern'
})}
>
<IndexPatternSelect
placeholder={intl.formatMessage({
id: 'inputControl.editor.indexPatternSelect.patternPlaceholder',
defaultMessage: 'Select index pattern...'
})}
indexPatternId={indexPatternId}
onChange={onChange}
data-test-subj={selectId}
/>
</EuiFormRow>
);
}

IndexPatternSelectFormRowUi.propTypes = {
onChange: PropTypes.func.isRequired,
indexPatternId: PropTypes.string,
controlIndex: PropTypes.number.isRequired,
};

export const IndexPatternSelectFormRow = injectI18n(IndexPatternSelectFormRowUi);
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { IndexPatternSelect } from './index_pattern_select';
import { IndexPatternSelectFormRow } from './index_pattern_select_form_row';
import { FieldSelect } from './field_select';
import { injectI18n } from '@kbn/i18n/react';

Expand Down Expand Up @@ -220,11 +220,9 @@ class ListControlEditorUi extends Component {
return (
<div>

<IndexPatternSelect
<IndexPatternSelectFormRow
indexPatternId={this.props.controlParams.indexPattern}
onChange={this.props.handleIndexPatternChange}
getIndexPatterns={this.props.getIndexPatterns}
getIndexPattern={this.props.getIndexPattern}
controlIndex={this.props.controlIndex}
/>

Expand All @@ -245,7 +243,6 @@ class ListControlEditorUi extends Component {
}

ListControlEditorUi.propTypes = {
getIndexPatterns: PropTypes.func.isRequired,
getIndexPattern: PropTypes.func.isRequired,
controlIndex: PropTypes.number.isRequired,
controlParams: PropTypes.object.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import sinon from 'sinon';
import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
import { findTestSubject } from '@elastic/eui/lib/test';
import { getIndexPatternMock } from './__tests__/get_index_pattern_mock';
import { getIndexPatternsMock } from './__tests__/get_index_patterns_mock';

import {
ListControlEditor,
Expand Down Expand Up @@ -68,7 +67,6 @@ describe('renders', () => {
}
};
const component = shallowWithIntl(<ListControlEditor.WrappedComponent
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand All @@ -94,7 +92,6 @@ describe('renders', () => {
{ value: '2', text: 'fieldB' }
];
const component = shallowWithIntl(<ListControlEditor.WrappedComponent
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand Down Expand Up @@ -129,7 +126,6 @@ describe('renders', () => {
}
};
const component = shallowWithIntl(<ListControlEditor.WrappedComponent
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand Down Expand Up @@ -163,7 +159,6 @@ describe('renders', () => {
}
};
const component = shallowWithIntl(<ListControlEditor.WrappedComponent
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand Down Expand Up @@ -197,7 +192,6 @@ describe('renders', () => {
}
};
const component = shallowWithIntl(<ListControlEditor.WrappedComponent
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand All @@ -221,7 +215,6 @@ describe('renders', () => {

test('handleCheckboxOptionChange - multiselect', async () => {
const component = mountWithIntl(<ListControlEditor.WrappedComponent
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand Down Expand Up @@ -259,7 +252,6 @@ test('handleCheckboxOptionChange - multiselect', async () => {

test('handleNumberOptionChange - size', async () => {
const component = mountWithIntl(<ListControlEditor.WrappedComponent
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import PropTypes from 'prop-types';
import React from 'react';
import { IndexPatternSelect } from './index_pattern_select';
import { IndexPatternSelectFormRow } from './index_pattern_select_form_row';
import { FieldSelect } from './field_select';

import {
Expand All @@ -45,11 +45,9 @@ export function RangeControlEditor(props) {
return (
<div>

<IndexPatternSelect
<IndexPatternSelectFormRow
indexPatternId={props.controlParams.indexPattern}
onChange={props.handleIndexPatternChange}
getIndexPatterns={props.getIndexPatterns}
getIndexPattern={props.getIndexPattern}
controlIndex={props.controlIndex}
/>

Expand Down Expand Up @@ -96,7 +94,6 @@ export function RangeControlEditor(props) {
}

RangeControlEditor.propTypes = {
getIndexPatterns: PropTypes.func.isRequired,
getIndexPattern: PropTypes.func.isRequired,
controlIndex: PropTypes.number.isRequired,
controlParams: PropTypes.object.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { shallow } from 'enzyme';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { findTestSubject } from '@elastic/eui/lib/test';
import { getIndexPatternMock } from './__tests__/get_index_pattern_mock';
import { getIndexPatternsMock } from './__tests__/get_index_patterns_mock';

import {
RangeControlEditor,
Expand Down Expand Up @@ -52,7 +51,6 @@ beforeEach(() => {

test('renders RangeControlEditor', () => {
const component = shallow(<RangeControlEditor
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand All @@ -65,7 +63,6 @@ test('renders RangeControlEditor', () => {

test('handleNumberOptionChange - step', () => {
const component = mountWithIntl(<RangeControlEditor
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand All @@ -92,7 +89,6 @@ test('handleNumberOptionChange - step', () => {

test('handleNumberOptionChange - decimalPlaces', () => {
const component = mountWithIntl(<RangeControlEditor
getIndexPatterns={getIndexPatternsMock}
getIndexPattern={getIndexPatternMock}
controlIndex={0}
controlParams={controlParams}
Expand Down
Loading

0 comments on commit c7ec189

Please sign in to comment.