Skip to content

Commit

Permalink
Merge branch 'master' into ftr/find+findAll-on-webElementWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 20, 2020
2 parents 7e344a8 + 19f719c commit 0adfa57
Show file tree
Hide file tree
Showing 188 changed files with 7,463 additions and 844 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pr-project-assigner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
with:
issue-mappings: |
[
{ "label": "Team:AppArch", "projectNumber": 37, "columnName": "Review in progress" },
{ "label": "Feature:Lens", "projectNumber": 32, "columnName": "In progress" },
{ "label": "Team:Canvas", "projectNumber": 38, "columnName": "Review in progress" }
]
ghToken: ${{ secrets.GITHUB_TOKEN }}
ghToken: ${{ secrets.PROJECT_ASSIGNER_TOKEN }}

# { "label": "Team:AppArch", "projectNumber": 37, "columnName": "Review in progress" },
# { "label": "Feature:Lens", "projectNumber": 32, "columnName": "In progress" },
# { "label": "Team:Canvas", "projectNumber": 38, "columnName": "Review in progress" }
2 changes: 1 addition & 1 deletion .github/workflows/project-assigner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
id: project_assigner
with:
issue-mappings: '[{"label": "Team:AppArch", "projectNumber": 37, "columnName": "To triage"}, {"label": "Feature:Lens", "projectNumber": 32, "columnName": "Long-term goals"}, {"label": "Team:Canvas", "projectNumber": 38, "columnName": "Inbox"}]'
ghToken: ${{ secrets.GITHUB_TOKEN }}
ghToken: ${{ secrets.PROJECT_ASSIGNER_TOKEN }}


Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ interface State {
}

