Skip to content

Commit

Permalink
Merge branch 'master' into np/remote_clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Feb 10, 2020
2 parents 4c722fe + d31cf6a commit a658699
Show file tree
Hide file tree
Showing 48 changed files with 708 additions and 346 deletions.
36 changes: 31 additions & 5 deletions docs/canvas/canvas-elements.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ When you add elements to your workpad, you can:
[[add-canvas-element]]
=== Add elements to your workpad

Choose the elements to display on your workpad, then familiarize yourself with the element using the preconfigured demo data. By default, every element you add to a workpad uses demo data until you change the data source. The demo data includes a small sample data set that you can use to experiment with your element.
Choose the elements to display on your workpad, then familiarize yourself with the element using the preconfigured demo data. By default, most elements use demo data until you change the data source. The demo data includes a small sample data set that you can use to experiment with your element.

To add a Canvas element:

. Click *Add element*.

Expand All @@ -31,13 +33,26 @@ image::images/canvas-element-select.gif[Canvas elements]

. Play around with the default settings and see what the element can do.

TIP: Want to use a different element? You can delete the element by selecting it, clicking the *Element options* icon in the top right, then selecting *Delete*.
To add a map:

. Click *Embed object*.

. Select the map you want to add to the workpad.
+
[role="screenshot"]
image::images/canvas-map-embed.gif[]

NOTE: Demo data is only supported on Canvas elements. Maps do not support demo data.

Want to use a different element? You can delete the element by selecting it, clicking the *Element options* icon in the top right, then selecting *Delete*.

[float]
[[connect-element-data]]
=== Connect the element to your data
=== Connect the Canvas element to your data

When you have finished using the demo data, connect the element to a data source.
When you have finished using the demo data, connect the Canvas element to a data source.

NOTE: Maps do not support data sources. To change the map data, refer to <<maps, Elastic Maps>>.

. Make sure that the element is selected, then select *Data*.

Expand Down Expand Up @@ -142,7 +157,7 @@ text.align: center;
[[configure-auto-refresh-interval]]
==== Change the data auto-refresh interval

Increase or decrease how often your data refreshes on your workpad.
Increase or decrease how often your Canvas element data refreshes on your workpad.

. In the top left corner, click the *Control settings* icon.

Expand All @@ -153,6 +168,17 @@ image::images/canvas-refresh-interval.png[Element data refresh interval]

TIP: To manually refresh the data, click the *Refresh data* icon.

[float]
[[canvas-time-range]]
==== Customize map time ranges

Configure the maps on your workpad for a specific time range.

From the panel menu, select *Customize time range* to expose a time filter dedicated to the map.

[role="screenshot"]
image::images/canvas_map-time-filter.gif[]

[float]
[[organize-element]]
=== Organize the elements on your workpad
Expand Down
Binary file added docs/images/canvas-map-embed.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/canvas_map-time-filter.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

import { I18nStart, SavedObjectsStart, IUiSettingsClient, CoreStart } from 'src/core/public';
import { createGetterSetter } from '../../../../plugins/kibana_utils/public';
import { DataPublicPluginStart, FieldFormatsStart } from '../../../../plugins/data/public';
import { DataPublicPluginStart } from '../../../../plugins/data/public';

export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');

export const [getFieldFormats, setFieldFormats] = createGetterSetter<FieldFormatsStart>(
'FieldFormats'
);
export const [getFieldFormats, setFieldFormats] = createGetterSetter<
DataPublicPluginStart['fieldFormats']
>('FieldFormats');

