[Canvas] Move expressions used in Canvas only back into Canvas plugin (#214993)

## Summary

Closes [214026](https://github.com/elastic/kibana/issues/214026).

This deletes the following expression plugins/package and moves the code
back into Canvas because they are functions and renderers used
exclusively by Canvas:
- `expression_image`
- `expression_error`
- `expression_repeat_image`
- `expression_reveal_image`
- `expression_shape`
- `kbn-expression-utils`

This reduces the number of plugins loaded on Kibana start and will only
load these functions when using Canvas.

To test, import these Canvas workpad saved objects to enable Canvas:

[test-workpads.ndjson.zip](https://github.com/user-attachments/files/19766567/test-workpads.ndjson.zip)

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Catherine Liu 2025-04-16 13:42:21 -07:00 committed by GitHub
parent a70226ab92
commit a015e5f9f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
314 changed files with 2304 additions and 4423 deletions

7
.github/CODEOWNERS vendored
View file

@ -317,7 +317,6 @@ src/platform/packages/private/kbn-ci-stats-reporter @elastic/kibana-operations
src/platform/packages/private/kbn-code-owners @elastic/appex-qa
src/platform/packages/private/kbn-config-mocks @elastic/kibana-core
src/platform/packages/private/kbn-esql-editor @elastic/kibana-esql
src/platform/packages/private/kbn-expression-utils @elastic/kibana-presentation
src/platform/packages/private/kbn-ftr-screenshot-filename @elastic/kibana-operations @elastic/appex-qa
src/platform/packages/private/kbn-gen-ai-functional-testing @elastic/appex-ai-infra
src/platform/packages/private/kbn-generate-csv @elastic/response-ops
@ -677,12 +676,6 @@ src/platform/plugins/shared/embeddable @elastic/kibana-presentation
src/platform/plugins/shared/es_ui_shared @elastic/kibana-management
src/platform/plugins/shared/esql @elastic/kibana-esql
src/platform/plugins/shared/esql_datagrid @elastic/kibana-esql
src/platform/plugins/shared/expression_error @elastic/kibana-presentation
src/platform/plugins/shared/expression_image @elastic/kibana-presentation
src/platform/plugins/shared/expression_metric @elastic/kibana-presentation
src/platform/plugins/shared/expression_repeat_image @elastic/kibana-presentation
src/platform/plugins/shared/expression_reveal_image @elastic/kibana-presentation
src/platform/plugins/shared/expression_shape @elastic/kibana-presentation
src/platform/plugins/shared/expressions @elastic/kibana-visualizations
src/platform/plugins/shared/field_formats @elastic/kibana-data-discovery
src/platform/plugins/shared/files @elastic/appex-sharedux

View file

@ -38,19 +38,13 @@
"kbnGridLayout": "src/platform/packages/private/kbn-grid-layout",
"esUi": "src/platform/plugins/shared/es_ui_shared",
"expandableFlyout": "packages/kbn-expandable-flyout",
"expressionError": "src/platform/plugins/shared/expression_error",
"expressionGauge": "src/platform/plugins/shared/chart_expressions/expression_gauge",
"expressionHeatmap": "src/platform/plugins/shared/chart_expressions/expression_heatmap",
"expressionImage": "src/platform/plugins/shared/expression_image",
"expressionMetric": "src/platform/plugins/shared/expression_metric",
"expressionMetricVis": "src/platform/plugins/shared/chart_expressions/expression_metric",
"expressionLegacyMetricVis": "src/platform/plugins/shared/chart_expressions/expression_legacy_metric",
"expressionPartitionVis": "src/platform/plugins/shared/chart_expressions/expression_partition_vis",
"expressionXY": "src/platform/plugins/shared/chart_expressions/expression_xy",
"expressionRepeatImage": "src/platform/plugins/shared/expression_repeat_image",
"expressionRevealImage": "src/platform/plugins/shared/expression_reveal_image",
"expressions": "src/platform/plugins/shared/expressions",
"expressionShape": "src/platform/plugins/shared/expression_shape",
"expressionTagcloud": "src/platform/plugins/shared/chart_expressions/expression_tagcloud",
"eventAnnotation": "src/platform/plugins/private/event_annotation",
"eventAnnotationListing": "src/platform/plugins/private/event_annotation_listing",

View file

@ -39,18 +39,12 @@ mapped_pages:
| [esUiShared](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/es_ui_shared/README.md) | This plugin contains reusable code in the form of self-contained modules (or libraries). Each of these modules exports a set of functionality relevant to the domain of the module. |
| [eventAnnotation](https://github.com/elastic/kibana/blob/main/src/platform/plugins/private/event_annotation/README.md) | The Event Annotation service contains expressions for event annotations |
| [eventAnnotationListing](https://github.com/elastic/kibana/blob/main/src/platform/plugins/private/event_annotation_listing/README.md) | This plugin contains the library listing page for event annotation groups. |
| [expressionError](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/expression_error/README.md) | Expression Error plugin adds an error renderer to the expression plugin. The renderer will display the error image. |
| [expressionGauge](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/chart_expressions/expression_gauge) | WARNING: Missing or empty README. |
| [expressionHeatmap](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/chart_expressions/expression_heatmap) | WARNING: Missing or empty README. |
| [expressionImage](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/expression_image/README.md) | Expression Image plugin adds an image renderer to the expression plugin. The renderer will display the given image. |
| [expressionLegacyMetricVis](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/chart_expressions/expression_legacy_metric/README.md) | Expression MetricVis plugin adds a metric renderer and function to the expression plugin. The renderer will display the metric chart. |
| [expressionMetric](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/expression_metric/README.md) | Expression Metric plugin adds a metric renderer and function to the expression plugin. |
| [expressionMetricVis](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/chart_expressions/expression_metric/README.md) | Expression MetricVis plugin adds a metric renderer and function to the expression plugin. The renderer will display the metric chart. |
| [expressionPartitionVis](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/chart_expressions/expression_partition_vis/README.md) | Expression Partition Visualization plugin adds a partitionVis renderer and pieVis, mosaicVis, treemapVis, waffleVis functions to the expression plugin. The renderer will display the pie, waffle, treemap and mosaic charts. |
| [expressionRepeatImage](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/expression_repeat_image/README.md) | Expression Repeat Image plugin adds a repeatImage function to the expression plugin and an associated renderer. The renderer will display the given image in mutliple instances. |
| [expressionRevealImage](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/expression_reveal_image/README.md) | Expression Reveal Image plugin adds a revealImage function to the expression plugin and an associated renderer. The renderer will display the given percentage of a given image. |
| [expressions](kibana-expressions-plugin.md) | Expression pipeline is a chain of functions that *pipe* its output to the input of the next function. Functions can be configured using arguments provided by the user. The final output of the expression pipeline can be rendered using one of the *renderers* registered in `expressions` plugin. All the arguments to expression functions need to be serializable, as well as input and output. Expression functions should try to stay 'pure'. This makes functions easy to reuse and also make it possible to serialize the whole chain as well as output at every step of execution. It is possible to add comments to expressions by starting them with a `//` sequence or by using `/*` and `*/` to enclose multi-line comments. Expressions power visualizations in Dashboard and Lens, as well as, every *element* in Canvas is backed by an expression. This plugin provides methods which will parse & execute an *expression pipeline* string for you, as well as a series of registries for advanced users who might want to incorporate their own functions, types, and renderers into the service for use in their own application. |
| [expressionShape](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/expression_shape/README.md) | Expression Shape plugin adds a shape function to the expression plugin and an associated renderer. The renderer will display the given shape with selected decorations. |
| [expressionTagcloud](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/chart_expressions/expression_tagcloud/README.md) | Expression Tagcloud plugin adds a tagcloud renderer and function to the expression plugin. The renderer will display the Wordcloud chart. |
| [expressionXY](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/chart_expressions/expression_xy/README.md) | Expression XY plugin adds a xy renderer and function to the expression plugin. The renderer will display the xy chart. |
| [fieldFormats](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/field_formats/README.md) | Index pattern fields formatters |

View file

@ -522,19 +522,12 @@
"@kbn/expandable-flyout": "link:x-pack/solutions/security/packages/expandable-flyout",
"@kbn/exploratory-view-example-plugin": "link:x-pack/examples/exploratory_view_example",
"@kbn/exploratory-view-plugin": "link:x-pack/solutions/observability/plugins/exploratory_view",
"@kbn/expression-error-plugin": "link:src/platform/plugins/shared/expression_error",
"@kbn/expression-gauge-plugin": "link:src/platform/plugins/shared/chart_expressions/expression_gauge",
"@kbn/expression-heatmap-plugin": "link:src/platform/plugins/shared/chart_expressions/expression_heatmap",
"@kbn/expression-image-plugin": "link:src/platform/plugins/shared/expression_image",
"@kbn/expression-legacy-metric-vis-plugin": "link:src/platform/plugins/shared/chart_expressions/expression_legacy_metric",
"@kbn/expression-metric-plugin": "link:src/platform/plugins/shared/expression_metric",
"@kbn/expression-metric-vis-plugin": "link:src/platform/plugins/shared/chart_expressions/expression_metric",
"@kbn/expression-partition-vis-plugin": "link:src/platform/plugins/shared/chart_expressions/expression_partition_vis",
"@kbn/expression-repeat-image-plugin": "link:src/platform/plugins/shared/expression_repeat_image",
"@kbn/expression-reveal-image-plugin": "link:src/platform/plugins/shared/expression_reveal_image",
"@kbn/expression-shape-plugin": "link:src/platform/plugins/shared/expression_shape",
"@kbn/expression-tagcloud-plugin": "link:src/platform/plugins/shared/chart_expressions/expression_tagcloud",
"@kbn/expression-utils": "link:src/platform/packages/private/kbn-expression-utils",
"@kbn/expression-xy-plugin": "link:src/platform/plugins/shared/chart_expressions/expression_xy",
"@kbn/expressions-explorer-plugin": "link:examples/expressions_explorer",
"@kbn/expressions-plugin": "link:src/platform/plugins/shared/expressions",

View file

@ -50,18 +50,12 @@ pageLoadAssetSize:
eventAnnotation: 30000
eventAnnotationListing: 25841
exploratoryView: 74673
expressionError: 22127
expressionGauge: 25000
expressionHeatmap: 27505
expressionImage: 19288
expressionLegacyMetricVis: 23121
expressionMetric: 22238
expressionMetricVis: 23121
expressionPartitionVis: 44888
expressionRepeatImage: 22341
expressionRevealImage: 25675
expressions: 140958
expressionShape: 34008
expressionTagcloud: 27505
expressionXY: 45000
features: 21723

View file

@ -30,16 +30,10 @@ export const storybookAliases = {
esql_editor: 'src/platform/packages/private/kbn-esql-editor/.storybook',
event_stacktrace: 'x-pack/platform/packages/shared/kbn-event-stacktrace/.storybook',
expandable_flyout: 'x-pack/solutions/security/packages/expandable-flyout/.storybook',
expression_error: 'src/platform/plugins/shared/expression_error/.storybook',
expression_image: 'src/platform/plugins/shared/expression_image/.storybook',
expression_metric_vis:
'src/platform/plugins/shared/chart_expressions/expression_legacy_metric/.storybook',
expression_metric: 'src/platform/plugins/shared/expression_metric/.storybook',
expression_partition_vis:
'src/platform/plugins/shared/chart_expressions/expression_partition_vis/.storybook',
expression_repeat_image: 'src/platform/plugins/shared/expression_repeat_image/.storybook',
expression_reveal_image: 'src/platform/plugins/shared/expression_reveal_image/.storybook',
expression_shape: 'src/platform/plugins/shared/expression_shape/.storybook',
expression_tagcloud:
'src/platform/plugins/shared/chart_expressions/expression_tagcloud/.storybook',
fleet: 'x-pack/platform/plugins/shared/fleet/.storybook',

View file

@ -1,3 +0,0 @@
# @kbn/expression-utils
Empty package generated by @kbn/generate

View file

@ -1,19 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export {
elasticLogo,
elasticOutline,
isValidUrl,
isValidHttpUrl,
resolveWithMissingImage,
resolveFromArgs,
encode,
parseDataUrl,
} from './src';

View file

@ -1,14 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/packages/private/kbn-expression-utils'],
};

View file

@ -1,7 +0,0 @@
{
"type": "shared-common",
"id": "@kbn/expression-utils",
"owner": "@elastic/kibana-presentation",
"group": "platform",
"visibility": "private"
}

View file

@ -1,6 +0,0 @@
{
"name": "@kbn/expression-utils",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// A cheap regex to distinguish an HTTP URL string from a data URL string
const httpurlRegex = /^https?:\/\/\S+(?:[0-9]+)?\/\S{1,}/;
export function isValidHttpUrl(str: string): boolean {
return httpurlRegex.test(str);
}

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './dataurl';
export { elasticLogo } from './elastic_logo';
export { elasticOutline } from './elastic_outline';
export * from './httpurl';
export * from './resolve_dataurl';
export * from './url';

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { isValidDataUrl } from './dataurl';
import { isValidHttpUrl } from './httpurl';
export function isValidUrl(url: string) {
return isValidDataUrl(url) || isValidHttpUrl(url);
}

View file

@ -1,17 +0,0 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
],
"exclude": [
"target/**/*"
],
"kbn_references": []
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// eslint-disable-next-line import/no-commonjs
module.exports = require('@kbn/storybook').defaultConfig;

View file

@ -1,9 +0,0 @@
# expressionRevealImage
Expression Error plugin adds an `error` renderer to the expression plugin. The renderer will display the error image.
---
## Development
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment.

View file

@ -1,13 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export const PLUGIN_ID = 'expressionError';
export const PLUGIN_NAME = 'expressionError';
export const JSON = 'JSON';

View file

@ -1,12 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// TODO: https://github.com/elastic/kibana/issues/110893
export { PLUGIN_ID, PLUGIN_NAME, JSON } from './constants';

View file

@ -1,19 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export type OriginString = 'bottom' | 'left' | 'top' | 'right';
export interface ErrorRendererConfig {
error: Error;
}
export interface NodeDimensions {
width: number;
height: number;
}

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './expression_renderers';

View file

@ -1,20 +0,0 @@
{
"type": "plugin",
"id": "@kbn/expression-error-plugin",
"owner": [
"@elastic/kibana-presentation"
],
"group": "platform",
"visibility": "shared",
"description": "Adds 'error' renderer to expressions",
"plugin": {
"id": "expressionError",
"browser": true,
"server": false,
"requiredPlugins": [
"expressions",
"presentationUtil"
],
"requiredBundles": []
}
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// eslint-disable-next-line import/no-default-export
export { Debug as default } from './debug';

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// eslint-disable-next-line import/no-default-export
export { Error as default } from './error';

View file

@ -1,16 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { lazy } from 'react';
export const LazyErrorComponent = lazy(() => import('./error'));
export const LazyDebugComponent = lazy(() => import('./debug'));
export const LazyErrorRenderComponent = lazy(() => import('./error_component'));
export const LazyDebugRenderComponent = lazy(() => import('./debug_component'));

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { getErrorRenderer, errorRendererFactory } from './error_renderer';
export { getDebugRenderer, debugRendererFactory } from './debug_renderer';

View file

@ -1,25 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionErrorPlugin } from './plugin';
export type { ExpressionErrorPluginSetup, ExpressionErrorPluginStart } from './plugin';
export function plugin() {
return new ExpressionErrorPlugin();
}
export {
getErrorRenderer,
getDebugRenderer,
errorRendererFactory,
debugRendererFactory,
} from './expression_renderers';
export { LazyDebugComponent, LazyErrorComponent } from './components';

View file

@ -1,38 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import { ExpressionsStart, ExpressionsSetup } from '@kbn/expressions-plugin/public';
import { debugRendererFactory, errorRendererFactory } from './expression_renderers';
interface SetupDeps {
expressions: ExpressionsSetup;
}
interface StartDeps {
expression: ExpressionsStart;
}
export type ExpressionErrorPluginSetup = void;
export type ExpressionErrorPluginStart = void;
export class ExpressionErrorPlugin
implements Plugin<ExpressionErrorPluginSetup, ExpressionErrorPluginStart, SetupDeps, StartDeps>
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionErrorPluginSetup {
core.getStartServices().then(([start]) => {
expressions.registerRenderer(errorRendererFactory(start));
expressions.registerRenderer(debugRendererFactory(start));
});
}
public start(core: CoreStart): ExpressionErrorPluginStart {}
public stop() {}
}

View file

@ -1,25 +0,0 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"isolatedModules": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
],
"kbn_references": [
"@kbn/core",
"@kbn/presentation-util-plugin",
"@kbn/expressions-plugin",
"@kbn/i18n",
"@kbn/shared-ux-markdown",
"@kbn/react-kibana-context-theme",
"@kbn/i18n-react",
"@kbn/shared-ux-error-boundary",
],
"exclude": [
"target/**/*",
]
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// eslint-disable-next-line import/no-commonjs
module.exports = require('@kbn/storybook').defaultConfig;

View file

@ -1,9 +0,0 @@
# expressionRevealImage
Expression Image plugin adds an `image` renderer to the expression plugin. The renderer will display the given image.
---
## Development
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment.

View file

@ -1,13 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionFunction } from '@kbn/expressions-plugin/common';
import { imageFunction } from '../common/expression_functions';
export const functionSpecs = [imageFunction].map((fn) => new ExpressionFunction(fn()));

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { functionSpecs } from './function_specs';
export { imageFunction } from '../common/expression_functions';

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export const PLUGIN_ID = 'expressionImage';
export const PLUGIN_NAME = 'expressionImage';
export const CONTEXT = '_context_';
export const BASE64 = '`base64`';
export const URL = 'URL';

View file

@ -1,96 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { i18n } from '@kbn/i18n';
import { BASE64, URL } from '../constants';
import { ExpressionImageFunction, ImageMode } from '../types';
export const strings = {
help: i18n.translate('expressionImage.functions.imageHelpText', {
defaultMessage:
'Displays an image. Provide an image asset as a {BASE64} data {URL}, or pass in a sub-expression.',
values: {
BASE64,
URL,
},
}),
args: {
dataurl: i18n.translate('expressionImage.functions.image.args.dataurlHelpText', {
defaultMessage: 'The {https} {URL} or {BASE64} data {URL} of an image.',
values: {
BASE64,
https: 'HTTP(S)',
URL,
},
}),
mode: i18n.translate('expressionImage.functions.image.args.modeHelpText', {
defaultMessage:
'{contain} shows the entire image, scaled to fit. ' +
'{cover} fills the container with the image, cropping from the sides or bottom as needed. ' +
'{stretch} resizes the height and width of the image to 100% of the container.',
values: {
contain: `\`"${ImageMode.CONTAIN}"\``,
cover: `\`"${ImageMode.COVER}"\``,
stretch: `\`"${ImageMode.STRETCH}"\``,
},
}),
},
};
const errors = {
invalidImageMode: () =>
i18n.translate('expressionImage.functions.image.invalidImageModeErrorMessage', {
defaultMessage: '"mode" must be "{contain}", "{cover}", or "{stretch}"',
values: {
contain: ImageMode.CONTAIN,
cover: ImageMode.COVER,
stretch: ImageMode.STRETCH,
},
}),
};
export const imageFunction: ExpressionImageFunction = () => {
const { help, args: argHelp } = strings;
return {
name: 'image',
aliases: [],
type: 'image',
inputTypes: ['null'],
help,
args: {
dataurl: {
// This was accepting dataurl, but there was no facility in fn for checking type and handling a dataurl type.
types: ['string', 'null'],
help: argHelp.dataurl,
aliases: ['_', 'url'],
default: null,
},
mode: {
types: ['string'],
help: argHelp.mode,
default: 'contain',
options: Object.values(ImageMode),
},
},
fn: async (input, { dataurl, mode }) => {
if (!mode || !Object.values(ImageMode).includes(mode)) {
throw new Error(errors.invalidImageMode());
}
const { elasticLogo, resolveWithMissingImage } = await import('@kbn/expression-utils');
const modeStyle = mode === 'stretch' ? '100% 100%' : mode;
return {
type: 'image',
mode: modeStyle,
dataurl: resolveWithMissingImage(dataurl, elasticLogo) as string,
};
},
};
};

View file

@ -1,14 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { imageFunction } from './image_function';
export const functions = [imageFunction];
export { imageFunction };

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// TODO: https://github.com/elastic/kibana/issues/110893
export { PLUGIN_ID, PLUGIN_NAME, CONTEXT, BASE64, URL } from './constants';
export type {
Return,
ExpressionImageFunction,
OriginString,
ImageRendererConfig,
NodeDimensions,
} from './types';
export { ImageMode } from './types';

View file

@ -1,34 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
export enum ImageMode {
CONTAIN = 'contain',
COVER = 'cover',
STRETCH = 'stretch',
}
interface Arguments {
dataurl: string | null;
mode: ImageMode | null;
}
export interface Return {
type: 'image';
mode: string;
dataurl: string;
}
export type ExpressionImageFunction = () => ExpressionFunctionDefinition<
'image',
null,
Arguments,
Promise<Return>
>;

View file

@ -1,22 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ImageMode } from './expression_functions';
export type OriginString = 'bottom' | 'left' | 'top' | 'right';
export interface ImageRendererConfig {
dataurl: string | null;
mode: ImageMode | null;
}
export interface NodeDimensions {
width: number;
height: number;
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './expression_functions';
export * from './expression_renderers';

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/plugins/shared/expression_image'],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/src/platform/plugins/shared/expression_image',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/src/platform/plugins/shared/expression_image/{common,public,server}/**/*.{ts,tsx}',
],
};

