[Lens][Event annotations] Move logic into packages (#161500)

This commit is contained in:
Drew Tate 2023-07-19 09:46:57 -05:00 committed by GitHub
parent 11cc1e1be6
commit 092e988df2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
198 changed files with 840 additions and 628 deletions

4
.github/CODEOWNERS vendored
View file

@ -360,6 +360,8 @@ packages/kbn-eslint-plugin-eslint @elastic/kibana-operations
packages/kbn-eslint-plugin-imports @elastic/kibana-operations packages/kbn-eslint-plugin-imports @elastic/kibana-operations
packages/kbn-eslint-plugin-telemetry @elastic/actionable-observability packages/kbn-eslint-plugin-telemetry @elastic/actionable-observability
x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin @elastic/kibana-security x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin @elastic/kibana-security
packages/kbn-event-annotation-common @elastic/kibana-visualizations
packages/kbn-event-annotation-components @elastic/kibana-visualizations
src/plugins/event_annotation @elastic/kibana-visualizations src/plugins/event_annotation @elastic/kibana-visualizations
x-pack/test/plugin_api_integration/plugins/event_log @elastic/response-ops x-pack/test/plugin_api_integration/plugins/event_log @elastic/response-ops
x-pack/plugins/event_log @elastic/response-ops x-pack/plugins/event_log @elastic/response-ops
@ -762,7 +764,7 @@ src/plugins/vis_types/timeseries @elastic/kibana-visualizations
src/plugins/vis_types/vega @elastic/kibana-visualizations src/plugins/vis_types/vega @elastic/kibana-visualizations
src/plugins/vis_types/vislib @elastic/kibana-visualizations src/plugins/vis_types/vislib @elastic/kibana-visualizations
src/plugins/vis_types/xy @elastic/kibana-visualizations src/plugins/vis_types/xy @elastic/kibana-visualizations
src/plugins/visualization_ui_components @elastic/kibana-visualizations packages/kbn-visualization-ui-components @elastic/kibana-visualizations
src/plugins/visualizations @elastic/kibana-visualizations src/plugins/visualizations @elastic/kibana-visualizations
x-pack/plugins/watcher @elastic/platform-deployment-management x-pack/plugins/watcher @elastic/platform-deployment-management
packages/kbn-web-worker-stub @elastic/kibana-operations packages/kbn-web-worker-stub @elastic/kibana-operations

View file

@ -44,6 +44,8 @@
"expressionShape": "src/plugins/expression_shape", "expressionShape": "src/plugins/expression_shape",
"expressionTagcloud": "src/plugins/chart_expressions/expression_tagcloud", "expressionTagcloud": "src/plugins/chart_expressions/expression_tagcloud",
"eventAnnotation": "src/plugins/event_annotation", "eventAnnotation": "src/plugins/event_annotation",
"eventAnnotationCommon": "packages/kbn-event-annotation-common",
"eventAnnotationComponents": "packages/kbn-event-annotation-components",
"fieldFormats": "src/plugins/field_formats", "fieldFormats": "src/plugins/field_formats",
"files": "src/plugins/files", "files": "src/plugins/files",
"filesManagement": "src/plugins/files_management", "filesManagement": "src/plugins/files_management",
@ -72,7 +74,11 @@
"kibanaOverview": "src/plugins/kibana_overview", "kibanaOverview": "src/plugins/kibana_overview",
"lists": "packages/kbn-securitysolution-list-utils/src", "lists": "packages/kbn-securitysolution-list-utils/src",
"exceptionList-components": "packages/kbn-securitysolution-exception-list-components/src", "exceptionList-components": "packages/kbn-securitysolution-exception-list-components/src",
"management": ["src/legacy/core_plugins/management", "src/plugins/management", "packages/kbn-management"], "management": [
"src/legacy/core_plugins/management",
"src/plugins/management",
"packages/kbn-management"
],
"monaco": "packages/kbn-monaco/src", "monaco": "packages/kbn-monaco/src",
"navigation": "src/plugins/navigation", "navigation": "src/plugins/navigation",
"newsfeed": "src/plugins/newsfeed", "newsfeed": "src/plugins/newsfeed",
@ -113,7 +119,7 @@
"visTypeVislib": "src/plugins/vis_types/vislib", "visTypeVislib": "src/plugins/vis_types/vislib",
"visTypeXy": "src/plugins/vis_types/xy", "visTypeXy": "src/plugins/vis_types/xy",
"visualizations": "src/plugins/visualizations", "visualizations": "src/plugins/visualizations",
"visualizationUiComponents": "src/plugins/visualization_ui_components", "visualizationUiComponents": "packages/kbn-visualization-ui-components",
"unifiedSearch": "src/plugins/unified_search", "unifiedSearch": "src/plugins/unified_search",
"unifiedFieldList": "packages/kbn-unified-field-list", "unifiedFieldList": "packages/kbn-unified-field-list",
"unifiedHistogram": "src/plugins/unified_histogram" "unifiedHistogram": "src/plugins/unified_histogram"

View file

@ -407,10 +407,6 @@ The plugin exposes the static DefaultEditorController class to consume.
|WARNING: Missing README. |WARNING: Missing README.
|{kib-repo}blob/{branch}/src/plugins/visualization_ui_components/README.md[visualizationUiComponents]
|A series of UI components pulled out of Lens to make them available outside Lens.
|=== |===
[discrete] [discrete]

View file

@ -394,6 +394,8 @@
"@kbn/es-types": "link:packages/kbn-es-types", "@kbn/es-types": "link:packages/kbn-es-types",
"@kbn/es-ui-shared-plugin": "link:src/plugins/es_ui_shared", "@kbn/es-ui-shared-plugin": "link:src/plugins/es_ui_shared",
"@kbn/eso-plugin": "link:x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin", "@kbn/eso-plugin": "link:x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin",
"@kbn/event-annotation-common": "link:packages/kbn-event-annotation-common",
"@kbn/event-annotation-components": "link:packages/kbn-event-annotation-components",
"@kbn/event-annotation-plugin": "link:src/plugins/event_annotation", "@kbn/event-annotation-plugin": "link:src/plugins/event_annotation",
"@kbn/event-log-fixture-plugin": "link:x-pack/test/plugin_api_integration/plugins/event_log", "@kbn/event-log-fixture-plugin": "link:x-pack/test/plugin_api_integration/plugins/event_log",
"@kbn/event-log-plugin": "link:x-pack/plugins/event_log", "@kbn/event-log-plugin": "link:x-pack/plugins/event_log",
@ -750,7 +752,7 @@
"@kbn/vis-type-vega-plugin": "link:src/plugins/vis_types/vega", "@kbn/vis-type-vega-plugin": "link:src/plugins/vis_types/vega",
"@kbn/vis-type-vislib-plugin": "link:src/plugins/vis_types/vislib", "@kbn/vis-type-vislib-plugin": "link:src/plugins/vis_types/vislib",
"@kbn/vis-type-xy-plugin": "link:src/plugins/vis_types/xy", "@kbn/vis-type-xy-plugin": "link:src/plugins/vis_types/xy",
"@kbn/visualization-ui-components": "link:src/plugins/visualization_ui_components", "@kbn/visualization-ui-components": "link:packages/kbn-visualization-ui-components",
"@kbn/visualizations-plugin": "link:src/plugins/visualizations", "@kbn/visualizations-plugin": "link:src/plugins/visualizations",
"@kbn/watcher-plugin": "link:x-pack/plugins/watcher", "@kbn/watcher-plugin": "link:x-pack/plugins/watcher",
"@loaders.gl/core": "^2.3.1", "@loaders.gl/core": "^2.3.1",

View file

@ -2,5 +2,6 @@
"name": "@kbn/coloring", "name": "@kbn/coloring",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0" "license": "SSPL-1.0 OR Elastic License 2.0",
"sideEffects": false
} }

View file

@ -0,0 +1,3 @@
# @kbn/event-annotation-common
A few core annotation-related types and utilities that are available in both server and browser contexts.

View file

@ -0,0 +1,52 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/
export const AvailableAnnotationIcons = {
ASTERISK: 'asterisk',
ALERT: 'alert',
BELL: 'bell',
BOLT: 'bolt',
BUG: 'bug',
CIRCLE: 'circle',
EDITOR_COMMENT: 'editorComment',
FLAG: 'flag',
HEART: 'heart',
MAP_MARKER: 'mapMarker',
PIN_FILLED: 'pinFilled',
STAR_EMPTY: 'starEmpty',
STAR_FILLED: 'starFilled',
TAG: 'tag',
TRIANGLE: 'triangle',
} as const;
export const EVENT_ANNOTATION_GROUP_TYPE = 'event-annotation-group';
export {
defaultAnnotationColor,
defaultAnnotationRangeColor,
defaultAnnotationLabel,
getDefaultManualAnnotation,
getDefaultQueryAnnotation,
createCopiedAnnotation,
isRangeAnnotationConfig,
isManualPointAnnotationConfig,
isQueryAnnotationConfig,
} from './util';
export type {
EventAnnotationGroupContent,
AvailableAnnotationIcon,
PointStyleProps,
EventAnnotationConfig,
EventAnnotationGroupConfig,
RangeStyleProps,
ManualAnnotationType,
PointInTimeEventAnnotationConfig,
RangeEventAnnotationConfig,
QueryPointEventAnnotationConfig,
} from './types';

