Skip to content

Commit 4fa3dc4

Browse files
XavierMkqualters-elasticmisticandrew-goldstein
authored
[RAC] T-Grid is moving to a new home (elastic#100265)
* wip * First pass at standalone and embedded redux stores and usage * wip * First pass at standalone and embedded redux stores and usage * wip * clean up * wip * refact(NA): remove extra pkg_npm target and add specific target folders on @kbn/i18n * cleanup * - fixes type errors in tests * WIP remove use_manage_timeline * wip add query + selector * finishing integrating timeline manage context from redux * integrating t-grid in security solution * fix RowRender type * WIP begin to move components from package to plugin * integration of t-grid inside of security solution * wip to make redux work * little trick to make it render * - fixes a few type errors * better integration betwen tgrid and security solutions * bringing back tsconfig on timeline * wip integration t-grid in observability * fix types * fix type in security solutions * add type to import + trie dto get the bundle size as small as possible * fix type in integration test * fix type in integration test * - fix tests * clean up to use technical fields * - fixes unit tests * - mocks the `useDateFormat` function of the `useKibana` service to fix unit tests * fix t-grid settings vs create timeline + fix inspect button * fix last suites test * Update unit tests, snapshots and lint * Fix bad merge * fix plugin export * Fix some failing tests * fix unit tets in timelines plugins * fix latest test * fix i18n * free obs from t-grid * Fix timeline functional plugin types * fix store provider * Update failing defaultHeader test * Fix i18n usage in security solution * Fix remaining i18n errors in timelines plugin * Dedupe common shared types * move drag and drop utils in package to avoid duplication * More shared type cleanup * add feature flag * review I * fix merge with master * fix i18n translation * More type deduping * Use @kbn/common-utils, fix remaining types * fix types * fix tests * missing type * fix cypress tests Co-authored-by: Kevin Qualters <kevin.qualters@elastic.co> Co-authored-by: Tiago Costa <tiagoffcc@hotmail.com> Co-authored-by: Andrew Goldstein <andrew.goldstein@elastic.co>
1 parent 369127e commit 4fa3dc4

File tree

528 files changed

+60238
-3994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

528 files changed

+60238
-3994
lines changed

.eslintrc.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,8 @@ module.exports = {
893893
files: [
894894
'x-pack/plugins/security_solution/public/**/*.{js,mjs,ts,tsx}',
895895
'x-pack/plugins/security_solution/common/**/*.{js,mjs,ts,tsx}',
896+
'x-pack/plugins/timelines/public/**/*.{js,mjs,ts,tsx}',
897+
'x-pack/plugins/timelines/common/**/*.{js,mjs,ts,tsx}',
896898
],
897899
rules: {
898900
'import/no-nodejs-modules': 'error',
@@ -907,7 +909,10 @@ module.exports = {
907909
},
908910
{
909911
// typescript only for front and back end
910-
files: ['x-pack/plugins/security_solution/**/*.{ts,tsx}'],
912+
files: [
913+
'x-pack/plugins/security_solution/**/*.{ts,tsx}',
914+
'x-pack/plugins/timelines/**/*.{ts,tsx}',
915+
],
911916
rules: {
912917
'@typescript-eslint/no-this-alias': 'error',
913918
'@typescript-eslint/no-explicit-any': 'error',
@@ -917,7 +922,10 @@ module.exports = {
917922
},
918923
{
919924
// typescript and javascript for front and back end
920-
files: ['x-pack/plugins/security_solution/**/*.{js,mjs,ts,tsx}'],
925+
files: [
926+
'x-pack/plugins/security_solution/**/*.{js,mjs,ts,tsx}',
927+
'x-pack/plugins/timelines/**/*.{js,mjs,ts,tsx}',
928+
],
921929
plugins: ['eslint-plugin-node', 'react'],
922930
env: {
923931
jest: true,

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
"@kbn/securitysolution-list-api": "link:bazel-bin/packages/kbn-securitysolution-list-api",
150150
"@kbn/securitysolution-list-hooks": "link:bazel-bin/packages/kbn-securitysolution-list-hooks",
151151
"@kbn/securitysolution-list-utils": "link:bazel-bin/packages/kbn-securitysolution-list-utils",
152+
"@kbn/securitysolution-t-grid": "link:bazel-bin/packages/kbn-securitysolution-t-grid",
152153
"@kbn/securitysolution-utils": "link:bazel-bin/packages/kbn-securitysolution-utils",
153154
"@kbn/server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools",
154155
"@kbn/server-route-repository": "link:bazel-bin/packages/kbn-server-route-repository",
@@ -217,6 +218,8 @@
217218
"cytoscape-dagre": "^2.2.2",
218219
"d3": "3.5.17",
219220
"d3-array": "1.2.4",
221+
"d3-cloud": "1.2.5",
222+
"d3-interpolate": "^3.0.1",
220223
"d3-scale": "1.0.7",
221224
"d3-shape": "^1.1.0",
222225
"d3-time": "^1.1.0",
@@ -511,6 +514,7 @@
511514
"@types/cytoscape": "^3.14.0",
512515
"@types/d3": "^3.5.43",
513516
"@types/d3-array": "^1.2.7",
517+
"@types/d3-interpolate": "^2.0.0",
514518
"@types/d3-scale": "^2.1.1",
515519
"@types/d3-shape": "^1.3.1",
516520
"@types/d3-time": "^1.0.10",

packages/BUILD.bazel

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
filegroup(
44
name = "build",
55
srcs = [
6-
"//packages/elastic-datemath:build",
6+
"//packages/elastic-datemath:build",
77
"//packages/elastic-eslint-config-kibana:build",
88
"//packages/elastic-safer-lodash-set:build",
99
"//packages/kbn-ace:build",
@@ -41,6 +41,7 @@ filegroup(
4141
"//packages/kbn-securitysolution-list-utils:build",
4242
"//packages/kbn-securitysolution-utils:build",
4343
"//packages/kbn-securitysolution-es-utils:build",
44+
"//packages/kbn-securitysolution-t-grid:build",
4445
"//packages/kbn-securitysolution-hook-utils:build",
4546
"//packages/kbn-server-http-tools:build",
4647
"//packages/kbn-server-route-repository:build",

packages/kbn-optimizer/limits.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pageLoadAssetSize:
6767
searchprofiler: 67080
6868
security: 95864
6969
securityOss: 30806
70-
securitySolution: 76000
70+
securitySolution: 217673
7171
share: 99061
7272
snapshotRestore: 79032
7373
spaces: 57868
@@ -107,7 +107,7 @@ pageLoadAssetSize:
107107
dataVisualizer: 27530
108108
banners: 17946
109109
mapsEms: 26072
110-
timelines: 28613
110+
timelines: 230410
111111
screenshotMode: 17856
112112
visTypePie: 35583
113113
cases: 144442
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
2+
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
3+
4+
PKG_BASE_NAME = "kbn-securitysolution-t-grid"
5+
6+
PKG_REQUIRE_NAME = "@kbn/securitysolution-t-grid"
7+
8+
SOURCE_FILES = glob(
9+
[
10+
"src/**/*.ts",
11+
"src/**/*.tsx",
12+
],
13+
exclude = [
14+
"**/*.test.*",
15+
"**/*.mock.*",
16+
],
17+
)
18+
19+
SRCS = SOURCE_FILES
20+
21+
filegroup(
22+
name = "srcs",
23+
srcs = SRCS,
24+
)
25+
26+
NPM_MODULE_EXTRA_FILES = [
27+
"react/package.json",
28+
"package.json",
29+
"README.md",
30+
]
31+
32+
SRC_DEPS = [
33+
"//packages/kbn-babel-preset",
34+
"//packages/kbn-dev-utils",
35+
"//packages/kbn-i18n",
36+
"@npm//@babel/core",
37+
"@npm//babel-loader",
38+
"@npm//enzyme",
39+
"@npm//jest",
40+
"@npm//lodash",
41+
"@npm//react",
42+
"@npm//react-beautiful-dnd",
43+
"@npm//tslib",
44+
]
45+
46+
TYPES_DEPS = [
47+
"@npm//typescript",
48+
"@npm//@types/enzyme",
49+
"@npm//@types/jest",
50+
"@npm//@types/lodash",
51+
"@npm//@types/node",
52+
"@npm//@types/react",
53+
"@npm//@types/react-beautiful-dnd",
54+
]
55+
56+
DEPS = SRC_DEPS + TYPES_DEPS
57+
58+
ts_config(
59+
name = "tsconfig",
60+
src = "tsconfig.json",
61+
deps = [
62+
"//:tsconfig.base.json",
63+
],
64+
)
65+
66+
ts_config(
67+
name = "tsconfig_browser",
68+
src = "tsconfig.browser.json",
69+
deps = [
70+
"//:tsconfig.base.json",
71+
"//:tsconfig.browser.json",
72+
],
73+
)
74+
75+
ts_project(
76+
name = "tsc",
77+
args = ["--pretty"],
78+
srcs = SRCS,
79+
deps = DEPS,
80+
declaration = True,
81+
declaration_dir = "target_types",
82+
declaration_map = True,
83+
incremental = True,
84+
out_dir = "target_node",
85+
root_dir = "src",
86+
source_map = True,
87+
tsconfig = ":tsconfig",
88+
)
89+
90+
ts_project(
91+
name = "tsc_browser",
92+
args = ['--pretty'],
93+
srcs = SRCS,
94+
deps = DEPS,
95+
allow_js = True,
96+
declaration = False,
97+
incremental = True,
98+
out_dir = "target_web",
99+
source_map = True,
100+
root_dir = "src",
101+
tsconfig = ":tsconfig_browser",
102+
)
103+
104+
js_library(
105+
name = PKG_BASE_NAME,
106+
package_name = PKG_REQUIRE_NAME,
107+
srcs = NPM_MODULE_EXTRA_FILES,
108+
visibility = ["//visibility:public"],
109+
deps = [":tsc", ":tsc_browser"] + DEPS,
110+
)
111+
112+
pkg_npm(
113+
name = "npm_module",
114+
deps = [
115+
":%s" % PKG_BASE_NAME,
116+
],
117+
)
118+
119+
filegroup(
120+
name = "build",
121+
srcs = [
122+
":npm_module",
123+
],
124+
visibility = ["//visibility:public"],
125+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# kbn-securitysolution-t-grid
2+
3+
We do not want to create circular dependencies between security_solution and timelines plugins. Therefore , we will use this packages to share components between these two plugins.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
module.exports = {
10+
env: {
11+
web: {
12+
presets: ['@kbn/babel-preset/webpack_preset'],
13+
},
14+
node: {
15+
presets: ['@kbn/babel-preset/node_preset'],
16+
},
17+
},
18+
ignore: ['**/*.test.ts', '**/*.test.tsx'],
19+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
module.exports = {
10+
preset: '@kbn/test',
11+
rootDir: '../..',
12+
roots: ['<rootDir>/packages/kbn-securitysolution-t-grid'],
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@kbn/securitysolution-t-grid",
3+
"version": "1.0.0",
4+
"description": "security solution t-grid packages will allow sharing components between timelines and security_solution plugin until we transfer all functionality to timelines plugin",
5+
"license": "SSPL-1.0 OR Elastic License 2.0",
6+
"browser": "./target_web/browser.js",
7+
"main": "./target_node/index.js",
8+
"types": "./target_types/index.d.ts",
9+
"private": true
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"browser": "../target_web/react",
3+
"main": "../target_node/react",
4+
"types": "../target_types/react/index.d.ts"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
export const HIGHLIGHTED_DROP_TARGET_CLASS_NAME = 'highlighted-drop-target';
10+
export const EMPTY_PROVIDERS_GROUP_CLASS_NAME = 'empty-providers-group';
11+
12+
/** The draggable will move this many pixels via the keyboard when the arrow key is pressed */
13+
export const KEYBOARD_DRAG_OFFSET = 20;
14+
15+
export const DRAGGABLE_KEYBOARD_WRAPPER_CLASS_NAME = 'draggable-keyboard-wrapper';
16+
17+
export const ROW_RENDERER_CLASS_NAME = 'row-renderer';
18+
19+
export const NOTES_CONTAINER_CLASS_NAME = 'notes-container';
20+
21+
export const NOTE_CONTENT_CLASS_NAME = 'note-content';
22+
23+
/** This class is added to the document body while dragging */
24+
export const IS_DRAGGING_CLASS_NAME = 'is-dragging';
25+
26+
export const HOVER_ACTIONS_ALWAYS_SHOW_CLASS_NAME = 'hover-actions-always-show';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
export * from './constants';
10+
export * from './utils';
11+
export * from './mock';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
export * from './mock_event_details';

x-pack/plugins/security_solution/common/utils/mock_event_details.ts packages/kbn-securitysolution-t-grid/src/mock/mock_event_details.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
33
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
67
*/
78

89
export const eventHit = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { has } from 'lodash/fp';
10+
11+
export interface AppError extends Error {
12+
body: {
13+
message: string;
14+
};
15+
}
16+
17+
export interface KibanaError extends AppError {
18+
body: {
19+
message: string;
20+
statusCode: number;
21+
};
22+
}
23+
24+
export interface SecurityAppError extends AppError {
25+
body: {
26+
message: string;
27+
status_code: number;
28+
};
29+
}
30+
31+
export const isKibanaError = (error: unknown): error is KibanaError =>
32+
has('message', error) && has('body.message', error) && has('body.statusCode', error);
33+
34+
export const isSecurityAppError = (error: unknown): error is SecurityAppError =>
35+
has('message', error) && has('body.message', error) && has('body.status_code', error);
36+
37+
export const isAppError = (error: unknown): error is AppError =>
38+
isKibanaError(error) || isSecurityAppError(error);
39+
40+
export const isNotFoundError = (error: unknown) =>
41+
(isKibanaError(error) && error.body.statusCode === 404) ||
42+
(isSecurityAppError(error) && error.body.status_code === 404);

0 commit comments

Comments
 (0)