export const [getSavedObjectsClient, setSavedObjectsClient] = createGetterSetter<SavedObjectsStart>(
'SavedObjectsClient'
Expand Down
11 changes: 4 additions & 7 deletions src/plugins/data/public/autocomplete/autocomplete_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@
*/

import { CoreSetup } from 'src/core/public';
import { QuerySuggestionsGetFn } from './providers/query_suggestion_provider';
import { QuerySuggestionGetFn } from './providers/query_suggestion_provider';
import {
setupValueSuggestionProvider,
ValueSuggestionsGetFn,
} from './providers/value_suggestion_provider';

export class AutocompleteService {
private readonly querySuggestionProviders: Map<string, QuerySuggestionsGetFn> = new Map();
private readonly querySuggestionProviders: Map<string, QuerySuggestionGetFn> = new Map();
private getValueSuggestions?: ValueSuggestionsGetFn;

private addQuerySuggestionProvider = (
language: string,
provider: QuerySuggestionsGetFn
): void => {
private addQuerySuggestionProvider = (language: string, provider: QuerySuggestionGetFn): void => {
if (language && provider) {
this.querySuggestionProviders.set(language, provider);
}
};

private getQuerySuggestions: QuerySuggestionsGetFn = args => {
private getQuerySuggestions: QuerySuggestionGetFn = args => {
const { language } = args;
const provider = this.querySuggestionProviders.get(language);

Expand Down
13 changes: 10 additions & 3 deletions src/plugins/data/public/autocomplete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
import * as autocomplete from './static';
export { AutocompleteService, AutocompleteSetup, AutocompleteStart } from './autocomplete_service';

export { autocomplete };
export {
QuerySuggestion,
QuerySuggestionTypes,
QuerySuggestionGetFn,
QuerySuggestionGetFnArgs,
QuerySuggestionBasic,
QuerySuggestionField,
} from './providers/query_suggestion_provider';

export { AutocompleteService, AutocompleteSetup, AutocompleteStart } from './autocomplete_service';
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@

import { IFieldType, IIndexPattern } from '../../../common/index_patterns';

export enum QuerySuggestionsTypes {
export enum QuerySuggestionTypes {
Field = 'field',
Value = 'value',
Operator = 'operator',
Conjunction = 'conjunction',
RecentSearch = 'recentSearch',
}

export type QuerySuggestionsGetFn = (
args: QuerySuggestionsGetFnArgs
export type QuerySuggestionGetFn = (
args: QuerySuggestionGetFnArgs
) => Promise<QuerySuggestion[]> | undefined;

/** @public **/
export interface QuerySuggestionsGetFnArgs {
export interface QuerySuggestionGetFnArgs {
language: string;
indexPatterns: IIndexPattern[];
query: string;
Expand All @@ -43,8 +43,8 @@ export interface QuerySuggestionsGetFnArgs {
}

/** @public **/
export interface BasicQuerySuggestion {
type: QuerySuggestionsTypes;
export interface QuerySuggestionBasic {
type: QuerySuggestionTypes;
description?: string | JSX.Element;
end: number;
start: number;
Expand All @@ -53,10 +53,10 @@ export interface BasicQuerySuggestion {
}

/** @public **/
export interface FieldQuerySuggestion extends BasicQuerySuggestion {
type: QuerySuggestionsTypes.Field;
export interface QuerySuggestionField extends QuerySuggestionBasic {
type: QuerySuggestionTypes.Field;
field: IFieldType;
}

/** @public **/
export type QuerySuggestion = BasicQuerySuggestion | FieldQuerySuggestion;
export type QuerySuggestion = QuerySuggestionBasic | QuerySuggestionField;
27 changes: 0 additions & 27 deletions src/plugins/data/public/autocomplete/static.ts

This file was deleted.

12 changes: 11 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,17 @@ export {
FieldFormatConfig,
FieldFormatId,
} from '../common';
export { autocomplete } from './autocomplete';

export {
QuerySuggestion,
QuerySuggestionTypes,
QuerySuggestionGetFn,
QuerySuggestionGetFnArgs,
QuerySuggestionBasic,
QuerySuggestionField,
} from './autocomplete';

export * from './field_formats';
export * from './index_patterns';
export * from './search';
export * from './query';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { InjectedIntl, injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { debounce, compact, isEqual } from 'lodash';
import { Toast } from 'src/core/public';
import {
autocomplete,
IDataPluginServices,
IIndexPattern,
PersistedLog,
Expand All @@ -46,6 +45,8 @@ import {
getQueryLog,
Query,
} from '../..';
import { QuerySuggestion, QuerySuggestionTypes } from '../../autocomplete';

import { withKibana, KibanaReactContextValue, toMountPoint } from '../../../../kibana_react/public';
import { fetchIndexPatterns } from './fetch_index_patterns';
import { QueryLanguageSwitcher } from './language_switcher';
Expand All @@ -70,7 +71,7 @@ interface Props {
interface State {
isSuggestionsVisible: boolean;
index: number | null;
suggestions: autocomplete.QuerySuggestion[];
suggestions: QuerySuggestion[];
suggestionLimit: number;
selectionStart: number | null;
selectionEnd: number | null;
Expand Down Expand Up @@ -191,7 +192,7 @@ export class QueryStringInputUI extends Component<Props, State> {
const text = toUser(recentSearch);
const start = 0;
const end = query.length;
return { type: autocomplete.QuerySuggestionsTypes.RecentSearch, text, start, end };
return { type: QuerySuggestionTypes.RecentSearch, text, start, end };
});
};

Expand Down Expand Up @@ -317,7 +318,7 @@ export class QueryStringInputUI extends Component<Props, State> {
}
};

private selectSuggestion = (suggestion: autocomplete.QuerySuggestion) => {
private selectSuggestion = (suggestion: QuerySuggestion) => {
if (!this.inputRef) {
return;
}
Expand All @@ -341,13 +342,13 @@ export class QueryStringInputUI extends Component<Props, State> {
selectionEnd: start + (cursorIndex ? cursorIndex : text.length),
});

if (type === autocomplete.QuerySuggestionsTypes.RecentSearch) {
if (type === QuerySuggestionTypes.RecentSearch) {
this.setState({ isSuggestionsVisible: false, index: null });
this.onSubmit({ query: newQueryString, language: this.props.query.language });
}
};

private handleNestedFieldSyntaxNotification = (suggestion: autocomplete.QuerySuggestion) => {
private handleNestedFieldSyntaxNotification = (suggestion: QuerySuggestion) => {
if (
'field' in suggestion &&
suggestion.field.subType &&
Expand Down Expand Up @@ -449,7 +450,7 @@ export class QueryStringInputUI extends Component<Props, State> {
}
};

private onClickSuggestion = (suggestion: autocomplete.QuerySuggestion) => {
private onClickSuggestion = (suggestion: QuerySuggestion) => {
if (!this.inputRef) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@

import { mount, shallow } from 'enzyme';
import React from 'react';
import { autocomplete } from '../..';
import { QuerySuggestion, QuerySuggestionTypes } from '../../autocomplete';
import { SuggestionComponent } from './suggestion_component';

const noop = () => {
return;
};

const mockSuggestion: autocomplete.QuerySuggestion = {
const mockSuggestion: QuerySuggestion = {
description: 'This is not a helpful suggestion',
end: 0,
start: 42,
text: 'as promised, not helpful',
type: autocomplete.QuerySuggestionsTypes.Value,
type: QuerySuggestionTypes.Value,
};

describe('SuggestionComponent', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/data/public/ui/typeahead/suggestion_component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { EuiIcon } from '@elastic/eui';
import classNames from 'classnames';
import React, { FunctionComponent } from 'react';
import { autocomplete } from '../..';
import { QuerySuggestion } from '../../autocomplete';

function getEuiIconType(type: string) {
switch (type) {
Expand All @@ -40,10 +40,10 @@ function getEuiIconType(type: string) {
}

interface Props {
onClick: (suggestion: autocomplete.QuerySuggestion) => void;
onClick: (suggestion: QuerySuggestion) => void;
onMouseEnter: () => void;
selected: boolean;
suggestion: autocomplete.QuerySuggestion;
suggestion: QuerySuggestion;
innerRef: (node: HTMLDivElement) => void;
ariaId: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@

import { mount, shallow } from 'enzyme';
import React from 'react';
import { autocomplete } from '../..';
import { QuerySuggestion, QuerySuggestionTypes } from '../../autocomplete';
import { SuggestionComponent } from './suggestion_component';
import { SuggestionsComponent } from './suggestions_component';

const noop = () => {
return;
};

const mockSuggestions: autocomplete.QuerySuggestion[] = [
const mockSuggestions: QuerySuggestion[] = [
{
description: 'This is not a helpful suggestion',
end: 0,
start: 42,
text: 'as promised, not helpful',
type: autocomplete.QuerySuggestionsTypes.Value,
type: QuerySuggestionTypes.Value,
},
{
description: 'This is another unhelpful suggestion',
end: 0,
start: 42,
text: 'yep',
type: autocomplete.QuerySuggestionsTypes.Field,
type: QuerySuggestionTypes.Field,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

import { isEmpty } from 'lodash';
import React, { Component } from 'react';
import { autocomplete } from '../..';
import { QuerySuggestion } from '../..';
import { SuggestionComponent } from './suggestion_component';

interface Props {
index: number | null;
onClick: (suggestion: autocomplete.QuerySuggestion) => void;
onClick: (suggestion: QuerySuggestion) => void;
onMouseEnter: (index: number) => void;
show: boolean;
suggestions: autocomplete.QuerySuggestion[];
suggestions: QuerySuggestion[];
loadMore: () => void;
}

Expand Down
Loading

0 comments on commit a658699

Please sign in to comment.