Skip to content

Commit

Permalink
Merge branch 'master' into component-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 21, 2020
2 parents aa19c26 + 8d5a5d0 commit 3f1f5bd
Show file tree
Hide file tree
Showing 63 changed files with 414 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
*/

import { functions as commonFunctions } from '../common';
import { functions as externalFunctions } from '../external';
import { location } from './location';
import { markdown } from './markdown';
import { urlparam } from './urlparam';

export const functions = [location, markdown, urlparam, ...commonFunctions];
export const functions = [location, markdown, urlparam, ...commonFunctions, ...externalFunctions];
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ import { rounddate } from './rounddate';
import { rowCount } from './rowCount';
import { repeatImage } from './repeatImage';
import { revealImage } from './revealImage';
import { savedLens } from './saved_lens';
import { savedMap } from './saved_map';
import { savedSearch } from './saved_search';
import { savedVisualization } from './saved_visualization';
import { seriesStyle } from './seriesStyle';
import { shape } from './shape';
import { sort } from './sort';
Expand Down Expand Up @@ -110,10 +106,6 @@ export const functions = [
revealImage,
rounddate,
rowCount,
savedLens,
savedMap,
savedSearch,
savedVisualization,
seriesStyle,
shape,
sort,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { savedLens } from './saved_lens';
import { savedMap } from './saved_map';
import { savedSearch } from './saved_search';
import { savedVisualization } from './saved_visualization';

export const functions = [savedLens, savedMap, savedSearch, savedVisualization];
37 changes: 37 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/renderers/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { debug } from './debug';
import { error } from './error';
import { image } from './image';
import { markdown } from './markdown';
import { metric } from './metric';
import { pie } from './pie';
import { plot } from './plot';
import { progress } from './progress';
import { repeatImage } from './repeat_image';
import { revealImage } from './reveal_image';
import { shape } from './shape';
import { table } from './table';
import { text } from './text';

export const renderFunctions = [
debug,
error,
image,
markdown,
metric,
pie,
plot,
progress,
repeatImage,
revealImage,
shape,
table,
text,
];

export const renderFunctionFactories = [];
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { embeddableRendererFactory } from './embeddable';

export const renderFunctions = [];
export const renderFunctionFactories = [embeddableRendererFactory];
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { toExpression } from './lens';
import { SavedLensInput } from '../../../functions/common/saved_lens';
import { SavedLensInput } from '../../../functions/external/saved_lens';
import { fromExpression, Ast } from '@kbn/interpreter/common';

const baseEmbeddableInput = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedLensInput } from '../../../functions/common/saved_lens';
import { SavedLensInput } from '../../../functions/external/saved_lens';

export function toExpression(input: SavedLensInput): string {
const expressionParts = [] as string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import PropTypes from 'prop-types';
import React, { FunctionComponent } from 'react';
import { ComponentStrings } from '../../../../i18n';
import { ComponentStrings } from '../../../../../i18n';

const { AdvancedFilter: strings } = ComponentStrings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { RendererFactory } from '../../../types';
import { RendererFactory } from '../../../../types';
import { AdvancedFilter } from './component';
import { RendererStrings } from '../../../i18n';
import { RendererStrings } from '../../../../i18n';

const { advancedFilter: strings } = RendererStrings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { EuiIcon } from '@elastic/eui';
import PropTypes from 'prop-types';
import React, { ChangeEvent, FocusEvent, FunctionComponent } from 'react';
import { ComponentStrings } from '../../../../i18n';
import { ComponentStrings } from '../../../../../i18n';

const { DropdownFilter: strings } = ComponentStrings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { fromExpression, toExpression, Ast } from '@kbn/interpreter/common';
import { get } from 'lodash';
import React from 'react';
import ReactDOM from 'react-dom';
import { syncFilterExpression } from '../../../public/lib/sync_filter_expression';
import { RendererFactory } from '../../../types';
import { syncFilterExpression } from '../../../../public/lib/sync_filter_expression';
import { RendererFactory } from '../../../../types';
import { DropdownFilter } from './component';
import { RendererStrings } from '../../../i18n';
import { RendererStrings } from '../../../../i18n';

const { dropdownFilter: strings } = RendererStrings;

Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { advancedFilter } from './advanced_filter';
import { dropdownFilter } from './dropdown_filter';
import { timeFilterFactory } from './time_filter';

export const renderFunctions = [advancedFilter, dropdownFilter];
export const renderFunctionFactories = [timeFilterFactory];
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TimeFilter } from './time_filter';