View file

@ -1,20 +0,0 @@
{
"type": "plugin",
"id": "@kbn/expression-image-plugin",
"owner": [
"@elastic/kibana-presentation"
],
"group": "platform",
"visibility": "shared",
"description": "Adds 'image' function and renderer to expressions",
"plugin": {
"id": "expressionImage",
"browser": true,
"server": true,
"requiredPlugins": [
"expressions",
"presentationUtil"
],
"requiredBundles": []
}
}

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { imageRendererFactory, getImageRenderer } from './image_renderer';

View file

@ -1,18 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionImagePlugin } from './plugin';
export type { ExpressionImagePluginSetup, ExpressionImagePluginStart } from './plugin';
export function plugin() {
return new ExpressionImagePlugin();
}
export { imageRendererFactory, getImageRenderer } from './expression_renderers';

View file

@ -1,39 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import { ExpressionsStart, ExpressionsSetup } from '@kbn/expressions-plugin/public';
import { imageRendererFactory } from './expression_renderers';
import { imageFunction } from '../common/expression_functions';
interface SetupDeps {
expressions: ExpressionsSetup;
}
interface StartDeps {
expression: ExpressionsStart;
}
export type ExpressionImagePluginSetup = void;
export type ExpressionImagePluginStart = void;
export class ExpressionImagePlugin
implements Plugin<ExpressionImagePluginSetup, ExpressionImagePluginStart, SetupDeps, StartDeps>
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionImagePluginSetup {
core.getStartServices().then(([start]) => {
expressions.registerFunction(imageFunction);
expressions.registerRenderer(imageRendererFactory(start));
});
}
public start(core: CoreStart): ExpressionImagePluginStart {}
public stop() {}
}

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export type { ExpressionImagePluginSetup, ExpressionImagePluginStart } from './plugin';
export async function plugin() {
const { ExpressionImagePlugin } = await import('./plugin');
return new ExpressionImagePlugin();
}