export class ValidatedDualRange extends Component<Props> {
static defaultProps: { fullWidth: boolean; allowEmptyRange: boolean; compressed: boolean };
static defaultProps: { fullWidth: boolean; allowEmptyRange: boolean; compressed: boolean } = {
allowEmptyRange: true,
fullWidth: false,
compressed: false,
};

static getDerivedStateFromProps(nextProps: Props, prevState: State) {
if (nextProps.value !== prevState.prevValue) {
Expand Down Expand Up @@ -125,9 +129,3 @@ export class ValidatedDualRange extends Component<Props> {
);
}
}

ValidatedDualRange.defaultProps = {
allowEmptyRange: true,
fullWidth: false,
compressed: false,
};
1 change: 1 addition & 0 deletions vars/kibanaPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def withGcsArtifactUpload(workerName, closure) {
def uploadPrefix = "kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/${workerName}"
def ARTIFACT_PATTERNS = [
'target/kibana-*',
'target/kibana-siem/**/*.png',
'target/junit/**/*',
'test/**/screenshots/**/*.png',
'test/functional/failure_debug/html/*.html',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"xpack.transform": "plugins/transform",
"xpack.triggersActionsUI": "plugins/triggers_actions_ui",
"xpack.upgradeAssistant": "plugins/upgrade_assistant",
"xpack.uptime": "legacy/plugins/uptime",
"xpack.uptime": ["plugins/uptime", "legacy/plugins/uptime"],
"xpack.watcher": "plugins/watcher"
},
"translations": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
// @ts-ignore
import { MAP_SAVED_OBJECT_TYPE } from '../../../maps/common/constants';
import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../../../../src/legacy/core_plugins/visualizations/public';
import { LENS_EMBEDDABLE_TYPE } from '../../../../../plugins/lens/common/constants';
import { SEARCH_EMBEDDABLE_TYPE } from '../../../../../../src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/constants';

export const EmbeddableTypes: { map: string; search: string; visualization: string } = {
export const EmbeddableTypes: {
lens: string;
map: string;
search: string;
visualization: string;
} = {
lens: LENS_EMBEDDABLE_TYPE,
map: MAP_SAVED_OBJECT_TYPE,
search: SEARCH_EMBEDDABLE_TYPE,
visualization: VISUALIZE_EMBEDDABLE_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ 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';
Expand Down Expand Up @@ -109,6 +110,7 @@ export const functions = [
revealImage,
rounddate,
rowCount,
savedLens,
savedMap,
savedSearch,
savedVisualization,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.
*/
jest.mock('ui/new_platform');
import { savedLens } from './saved_lens';
import { getQueryFilters } from '../../../public/lib/build_embeddable_filters';

const filterContext = {
and: [
{ and: [], value: 'filter-value', column: 'filter-column', type: 'exactly' },
{
and: [],
column: 'time-column',
type: 'time',
from: '2019-06-04T04:00:00.000Z',
to: '2019-06-05T04:00:00.000Z',
},
],
};

describe('savedLens', () => {
const fn = savedLens().fn;
const args = {
id: 'some-id',
title: null,
timerange: null,
};

it('accepts null context', () => {
const expression = fn(null, args, {} as any);

expect(expression.input.filters).toEqual([]);
});

it('accepts filter context', () => {
const expression = fn(filterContext, args, {} as any);
const embeddableFilters = getQueryFilters(filterContext.and);

expect(expression.input.filters).toEqual(embeddableFilters);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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 { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { TimeRange } from 'src/plugins/data/public';
import { EmbeddableInput } from 'src/legacy/core_plugins/embeddable_api/public/np_ready/public';
import { getQueryFilters } from '../../../public/lib/build_embeddable_filters';
import { Filter, TimeRange as TimeRangeArg } from '../../../types';
import {
EmbeddableTypes,
EmbeddableExpressionType,
EmbeddableExpression,
} from '../../expression_types';
import { getFunctionHelp } from '../../../i18n';
import { Filter as DataFilter } from '../../../../../../../src/plugins/data/public';

interface Arguments {
id: string;
title: string | null;
timerange: TimeRangeArg | null;
}

export type SavedLensInput = EmbeddableInput & {
id: string;
timeRange?: TimeRange;
filters: DataFilter[];
};

const defaultTimeRange = {
from: 'now-15m',
to: 'now',
};

type Return = EmbeddableExpression<SavedLensInput>;

export function savedLens(): ExpressionFunctionDefinition<
'savedLens',
Filter | null,
Arguments,
Return
> {
const { help, args: argHelp } = getFunctionHelp().savedLens;
return {
name: 'savedLens',
help,
args: {
id: {
types: ['string'],
required: false,
help: argHelp.id,
},
timerange: {
types: ['timerange'],
help: argHelp.timerange,
required: false,
},
title: {
types: ['string'],
help: argHelp.title,
required: false,
},
},
type: EmbeddableExpressionType,
fn: (context, args) => {
const filters = context ? context.and : [];

return {
type: EmbeddableExpressionType,
input: {
id: args.id,
filters: getQueryFilters(filters),
timeRange: args.timerange || defaultTimeRange,
title: args.title ? args.title : undefined,
disableTriggers: true,
},
embeddableType: EmbeddableTypes.lens,
};
},
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.canvasEmbeddable {
.embPanel {
border: none;
background: none;

.embPanel__title {
margin-bottom: $euiSizeXS;
}

.embPanel__optionsMenuButton {
border-radius: $euiBorderRadius;
}

.canvas-isFullscreen & {
.embPanel__optionsMenuButton {
opacity: 0;
}

&:focus .embPanel__optionsMenuButton,
&:hover .embPanel__optionsMenuButton {
opacity: 1;
}
}
}

.euiTable {
background: none;
}

.lnsExpressionRenderer {
@include euiScrollBar;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_a
import { EmbeddableExpression } from '../../expression_types/embeddable';
import { RendererStrings } from '../../../i18n';
import { getSavedObjectFinder } from '../../../../../../../src/plugins/saved_objects/public';

const { embeddable: strings } = RendererStrings;
import { embeddableInputToExpression } from './embeddable_input_to_expression';
import { EmbeddableInput } from '../../expression_types';
import { RendererHandlers } from '../../../types';
import { CANVAS_EMBEDDABLE_CLASSNAME } from '../../../common/lib';

const { embeddable: strings } = RendererStrings;

const embeddablesRegistry: {
[key: string]: IEmbeddable;
Expand All @@ -31,7 +32,7 @@ const embeddablesRegistry: {
const renderEmbeddable = (embeddableObject: IEmbeddable, domNode: HTMLElement) => {
return (
<div
className="embeddable"
className={CANVAS_EMBEDDABLE_CLASSNAME}
style={{ width: domNode.offsetWidth, height: domNode.offsetHeight, cursor: 'auto' }}
>
<I18nContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
jest.mock('ui/new_platform');
import { embeddableInputToExpression } from './embeddable_input_to_expression';
import { SavedMapInput } from '../../functions/common/saved_map';
import { SavedLensInput } from '../../functions/common/saved_lens';
import { EmbeddableTypes } from '../../expression_types';
import { fromExpression, Ast } from '@kbn/interpreter/common';

const baseSavedMapInput = {
const baseEmbeddableInput = {
id: 'embeddableId',
filters: [],
};

const baseSavedMapInput = {
...baseEmbeddableInput,
isLayerTOCOpen: false,
refreshConfig: {
isPaused: true,
Expand Down Expand Up @@ -73,4 +78,45 @@ describe('input to expression', () => {
expect(timerangeExpression.chain[0].arguments.to[0]).toEqual(input.timeRange?.to);
});
});

describe('Lens Embeddable', () => {
it('converts to a savedLens expression', () => {
const input: SavedLensInput = {
...baseEmbeddableInput,
};

const expression = embeddableInputToExpression(input, EmbeddableTypes.lens);
const ast = fromExpression(expression);

expect(ast.type).toBe('expression');
expect(ast.chain[0].function).toBe('savedLens');

expect(ast.chain[0].arguments.id).toStrictEqual([input.id]);

expect(ast.chain[0].arguments).not.toHaveProperty('title');
expect(ast.chain[0].arguments).not.toHaveProperty('timerange');
});

it('includes optional input values', () => {
const input: SavedLensInput = {
...baseEmbeddableInput,
title: 'title',
timeRange: {
from: 'now-1h',
to: 'now',
},
};

const expression = embeddableInputToExpression(input, EmbeddableTypes.map);
const ast = fromExpression(expression);

expect(ast.chain[0].arguments).toHaveProperty('title', [input.title]);
expect(ast.chain[0].arguments).toHaveProperty('timerange');

const timerangeExpression = ast.chain[0].arguments.timerange[0] as Ast;
expect(timerangeExpression.chain[0].function).toBe('timerange');
expect(timerangeExpression.chain[0].arguments.from[0]).toEqual(input.timeRange?.from);
expect(timerangeExpression.chain[0].arguments.to[0]).toEqual(input.timeRange?.to);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { EmbeddableTypes, EmbeddableInput } from '../../expression_types';
import { SavedMapInput } from '../../functions/common/saved_map';
import { SavedLensInput } from '../../functions/common/saved_lens';

/*
Take the input from an embeddable and the type of embeddable and convert it into an expression
Expand Down Expand Up @@ -46,5 +47,23 @@ export function embeddableInputToExpression(
}
}

if (embeddableType === EmbeddableTypes.lens) {
const lensInput = input as SavedLensInput;

expressionParts.push('savedLens');

expressionParts.push(`id="${input.id}"`);

if (input.title) {
expressionParts.push(`title="${input.title}"`);
}

if (lensInput.timeRange) {
expressionParts.push(
`timerange={timerange from="${lensInput.timeRange.from}" to="${lensInput.timeRange.to}"}`
);
}
}

return expressionParts.join(' ');
}
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/canvas/common/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export const API_ROUTE_SHAREABLE_BASE = '/public/canvas';
export const API_ROUTE_SHAREABLE_ZIP = '/public/canvas/zip';
export const API_ROUTE_SHAREABLE_RUNTIME = '/public/canvas/runtime';
export const API_ROUTE_SHAREABLE_RUNTIME_DOWNLOAD = `/public/canvas/${SHAREABLE_RUNTIME_NAME}.js`;
export const CANVAS_EMBEDDABLE_CLASSNAME = `canvasEmbeddable`;
Loading

0 comments on commit 0adfa57

Please sign in to comment.