export { TimeFilter };
export { TimeFilter } from './time_filter';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { get } from 'lodash';
import { fromExpression } from '@kbn/interpreter/common';
import { UnitStrings } from '../../../../i18n/units';
import { UnitStrings } from '../../../../../i18n/units';

const { quickRanges: strings } = UnitStrings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import ReactDOM from 'react-dom';
import React from 'react';
import { toExpression } from '@kbn/interpreter/common';
import { UI_SETTINGS } from '../../../../../../src/plugins/data/public';
import { syncFilterExpression } from '../../../public/lib/sync_filter_expression';
import { RendererStrings } from '../../../i18n';
import { UI_SETTINGS } from '../../../../../../../src/plugins/data/public';
import { syncFilterExpression } from '../../../../public/lib/sync_filter_expression';
import { RendererStrings } from '../../../../i18n';
import { TimeFilter } from './components';
import { StartInitializer } from '../../plugin';
import { RendererHandlers } from '../../../types';
import { Arguments } from '../../functions/common/timefilterControl';
import { RendererFactory } from '../../../types';
import { StartInitializer } from '../../../plugin';
import { RendererHandlers } from '../../../../types';
import { Arguments } from '../../../functions/common/timefilterControl';
import { RendererFactory } from '../../../../types';

const { timeFilter: strings } = RendererStrings;

Expand Down
51 changes: 16 additions & 35 deletions x-pack/plugins/canvas/canvas_plugin_src/renderers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,21 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { advancedFilter } from './advanced_filter';
import { debug } from './debug';
import { dropdownFilter } from './dropdown_filter';
import { embeddableRendererFactory } from './embeddable/embeddable';
import { error } from './error';
import { image } from './image';
import { markdown } from './markdown';
import { metric } from './metric';
import { pie } from './pie';
import { plot } from './plot';
import { progress } from './progress';
import { repeatImage } from './repeat_image';
import { revealImage } from './reveal_image';
import { shape } from './shape';
import { table } from './table';
import { text } from './text';
import { timeFilterFactory } from './time_filter';
import {
renderFunctions as embeddableFunctions,
renderFunctionFactories as embeddableFactories,
} from './embeddable';

export const renderFunctions = [
advancedFilter,
debug,
dropdownFilter,
error,
image,
markdown,
metric,
pie,
plot,
progress,
repeatImage,
revealImage,
shape,
table,
text,
];
import {
renderFunctions as filterFunctions,
renderFunctionFactories as filterFactories,
} from './filters';

import { renderFunctions as coreFunctions, renderFunctionFactories as coreFactories } from './core';

export const renderFunctionFactories = [embeddableRendererFactory, timeFilterFactory];
export const renderFunctions = [...coreFunctions, ...filterFunctions, ...embeddableFunctions];
export const renderFunctionFactories = [
...coreFactories,
...embeddableFactories,
...filterFactories,
];
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/i18n/functions/dict/saved_lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import { savedLens } from '../../../canvas_plugin_src/functions/common/saved_lens';
import { savedLens } from '../../../canvas_plugin_src/functions/external/saved_lens';
import { FunctionHelp } from '../function_help';
import { FunctionFactory } from '../../../types';

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/i18n/functions/dict/saved_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import { savedMap } from '../../../canvas_plugin_src/functions/common/saved_map';
import { savedMap } from '../../../canvas_plugin_src/functions/external/saved_map';
import { FunctionHelp } from '../function_help';
import { FunctionFactory } from '../../../types';

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/i18n/functions/dict/saved_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import { savedSearch } from '../../../canvas_plugin_src/functions/common/saved_search';
import { savedSearch } from '../../../canvas_plugin_src/functions/external/saved_search';
import { FunctionHelp } from '../function_help';
import { FunctionFactory } from '../../../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import { savedVisualization } from '../../../canvas_plugin_src/functions/common/saved_visualization';
import { savedVisualization } from '../../../canvas_plugin_src/functions/external/saved_visualization';
import { FunctionHelp } from '../function_help';
import { FunctionFactory } from '../../../types';

Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/canvas/public/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
@import '../components/workpad_page/workpad_interactive_page/workpad_interactive_page';
@import '../components/workpad_page/workpad_static_page/workpad_static_page';

