Skip to content

Commit

Permalink
Merge branch 'master' into feat/ssource-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Dec 2, 2020
2 parents 84136f6 + cc341b3 commit a27f803
Showing 465 changed files with 8,570 additions and 4,101 deletions.
25 changes: 24 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -262,8 +262,31 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib

# Enterprise Search
# Shared
/x-pack/plugins/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/common/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/shared/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/__mocks__/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/lib/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/__mocks__/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/lib/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/routes/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/test/functional_enterprise_search/ @elastic/enterprise-search-frontend
# App Search
/x-pack/plugins/enterprise_search/public/applications/app_search/ @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/routes/app_search/ @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/app_search/ @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/app_search/ @elastic/app-search-frontend
# Workplace Search
/x-pack/plugins/enterprise_search/public/applications/workplace_search/ @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/routes/workplace_search/ @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/workplace_search/ @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/workplace_search/ @elastic/workplace-search-frontend

# Elasticsearch UI
/src/plugins/dev_tools/ @elastic/es-ui
4 changes: 4 additions & 0 deletions src/plugins/charts/README.md
Original file line number Diff line number Diff line change
@@ -27,3 +27,7 @@ Truncated color mappings in `value`/`text` form
## Theme

See Theme service [docs](public/services/theme/README.md)

## Palettes

See palette service [docs](public/services/palettes/README.md)
33 changes: 33 additions & 0 deletions src/plugins/charts/public/services/palettes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Palette Service

The `palette` service offers a collection of palettes which implement a uniform interface for assigning colors to charts. The service provides methods for switching palettes
easily. It's used by the x-pack plugins `canvas` and `lens`.

Each palette is allowed to store some state as well which has to be handled by the consumer.

Palettes are integrated with the expression as well using the `system_palette` and `palette` functions.

## Using the palette service

To consume the palette service, use `charts.palettes.getPalettes` to lazily load the async bundle implementing existing palettes. This is recommended to be called in the renderer, not as part of the `setup` or `start` phases of a plugin.

All palette definitions can be loaded using `paletteService.getAll()`. If the id of the palette is known, it can be fetched using `paleteService.get(id)`.

One a palette is loaded, there are two ways to request colors - either by fetching a list of colors (`getColors`) or by specifying the chart object to be colored (`getColor`). If possible, using `getColor` is recommended because it allows the palette implementation to apply custom logic to coloring (e.g. lightening up colors or syncing colors) which has to be implemented by the consumer if `getColors` is used).

### SeriesLayer

If `getColor` is used, an array of `SeriesLayer` objects has to be passed in. These correspond with the current series in the chart a color has to be determined for. An array is necessary as some charts are constructed hierarchically (e.g. pie charts or treemaps). The array of objects represents the current series with all ancestors up to the corresponding root series. For each layer in the series hierarchy, the number of "sibling" series and the position of the current series has to be specified along with the name of the series.

## Custom palette

All palettes are stateless and define their own colors except for the `custom` palette which takes a state of the form
```ts
{ colors: string[]; gradient: boolean }
```

This state has to be passed into the `getColors` and `getColor` function to retrieve specific colors.

## Registering new palettes

Currently palettes can't be extended dynamically.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@ import { getTitle, ControlParams, CONTROL_TYPES, ControlParamsOptions } from '..
import { IIndexPattern } from '../../../../data/public';
import { InputControlVisDependencies } from '../../plugin';

import './control_editor.scss';