View file

@ -0,0 +1,13 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/
module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-event-annotation-common'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/event-annotation-common",
"owner": "@elastic/kibana-visualizations"
}

View file

@ -0,0 +1,7 @@
{
"name": "@kbn/event-annotation-common",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"sideEffects": false
}

View file

@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/data-plugin",
"@kbn/content-management-table-list-view-table",
"@kbn/visualization-ui-components",
"@kbn/ui-theme",
"@kbn/i18n",
]
}

View file

@ -0,0 +1,89 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/
import { $Values } from 'utility-types';
import { DataViewSpec, KibanaQueryOutput } from '@kbn/data-plugin/common';
import { UserContentCommonSchema } from '@kbn/content-management-table-list-view-table';
import type { LineStyle } from '@kbn/visualization-ui-components';
import { AvailableAnnotationIcons } from '.';
export type AvailableAnnotationIcon = $Values<typeof AvailableAnnotationIcons>;
export type PointStyleProps = StyleSharedProps & {
icon?: AvailableAnnotationIcon;
lineWidth?: number;
lineStyle?: LineStyle;
textVisibility?: boolean;
};
export type PointInTimeEventAnnotationConfig = {
id: string;
type: ManualAnnotationType;
key: {
type: 'point_in_time';
timestamp: string;
};
} & PointStyleProps;
export type Fill = 'inside' | 'outside' | 'none';
export type ManualAnnotationType = 'manual';
export type QueryAnnotationType = 'query';
export type KeyType = 'point_in_time' | 'range';
interface StyleSharedProps {
label: string;
color?: string;
isHidden?: boolean;
}
export type RangeStyleProps = StyleSharedProps & {
outside?: boolean;
};
export type RangeEventAnnotationConfig = {
type: ManualAnnotationType;
id: string;
key: {
type: 'range';
timestamp: string;
endTimestamp: string;
};
} & RangeStyleProps;
export type StyleProps = PointStyleProps & RangeStyleProps;
export type QueryPointEventAnnotationConfig = {
id: string;
type: QueryAnnotationType;
filter: KibanaQueryOutput;
timeField?: string;
textField?: string;
extraFields?: string[];
key: {
type: 'point_in_time';
};
} & PointStyleProps;
export type EventAnnotationConfig =
| PointInTimeEventAnnotationConfig
| RangeEventAnnotationConfig
| QueryPointEventAnnotationConfig;
export interface EventAnnotationGroupConfig {
annotations: EventAnnotationConfig[];
indexPatternId: string;
ignoreGlobalFilters: boolean;
title: string;
description: string;
tags: string[];
dataViewSpec?: DataViewSpec;
}
export type EventAnnotationGroupContent = UserContentCommonSchema & {
attributes: { indexPatternId: string; dataViewSpec?: DataViewSpec };
};

View file

@ -6,12 +6,14 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import { euiLightVars } from '@kbn/ui-theme'; import { euiLightVars } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import { import {
EventAnnotationConfig, EventAnnotationConfig,
RangeEventAnnotationConfig, RangeEventAnnotationConfig,
PointInTimeEventAnnotationConfig, PointInTimeEventAnnotationConfig,
QueryPointEventAnnotationConfig, QueryPointEventAnnotationConfig,
} from '../../common'; } from './types';
export const defaultAnnotationColor = euiLightVars.euiColorAccent; export const defaultAnnotationColor = euiLightVars.euiColorAccent;
// Do not compute it live as dependencies will add tens of Kbs to the plugin // Do not compute it live as dependencies will add tens of Kbs to the plugin
export const defaultAnnotationRangeColor = `#F04E981A`; // defaultAnnotationColor with opacity 0.1 export const defaultAnnotationRangeColor = `#F04E981A`; // defaultAnnotationColor with opacity 0.1
@ -33,3 +35,57 @@ export const isQueryAnnotationConfig = (
): annotation is QueryPointEventAnnotationConfig => { ): annotation is QueryPointEventAnnotationConfig => {
return Boolean(annotation && annotation.type === 'query'); return Boolean(annotation && annotation.type === 'query');
}; };
export const createCopiedAnnotation = (
newId: string,
timestamp: string,
source?: EventAnnotationConfig
): EventAnnotationConfig => {
if (!source) {
return getDefaultManualAnnotation(newId, timestamp);
}
return {
...source,
id: newId,
};
};
export const defaultAnnotationLabel = i18n.translate(
'eventAnnotationCommon.manualAnnotation.defaultAnnotationLabel',
{
defaultMessage: 'Event',
}
);
export const getDefaultManualAnnotation = (
id: string,
timestamp: string
): EventAnnotationConfig => ({
label: defaultAnnotationLabel,
type: 'manual',
key: {
type: 'point_in_time',
timestamp,
},
icon: 'triangle',
id,
});
export const getDefaultQueryAnnotation = (
id: string,
fieldName: string,
timeField: string
): EventAnnotationConfig => ({
filter: {
type: 'kibana_query',
query: `${fieldName}: *`,
language: 'kuery',
},
timeField,
type: 'query',
key: {
type: 'point_in_time',
},
id,
label: `${fieldName}: *`,
});

View file

@ -0,0 +1,3 @@
# @kbn/event-annotation-components
A collection of static components used for interacting with event annotations.

View file