@import '../../canvas_plugin_src/renderers/advanced_filter/component/advanced_filter.scss';
@import '../../canvas_plugin_src/renderers/dropdown_filter/component/dropdown_filter.scss';
@import '../../canvas_plugin_src/renderers/filters/advanced_filter/component/advanced_filter.scss';
@import '../../canvas_plugin_src/renderers/filters/dropdown_filter/component/dropdown_filter.scss';
@import '../../canvas_plugin_src/renderers/embeddable/embeddable.scss';
@import '../../canvas_plugin_src/renderers/plot/plot.scss';
@import '../../canvas_plugin_src/renderers/reveal_image/reveal_image.scss';
@import '../../canvas_plugin_src/renderers/time_filter/time_filter.scss';
@import '../../canvas_plugin_src/renderers/filters/time_filter/time_filter.scss';
@import '../../canvas_plugin_src/uis/arguments/image_upload/image_upload.scss';
9 changes: 8 additions & 1 deletion x-pack/plugins/canvas/types/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { functions as commonFunctions } from '../canvas_plugin_src/functions/common';
import { functions as browserFunctions } from '../canvas_plugin_src/functions/browser';
import { functions as serverFunctions } from '../canvas_plugin_src/functions/server';
import { functions as externalFunctions } from '../canvas_plugin_src/functions/external';
import { initFunctions } from '../public/functions';

/**
Expand Down Expand Up @@ -87,6 +88,7 @@ export type FunctionFactory<FnFactory> =
type CommonFunction = FunctionFactory<typeof commonFunctions[number]>;
type BrowserFunction = FunctionFactory<typeof browserFunctions[number]>;
type ServerFunction = FunctionFactory<typeof serverFunctions[number]>;
type ExternalFunction = FunctionFactory<typeof externalFunctions[number]>;
type ClientFunctions = FunctionFactory<
ReturnType<typeof initFunctions> extends Array<infer U> ? U : never
>;
Expand All @@ -95,7 +97,12 @@ type ClientFunctions = FunctionFactory<
* A collection of all Canvas Functions.
*/

export type CanvasFunction = CommonFunction | BrowserFunction | ServerFunction | ClientFunctions;
export type CanvasFunction =
| CommonFunction
| BrowserFunction
| ServerFunction
| ExternalFunction
| ClientFunctions;

/**
* Represents a function called by the `case` Function.
Expand Down
32 changes: 32 additions & 0 deletions x-pack/plugins/lists/public/common/hooks/use_async.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,36 @@ describe('useAsync', () => {

expect(result.current.loading).toBe(false);
});

it('multiple start calls reset state', async () => {
let resolve: (result: string) => void;
fn.mockImplementation(() => new Promise((_resolve) => (resolve = _resolve)));

const { result, waitForNextUpdate } = renderHook(() => useAsync(fn));

act(() => {
result.current.start(args);
});

expect(result.current.loading).toBe(true);

act(() => resolve('result'));
await waitForNextUpdate();

expect(result.current.loading).toBe(false);
expect(result.current.result).toBe('result');

act(() => {
result.current.start(args);
});

expect(result.current.loading).toBe(true);
expect(result.current.result).toBe(undefined);

act(() => resolve('result'));
await waitForNextUpdate();

expect(result.current.loading).toBe(false);
expect(result.current.result).toBe('result');
});
});
2 changes: 2 additions & 0 deletions x-pack/plugins/lists/public/common/hooks/use_async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const useAsync = <Args extends unknown[], Result>(
const start = useCallback(
(...args: Args) => {
setLoading(true);
setResult(undefined);
setError(undefined);
fn(...args)
.then((r) => isMounted() && setResult(r))
.catch((e) => isMounted() && setError(e))
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/security_solution/common/endpoint/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export const alertsIndexPattern = 'logs-endpoint.alerts-*';
export const metadataIndexPattern = 'metrics-endpoint.metadata-*';
export const policyIndexPattern = 'metrics-endpoint.policy-*';
export const telemetryIndexPattern = 'metrics-endpoint.telemetry-*';
export const LIMITED_CONCURRENCY_ENDPOINT_ROUTE_TAG = 'endpoint:limited-concurrency';
export const LIMITED_CONCURRENCY_ENDPOINT_COUNT = 100;
Loading

0 comments on commit 3f1f5bd

Please sign in to comment.