View file

@ -1,35 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/server';
import { ExpressionsServerStart, ExpressionsServerSetup } from '@kbn/expressions-plugin/server';
import { imageFunction } from '../common/expression_functions';
interface SetupDeps {
expressions: ExpressionsServerSetup;
}
interface StartDeps {
expression: ExpressionsServerStart;
}
export type ExpressionImagePluginSetup = void;
export type ExpressionImagePluginStart = void;
export class ExpressionImagePlugin
implements Plugin<ExpressionImagePluginSetup, ExpressionImagePluginStart, SetupDeps, StartDeps>
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionImagePluginSetup {
expressions.registerFunction(imageFunction);
}
public start(core: CoreStart): ExpressionImagePluginStart {}
public stop() {}
}

View file

@ -1,26 +0,0 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"isolatedModules": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
"__fixtures__/**/*",
],
"kbn_references": [
"@kbn/core",
"@kbn/presentation-util-plugin",
"@kbn/expressions-plugin",
"@kbn/expect",
"@kbn/i18n",
"@kbn/react-kibana-context-theme",
"@kbn/shared-ux-error-boundary",
"@kbn/expression-utils",
],
"exclude": [
"target/**/*",
]
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// eslint-disable-next-line import/no-commonjs
module.exports = require('@kbn/storybook').defaultConfig;