interface ControlEditorUiProps {
controlIndex: number;
controlParams: ControlParams;
Original file line number Diff line number Diff line change
@@ -21,16 +21,16 @@ import React from 'react';
import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
import { getDepsMock, getIndexPatternMock } from '../../test_utils';
import { ControlsTab, ControlsTabUiProps } from './controls_tab';
import ControlsTab, { ControlsTabProps } from './controls_tab';
import { Vis } from '../../../../visualizations/public';

const indexPatternsMock = {
get: getIndexPatternMock,
};
let props: ControlsTabUiProps;
let props: ControlsTabProps;

beforeEach(() => {
props = {
props = ({
deps: getDepsMock(),
vis: ({
API: {
@@ -78,18 +78,18 @@ beforeEach(() => {
},
setValue: jest.fn(),
intl: null as any,
};
} as unknown) as ControlsTabProps;
});

test('renders ControlsTab', () => {
const component = shallowWithIntl(<ControlsTab.WrappedComponent {...props} />);
const component = shallowWithIntl(<ControlsTab {...props} />);

expect(component).toMatchSnapshot();
});

describe('behavior', () => {
test('add control button', () => {
const component = mountWithIntl(<ControlsTab.WrappedComponent {...props} />);
const component = mountWithIntl(<ControlsTab {...props} />);

findTestSubject(component, 'inputControlEditorAddBtn').simulate('click');

@@ -102,7 +102,7 @@ describe('behavior', () => {
});

test('remove control button', () => {
const component = mountWithIntl(<ControlsTab.WrappedComponent {...props} />);
const component = mountWithIntl(<ControlsTab {...props} />);
findTestSubject(component, 'inputControlEditorRemoveControl0').simulate('click');
const expectedParams = [
'controls',
@@ -125,7 +125,7 @@ describe('behavior', () => {
});

test('move down control button', () => {
const component = mountWithIntl(<ControlsTab.WrappedComponent {...props} />);
const component = mountWithIntl(<ControlsTab {...props} />);
findTestSubject(component, 'inputControlEditorMoveDownControl0').simulate('click');
const expectedParams = [
'controls',
@@ -162,7 +162,7 @@ describe('behavior', () => {
});

test('move up control button', () => {
const component = mountWithIntl(<ControlsTab.WrappedComponent {...props} />);
const component = mountWithIntl(<ControlsTab {...props} />);
findTestSubject(component, 'inputControlEditorMoveUpControl1').simulate('click');
const expectedParams = [
'controls',
Original file line number Diff line number Diff line change
@@ -18,7 +18,8 @@
*/

import React, { PureComponent } from 'react';
import { injectI18n, FormattedMessage, InjectedIntlProps } from '@kbn/i18n/react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

import {
EuiButton,
@@ -44,22 +45,17 @@ import {
} from '../../editor_utils';
import { getLineageMap, getParentCandidates } from '../../lineage';
import { InputControlVisDependencies } from '../../plugin';
import { InputControlVisParams } from '../../types';

interface ControlsTabUiState {
type: CONTROL_TYPES;
}

interface ControlsTabUiParams {
controls: ControlParams[];
}
type ControlsTabUiInjectedProps = InjectedIntlProps &
Pick<VisOptionsProps<ControlsTabUiParams>, 'vis' | 'stateParams' | 'setValue'> & {
deps: InputControlVisDependencies;
};
export type ControlsTabProps = VisOptionsProps<InputControlVisParams> & {
deps: InputControlVisDependencies;
};

export type ControlsTabUiProps = ControlsTabUiInjectedProps;

class ControlsTabUi extends PureComponent<ControlsTabUiProps, ControlsTabUiState> {
class ControlsTab extends PureComponent<ControlsTabProps, ControlsTabUiState> {
state = {
type: CONTROL_TYPES.LIST,
};
@@ -161,8 +157,6 @@ class ControlsTabUi extends PureComponent<ControlsTabUiProps, ControlsTabUiState
}

render() {
const { intl } = this.props;

return (
<div>
{this.renderControls()}
@@ -176,25 +170,31 @@ class ControlsTabUi extends PureComponent<ControlsTabUiProps, ControlsTabUiState
options={[
{
value: CONTROL_TYPES.RANGE,
text: intl.formatMessage({
id: 'inputControl.editor.controlsTab.select.rangeDropDownOptionLabel',
defaultMessage: 'Range slider',
}),
text: i18n.translate(
'inputControl.editor.controlsTab.select.rangeDropDownOptionLabel',
{
defaultMessage: 'Range slider',
}
),
},
{
value: CONTROL_TYPES.LIST,
text: intl.formatMessage({
id: 'inputControl.editor.controlsTab.select.listDropDownOptionLabel',
defaultMessage: 'Options list',
}),
text: i18n.translate(
'inputControl.editor.controlsTab.select.listDropDownOptionLabel',
{
defaultMessage: 'Options list',
}
),
},
]}
value={this.state.type}
onChange={(event) => this.setState({ type: event.target.value as CONTROL_TYPES })}
aria-label={intl.formatMessage({
id: 'inputControl.editor.controlsTab.select.controlTypeAriaLabel',
defaultMessage: 'Select control type',
})}
aria-label={i18n.translate(
'inputControl.editor.controlsTab.select.controlTypeAriaLabel',
{
defaultMessage: 'Select control type',
}
)}
/>
</EuiFormRow>
</EuiFlexItem>
@@ -205,10 +205,12 @@ class ControlsTabUi extends PureComponent<ControlsTabUiProps, ControlsTabUiState
onClick={this.handleAddControl}
iconType="plusInCircle"
data-test-subj="inputControlEditorAddBtn"
aria-label={intl.formatMessage({
id: 'inputControl.editor.controlsTab.select.addControlAriaLabel',
defaultMessage: 'Add control',
})}
aria-label={i18n.translate(
'inputControl.editor.controlsTab.select.addControlAriaLabel',
{
defaultMessage: 'Add control',
}
)}
>
<FormattedMessage
id="inputControl.editor.controlsTab.addButtonLabel"
@@ -224,8 +226,6 @@ class ControlsTabUi extends PureComponent<ControlsTabUiProps, ControlsTabUiState
}
}

export const ControlsTab = injectI18n(ControlsTabUi);

export const getControlsTab = (deps: InputControlVisDependencies) => (
props: Omit<ControlsTabUiProps, 'core'>
) => <ControlsTab {...props} deps={deps} />;
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { ControlsTab as default };
34 changes: 34 additions & 0 deletions src/plugins/input_control_vis/public/components/editor/index.tsx
Original file line number Diff line number Diff line change
@@ -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 React, { lazy } from 'react';
import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import { InputControlVisDependencies } from '../../plugin';
import { InputControlVisParams } from '../../types';

const ControlsTab = lazy(() => import('./controls_tab'));
const OptionsTab = lazy(() => import('./options_tab'));

export const getControlsTab = (deps: InputControlVisDependencies) => (
props: VisOptionsProps<InputControlVisParams>
) => <ControlsTab {...props} deps={deps} />;

export const OptionsTabLazy = (props: VisOptionsProps<InputControlVisParams>) => (
<OptionsTab {...props} />
);
Original file line number Diff line number Diff line change
@@ -22,21 +22,21 @@ import { shallow } from 'enzyme';
import { mountWithIntl } from '@kbn/test/jest';

import { Vis } from '../../../../visualizations/public';
import { OptionsTab, OptionsTabProps } from './options_tab';
import OptionsTab, { OptionsTabProps } from './options_tab';

describe('OptionsTab', () => {
let props: OptionsTabProps;

beforeEach(() => {
props = {
props = ({
vis: {} as Vis,
stateParams: {
updateFiltersOnChange: false,
useTimeFilter: false,
pinFilters: false,
},
setValue: jest.fn(),
};
} as unknown) as OptionsTabProps;
});

it('should renders OptionsTab', () => {
Original file line number Diff line number Diff line change
@@ -24,20 +24,11 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSwitchEvent } from '@elastic/eui';

import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import { InputControlVisParams } from '../../types';

interface OptionsTabParams {
updateFiltersOnChange: boolean;
useTimeFilter: boolean;
pinFilters: boolean;
}
type OptionsTabInjectedProps = Pick<
VisOptionsProps<OptionsTabParams>,
'vis' | 'setValue' | 'stateParams'
>;

export type OptionsTabProps = OptionsTabInjectedProps;
export type OptionsTabProps = VisOptionsProps<InputControlVisParams>;

export class OptionsTab extends PureComponent<OptionsTabProps> {
class OptionsTab extends PureComponent<OptionsTabProps> {
handleUpdateFiltersChange = (event: EuiSwitchEvent) => {
this.props.setValue('updateFiltersOnChange', event.target.checked);
};
@@ -98,3 +89,6 @@ export class OptionsTab extends PureComponent<OptionsTabProps> {
);
}
}
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { OptionsTab as default };
Loading

0 comments on commit a27f803

Please sign in to comment.