-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lens embeddables to embed flyout
Fixed import embedded panel styles (#58654) Merging to WIP draft branch
- Loading branch information
Showing
9 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
101 changes: 101 additions & 0 deletions
101
x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/saved_lens.ts
This file contains 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,101 @@ | ||
/* | ||
* 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 { ExpressionFunction } from 'src/plugins/expressions/common/types'; | ||
import { TimeRange } from 'src/plugins/data/public'; | ||
import { EmbeddableInput } from 'src/legacy/core_plugins/embeddable_api/public/np_ready/public'; | ||
import { getQueryFilters } from '../../../server/lib/build_embeddable_filters'; | ||
import { Filter, MapCenter, TimeRange as TimeRangeArg } from '../../../types'; | ||
import { | ||
EmbeddableTypes, | ||
EmbeddableExpressionType, | ||
EmbeddableExpression, | ||
} from '../../expression_types'; | ||
import { getFunctionHelp } from '../../../i18n'; | ||
import { esFilters } from '../../../../../../../src/plugins/data/public'; | ||
|
||
interface Arguments { | ||
id: string; | ||
hideLayer: string[]; | ||
title: string | null; | ||
timerange: TimeRangeArg | null; | ||
} | ||
|
||
// Map embeddable is missing proper typings, so type is just to document what we | ||
// are expecting to pass to the embeddable | ||
export type SavedLensInput = EmbeddableInput & { | ||
id: string; | ||
isLayerTOCOpen: boolean; | ||
timeRange?: TimeRange; | ||
refreshConfig: { | ||
isPaused: boolean; | ||
interval: number; | ||
}; | ||
hideFilterActions: true; | ||
filters: esFilters.Filter[]; | ||
hiddenLayers?: string[]; | ||
}; | ||
|
||
const defaultTimeRange = { | ||
from: 'now-15m', | ||
to: 'now', | ||
}; | ||
|
||
type Return = EmbeddableExpression<SavedLensInput>; | ||
|
||
export function savedLens(): ExpressionFunction<'savedLens', Filter | null, Arguments, Return> { | ||
// TODO: update function help | ||
const { help, args: argHelp } = getFunctionHelp().savedMap; | ||
return { | ||
name: 'savedLens', | ||
help, | ||
args: { | ||
id: { | ||
types: ['string'], | ||
required: false, | ||
help: argHelp.id, | ||
}, | ||
hideLayer: { | ||
types: ['string'], | ||
help: argHelp.hideLayer, | ||
required: false, | ||
multi: true, | ||
}, | ||
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, | ||
refreshConfig: { | ||
isPaused: false, | ||
interval: 0, | ||
}, | ||
hideFilterActions: true, | ||
title: args.title ? args.title : undefined, | ||
isLayerTOCOpen: false, | ||
hiddenLayers: args.hideLayer || [], | ||
}, | ||
embeddableType: EmbeddableTypes.lens, | ||
}; | ||
}, | ||
}; | ||
} |
This file contains 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 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 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 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 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 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