View file

@ -1,9 +0,0 @@
# expressionMetric
Expression Metric plugin adds a `metric` renderer and function to the expression plugin.
---
## Development
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment.

View file

@ -1,13 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionFunction } from '@kbn/expressions-plugin/common';
import { metricFunction } from '../common/expression_functions';
export const functionSpecs = [metricFunction].map((fn) => new ExpressionFunction(fn()));

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './function_specs';

View file

@ -1,16 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export const PLUGIN_ID = 'expressionMetric';
export const PLUGIN_NAME = 'expressionMetric';
export const FONT_FAMILY = '`font-family`';
export const FONT_WEIGHT = '`font-weight`';
export const CSS = 'CSS';
export const NUMERALJS = 'Numeral pattern';

View file

@ -1,14 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { metricFunction } from './metric_function';
export const functions = [metricFunction];
export { metricFunction };

View file

@ -1,99 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { i18n } from '@kbn/i18n';
import { openSans } from '@kbn/expressions-plugin/common/fonts';
import { FONT_FAMILY, FONT_WEIGHT, CSS, NUMERALJS } from '../constants';
import { ExpressionMetricFunction } from '../types';
export const strings = {
help: i18n.translate('expressionMetric.functions.metricHelpText', {
defaultMessage: 'Displays a number over a label.',
}),
args: {
label: i18n.translate('expressionMetric.functions.metric.args.labelHelpText', {
defaultMessage: 'The text describing the metric.',
}),
labelFont: i18n.translate('expressionMetric.functions.metric.args.labelFontHelpText', {
defaultMessage:
'The {CSS} font properties for the label. For example, {FONT_FAMILY} or {FONT_WEIGHT}.',
values: {
CSS,
FONT_FAMILY,
FONT_WEIGHT,
},
}),
metricFont: i18n.translate('expressionMetric.functions.metric.args.metricFontHelpText', {
defaultMessage:
'The {CSS} font properties for the metric. For example, {FONT_FAMILY} or {FONT_WEIGHT}.',
values: {
CSS,
FONT_FAMILY,
FONT_WEIGHT,
},
}),
// TODO: Find a way to generate the docs URL here
metricFormat: i18n.translate('expressionMetric.functions.metric.args.metricFormatHelpText', {
defaultMessage: 'A {NUMERALJS} format string. For example, {example1} or {example2}.',
values: {
example1: '`"0.0a"`',
example2: '`"0%"`',
NUMERALJS,
},
}),
},
};
export const metricFunction: ExpressionMetricFunction = () => {
const { help, args: argHelp } = strings;
return {
name: 'metric',
aliases: [],
type: 'render',
inputTypes: ['number', 'string', 'null'],
help,
args: {
label: {
types: ['string'],
aliases: ['_', 'text', 'description'],
help: argHelp.label,
default: '""',
},
labelFont: {
types: ['style'],
help: argHelp.labelFont,
default: `{font size=14 family="${openSans.value}" color="#000000" align=center}`,
},
metricFont: {
types: ['style'],
help: argHelp.metricFont,
default: `{font size=48 family="${openSans.value}" color="#000000" align=center lHeight=48}`,
},
metricFormat: {
types: ['string'],
aliases: ['format'],
help: argHelp.metricFormat,
},
},
fn: (input, { label, labelFont, metricFont, metricFormat }) => {
return {
type: 'render',
as: 'metric',
value: {
metric: input === null ? '?' : input,
label,
labelFont,
metricFont,
metricFormat,
},
};
},
};
};

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// TODO: https://github.com/elastic/kibana/issues/110893
export { PLUGIN_ID, PLUGIN_NAME, FONT_FAMILY, FONT_WEIGHT, CSS, NUMERALJS } from './constants';
export type {
Input,
Arguments,
ExpressionMetricFunction,
MetricRendererConfig,
NodeDimensions,
} from './types';
export { functions, metricFunction } from './expression_functions';

