-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Canvas] Add Lens embeddables #57499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9ed756a
Added lens embeddables to embed flyout
cqliu1 a38229d
Added i18n strings for savedLens
cqliu1 b7da603
Added tests for lens embeddables
cqliu1 d218646
Updated tests
cqliu1 56e4ba7
Updated tests
cqliu1 02c9b51
Added style overrides for lens table
cqliu1 1f4cdbb
DDisables triggers on lens emebeddable
cqliu1 3c96ef7
Updated test
cqliu1 3e31039
Sets embeddable view mode according to app state
cqliu1 ae51ec5
Fix embeddable component
cqliu1 d6d43ed
Removed embeddable view mode logic
cqliu1 533eead
Removed unused import
cqliu1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/saved_lens.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| }); | ||
| }); |
83 changes: 83 additions & 0 deletions
83
x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/saved_lens.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }; | ||
| }, | ||
| }; | ||
| } |
33 changes: 33 additions & 0 deletions
33
x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
x-pack/legacy/plugins/canvas/i18n/functions/dict/saved_lens.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * 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 { i18n } from '@kbn/i18n'; | ||
| import { savedLens } from '../../../canvas_plugin_src/functions/common/saved_lens'; | ||
| import { FunctionHelp } from '../function_help'; | ||
| import { FunctionFactory } from '../../../types'; | ||
|
|
||
| export const help: FunctionHelp<FunctionFactory<typeof savedLens>> = { | ||
| help: i18n.translate('xpack.canvas.functions.savedLensHelpText', { | ||
| defaultMessage: `Returns an embeddable for a saved lens object`, | ||
| }), | ||
| args: { | ||
| id: i18n.translate('xpack.canvas.functions.savedLens.args.idHelpText', { | ||
| defaultMessage: `The ID of the Saved Lens Object`, | ||
| }), | ||
| timerange: i18n.translate('xpack.canvas.functions.savedLens.args.timerangeHelpText', { | ||
| defaultMessage: `The timerange of data that should be included`, | ||
| }), | ||
| title: i18n.translate('xpack.canvas.functions.savedLens.args.titleHelpText', { | ||
| defaultMessage: `The title for the lens emebeddable`, | ||
| }), | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more of a @ryankeairns concern, but I think we should keep the border at least in edit mode. It feels weird having the gear hanging out in the top disconnected from everything, but the border at least boxes it in and gives you some clue that all of that is tied in together.