Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fa87a17
event annotation application plugin
drewdaemon Jul 6, 2023
4848a8a
remove unused components from event_annotation plugin
drewdaemon Jul 6, 2023
339ea55
add visualization-ui-components package
drewdaemon Jul 6, 2023
5af5eaa
move components to static package
drewdaemon Jul 7, 2023
10217b9
remove unified-search import
drewdaemon Jul 7, 2023
d3bd38a
fix type config
drewdaemon Jul 7, 2023
e177f84
remove visualization_ui_components plugin
drewdaemon Jul 7, 2023
f6eaf59
event-annotation-components package
drewdaemon Jul 7, 2023
81a257d
resolve boundary crossing
drewdaemon Jul 10, 2023
c327b3d
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 10, 2023
d0db8ad
Merge branch 'main' of github.com:elastic/kibana into create-event-an…
drewdaemon Jul 10, 2023
723b313
Merge branch 'create-event-annotation-application-plugin' of github.c…
drewdaemon Jul 10, 2023
65e1641
remove errant tsconfig entry
drewdaemon Jul 10, 2023
9f65270
README
drewdaemon Jul 10, 2023
7e1fe03
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 10, 2023
bd9cdc2
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jul 10, 2023
dcf42e6
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Jul 10, 2023
955ae71
remove circular type dependency
drewdaemon Jul 10, 2023
1c24c73
Merge branch 'create-event-annotation-application-plugin' of github.c…
drewdaemon Jul 10, 2023
1934b15
limits
drewdaemon Jul 10, 2023
521519e
Merge branch 'main' of github.com:elastic/kibana into create-event-an…
drewdaemon Jul 12, 2023
8ccb786
remove event_annotation_application plugin
drewdaemon Jul 12, 2023
6346453
resolve unit test failures
drewdaemon Jul 12, 2023
df98d34
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 12, 2023
087c811
Merge branch 'create-event-annotation-application-plugin' of github.c…
drewdaemon Jul 12, 2023
b19ad28
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jul 12, 2023
537d765
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Jul 12, 2023
76fb886
update limits
drewdaemon Jul 12, 2023
6c74ad8
Merge branch 'create-event-annotation-application-plugin' of github.c…
drewdaemon Jul 12, 2023
26feb47
fix dependency version
drewdaemon Jul 12, 2023
b3ca867
fix i18n
drewdaemon Jul 12, 2023
73ff0d4
fix type
drewdaemon Jul 12, 2023
1dbc3a2
import QueryStringInput directly
drewdaemon Jul 13, 2023
406c378
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 13, 2023
bf04604
Merge branch 'main' into create-event-annotation-application-plugin
kibanamachine Jul 13, 2023
548d77a
Merge branch 'main' into create-event-annotation-application-plugin
kibanamachine Jul 14, 2023
f69fd27
add sideeffects hints
drewdaemon Jul 18, 2023
4c1c6a8
Merge branch 'create-event-annotation-application-plugin' of github.c…
drewdaemon Jul 18, 2023
327c196
make kbn-coloring tree-shakeable
drewdaemon Jul 18, 2023
c4553b1
Merge branch 'main' of github.com:elastic/kibana into create-event-an…
drewdaemon Jul 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ packages/kbn-eslint-plugin-eslint @elastic/kibana-operations
packages/kbn-eslint-plugin-imports @elastic/kibana-operations
packages/kbn-eslint-plugin-telemetry @elastic/actionable-observability
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
x-pack/test/plugin_api_integration/plugins/event_log @elastic/response-ops
x-pack/plugins/event_log @elastic/response-ops
Expand Down Expand Up @@ -759,7 +761,7 @@ src/plugins/vis_types/timeseries @elastic/kibana-visualizations
src/plugins/vis_types/vega @elastic/kibana-visualizations
src/plugins/vis_types/vislib @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
x-pack/plugins/watcher @elastic/platform-deployment-management
packages/kbn-web-worker-stub @elastic/kibana-operations
Expand Down
10 changes: 8 additions & 2 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"expressionShape": "src/plugins/expression_shape",
"expressionTagcloud": "src/plugins/chart_expressions/expression_tagcloud",
"eventAnnotation": "src/plugins/event_annotation",
"eventAnnotationCommon": "packages/kbn-event-annotation-common",
"eventAnnotationComponents": "packages/kbn-event-annotation-components",
"fieldFormats": "src/plugins/field_formats",
"files": "src/plugins/files",
"filesManagement": "src/plugins/files_management",
Expand Down Expand Up @@ -71,7 +73,11 @@
"kibanaOverview": "src/plugins/kibana_overview",
"lists": "packages/kbn-securitysolution-list-utils/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",
"navigation": "src/plugins/navigation",
"newsfeed": "src/plugins/newsfeed",
Expand Down Expand Up @@ -112,7 +118,7 @@
"visTypeVislib": "src/plugins/vis_types/vislib",
"visTypeXy": "src/plugins/vis_types/xy",
"visualizations": "src/plugins/visualizations",
"visualizationUiComponents": "src/plugins/visualization_ui_components",
"visualizationUiComponents": "packages/kbn-visualization-ui-components",
"unifiedSearch": "src/plugins/unified_search",
"unifiedFieldList": "packages/kbn-unified-field-list",
"unifiedHistogram": "src/plugins/unified_histogram"
Expand Down
4 changes: 0 additions & 4 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,6 @@ The plugin exposes the static DefaultEditorController class to consume.
|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]
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@
"@kbn/es-types": "link:packages/kbn-es-types",
"@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/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-log-fixture-plugin": "link:x-pack/test/plugin_api_integration/plugins/event_log",
"@kbn/event-log-plugin": "link:x-pack/plugins/event_log",
Expand Down Expand Up @@ -747,7 +749,7 @@
"@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-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/watcher-plugin": "link:x-pack/plugins/watcher",
"@loaders.gl/core": "^2.3.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-event-annotation-common/README.md
Original file line number Diff line number Diff line change
@@ -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.
52 changes: 52 additions & 0 deletions packages/kbn-event-annotation-common/index.ts
Original file line number Diff line number Diff line change
@@ -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';
13 changes: 13 additions & 0 deletions packages/kbn-event-annotation-common/jest.config.js
Original file line number Diff line number Diff line change
@@ -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'],
};
5 changes: 5 additions & 0 deletions packages/kbn-event-annotation-common/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/event-annotation-common",
"owner": "@elastic/kibana-visualizations"
}
6 changes: 6 additions & 0 deletions packages/kbn-event-annotation-common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/event-annotation-common",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
drewdaemon marked this conversation as resolved.
Show resolved Hide resolved
}
23 changes: 23 additions & 0 deletions packages/kbn-event-annotation-common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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",
]
}
89 changes: 89 additions & 0 deletions packages/kbn-event-annotation-common/types.ts
Original file line number Diff line number Diff line change
@@ -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 };
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* Side Public License, v 1.
*/
import { euiLightVars } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import {
EventAnnotationConfig,
RangeEventAnnotationConfig,
PointInTimeEventAnnotationConfig,
QueryPointEventAnnotationConfig,
} from '../../common';
} from './types';

export const defaultAnnotationColor = euiLightVars.euiColorAccent;
// Do not compute it live as dependencies will add tens of Kbs to the plugin
export const defaultAnnotationRangeColor = `#F04E981A`; // defaultAnnotationColor with opacity 0.1
Expand All @@ -33,3 +35,57 @@ export const isQueryAnnotationConfig = (
): annotation is QueryPointEventAnnotationConfig => {
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}: *`,
});
3 changes: 3 additions & 0 deletions packages/kbn-event-annotation-components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/event-annotation-components

A collection of static components used for interacting with event annotations.
Loading