View file

@ -1,30 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import {
ExpressionFunctionDefinition,
ExpressionValueRender,
Style,
} from '@kbn/expressions-plugin/common';
export type Input = number | string | null;
export interface Arguments {
label: string;
metricFont: Style;
metricFormat: string;
labelFont: Style;
}
export type ExpressionMetricFunction = () => ExpressionFunctionDefinition<
'metric',
Input,
Arguments,
ExpressionValueRender<Arguments>
>;

View file

@ -1,28 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { Style } from '@kbn/expressions-plugin/common';
export interface MetricRendererConfig {
/** The text to display under the metric */
label: string;
/** Font settings for the label */
labelFont: Style;
/** Value of the metric to display */
metric: string | number | null;
/** Font settings for the metric */
metricFont: Style;
/** NumeralJS format string */
metricFormat: string;
}
export interface NodeDimensions {
width: number;
height: number;
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './expression_functions';
export * from './expression_renderers';

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/plugins/shared/expression_metric'],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/src/platform/plugins/shared/expression_metric',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/src/platform/plugins/shared/expression_metric/{common,public,server}/**/*.{ts,tsx}',
],
};

View file

@ -1,20 +0,0 @@
{
"type": "plugin",
"id": "@kbn/expression-metric-plugin",
"owner": [
"@elastic/kibana-presentation"
],
"group": "platform",
"visibility": "shared",
"description": "Adds 'metric' function and renderer to expressions",
"plugin": {
"id": "expressionMetric",
"browser": true,
"server": true,
"requiredPlugins": [
"expressions",
"presentationUtil"
],
"requiredBundles": []
}
}

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { MetricComponent } from './metric_component';

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { metricRendererFactory, getMetricRenderer } from './metric_renderer';