@ -7,7 +7,7 @@
*/ */
import './index.scss'; import './index.scss';
import { isFieldLensCompatible } from '@kbn/visualization-ui-components/public'; import { isFieldLensCompatible } from '@kbn/visualization-ui-components';
import React, { useCallback, useEffect } from 'react'; import React, { useCallback, useEffect } from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { EuiFormRow, EuiSwitch, EuiSwitchEvent, EuiButtonGroup, EuiSpacer } from '@elastic/eui'; import { EuiFormRow, EuiSwitch, EuiSwitchEvent, EuiButtonGroup, EuiSpacer } from '@elastic/eui';
@ -21,19 +21,19 @@ import {
FieldPicker, FieldPicker,
FieldOption, FieldOption,
type QueryInputServices, type QueryInputServices,
} from '@kbn/visualization-ui-components/public'; } from '@kbn/visualization-ui-components';
import type { FieldOptionValue } from '@kbn/visualization-ui-components/public'; import type { FieldOptionValue } from '@kbn/visualization-ui-components';
import { DataView } from '@kbn/data-views-plugin/common'; import { DataView } from '@kbn/data-views-plugin/common';
import { useExistingFieldsReader } from '@kbn/unified-field-list/src/hooks/use_existing_fields'; import { useExistingFieldsReader } from '@kbn/unified-field-list/src/hooks/use_existing_fields';
import moment from 'moment'; import moment from 'moment';
import { htmlIdGenerator } from '@elastic/eui'; import { htmlIdGenerator } from '@elastic/eui';
import { isQueryAnnotationConfig, isRangeAnnotationConfig } from '../..'; import type {
import {
AvailableAnnotationIcon, AvailableAnnotationIcon,
EventAnnotationConfig, EventAnnotationConfig,
PointInTimeEventAnnotationConfig, PointInTimeEventAnnotationConfig,
QueryPointEventAnnotationConfig, QueryPointEventAnnotationConfig,
} from '../../../common'; } from '@kbn/event-annotation-common';
import { isQueryAnnotationConfig, isRangeAnnotationConfig } from '../..';
import { import {
defaultAnnotationColor, defaultAnnotationColor,
defaultAnnotationLabel, defaultAnnotationLabel,
@ -88,35 +88,38 @@ const AnnotationEditorControls = ({
return ( return (
<> <>
<DimensionEditorSection <DimensionEditorSection
title={i18n.translate('eventAnnotation.xyChart.placement', { title={i18n.translate('eventAnnotationComponents.xyChart.placement', {
defaultMessage: 'Placement', defaultMessage: 'Placement',
})} })}
> >
<EuiFormRow <EuiFormRow
label={i18n.translate('eventAnnotation.xyChart.annotationDate.placementType', { label={i18n.translate('eventAnnotationComponents.xyChart.annotationDate.placementType', {
defaultMessage: 'Placement type', defaultMessage: 'Placement type',
})} })}
display="rowCompressed" display="rowCompressed"
fullWidth fullWidth
> >
<EuiButtonGroup <EuiButtonGroup
legend={i18n.translate('eventAnnotation.xyChart.annotationDate.placementType', { legend={i18n.translate(
'eventAnnotationComponents.xyChart.annotationDate.placementType',
{
defaultMessage: 'Placement type', defaultMessage: 'Placement type',
})} }
)}
data-test-subj="lns-xyAnnotation-placementType" data-test-subj="lns-xyAnnotation-placementType"
name="placementType" name="placementType"
buttonSize="compressed" buttonSize="compressed"
options={[ options={[
{ {
id: `lens_xyChart_annotation_manual`, id: `lens_xyChart_annotation_manual`,
label: i18n.translate('eventAnnotation.xyChart.annotation.manual', { label: i18n.translate('eventAnnotationComponents.xyChart.annotation.manual', {
defaultMessage: 'Static date', defaultMessage: 'Static date',
}), }),
'data-test-subj': 'lnsXY_annotation_manual', 'data-test-subj': 'lnsXY_annotation_manual',
}, },
{ {
id: `lens_xyChart_annotation_query`, id: `lens_xyChart_annotation_query`,
label: i18n.translate('eventAnnotation.xyChart.annotation.query', { label: i18n.translate('eventAnnotationComponents.xyChart.annotation.query', {
defaultMessage: 'Custom query', defaultMessage: 'Custom query',
}), }),
'data-test-subj': 'lnsXY_annotation_query', 'data-test-subj': 'lnsXY_annotation_query',
@ -183,7 +186,7 @@ const AnnotationEditorControls = ({
)} )}
</DimensionEditorSection> </DimensionEditorSection>
<DimensionEditorSection <DimensionEditorSection
title={i18n.translate('eventAnnotation.xyChart.appearance', { title={i18n.translate('eventAnnotationComponents.xyChart.appearance', {
defaultMessage: 'Appearance', defaultMessage: 'Appearance',
})} })}
> >
@ -276,14 +279,14 @@ const AnnotationEditorControls = ({
)} )}
{isRange && ( {isRange && (
<EuiFormRow <EuiFormRow
label={i18n.translate('eventAnnotation.xyChart.fillStyle', { label={i18n.translate('eventAnnotationComponents.xyChart.fillStyle', {
defaultMessage: 'Fill', defaultMessage: 'Fill',
})} })}
display="columnCompressed" display="columnCompressed"
fullWidth fullWidth
> >
<EuiButtonGroup <EuiButtonGroup
legend={i18n.translate('eventAnnotation.xyChart.fillStyle', { legend={i18n.translate('eventAnnotationComponents.xyChart.fillStyle', {
defaultMessage: 'Fill', defaultMessage: 'Fill',
})} })}
data-test-subj="lns-xyAnnotation-fillStyle" data-test-subj="lns-xyAnnotation-fillStyle"
@ -292,14 +295,14 @@ const AnnotationEditorControls = ({
options={[ options={[
{ {
id: `lens_xyChart_fillStyle_inside`, id: `lens_xyChart_fillStyle_inside`,
label: i18n.translate('eventAnnotation.xyChart.fillStyle.inside', { label: i18n.translate('eventAnnotationComponents.xyChart.fillStyle.inside', {
defaultMessage: 'Inside', defaultMessage: 'Inside',
}), }),
'data-test-subj': 'lnsXY_fillStyle_inside', 'data-test-subj': 'lnsXY_fillStyle_inside',
}, },
{ {
id: `lens_xyChart_fillStyle_outside`, id: `lens_xyChart_fillStyle_outside`,
label: i18n.translate('eventAnnotation.xyChart.fillStyle.outside', { label: i18n.translate('eventAnnotationComponents.xyChart.fillStyle.outside', {
defaultMessage: 'Outside', defaultMessage: 'Outside',
}), }),
'data-test-subj': 'lnsXY_fillStyle_inside', 'data-test-subj': 'lnsXY_fillStyle_inside',
@ -324,12 +327,12 @@ const AnnotationEditorControls = ({
showAlpha={isRange} showAlpha={isRange}
setConfig={update} setConfig={update}
disableHelpTooltip disableHelpTooltip
label={i18n.translate('eventAnnotation.xyChart.lineColor.label', { label={i18n.translate('eventAnnotationComponents.xyChart.lineColor.label', {
defaultMessage: 'Color', defaultMessage: 'Color',
})} })}
/> />
<ConfigPanelGenericSwitch <ConfigPanelGenericSwitch
label={i18n.translate('eventAnnotation.xyChart.annotation.hide', { label={i18n.translate('eventAnnotationComponents.xyChart.annotation.hide', {
defaultMessage: 'Hide annotation', defaultMessage: 'Hide annotation',
})} })}
data-test-subj="lns-annotations-hide-annotation" data-test-subj="lns-annotations-hide-annotation"
@ -339,7 +342,7 @@ const AnnotationEditorControls = ({
</DimensionEditorSection> </DimensionEditorSection>
{isQueryBased && currentAnnotation && ( {isQueryBased && currentAnnotation && (
<DimensionEditorSection <DimensionEditorSection
title={i18n.translate('eventAnnotation.xyChart.tooltip', { title={i18n.translate('eventAnnotationComponents.xyChart.tooltip', {
defaultMessage: 'Tooltip', defaultMessage: 'Tooltip',
})} })}
> >
@ -347,7 +350,7 @@ const AnnotationEditorControls = ({
display="rowCompressed" display="rowCompressed"
className="lnsRowCompressedMargin" className="lnsRowCompressedMargin"
fullWidth fullWidth
label={i18n.translate('eventAnnotation.xyChart.annotation.tooltip', { label={i18n.translate('eventAnnotationComponents.xyChart.annotation.tooltip', {
defaultMessage: 'Show additional fields', defaultMessage: 'Show additional fields',
})} })}
> >

View file

@ -11,27 +11,27 @@ import { pick } from 'lodash';
import { euiLightVars } from '@kbn/ui-theme'; import { euiLightVars } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import chroma from 'chroma-js'; import chroma from 'chroma-js';
import { isQueryAnnotationConfig, isRangeAnnotationConfig } from '../..';
import type { import type {
EventAnnotationConfig, EventAnnotationConfig,
RangeEventAnnotationConfig, RangeEventAnnotationConfig,
PointInTimeEventAnnotationConfig, PointInTimeEventAnnotationConfig,
QueryPointEventAnnotationConfig, QueryPointEventAnnotationConfig,
} from '../../../common'; } from '@kbn/event-annotation-common';
import { isQueryAnnotationConfig, isRangeAnnotationConfig } from '../..';
export const defaultAnnotationColor = euiLightVars.euiColorAccent; export const defaultAnnotationColor = euiLightVars.euiColorAccent;
// Do not compute it live as dependencies will add tens of Kbs to the plugin // Do not compute it live as dependencies will add tens of Kbs to the plugin
export const defaultAnnotationRangeColor = `#F04E981A`; // defaultAnnotationColor with opacity 0.1 export const defaultAnnotationRangeColor = `#F04E981A`; // defaultAnnotationColor with opacity 0.1
export const defaultAnnotationLabel = i18n.translate( export const defaultAnnotationLabel = i18n.translate(
'eventAnnotation.xyChart.defaultAnnotationLabel', 'eventAnnotationComponents.xyChart.defaultAnnotationLabel',
{ {
defaultMessage: 'Event', defaultMessage: 'Event',
} }
); );
export const defaultRangeAnnotationLabel = i18n.translate( export const defaultRangeAnnotationLabel = i18n.translate(
'eventAnnotation.xyChart.defaultRangeAnnotationLabel', 'eventAnnotationComponents.xyChart.defaultRangeAnnotationLabel',
{ {
defaultMessage: 'Event range', defaultMessage: 'Event range',
} }

View file

@ -8,43 +8,43 @@
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { IconTriangle, IconCircle } from '@kbn/chart-icons'; import { IconTriangle, IconCircle } from '@kbn/chart-icons';
import type { IconSet } from '@kbn/visualization-ui-components/public'; import type { IconSet } from '@kbn/visualization-ui-components';
import { AvailableAnnotationIcon } from '../../../common'; import type { AvailableAnnotationIcon } from '@kbn/event-annotation-common';
export const annotationsIconSet: IconSet<AvailableAnnotationIcon> = [ export const annotationsIconSet: IconSet<AvailableAnnotationIcon> = [
{ {
value: 'asterisk', value: 'asterisk',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.asteriskIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.asteriskIconLabel', {
defaultMessage: 'Asterisk', defaultMessage: 'Asterisk',
}), }),
}, },
{ {
value: 'alert', value: 'alert',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.alertIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.alertIconLabel', {
defaultMessage: 'Alert', defaultMessage: 'Alert',
}), }),
}, },
{ {
value: 'bell', value: 'bell',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.bellIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.bellIconLabel', {
defaultMessage: 'Bell', defaultMessage: 'Bell',
}), }),
}, },
{ {
value: 'bolt', value: 'bolt',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.boltIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.boltIconLabel', {
defaultMessage: 'Bolt', defaultMessage: 'Bolt',
}), }),
}, },
{ {
value: 'bug', value: 'bug',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.bugIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.bugIconLabel', {
defaultMessage: 'Bug', defaultMessage: 'Bug',
}), }),
}, },
{ {
value: 'circle', value: 'circle',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.circleIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.circleIconLabel', {
defaultMessage: 'Circle', defaultMessage: 'Circle',
}), }),
icon: IconCircle, icon: IconCircle,
@ -52,55 +52,55 @@ export const annotationsIconSet: IconSet<AvailableAnnotationIcon> = [
{ {
value: 'editorComment', value: 'editorComment',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.commentIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.commentIconLabel', {
defaultMessage: 'Comment', defaultMessage: 'Comment',
}), }),
}, },
{ {
value: 'flag', value: 'flag',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.flagIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.flagIconLabel', {
defaultMessage: 'Flag', defaultMessage: 'Flag',
}), }),
}, },
{ {
value: 'heart', value: 'heart',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.heartLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.heartLabel', {
defaultMessage: 'Heart', defaultMessage: 'Heart',
}), }),
}, },
{ {
value: 'mapMarker', value: 'mapMarker',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.mapMarkerLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.mapMarkerLabel', {
defaultMessage: 'Map Marker', defaultMessage: 'Map Marker',
}), }),
}, },
{ {
value: 'pinFilled', value: 'pinFilled',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.mapPinLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.mapPinLabel', {
defaultMessage: 'Map Pin', defaultMessage: 'Map Pin',
}), }),
}, },
{ {
value: 'starEmpty', value: 'starEmpty',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.starLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.starLabel', {
defaultMessage: 'Star', defaultMessage: 'Star',
}), }),
}, },
{ {
value: 'starFilled', value: 'starFilled',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.starFilledLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.starFilledLabel', {
defaultMessage: 'Star filled', defaultMessage: 'Star filled',
}), }),
}, },
{ {
value: 'tag', value: 'tag',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.tagIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.tagIconLabel', {
defaultMessage: 'Tag', defaultMessage: 'Tag',
}), }),
}, },
{ {
value: 'triangle', value: 'triangle',
label: i18n.translate('eventAnnotation.xyChart.iconSelect.triangleIconLabel', { label: i18n.translate('eventAnnotationComponents.xyChart.iconSelect.triangleIconLabel', {
defaultMessage: 'Triangle', defaultMessage: 'Triangle',
}), }),
icon: IconTriangle, icon: IconTriangle,

View file

@ -11,8 +11,11 @@ import AnnotationEditorControls from './annotation_editor_controls';
import React from 'react'; import React from 'react';
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import { EventAnnotationConfig, RangeEventAnnotationConfig } from '../../../common'; import type {
import { QueryInputServices } from '@kbn/visualization-ui-components/public'; EventAnnotationConfig,
RangeEventAnnotationConfig,
} from '@kbn/event-annotation-common';
import { QueryInputServices } from '@kbn/visualization-ui-components';
import moment from 'moment'; import moment from 'moment';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import { EuiButtonGroup } from '@elastic/eui'; import { EuiButtonGroup } from '@elastic/eui';

View file

@ -35,7 +35,7 @@ export const ConfigPanelManualAnnotation = ({
<ConfigPanelRangeDatePicker <ConfigPanelRangeDatePicker
dataTestSubj="lns-xyAnnotation-fromTime" dataTestSubj="lns-xyAnnotation-fromTime"
calendarClassName={calendarClassName} calendarClassName={calendarClassName}
prependLabel={i18n.translate('eventAnnotation.xyChart.annotationDate.from', { prependLabel={i18n.translate('eventAnnotationComponents.xyChart.annotationDate.from', {
defaultMessage: 'From', defaultMessage: 'From',
})} })}
value={moment(annotation?.key.timestamp)} value={moment(annotation?.key.timestamp)}
@ -62,14 +62,14 @@ export const ConfigPanelManualAnnotation = ({
} }
} }
}} }}
label={i18n.translate('eventAnnotation.xyChart.annotationDate', { label={i18n.translate('eventAnnotationComponents.xyChart.annotationDate', {
defaultMessage: 'Annotation date', defaultMessage: 'Annotation date',
})} })}
/> />
<ConfigPanelRangeDatePicker <ConfigPanelRangeDatePicker
dataTestSubj="lns-xyAnnotation-toTime" dataTestSubj="lns-xyAnnotation-toTime"
calendarClassName={calendarClassName} calendarClassName={calendarClassName}
prependLabel={i18n.translate('eventAnnotation.xyChart.annotationDate.to', { prependLabel={i18n.translate('eventAnnotationComponents.xyChart.annotationDate.to', {
defaultMessage: 'To', defaultMessage: 'To',
})} })}
value={moment(annotation?.key.endTimestamp)} value={moment(annotation?.key.endTimestamp)}
@ -102,7 +102,7 @@ export const ConfigPanelManualAnnotation = ({
<ConfigPanelRangeDatePicker <ConfigPanelRangeDatePicker
dataTestSubj="lns-xyAnnotation-time" dataTestSubj="lns-xyAnnotation-time"
calendarClassName={calendarClassName} calendarClassName={calendarClassName}
label={i18n.translate('eventAnnotation.xyChart.annotationDate', { label={i18n.translate('eventAnnotationComponents.xyChart.annotationDate', {
defaultMessage: 'Annotation date', defaultMessage: 'Annotation date',
})} })}
value={moment(annotation?.key.timestamp)} value={moment(annotation?.key.timestamp)}

View file

@ -16,11 +16,11 @@ import {
FieldOptionValue, FieldOptionValue,
FieldPicker, FieldPicker,
FilterQueryInput, FilterQueryInput,
isFieldLensCompatible,
type QueryInputServices, type QueryInputServices,
} from '@kbn/visualization-ui-components/public'; } from '@kbn/visualization-ui-components';
import type { DataView } from '@kbn/data-views-plugin/common'; import type { DataView } from '@kbn/data-views-plugin/common';
import { isFieldLensCompatible } from '@kbn/visualization-ui-components/public'; import type { QueryPointEventAnnotationConfig } from '@kbn/event-annotation-common';
import type { QueryPointEventAnnotationConfig } from '../../../common';
export const defaultQuery: Query = { export const defaultQuery: Query = {
query: '', query: '',
@ -71,7 +71,7 @@ export const ConfigPanelQueryAnnotation = ({
display="rowCompressed" display="rowCompressed"
className="lnsRowCompressedMargin" className="lnsRowCompressedMargin"
fullWidth fullWidth
label={i18n.translate('eventAnnotation.xyChart.annotation.queryInput', { label={i18n.translate('eventAnnotationComponents.xyChart.annotation.queryInput', {
defaultMessage: 'Annotation query', defaultMessage: 'Annotation query',
})} })}
> >
@ -92,7 +92,7 @@ export const ConfigPanelQueryAnnotation = ({
<EuiFormRow <EuiFormRow
display="rowCompressed" display="rowCompressed"
fullWidth fullWidth
label={i18n.translate('eventAnnotation.xyChart.annotation.queryField', { label={i18n.translate('eventAnnotationComponents.xyChart.annotation.queryField', {
defaultMessage: 'Target date field', defaultMessage: 'Target date field',
})} })}
> >

View file

@ -17,8 +17,11 @@ import {
EuiDatePicker, EuiDatePicker,
} from '@elastic/eui'; } from '@elastic/eui';
import moment from 'moment'; import moment from 'moment';
import type {
PointInTimeEventAnnotationConfig,
RangeEventAnnotationConfig,
} from '@kbn/event-annotation-common';
import { isRangeAnnotationConfig } from '../..'; import { isRangeAnnotationConfig } from '../..';
import type { PointInTimeEventAnnotationConfig, RangeEventAnnotationConfig } from '../../../common';
import { defaultRangeAnnotationLabel, defaultAnnotationLabel } from './helpers'; import { defaultRangeAnnotationLabel, defaultAnnotationLabel } from './helpers';
import { toLineAnnotationColor, toRangeAnnotationColor } from './helpers'; import { toLineAnnotationColor, toRangeAnnotationColor } from './helpers';
import type { ManualEventAnnotationType } from './types'; import type { ManualEventAnnotationType } from './types';
@ -39,7 +42,7 @@ export const ConfigPanelApplyAsRangeSwitch = ({
data-test-subj="lns-xyAnnotation-rangeSwitch" data-test-subj="lns-xyAnnotation-rangeSwitch"
label={ label={
<EuiText size="xs"> <EuiText size="xs">
{i18n.translate('eventAnnotation.xyChart.applyAsRange', { {i18n.translate('eventAnnotationComponents.xyChart.applyAsRange', {
defaultMessage: 'Apply as range', defaultMessage: 'Apply as range',
})} })}
</EuiText> </EuiText>

View file

@ -19,10 +19,10 @@ import {
DragDropBuckets, DragDropBuckets,
DraggableBucketContainer, DraggableBucketContainer,
FieldsBucketContainer, FieldsBucketContainer,
} from '@kbn/visualization-ui-components/public'; isFieldLensCompatible,
} from '@kbn/visualization-ui-components';
import { DataView } from '@kbn/data-views-plugin/common'; import { DataView } from '@kbn/data-views-plugin/common';
import { isFieldLensCompatible } from '@kbn/visualization-ui-components/public'; import type { QueryPointEventAnnotationConfig } from '@kbn/event-annotation-common';
import { QueryPointEventAnnotationConfig } from '../../../common';
export const MAX_TOOLTIP_FIELDS_SIZE = 2; export const MAX_TOOLTIP_FIELDS_SIZE = 2;
@ -98,7 +98,7 @@ export function TooltipSection({
onClick={() => { onClick={() => {
handleInputChange([...localValues, { id: generateId(), value: undefined, isNew: true }]); handleInputChange([...localValues, { id: generateId(), value: undefined, isNew: true }]);
}} }}
label={i18n.translate('eventAnnotation.xyChart.annotation.tooltip.addField', { label={i18n.translate('eventAnnotationComponents.xyChart.annotation.tooltip.addField', {
defaultMessage: 'Add field', defaultMessage: 'Add field',
})} })}
isDisabled={localValues.length > MAX_TOOLTIP_FIELDS_SIZE} isDisabled={localValues.length > MAX_TOOLTIP_FIELDS_SIZE}
@ -115,7 +115,7 @@ export function TooltipSection({
className="lnsConfigPanelAnnotations__noFieldsPrompt" className="lnsConfigPanelAnnotations__noFieldsPrompt"
> >
<EuiText color="subdued" size="s" textAlign="center"> <EuiText color="subdued" size="s" textAlign="center">
{i18n.translate('eventAnnotation.xyChart.annotation.tooltip.noFields', { {i18n.translate('eventAnnotationComponents.xyChart.annotation.tooltip.noFields', {
defaultMessage: 'None selected', defaultMessage: 'None selected',
})} })}
</EuiText> </EuiText>
@ -170,7 +170,7 @@ export function TooltipSection({
handleInputChange(arrayRef.filter((_, i) => i !== index)); handleInputChange(arrayRef.filter((_, i) => i !== index));
}} }}
removeTitle={i18n.translate( removeTitle={i18n.translate(
'eventAnnotation.xyChart.annotation.tooltip.deleteButtonLabel', 'eventAnnotationComponents.xyChart.annotation.tooltip.deleteButtonLabel',
{ {
defaultMessage: 'Delete', defaultMessage: 'Delete',
} }

View file

@ -6,7 +6,10 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import type { PointInTimeEventAnnotationConfig, RangeEventAnnotationConfig } from '../../../common'; import type {
PointInTimeEventAnnotationConfig,
RangeEventAnnotationConfig,
} from '@kbn/event-annotation-common';
export type ManualEventAnnotationType = export type ManualEventAnnotationType =
| PointInTimeEventAnnotationConfig | PointInTimeEventAnnotationConfig

View file

@ -0,0 +1,135 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/
import React, { useEffect, useState } from 'react';
import { i18n } from '@kbn/i18n';
import type { CoreStart } from '@kbn/core/public';
import { FormattedMessage } from '@kbn/i18n-react';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import type { SavedObjectCommon } from '@kbn/saved-objects-finder-plugin/common';
import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public';
import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import {
EuiButton,
EuiEmptyPrompt,
EuiFlexGroup,
EuiFlexItem,
EuiLoadingSpinner,
EuiText,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { EVENT_ANNOTATION_GROUP_TYPE } from '@kbn/event-annotation-common';
export const EventAnnotationGroupSavedObjectFinder = ({
uiSettings,
http,
savedObjectsManagement,
fixedPageSize = 10,
checkHasAnnotationGroups,
onChoose,
onCreateNew,
}: {
uiSettings: IUiSettingsClient;
http: CoreStart['http'];
savedObjectsManagement: SavedObjectsManagementPluginStart;
fixedPageSize?: number;
checkHasAnnotationGroups: () => Promise<boolean>;
onChoose: (value: {
id: string;
type: string;
fullName: string;
savedObject: SavedObjectCommon<unknown>;
}) => void;
onCreateNew: () => void;
}) => {
const [hasAnnotationGroups, setHasAnnotationGroups] = useState<boolean | undefined>();
useEffect(() => {
checkHasAnnotationGroups().then(setHasAnnotationGroups);
}, [checkHasAnnotationGroups]);
return hasAnnotationGroups === undefined ? (
<EuiFlexGroup responsive={false} justifyContent="center">
<EuiFlexItem grow={0}>
<EuiLoadingSpinner />
</EuiFlexItem>
</EuiFlexGroup>
) : hasAnnotationGroups === false ? (
<EuiFlexGroup
css={css`
height: 100%;
`}
direction="column"
justifyContent="center"
>
<EuiFlexItem>
<EuiEmptyPrompt
titleSize="xs"
title={
<h2>
<FormattedMessage
id="eventAnnotationComponents.eventAnnotationGroup.savedObjectFinder.emptyPromptTitle"
defaultMessage="Start by adding an annotation layer"
/>
</h2>
}
body={
<EuiText size="s">
<p>
<FormattedMessage
id="eventAnnotationComponents.eventAnnotationGroup.savedObjectFinder.emptyPromptDescription"
defaultMessage="There are currently no annotations available to select from the library. Create a new layer to add annotations."
/>
</p>
</EuiText>
}
actions={
<EuiButton onClick={() => onCreateNew()} size="s">
<FormattedMessage
id="eventAnnotationComponents.eventAnnotationGroup.savedObjectFinder.emptyCTA"
defaultMessage="Create annotation layer"
/>
</EuiButton>
}
/>
</EuiFlexItem>
</EuiFlexGroup>
) : (
<SavedObjectFinder
key="searchSavedObjectFinder"
fixedPageSize={fixedPageSize}
onChoose={(id, type, fullName, savedObject) => {
onChoose({ id, type, fullName, savedObject });
}}
showFilter={false}
noItemsMessage={
<FormattedMessage
id="eventAnnotationComponents.eventAnnotationGroup.savedObjectFinder.notFoundLabel"
defaultMessage="No matching annotation groups found."
/>
}
savedObjectMetaData={savedObjectMetaData}
services={{
uiSettings,
http,
savedObjectsManagement,
}}
/>
);
};
const savedObjectMetaData = [
{
type: EVENT_ANNOTATION_GROUP_TYPE,
getIconForSavedObject: () => 'annotation',
name: i18n.translate('eventAnnotationComponents.eventAnnotationGroup.metadata.name', {
defaultMessage: 'Annotations Groups',
}),
includeFields: ['*'],
},
];

View file

@ -6,13 +6,13 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import type { AccessorConfig } from '@kbn/visualization-ui-components/public'; import type { AccessorConfig } from '@kbn/visualization-ui-components';
import { EventAnnotationConfig } from '../../common'; import type { EventAnnotationConfig } from '@kbn/event-annotation-common';
import { import {
defaultAnnotationColor, defaultAnnotationColor,
defaultAnnotationRangeColor, defaultAnnotationRangeColor,
isRangeAnnotationConfig, isRangeAnnotationConfig,
} from '../event_annotation_service/helpers'; } from '@kbn/event-annotation-common';
import { annotationsIconSet } from './annotation_editor_controls/icon_set'; import { annotationsIconSet } from './annotation_editor_controls/icon_set';
export const getAnnotationAccessor = (annotation: EventAnnotationConfig): AccessorConfig => { export const getAnnotationAccessor = (annotation: EventAnnotationConfig): AccessorConfig => {

View file

@ -17,12 +17,13 @@ import {
DimensionButton, DimensionButton,
DimensionTrigger, DimensionTrigger,
EmptyDimensionButton, EmptyDimensionButton,
} from '@kbn/visualization-ui-components/public'; } from '@kbn/visualization-ui-components';
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { euiThemeVars } from '@kbn/ui-theme'; import { euiThemeVars } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { createCopiedAnnotation, EventAnnotationConfig } from '../../../common'; import type { EventAnnotationConfig } from '@kbn/event-annotation-common';
import { createCopiedAnnotation } from '@kbn/event-annotation-common';
import { getAnnotationAccessor } from '..'; import { getAnnotationAccessor } from '..';
export const AnnotationList = ({ export const AnnotationList = ({
@ -39,7 +40,7 @@ export const AnnotationList = ({
setNewAnnotationId(uuidv4()); setNewAnnotationId(uuidv4());
}, [annotations.length]); }, [annotations.length]);
const addAnnotationText = i18n.translate('eventAnnotation.annotationList.add', { const addAnnotationText = i18n.translate('eventAnnotationComponents.annotationList.add', {
defaultMessage: 'Add annotation', defaultMessage: 'Add annotation',
}); });
@ -118,7 +119,7 @@ export const AnnotationList = ({
}} }}
> >
<DimensionButton <DimensionButton
groupLabel={i18n.translate('eventAnnotation.groupEditor.addAnnotation', { groupLabel={i18n.translate('eventAnnotationComponents.groupEditor.addAnnotation', {
defaultMessage: 'Annotations', defaultMessage: 'Annotations',
})} })}
onClick={() => selectAnnotation(annotation)} onClick={() => selectAnnotation(annotation)}

View file

@ -7,14 +7,15 @@
*/ */
import React, { ChangeEvent, FormEvent } from 'react'; import React, { ChangeEvent, FormEvent } from 'react';
import { EventAnnotationGroupConfig, getDefaultManualAnnotation } from '../../../common'; import type { EventAnnotationGroupConfig } from '@kbn/event-annotation-common';
import { getDefaultManualAnnotation } from '@kbn/event-annotation-common';
import { ReactWrapper } from 'enzyme'; import { ReactWrapper } from 'enzyme';
import { mountWithIntl } from '@kbn/test-jest-helpers'; import { mountWithIntl } from '@kbn/test-jest-helpers';
import { GroupEditorControls } from './group_editor_controls'; import { GroupEditorControls } from './group_editor_controls';
import { EuiTextAreaProps, EuiTextProps } from '@elastic/eui'; import { EuiTextAreaProps, EuiTextProps } from '@elastic/eui';
import type { DataView } from '@kbn/data-views-plugin/common'; import type { DataView } from '@kbn/data-views-plugin/common';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import type { QueryInputServices } from '@kbn/visualization-ui-components/public'; import type { QueryInputServices } from '@kbn/visualization-ui-components';
import { AnnotationEditorControls, ENABLE_INDIVIDUAL_ANNOTATION_EDITING } from '..'; import { AnnotationEditorControls, ENABLE_INDIVIDUAL_ANNOTATION_EDITING } from '..';
jest.mock('@elastic/eui', () => { jest.mock('@elastic/eui', () => {

View file

@ -19,12 +19,15 @@ import { css } from '@emotion/react';
import type { DataView, DataViewSpec } from '@kbn/data-views-plugin/common'; import type { DataView, DataViewSpec } from '@kbn/data-views-plugin/common';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react'; import { FormattedMessage } from '@kbn/i18n-react';
import { SavedObjectsTaggingApiUiComponent } from '@kbn/saved-objects-tagging-oss-plugin/public'; import type { SavedObjectsTaggingApiUiComponent } from '@kbn/saved-objects-tagging-oss-plugin/public';
import { euiThemeVars } from '@kbn/ui-theme'; import { euiThemeVars } from '@kbn/ui-theme';
import { QueryInputServices } from '@kbn/visualization-ui-components/public'; import { QueryInputServices } from '@kbn/visualization-ui-components';
import React, { useCallback, useEffect, useMemo, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { EVENT_ANNOTATION_APP_NAME } from '../../../common/constants'; import type {
import { EventAnnotationConfig, EventAnnotationGroupConfig } from '../../../common'; EventAnnotationConfig,
EventAnnotationGroupConfig,
} from '@kbn/event-annotation-common';
import { EVENT_ANNOTATION_APP_NAME } from '../../constants';
import { AnnotationEditorControls } from '../annotation_editor_controls'; import { AnnotationEditorControls } from '../annotation_editor_controls';
import { AnnotationList } from './annotation_list'; import { AnnotationList } from './annotation_list';
@ -99,16 +102,19 @@ export const GroupEditorControls = ({
`} `}
> >
<h4> <h4>
<FormattedMessage id="eventAnnotation.groupEditor.details" defaultMessage="Details" /> <FormattedMessage
id="eventAnnotationComponents.groupEditor.details"
defaultMessage="Details"
/>
</h4> </h4>
</EuiTitle> </EuiTitle>
<EuiForm> <EuiForm>
<EuiFormRow <EuiFormRow
label={i18n.translate('eventAnnotation.groupEditor.title', { label={i18n.translate('eventAnnotationComponents.groupEditor.title', {
defaultMessage: 'Title', defaultMessage: 'Title',
})} })}
isInvalid={showValidation && !isTitleValid(group.title)} isInvalid={showValidation && !isTitleValid(group.title)}
error={i18n.translate('eventAnnotation.groupEditor.titleRequired', { error={i18n.translate('eventAnnotationComponents.groupEditor.titleRequired', {
defaultMessage: 'A title is required.', defaultMessage: 'A title is required.',
})} })}
> >
@ -125,13 +131,13 @@ export const GroupEditorControls = ({
/> />
</EuiFormRow> </EuiFormRow>
<EuiFormRow <EuiFormRow
label={i18n.translate('eventAnnotation.groupEditor.description', { label={i18n.translate('eventAnnotationComponents.groupEditor.description', {
defaultMessage: 'Description', defaultMessage: 'Description',
})} })}
labelAppend={ labelAppend={
<EuiText color="subdued" size="xs"> <EuiText color="subdued" size="xs">
<FormattedMessage <FormattedMessage
id="eventAnnotation.groupEditor.optional" id="eventAnnotationComponents.groupEditor.optional"
defaultMessage="Optional" defaultMessage="Optional"
/> />
</EuiText> </EuiText>
@ -163,7 +169,7 @@ export const GroupEditorControls = ({
{ENABLE_INDIVIDUAL_ANNOTATION_EDITING && ( {ENABLE_INDIVIDUAL_ANNOTATION_EDITING && (
<> <>
<EuiFormRow <EuiFormRow
label={i18n.translate('eventAnnotation.groupEditor.dataView', { label={i18n.translate('eventAnnotationComponents.groupEditor.dataView', {
defaultMessage: 'Data view', defaultMessage: 'Data view',
})} })}
> >
@ -185,7 +191,7 @@ export const GroupEditorControls = ({
/> />
</EuiFormRow> </EuiFormRow>
<EuiFormRow <EuiFormRow
label={i18n.translate('eventAnnotation.groupEditor.addAnnotation', { label={i18n.translate('eventAnnotationComponents.groupEditor.addAnnotation', {
defaultMessage: 'Annotations', defaultMessage: 'Annotations',
})} })}
> >

View file

@ -7,14 +7,15 @@
*/ */
import { EuiButton, EuiFlyout } from '@elastic/eui'; import { EuiButton, EuiFlyout } from '@elastic/eui';
import { EventAnnotationGroupConfig, getDefaultManualAnnotation } from '../../common'; import { getDefaultManualAnnotation } from '@kbn/event-annotation-common';
import type { EventAnnotationGroupConfig } from '@kbn/event-annotation-common';
import { taggingApiMock } from '@kbn/saved-objects-tagging-oss-plugin/public/api.mock'; import { taggingApiMock } from '@kbn/saved-objects-tagging-oss-plugin/public/api.mock';
import { shallow, ShallowWrapper } from 'enzyme'; import { shallow, ShallowWrapper } from 'enzyme';
import React from 'react'; import React from 'react';
import { GroupEditorControls } from './group_editor_controls'; import { GroupEditorControls } from './group_editor_controls';
import { GroupEditorFlyout } from './group_editor_flyout'; import { GroupEditorFlyout } from './group_editor_flyout';
import { DataView } from '@kbn/data-views-plugin/common'; import { DataView } from '@kbn/data-views-plugin/common';
import type { QueryInputServices } from '@kbn/visualization-ui-components/public'; import type { QueryInputServices } from '@kbn/visualization-ui-components';
const simulateButtonClick = (component: ShallowWrapper, selector: string) => { const simulateButtonClick = (component: ShallowWrapper, selector: string) => {
(component.find(selector) as ShallowWrapper<Parameters<typeof EuiButton>[0]>).prop('onClick')!( (component.find(selector) as ShallowWrapper<Parameters<typeof EuiButton>[0]>).prop('onClick')!(

View file

@ -20,10 +20,13 @@ import {
} from '@elastic/eui'; } from '@elastic/eui';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react'; import { FormattedMessage } from '@kbn/i18n-react';
import { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import type { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public';
import { DataView, DataViewSpec } from '@kbn/data-views-plugin/common'; import { DataView, DataViewSpec } from '@kbn/data-views-plugin/common';
import type { QueryInputServices } from '@kbn/visualization-ui-components/public'; import type { QueryInputServices } from '@kbn/visualization-ui-components';
import { EventAnnotationConfig, EventAnnotationGroupConfig } from '../../common'; import type {
EventAnnotationConfig,
EventAnnotationGroupConfig,
} from '@kbn/event-annotation-common';
import { GroupEditorControls, isGroupValid } from './group_editor_controls'; import { GroupEditorControls, isGroupValid } from './group_editor_controls';
export const GroupEditorFlyout = ({ export const GroupEditorFlyout = ({
@ -78,7 +81,7 @@ export const GroupEditorFlyout = ({
<EuiTitle size="s"> <EuiTitle size="s">
<h2 id={flyoutHeadingId}> <h2 id={flyoutHeadingId}>
<FormattedMessage <FormattedMessage
id="eventAnnotation.groupEditorFlyout.title" id="eventAnnotationComponents.groupEditorFlyout.title"
defaultMessage="Edit annotation group" defaultMessage="Edit annotation group"
/> />
</h2> </h2>
@ -108,14 +111,17 @@ export const GroupEditorFlyout = ({
data-test-subj="backToGroupSettings" data-test-subj="backToGroupSettings"
onClick={() => setSelectedAnnotation(undefined)} onClick={() => setSelectedAnnotation(undefined)}
> >
<FormattedMessage id="eventAnnotation.edit.back" defaultMessage="Back" /> <FormattedMessage id="eventAnnotationComponents.edit.back" defaultMessage="Back" />
</EuiButtonEmpty> </EuiButtonEmpty>
</EuiFlexItem> </EuiFlexItem>
) : ( ) : (
<> <>
<EuiFlexItem grow={false}> <EuiFlexItem grow={false}>
<EuiButtonEmpty data-test-subj="cancelGroupEdit" onClick={onClose}> <EuiButtonEmpty data-test-subj="cancelGroupEdit" onClick={onClose}>
<FormattedMessage id="eventAnnotation.edit.cancel" defaultMessage="Cancel" /> <FormattedMessage
id="eventAnnotationComponents.edit.cancel"
defaultMessage="Cancel"
/>
</EuiButtonEmpty> </EuiButtonEmpty>
</EuiFlexItem> </EuiFlexItem>
<EuiFlexItem grow={false}> <EuiFlexItem grow={false}>
@ -132,7 +138,7 @@ export const GroupEditorFlyout = ({
}} }}
> >
<FormattedMessage <FormattedMessage
id="eventAnnotation.edit.save" id="eventAnnotationComponents.edit.save"
defaultMessage="Save annotation group" defaultMessage="Save annotation group"
/> />
</EuiButton> </EuiButton>

View file

@ -6,8 +6,11 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
// TODO - is this file needed?
export { AnnotationEditorControls, annotationsIconSet } from './annotation_editor_controls'; export { AnnotationEditorControls, annotationsIconSet } from './annotation_editor_controls';
export * from './group_editor_controls'; export * from './group_editor_controls';
export * from './get_annotation_accessor'; export * from './get_annotation_accessor';
export * from './table_list';

View file

@ -16,16 +16,19 @@ import {
TableListViewTable, TableListViewTable,
type UserContentCommonSchema, type UserContentCommonSchema,
} from '@kbn/content-management-table-list-view-table'; } from '@kbn/content-management-table-list-view-table';
import { EventAnnotationServiceType } from '../event_annotation_service/types'; import type { EventAnnotationServiceType } from '../types';
import { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import { shallow, ShallowWrapper } from 'enzyme'; import { shallow, ShallowWrapper } from 'enzyme';
import { EventAnnotationGroupConfig, EVENT_ANNOTATION_GROUP_TYPE } from '../../common'; import {
EventAnnotationGroupConfig,
EVENT_ANNOTATION_GROUP_TYPE,
} from '@kbn/event-annotation-common';
import { taggingApiMock } from '@kbn/saved-objects-tagging-oss-plugin/public/mocks'; import { taggingApiMock } from '@kbn/saved-objects-tagging-oss-plugin/public/mocks';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import { GroupEditorFlyout } from './group_editor_flyout'; import { GroupEditorFlyout } from './group_editor_flyout';
import { DataView } from '@kbn/data-views-plugin/common'; import { DataView } from '@kbn/data-views-plugin/common';
import { QueryInputServices } from '@kbn/visualization-ui-components/public'; import { QueryInputServices } from '@kbn/visualization-ui-components';
import { toastsServiceMock } from '@kbn/core-notifications-browser-mocks/src/toasts_service.mock'; import { toastsServiceMock } from '@kbn/core-notifications-browser-mocks/src/toasts_service.mock';
import { IToasts } from '@kbn/core-notifications-browser'; import { IToasts } from '@kbn/core-notifications-browser';

View file

@ -11,16 +11,18 @@ import { TableListViewTable } from '@kbn/content-management-table-list-view-tabl
import type { TableListTabParentProps } from '@kbn/content-management-tabbed-table-list-view'; import type { TableListTabParentProps } from '@kbn/content-management-tabbed-table-list-view';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import { SavedObjectsFindOptionsReference } from '@kbn/core-saved-objects-api-browser'; import type { SavedObjectsFindOptionsReference } from '@kbn/core-saved-objects-api-browser';
import { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public'; import type { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public';
import { DataView, DataViewSpec } from '@kbn/data-views-plugin/common'; import { DataView, DataViewSpec } from '@kbn/data-views-plugin/common';
import type { QueryInputServices } from '@kbn/visualization-ui-components/public'; import type { QueryInputServices } from '@kbn/visualization-ui-components';
import { IToasts } from '@kbn/core-notifications-browser'; import { IToasts } from '@kbn/core-notifications-browser';
import { EuiButton, EuiEmptyPrompt, EuiTitle } from '@elastic/eui'; import { EuiButton, EuiEmptyPrompt, EuiTitle } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react'; import { FormattedMessage } from '@kbn/i18n-react';
import { EventAnnotationGroupConfig } from '../../common'; import type {
import type { EventAnnotationServiceType } from '../event_annotation_service/types'; EventAnnotationGroupConfig,
import { EventAnnotationGroupContent } from '../../common/types'; EventAnnotationGroupContent,
} from '@kbn/event-annotation-common';
import type { EventAnnotationServiceType } from '../types';
import { GroupEditorFlyout } from './group_editor_flyout'; import { GroupEditorFlyout } from './group_editor_flyout';
export const SAVED_OBJECTS_LIMIT_SETTING = 'savedObjects:listingLimit'; export const SAVED_OBJECTS_LIMIT_SETTING = 'savedObjects:listingLimit';
@ -33,7 +35,7 @@ const getCustomColumn = (dataViews: DataView[]) => {
return { return {
field: 'dataView', field: 'dataView',
name: i18n.translate('eventAnnotation.tableList.dataView', { name: i18n.translate('eventAnnotationComponents.tableList.dataView', {
defaultMessage: 'Data view', defaultMessage: 'Data view',
}), }),
sortable: false, sortable: false,
@ -144,7 +146,7 @@ export const EventAnnotationGroupTableList = ({
<> <>
<TableListViewTable<EventAnnotationGroupContent> <TableListViewTable<EventAnnotationGroupContent>
refreshListBouncer={refreshListBouncer} refreshListBouncer={refreshListBouncer}
tableCaption={i18n.translate('eventAnnotation.tableList.listTitle', { tableCaption={i18n.translate('eventAnnotationComponents.tableList.listTitle', {
defaultMessage: 'Annotation Library', defaultMessage: 'Annotation Library',
})} })}
findItems={fetchItems} findItems={fetchItems}
@ -164,7 +166,7 @@ export const EventAnnotationGroupTableList = ({
<EuiTitle> <EuiTitle>
<h2> <h2>
<FormattedMessage <FormattedMessage
id="eventAnnotation.tableList.emptyPrompt.title" id="eventAnnotationComponents.tableList.emptyPrompt.title"
defaultMessage="Create your first annotation in Lens" defaultMessage="Create your first annotation in Lens"
/> />
</h2> </h2>
@ -173,7 +175,7 @@ export const EventAnnotationGroupTableList = ({
body={ body={
<p> <p>
<FormattedMessage <FormattedMessage
id="eventAnnotation.tableList.emptyPrompt.body" id="eventAnnotationComponents.tableList.emptyPrompt.body"
defaultMessage="You can create and save annotations for use across multiple visualization in the defaultMessage="You can create and save annotations for use across multiple visualization in the
Lens visualization editor." Lens visualization editor."
/> />
@ -182,7 +184,7 @@ export const EventAnnotationGroupTableList = ({
actions={ actions={
<EuiButton onClick={navigateToLens}> <EuiButton onClick={navigateToLens}>
<FormattedMessage <FormattedMessage
id="eventAnnotation.tableList.emptyPrompt.cta" id="eventAnnotationComponents.tableList.emptyPrompt.cta"
defaultMessage="Create new annotation in Lens" defaultMessage="Create new annotation in Lens"
/> />
</EuiButton> </EuiButton>
@ -190,10 +192,10 @@ export const EventAnnotationGroupTableList = ({
iconType="flag" iconType="flag"
/> />
} }
entityName={i18n.translate('eventAnnotation.tableList.entityName', { entityName={i18n.translate('eventAnnotationComponents.tableList.entityName', {
defaultMessage: 'annotation group', defaultMessage: 'annotation group',
})} })}
entityNamePlural={i18n.translate('eventAnnotation.tableList.entityNamePlural', { entityNamePlural={i18n.translate('eventAnnotationComponents.tableList.entityNamePlural', {
defaultMessage: 'annotation groups', defaultMessage: 'annotation groups',
})} })}
onClickTitle={editItem} onClickTitle={editItem}

View file

@ -6,4 +6,4 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
export type LineStyle = 'solid' | 'dashed' | 'dotted'; export const EVENT_ANNOTATION_APP_NAME = 'event-annotations';

View file

@ -0,0 +1,24 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/
export {
AnnotationEditorControls,
annotationsIconSet,
} from './components/annotation_editor_controls';
export { EventAnnotationGroupTableList, getAnnotationAccessor } from './components';
export {
defaultAnnotationColor,
defaultAnnotationRangeColor,
defaultAnnotationLabel,
createCopiedAnnotation,
isRangeAnnotationConfig,
isManualPointAnnotationConfig,
isQueryAnnotationConfig,
} from '@kbn/event-annotation-common';
export { EVENT_ANNOTATION_APP_NAME } from './constants';
export type { EventAnnotationServiceType } from './types';

View file

@ -6,4 +6,8 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
export {}; module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-event-annotation-components'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-browser",
"id": "@kbn/event-annotation-components",
"owner": "@elastic/kibana-visualizations"
}

View file

@ -0,0 +1,9 @@
{
"name": "@kbn/event-annotation-components",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"sideEffects": [
"*.scss"
]
}

View file

@ -0,0 +1,41 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"@emotion/react/types/css-prop",
]
},
"include": [
"**/*",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/i18n",
"@kbn/visualization-ui-components",
"@kbn/ui-theme",
"@kbn/chart-icons",
"@kbn/unified-field-list",
"@kbn/data-views-plugin",
"@kbn/data-plugin",
"@kbn/test-jest-helpers",
"@kbn/saved-objects-tagging-oss-plugin",
"@kbn/core-ui-settings-browser",
"@kbn/dom-drag-drop",
"@kbn/content-management-table-list-view-table",
"@kbn/content-management-tabbed-table-list-view",
"@kbn/event-annotation-common",
"@kbn/core",
"@kbn/i18n-react",
"@kbn/saved-objects-finder-plugin",
"@kbn/saved-objects-management-plugin",
"@kbn/core-notifications-browser-mocks",
"@kbn/core-notifications-browser",
"@kbn/core-saved-objects-api-browser",
"@kbn/expressions-plugin",
]
}

View file

@ -6,10 +6,13 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import { ExpressionAstExpression } from '@kbn/expressions-plugin/common/ast'; import { ExpressionAstExpression } from '@kbn/expressions-plugin/common';
import type { SavedObjectCommon } from '@kbn/saved-objects-finder-plugin/common'; import { SavedObjectCommon } from '@kbn/saved-objects-finder-plugin/common';
import { EventAnnotationGroupContent } from '../../common/types'; import type {
import { EventAnnotationConfig, EventAnnotationGroupConfig } from '../../common'; EventAnnotationConfig,
EventAnnotationGroupConfig,
EventAnnotationGroupContent,
} from '@kbn/event-annotation-common';
export interface EventAnnotationServiceType { export interface EventAnnotationServiceType {
loadAnnotationGroup: (savedObjectId: string) => Promise<EventAnnotationGroupConfig>; loadAnnotationGroup: (savedObjectId: string) => Promise<EventAnnotationGroupConfig>;

View file

@ -161,5 +161,4 @@ pageLoadAssetSize:
visTypeVislib: 242838 visTypeVislib: 242838
visTypeXy: 46868 visTypeXy: 46868
visualizations: 90000 visualizations: 90000
visualizationUiComponents: 76424
watcher: 43598 watcher: 43598

View file

@ -0,0 +1,3 @@
# @kbn/visualization-ui-components
A set of components for interacting with visualizations. In practice, this is a place to put Lens components we want available outside of Lens.

View file

@ -7,7 +7,6 @@
*/ */
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import React from 'react'; import React from 'react';
import { DimensionButton, DimensionButtonProps } from './dimension_button'; import { DimensionButton, DimensionButtonProps } from './dimension_button';

View file

@ -7,7 +7,6 @@
*/ */
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import React from 'react'; import React from 'react';
import { DimensionTrigger } from './trigger'; import { DimensionTrigger } from './trigger';

View file

@ -15,7 +15,7 @@ import {
EuiFlexItem, EuiFlexItem,
EuiFormRow, EuiFormRow,
} from '@elastic/eui'; } from '@elastic/eui';
import { LineStyle } from '../../common/types'; import { LineStyle } from '../types';
interface LineStyleConfig { interface LineStyleConfig {
lineStyle?: LineStyle; lineStyle?: LineStyle;

View file

@ -10,8 +10,10 @@ import React from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import type { Query } from '@kbn/es-query'; import type { Query } from '@kbn/es-query';
import { QueryStringInput } from '@kbn/unified-search-plugin/public'; import {
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; type UnifiedSearchPublicPluginStart,
QueryStringInput,
} from '@kbn/unified-search-plugin/public';
import type { HttpStart } from '@kbn/core-http-browser'; import type { HttpStart } from '@kbn/core-http-browser';
import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';

View file

@ -6,8 +6,6 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
import { VisualizationUiComponentsPlugin } from './plugin';
export { export {
FieldPicker, FieldPicker,
TruncatedLabel, TruncatedLabel,
@ -46,8 +44,4 @@ export type {
QueryInputServices, QueryInputServices,
} from './components'; } from './components';
export type { FormatFactory } from './types'; export type { FormatFactory, LineStyle } from './types';
export function plugin() {
return new VisualizationUiComponentsPlugin();
}

View file

@ -0,0 +1,14 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-visualization-ui-components'],
setupFiles: ['jest-canvas-mock'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-browser",
"id": "@kbn/visualization-ui-components",
"owner": "@elastic/kibana-visualizations"
}

View file

@ -2,5 +2,8 @@
"name": "@kbn/visualization-ui-components", "name": "@kbn/visualization-ui-components",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0" "license": "SSPL-1.0 OR Elastic License 2.0",
"sideEffects": [
"*.scss"
]
} }

View file

@ -1,13 +1,19 @@
{ {
"extends": "../../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "target/types", "outDir": "target/types",
"types": [
"jest",
"node",
"@emotion/react/types/css-prop",
"@testing-library/jest-dom"
]
}, },
"include": [ "include": [
"../../typings/**/*", "**/*",
"common/**/*", ],
"public/**/*", "exclude": [
"server/**/*", "target/**/*"
], ],
"kbn_references": [ "kbn_references": [
"@kbn/i18n", "@kbn/i18n",
@ -21,14 +27,9 @@
"@kbn/core-ui-settings-browser", "@kbn/core-ui-settings-browser",
"@kbn/core-notifications-browser", "@kbn/core-notifications-browser",
"@kbn/core-doc-links-browser", "@kbn/core-doc-links-browser",
"@kbn/core",
"@kbn/ui-theme", "@kbn/ui-theme",
"@kbn/coloring", "@kbn/coloring",
"@kbn/field-formats-plugin", "@kbn/field-formats-plugin",
"@kbn/unified-field-list" "@kbn/unified-field-list",
], ],
"exclude": [
"target/**/*",
]
} }

View file

@ -9,3 +9,5 @@
import type { IFieldFormat, SerializedFieldFormat } from '@kbn/field-formats-plugin/common'; import type { IFieldFormat, SerializedFieldFormat } from '@kbn/field-formats-plugin/common';
export type FormatFactory = (mapping?: SerializedFieldFormat) => IFieldFormat; export type FormatFactory = (mapping?: SerializedFieldFormat) => IFieldFormat;
export type LineStyle = 'solid' | 'dashed' | 'dotted';

View file

@ -8,10 +8,8 @@
import { CustomAnnotationTooltip } from '@elastic/charts'; import { CustomAnnotationTooltip } from '@elastic/charts';
import type { AllowedChartOverrides, AllowedSettingsOverrides } from '@kbn/charts-plugin/common'; import type { AllowedChartOverrides, AllowedSettingsOverrides } from '@kbn/charts-plugin/common';
import { import { ManualPointEventAnnotationArgs } from '@kbn/event-annotation-plugin/common';
AvailableAnnotationIcon, import type { AvailableAnnotationIcon } from '@kbn/event-annotation-common';
ManualPointEventAnnotationArgs,
} from '@kbn/event-annotation-plugin/common';
import { XY_VIS_RENDERER } from '../constants'; import { XY_VIS_RENDERER } from '../constants';
import type { AllowedXYOverrides, XYProps } from './expression_functions'; import type { AllowedXYOverrides, XYProps } from './expression_functions';

View file

@ -34,10 +34,7 @@ import type {
ManualRangeEventAnnotationRow, ManualRangeEventAnnotationRow,
} from '@kbn/event-annotation-plugin/common'; } from '@kbn/event-annotation-plugin/common';
import type { FieldFormat, FormatFactory } from '@kbn/field-formats-plugin/common'; import type { FieldFormat, FormatFactory } from '@kbn/field-formats-plugin/common';
import { import { defaultAnnotationColor, defaultAnnotationRangeColor } from '@kbn/event-annotation-common';
defaultAnnotationColor,
defaultAnnotationRangeColor,
} from '@kbn/event-annotation-plugin/public';
import { Datatable, DatatableColumn, DatatableRow } from '@kbn/expressions-plugin/common'; import { Datatable, DatatableColumn, DatatableRow } from '@kbn/expressions-plugin/common';
import { PointEventAnnotationRow } from '@kbn/event-annotation-plugin/common/manual_event_annotation/types'; import { PointEventAnnotationRow } from '@kbn/event-annotation-plugin/common/manual_event_annotation/types';
import { FormattedMessage } from '@kbn/i18n-react'; import { FormattedMessage } from '@kbn/i18n-react';

View file

@ -31,6 +31,7 @@
"@kbn/analytics", "@kbn/analytics",
"@kbn/kibana-react-plugin", "@kbn/kibana-react-plugin",
"@kbn/chart-expressions-common", "@kbn/chart-expressions-common",
"@kbn/event-annotation-common",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -6,26 +6,7 @@
* Side Public License, v 1. * Side Public License, v 1.
*/ */
export const AvailableAnnotationIcons = { // TODO - deduplicate with event_annotation_application
ASTERISK: 'asterisk',
ALERT: 'alert',
BELL: 'bell',
BOLT: 'bolt',
BUG: 'bug',
CIRCLE: 'circle',
EDITOR_COMMENT: 'editorComment',
FLAG: 'flag',
HEART: 'heart',
MAP_MARKER: 'mapMarker',
PIN_FILLED: 'pinFilled',
STAR_EMPTY: 'starEmpty',
STAR_FILLED: 'starFilled',
TAG: 'tag',
TRIANGLE: 'triangle',
} as const;
export const EVENT_ANNOTATION_GROUP_TYPE = 'event-annotation-group';
export const ANNOTATIONS_LISTING_VIEW_ID = 'annotations'; export const ANNOTATIONS_LISTING_VIEW_ID = 'annotations';
export const EVENT_ANNOTATION_APP_NAME = 'event-annotations'; export const EVENT_ANNOTATION_APP_NAME = 'event-annotations';

View file

@ -20,8 +20,8 @@ import {
} from '@kbn/content-management-plugin/common'; } from '@kbn/content-management-plugin/common';
import type { DataViewSpec } from '@kbn/data-views-plugin/common'; import type { DataViewSpec } from '@kbn/data-views-plugin/common';
import type { EventAnnotationConfig } from '@kbn/event-annotation-common';
import { EventAnnotationGroupContentType } from '../types'; import { EventAnnotationGroupContentType } from '../types';
import { EventAnnotationConfig } from '../../types';
export interface Reference { export interface Reference {
type: string; type: string;

View file

@ -1,24 +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 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 or the Server
* Side Public License, v 1.
*/
import { getDefaultManualAnnotation } from './manual_event_annotation';
import { EventAnnotationConfig } from './types';
export const createCopiedAnnotation = (
newId: string,
timestamp: string,
source?: EventAnnotationConfig
): EventAnnotationConfig => {
if (!source) {
return getDefaultManualAnnotation(newId, timestamp);
}
return {
...source,
id: newId,
};
};

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