View file

@ -1,18 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionMetricPlugin } from './plugin';
export type { ExpressionMetricPluginSetup, ExpressionMetricPluginStart } from './plugin';
export function plugin() {
return new ExpressionMetricPlugin();
}
export { metricRendererFactory, getMetricRenderer } from './expression_renderers';

View file

@ -1,39 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import { ExpressionsStart, ExpressionsSetup } from '@kbn/expressions-plugin/public';
import { metricFunction } from '../common/expression_functions';
import { metricRendererFactory } from './expression_renderers';
interface SetupDeps {
expressions: ExpressionsSetup;
}
interface StartDeps {
expression: ExpressionsStart;
}
export type ExpressionMetricPluginSetup = void;
export type ExpressionMetricPluginStart = void;
export class ExpressionMetricPlugin
implements Plugin<ExpressionMetricPluginSetup, ExpressionMetricPluginStart, SetupDeps, StartDeps>
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionMetricPluginSetup {
core.getStartServices().then(([start]) => {
expressions.registerFunction(metricFunction);
expressions.registerRenderer(metricRendererFactory(start));
});
}
public start(core: CoreStart): ExpressionMetricPluginStart {}
public stop() {}
}

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export type { ExpressionMetricPluginSetup, ExpressionMetricPluginStart } from './plugin';
export async function plugin() {
const { ExpressionMetricPlugin } = await import('./plugin');
return new ExpressionMetricPlugin();
}

View file

@ -1,35 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/server';
import { ExpressionsServerStart, ExpressionsServerSetup } from '@kbn/expressions-plugin/server';
import { metricFunction } from '../common';
interface SetupDeps {
expressions: ExpressionsServerSetup;
}
interface StartDeps {
expression: ExpressionsServerStart;
}
export type ExpressionMetricPluginSetup = void;
export type ExpressionMetricPluginStart = void;
export class ExpressionMetricPlugin
implements Plugin<ExpressionMetricPluginSetup, ExpressionMetricPluginStart, SetupDeps, StartDeps>
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionMetricPluginSetup {
expressions.registerFunction(metricFunction);
}
public start(core: CoreStart): ExpressionMetricPluginStart {}
public stop() {}
}

View file

@ -1,24 +0,0 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"isolatedModules": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
"__fixtures__/**/*",
],
"kbn_references": [
"@kbn/core",
"@kbn/presentation-util-plugin",
"@kbn/expressions-plugin",
"@kbn/i18n",
"@kbn/react-kibana-context-theme",
"@kbn/shared-ux-error-boundary",
],
"exclude": [
"target/**/*",
]
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// eslint-disable-next-line import/no-commonjs
module.exports = require('@kbn/storybook').defaultConfig;

View file

@ -1,9 +0,0 @@
# expressionRepeatImage
Expression Repeat Image plugin adds a `repeatImage` function to the expression plugin and an associated renderer. The renderer will display the given image in mutliple instances.
---
## Development
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment.

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export const PLUGIN_ID = 'expressionRepeatImage';
export const PLUGIN_NAME = 'expressionRepeatImage';
export const CONTEXT = '_context_';
export const BASE64 = '`base64`';
export const URL = 'URL';

View file

@ -1,14 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { repeatImageFunction } from './repeat_image_function';
export const functions = [repeatImageFunction];
export { repeatImageFunction };

View file

@ -1,113 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { i18n } from '@kbn/i18n';
import { CONTEXT, BASE64, URL } from '../constants';
import { ExpressionRepeatImageFunction } from '../types';
export const strings = {
help: i18n.translate('expressionRepeatImage.functions.repeatImageHelpText', {
defaultMessage: 'Configures a repeating image element.',
}),
args: {
emptyImage: i18n.translate(
'expressionRepeatImage.functions.repeatImage.args.emptyImageHelpText',
{
defaultMessage:
'Fills the difference between the {CONTEXT} and {maxArg} parameter for the element with this image. ' +
'Provide an image asset as a {BASE64} data {URL}, or pass in a sub-expression.',
values: {
BASE64,
CONTEXT,
maxArg: '`max`',
URL,
},
}
),
image: i18n.translate('expressionRepeatImage.functions.repeatImage.args.imageHelpText', {
defaultMessage:
'The image to repeat. Provide an image asset as a {BASE64} data {URL}, or pass in a sub-expression.',
values: {
BASE64,
URL,
},
}),
max: i18n.translate('expressionRepeatImage.functions.repeatImage.args.maxHelpText', {
defaultMessage: 'The maximum number of times the image can repeat.',
}),
size: i18n.translate('expressionRepeatImage.functions.repeatImage.args.sizeHelpText', {
defaultMessage:
'The maximum height or width of the image, in pixels. ' +
'When the image is taller than it is wide, this function limits the height.',
}),
},
};
const errors = {
getMissingMaxArgumentErrorMessage: () =>
i18n.translate('expressionRepeatImage.error.repeatImage.missingMaxArgument', {
defaultMessage: '{maxArgument} must be set if providing an {emptyImageArgument}',
values: {
maxArgument: '`max`',
emptyImageArgument: '`emptyImage`',
},
}),
};
export const repeatImageFunction: ExpressionRepeatImageFunction = () => {
const { help, args: argHelp } = strings;
return {
name: 'repeatImage',
aliases: [],
type: 'render',
inputTypes: ['number'],
help,
args: {
emptyImage: {
types: ['string', 'null'],
help: argHelp.emptyImage,
default: null,
},
image: {
types: ['string', 'null'],
help: argHelp.image,
default: null,
},
max: {
types: ['number', 'null'],
help: argHelp.max,
default: 1000,
},
size: {
types: ['number'],
default: 100,
help: argHelp.size,
},
},
fn: async (count, args) => {
const { elasticOutline, isValidUrl, resolveWithMissingImage } = await import(
'@kbn/expression-utils'
);
if (args.emptyImage !== null && isValidUrl(args.emptyImage) && args.max === null) {
throw new Error(errors.getMissingMaxArgumentErrorMessage());
}
return {
type: 'render',
as: 'repeatImage',
value: {
count: Math.floor(count),
...args,
image: resolveWithMissingImage(args.image, elasticOutline),
emptyImage: resolveWithMissingImage(args.emptyImage),
},
};
},
};
};

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// TODO: https://github.com/elastic/kibana/issues/110893
export { PLUGIN_ID, PLUGIN_NAME, CONTEXT, BASE64, URL } from './constants';
export type {
Return,
ExpressionRepeatImageFunction,
OriginString,
RepeatImageRendererConfig,
NodeDimensions,
} from './types';
export { functions, repeatImageFunction } from './expression_functions';

View file

@ -1,35 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import {
ExpressionFunctionDefinition,
ExpressionValueRender,
} from '@kbn/expressions-plugin/common';
interface Arguments {
image: string | null;
size: number;
max: number | null;
emptyImage: string | null;
}
export interface Return {
count: number;
image: string;
size: number;
max: number;
emptyImage: string | null;
}
export type ExpressionRepeatImageFunction = () => ExpressionFunctionDefinition<
'repeatImage',
number,
Arguments,
Promise<ExpressionValueRender<Arguments>>
>;

View file

@ -1,22 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export type OriginString = 'bottom' | 'left' | 'top' | 'right';
export interface RepeatImageRendererConfig {
max: number;
count: number;
emptyImage: string;
image: string;
size: number;
}
export interface NodeDimensions {
width: number;
height: number;
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './expression_functions';
export * from './expression_renderers';

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/plugins/shared/expression_repeat_image'],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/src/platform/plugins/shared/expression_repeat_image',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/src/platform/plugins/shared/expression_repeat_image/{common,public,server}/**/*.{ts,tsx}',
],
};

View file

@ -1,20 +0,0 @@
{
"type": "plugin",
"id": "@kbn/expression-repeat-image-plugin",
"owner": [
"@elastic/kibana-presentation"
],
"group": "platform",
"visibility": "shared",
"description": "Adds 'repeatImage' function and renderer to expressions",
"plugin": {
"id": "expressionRepeatImage",
"browser": true,
"server": true,
"requiredPlugins": [
"expressions",
"presentationUtil"
],
"requiredBundles": []
}
}

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './repeat_image_component';

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { getRepeatImageRenderer, repeatImageRendererFactory } from './repeat_image_renderer';

View file

@ -1,18 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionRepeatImagePlugin } from './plugin';
export type { ExpressionRepeatImagePluginSetup, ExpressionRepeatImagePluginStart } from './plugin';
export function plugin() {
return new ExpressionRepeatImagePlugin();
}
export { getRepeatImageRenderer, repeatImageRendererFactory } from './expression_renderers';

View file

@ -1,45 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import { ExpressionsStart, ExpressionsSetup } from '@kbn/expressions-plugin/public';
import { repeatImageFunction } from '../common/expression_functions';
import { repeatImageRendererFactory } from './expression_renderers';
interface SetupDeps {
expressions: ExpressionsSetup;
}
interface StartDeps {
expression: ExpressionsStart;
}
export type ExpressionRepeatImagePluginSetup = void;
export type ExpressionRepeatImagePluginStart = void;
export class ExpressionRepeatImagePlugin
implements
Plugin<
ExpressionRepeatImagePluginSetup,
ExpressionRepeatImagePluginStart,
SetupDeps,
StartDeps
>
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionRepeatImagePluginSetup {
core.getStartServices().then(([start]) => {
expressions.registerFunction(repeatImageFunction);
expressions.registerRenderer(repeatImageRendererFactory(start));
});
}
public start(core: CoreStart): ExpressionRepeatImagePluginStart {}
public stop() {}
}

View file

@ -1,15 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export type { ExpressionRepeatImagePluginSetup, ExpressionRepeatImagePluginStart } from './plugin';
export async function plugin() {
const { ExpressionRepeatImagePlugin } = await import('./plugin');
return new ExpressionRepeatImagePlugin();
}

View file

@ -1,41 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/server';
import { ExpressionsServerStart, ExpressionsServerSetup } from '@kbn/expressions-plugin/server';
import { repeatImageFunction } from '../common';
interface SetupDeps {
expressions: ExpressionsServerSetup;
}
interface StartDeps {
expression: ExpressionsServerStart;
}
export type ExpressionRepeatImagePluginSetup = void;
export type ExpressionRepeatImagePluginStart = void;
export class ExpressionRepeatImagePlugin
implements
Plugin<
ExpressionRepeatImagePluginSetup,
ExpressionRepeatImagePluginStart,
SetupDeps,
StartDeps
>
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionRepeatImagePluginSetup {
expressions.registerFunction(repeatImageFunction);
}
public start(core: CoreStart): ExpressionRepeatImagePluginStart {}
public stop() {}
}

View file

@ -1,25 +0,0 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"isolatedModules": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
],
"kbn_references": [
"@kbn/core",
"@kbn/presentation-util-plugin",
"@kbn/expressions-plugin",
"@kbn/i18n",
"@kbn/react-kibana-context-theme",
"@kbn/i18n-react",
"@kbn/shared-ux-error-boundary",
"@kbn/expression-utils"
],
"exclude": [
"target/**/*",
]
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// eslint-disable-next-line import/no-commonjs
module.exports = require('@kbn/storybook').defaultConfig;

View file

@ -1,9 +0,0 @@
# expressionRevealImage
Expression Reveal Image plugin adds a `revealImage` function to the expression plugin and an associated renderer. The renderer will display the given percentage of a given image.
---
## Development
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment.

View file

@ -1,14 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export const PLUGIN_ID = 'expressionRevealImage';
export const PLUGIN_NAME = 'expressionRevealImage';
export const BASE64 = '`base64`';
export const URL = 'URL';

View file

@ -1,14 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { revealImageFunction } from './reveal_image_function';
export const functions = [revealImageFunction];
export { revealImageFunction };

View file

@ -1,126 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { i18n } from '@kbn/i18n';
import { ExpressionRevealImageFunction, Origin, Position } from '../types';
import { BASE64, URL } from '../constants';
const strings = {
help: i18n.translate('expressionRevealImage.functions.revealImageHelpText', {
defaultMessage: 'Configures an image reveal element.',
}),
args: {
image: i18n.translate('expressionRevealImage.functions.revealImage.args.imageHelpText', {
defaultMessage:
'The image to reveal. Provide an image asset as a {BASE64} data {URL}, ' +
'or pass in a sub-expression.',
values: {
BASE64,
URL,
},
}),
emptyImage: i18n.translate(
'expressionRevealImage.functions.revealImage.args.emptyImageHelpText',
{
defaultMessage:
'An optional background image to reveal over. ' +
'Provide an image asset as a `{BASE64}` data {URL}, or pass in a sub-expression.',
values: {
BASE64,
URL,
},
}
),
origin: i18n.translate('expressionRevealImage.functions.revealImage.args.originHelpText', {
defaultMessage: 'The position to start the image fill. For example, {list}, or {end}.',
values: {
list: Object.values(Position)
.slice(0, -1)
.map((position) => `\`"${position}"\``)
.join(', '),
end: Object.values(Position).slice(-1)[0],
},
}),
},
};
export const errors = {
invalidPercent: (percent: number) =>
new Error(
i18n.translate('expressionRevealImage.functions.revealImage.invalidPercentErrorMessage', {
defaultMessage: "Invalid value: ''{percent}''. Percentage must be between 0 and 1",
values: {
percent,
},
})
),
invalidImageUrl: (imageUrl: string) =>
new Error(
i18n.translate('expressionRevealImage.functions.revealImage.invalidImageUrl', {
defaultMessage: "Invalid image url: ''{imageUrl}''.",
values: {
imageUrl,
},
})
),
};
export const revealImageFunction: ExpressionRevealImageFunction = () => {
const { help, args: argHelp } = strings;
return {
name: 'revealImage',
aliases: [],
type: 'render',
inputTypes: ['number'],
help,
args: {
image: {
types: ['string', 'null'],
help: argHelp.image,
default: null,
},
emptyImage: {
types: ['string', 'null'],
help: argHelp.emptyImage,
default: null,
},
origin: {
types: ['string'],
help: argHelp.origin,
default: 'bottom',
options: Object.values(Origin),
},
},
fn: async (percent, args) => {
if (percent > 1 || percent < 0) {
throw errors.invalidPercent(percent);
}
const { resolveWithMissingImage, elasticOutline, isValidUrl } = await import(
'@kbn/expression-utils'
);
if (args.image && !isValidUrl(args.image)) {
throw errors.invalidImageUrl(args.image);
}
return {
type: 'render',
as: 'revealImage',
value: {
percent,
...args,
image: resolveWithMissingImage(args.image, elasticOutline) as string,
emptyImage: resolveWithMissingImage(args.emptyImage) as string,
},
};
},
};
};

View file

@ -1,13 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
// TODO: https://github.com/elastic/kibana/issues/110893
export { PLUGIN_ID, PLUGIN_NAME, BASE64, URL } from './constants';
export { functions, revealImageFunction } from './expression_functions';

View file

@ -1,47 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import {
ExpressionFunctionDefinition,
ExpressionValueRender,
} from '@kbn/expressions-plugin/common';
export enum Origin {
TOP = 'top',
LEFT = 'left',
BOTTOM = 'bottom',
RIGHT = 'right',
}
interface Arguments {
image: string | null;
emptyImage: string | null;
origin: Origin;
}
export interface Output {
image: string;
emptyImage: string;
origin: Origin;
percent: number;
}
export type ExpressionRevealImageFunction = () => ExpressionFunctionDefinition<
'revealImage',
number,
Arguments,
Promise<ExpressionValueRender<Output>>
>;
export enum Position {
TOP = 'top',
BOTTOM = 'bottom',
LEFT = 'left',
RIGHT = 'right',
}

View file

@ -1,22 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export type OriginString = 'bottom' | 'left' | 'top' | 'right';
export interface RevealImageRendererConfig {
percent: number;
origin?: OriginString;
image: string;
emptyImage?: string;
}
export interface NodeDimensions {
width: number;
height: number;
}

View file

@ -1,11 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './expression_functions';
export * from './expression_renderers';

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/plugins/shared/expression_reveal_image'],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/src/platform/plugins/shared/expression_reveal_image',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/src/platform/plugins/shared/expression_reveal_image/{common,public,server}/**/*.{ts,tsx}',
],
};

View file

@ -1,20 +0,0 @@
{
"type": "plugin",
"id": "@kbn/expression-reveal-image-plugin",
"owner": [
"@elastic/kibana-presentation"
],
"group": "platform",
"visibility": "shared",
"description": "Adds 'revealImage' function and renderer to expressions",
"plugin": {
"id": "expressionRevealImage",
"browser": true,
"server": true,
"requiredPlugins": [
"expressions",
"presentationUtil"
],
"requiredBundles": []
}
}

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './reveal_image_component';

View file

@ -1,10 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { revealImageRendererFactory, getRevealImageRenderer } from './reveal_image_renderer';

View file

@ -1,18 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { ExpressionRevealImagePlugin } from './plugin';
export type { ExpressionRevealImagePluginSetup, ExpressionRevealImagePluginStart } from './plugin';
export function plugin() {
return new ExpressionRevealImagePlugin();
}
export { revealImageRendererFactory, getRevealImageRenderer } from './expression_renderers';

Some files were not shown because too many files have changed in this diff Show more