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

[Cases] Add Lens markdown plugin #96703

Merged
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
d1d567f
[Cases] Add Lens markdown plugin
patrykkopycinski Mar 23, 2021
18e90b4
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Apr 8, 2021
77edc5b
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Apr 9, 2021
601aaaa
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Apr 9, 2021
44b89fb
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Apr 9, 2021
4b46590
cleanup
patrykkopycinski Apr 9, 2021
7d49b2d
cleanup
patrykkopycinski Apr 9, 2021
8436ff6
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski May 29, 2021
df69565
Merge 8436ff62f55adf4a8e9de877a7f3852a21e2e334 into 0993a1c32114a0325…
patrykkopycinski Jun 14, 2021
60146c5
add lens to cases
stephmilovic Jun 14, 2021
ab71519
remove comments
stephmilovic Jun 14, 2021
6ff1f5c
Merge branch 'master' into feat/cases-lens-markdown-plugin
kibanamachine Jun 14, 2021
3aef8c6
Merge pull request #5 from stephmilovic/lens_cases
patrykkopycinski Jun 15, 2021
f1060bc
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 15, 2021
1c1cc05
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 15, 2021
022df3b
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 15, 2021
f87be1b
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 15, 2021
44636c3
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 16, 2021
20a0a77
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 17, 2021
c1a91ab
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 17, 2021
3d47eae
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 17, 2021
620e9db
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 18, 2021
48e2b82
[WIP]
patrykkopycinski Jun 18, 2021
1a8306e
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 20, 2021
a56fc49
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 21, 2021
039de02
wip
patrykkopycinski Jun 21, 2021
7a553c3
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 21, 2021
2ae9265
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 21, 2021
f44000e
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 21, 2021
a2740d1
Merge branch 'master' into feat/cases-lens-markdown-plugin
kibanamachine Jun 22, 2021
3c93fff
WIP
patrykkopycinski Jun 22, 2021
706d667
Merge branch 'feat/cases-lens-markdown-plugin' of github.com:patrykko…
patrykkopycinski Jun 22, 2021
15ffab8
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 22, 2021
dfa7473
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
130b9cb
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
9fc6d43
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
f585c32
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
293e470
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
24f377a
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
e3a96e2
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
33aa258
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 23, 2021
1ee0f3a
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 24, 2021
deffaec
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 24, 2021
5a3d197
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 24, 2021
c706c18
cleanup
patrykkopycinski Jun 24, 2021
485b0ae
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 24, 2021
e29aaf7
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 24, 2021
e7a7ef3
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 24, 2021
bbcbacd
WIP
patrykkopycinski Jun 24, 2021
9342833
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 25, 2021
22275e1
WIP
patrykkopycinski Jun 25, 2021
f0fbc82
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 25, 2021
1264487
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 26, 2021
d3ff6b2
cleanup
patrykkopycinski Jun 27, 2021
1c8fbbf
cleanup
patrykkopycinski Jun 27, 2021
8ab3b71
currentAppId
patrykkopycinski Jun 27, 2021
19c09af
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 27, 2021
5034a24
lens in obs
patrykkopycinski Jun 27, 2021
a05939d
update types
patrykkopycinski Jun 27, 2021
528ce5a
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 28, 2021
4a62f3d
i18n
patrykkopycinski Jun 28, 2021
589592e
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 29, 2021
b825b22
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 29, 2021
a4e942c
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 29, 2021
0891047
add feature flag
patrykkopycinski Jun 29, 2021
c422e59
move everything to cases
patrykkopycinski Jun 29, 2021
88b9434
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jun 29, 2021
27c12f3
PR comments
patrykkopycinski Jun 29, 2021
2580a7a
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 12, 2021
099fb1a
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 12, 2021
a99237d
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 14, 2021
914f931
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 14, 2021
6688536
update types
patrykkopycinski Jul 14, 2021
a5339b4
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 14, 2021
cbe7ecf
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 15, 2021
73d38d3
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 15, 2021
ae1df3e
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 15, 2021
5af9475
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 15, 2021
7973e63
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 15, 2021
e4d8af7
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 16, 2021
1e5d898
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 16, 2021
1fbee5d
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 16, 2021
4104d21
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 17, 2021
e4310b0
cleanup
patrykkopycinski Jul 17, 2021
ae60ba7
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 18, 2021
42b0c7e
migrations
patrykkopycinski Jul 19, 2021
bfacd39
hidden
patrykkopycinski Jul 19, 2021
f5dc789
package.json
patrykkopycinski Jul 19, 2021
e8c5c13
cleanup
patrykkopycinski Jul 19, 2021
1433c78
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 19, 2021
a537d3a
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 19, 2021
88583e0
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 20, 2021
631ec85
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 20, 2021
5cd5962
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 25, 2021
ffa5759
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 25, 2021
e79046d
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Jul 28, 2021
1ac2e1b
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 1, 2021
5d59b6b
update unit tests
patrykkopycinski Aug 1, 2021
c3375d3
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 3, 2021
cfcc356
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 4, 2021
9691ca2
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 4, 2021
835516f
WIP
patrykkopycinski Aug 4, 2021
b63776a
WIP
patrykkopycinski Aug 8, 2021
2d343c8
fix tsconfig
patrykkopycinski Aug 8, 2021
13c4d98
Cleanup
patrykkopycinski Aug 8, 2021
b119cdc
cleanup
patrykkopycinski Aug 8, 2021
b19c377
cleanup
patrykkopycinski Aug 8, 2021
fec3cbd
add mock
patrykkopycinski Aug 9, 2021
2029180
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 9, 2021
a72d875
imports
patrykkopycinski Aug 9, 2021
d11997b
cleanup
patrykkopycinski Aug 9, 2021
1dcc00f
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 12, 2021
35f7bee
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 13, 2021
af3fbe8
UX improvements
patrykkopycinski Aug 13, 2021
83c83d0
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 15, 2021
6e15a15
cleanup
patrykkopycinski Aug 15, 2021
7775cb8
cleanup
patrykkopycinski Aug 15, 2021
5513a45
update unit tests
patrykkopycinski Aug 16, 2021
b043f65
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 16, 2021
317e7dc
PR comments
patrykkopycinski Aug 16, 2021
a0199c5
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 17, 2021
1f85cad
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 17, 2021
c2a439f
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 17, 2021
2565f05
Merge branch 'master' of github.com:elastic/kibana into feat/cases-le…
patrykkopycinski Aug 17, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface EmbeddableEditorState
| --- | --- | --- |
| [embeddableId](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.embeddableid.md) | <code>string</code> | |
| [originatingApp](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.originatingapp.md) | <code>string</code> | |
| [originatingPath](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.originatingpath.md) | <code>string</code> | |
| [searchSessionId](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.searchsessionid.md) | <code>string</code> | Pass current search session id when navigating to an editor, Editors could use it continue previous search session |
| [valueInput](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.valueinput.md) | <code>EmbeddableInput</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-embeddable-public](./kibana-plugin-plugins-embeddable-public.md) &gt; [EmbeddableEditorState](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) &gt; [originatingPath](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.originatingpath.md)

## EmbeddableEditorState.originatingPath property

<b>Signature:</b>

```typescript
originatingPath?: string;
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"redux-thunks": "^1.0.0",
"remark-stringify": "^9.0.0",
"regenerator-runtime": "^0.13.3",
"request": "^2.88.0",
"require-in-the-middle": "^5.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/plugins/embeddable/public/lib/state_transfer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const EMBEDDABLE_EDITOR_STATE_KEY = 'embeddable_editor_state';
*/
export interface EmbeddableEditorState {
originatingApp: string;
originatingPath?: string;
embeddableId?: string;
valueInput?: EmbeddableInput;

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/embeddable/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ export interface EmbeddableEditorState {
embeddableId?: string;
// (undocumented)
originatingApp: string;
// (undocumented)
originatingPath?: string;
searchSessionId?: string;
// (undocumented)
valueInput?: EmbeddableInput;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/saved_objects/public/finder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
export {
SavedObjectMetaData,
SavedObjectFinderUi,
SavedObjectFinderUiProps,
getSavedObjectFinder,
} from './saved_object_finder';
7 changes: 6 additions & 1 deletion src/plugins/saved_objects/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export {
SaveResult,
showSaveModal,
} from './save_modal';
export { getSavedObjectFinder, SavedObjectFinderUi, SavedObjectMetaData } from './finder';
export {
getSavedObjectFinder,
SavedObjectFinderUi,
SavedObjectFinderUiProps,
SavedObjectMetaData,
} from './finder';
export {
SavedObjectLoader,
SavedObjectLoaderFindOptions,
Expand Down
8 changes: 6 additions & 2 deletions x-pack/examples/embedded_lens_example/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ export const App = (props: {
timeRange: time,
attributes: getLensAttributes(props.defaultIndexPattern!, color),
},
true
{
openInNewTab: true,
}
);
// eslint-disable-next-line no-bitwise
const newColor = '#' + ((Math.random() * 0xffffff) << 0).toString(16);
Expand All @@ -195,7 +197,9 @@ export const App = (props: {
timeRange: time,
attributes: getLensAttributes(props.defaultIndexPattern!, color),
},
false
{
openInNewTab: false,
}
);
}}
>
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ cases: CasesUiStart;
cases.getCreateCase({
onCancel: handleSetIsCancel,
onSuccess,
lensIntegration?: {
plugins: {
parsingPlugin,
processingPluginRenderer,
uiPlugin,
},
hooks: {
useInsertTimeline,
},
}
timelineIntegration?: {
plugins: {
parsingPlugin,
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/cases/common/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import {
UserActionField,
} from '../api';

export interface CasesUiConfigType {
markdownPlugins: {
lens: boolean;
};
}

export const StatusAll = 'all' as const;
export type StatusAllType = typeof StatusAll;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const LENS_ID = 'lens';
10 changes: 10 additions & 0 deletions x-pack/plugins/cases/common/utils/markdown_plugins/lens/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './constants';
export * from './parser';
export * from './serializer';
77 changes: 77 additions & 0 deletions x-pack/plugins/cases/common/utils/markdown_plugins/lens/parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { Plugin } from 'unified';
import { RemarkTokenizer } from '@elastic/eui';
import { LENS_ID } from './constants';

export const LensParser: Plugin = function () {
const Parser = this.Parser;
const tokenizers = Parser.prototype.blockTokenizers;
const methods = Parser.prototype.blockMethods;

const tokenizeLens: RemarkTokenizer = function (eat, value, silent) {
if (value.startsWith(`!{${LENS_ID}`) === false) return true;

const nextChar = value[6];

if (nextChar !== '{' && nextChar !== '}') return false; // this isn't actually a lens

if (silent) {
return true;
}

// is there a configuration?
const hasConfiguration = nextChar === '{';

let match = `!{${LENS_ID}`;
let configuration = {};

if (hasConfiguration) {
let configurationString = '';

let openObjects = 0;

for (let i = 6; i < value.length; i++) {
const char = value[i];
if (char === '{') {
openObjects++;
configurationString += char;
} else if (char === '}') {
openObjects--;
if (openObjects === -1) {
break;
}
configurationString += char;
} else {
configurationString += char;
}
}

match += configurationString;
try {
configuration = JSON.parse(configurationString);
} catch (e) {
const now = eat.now();
this.file.fail(`Unable to parse lens JSON configuration: ${e}`, {
line: now.line,
column: now.column + 6,
});
}
}

match += '}';

return eat(match)({
type: LENS_ID,
...configuration,
});
};

tokenizers.lens = tokenizeLens;
methods.splice(methods.indexOf('text'), 0, LENS_ID);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { TimeRange } from 'src/plugins/data/common';
import { LENS_ID } from './constants';

export interface LensSerializerProps {
attributes: Record<string, unknown>;
timeRange: TimeRange;
}

export const LensSerializer = ({ timeRange, attributes }: LensSerializerProps) =>
`!{${LENS_ID}${JSON.stringify({
timeRange,
attributes,
})}}`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './parser';
export * from './serializer';
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { Plugin } from 'unified';
import { RemarkTokenizer } from '@elastic/eui';
import * as i18n from './translations';

export const ID = 'timeline';
const PREFIX = '[';

export const TimelineParser: Plugin = function () {
const Parser = this.Parser;
const tokenizers = Parser.prototype.blockTokenizers;
const methods = Parser.prototype.blockMethods;

const tokenizeTimeline: RemarkTokenizer = function (eat, value, silent) {
if (
value.startsWith(PREFIX) === false ||
(value.startsWith(PREFIX) === true && !value.includes('timelines?timeline=(id'))
) {
return false;
}

let index = 0;
const nextChar = value[index];

if (nextChar !== PREFIX) {
return false;
}

if (silent) {
return true;
}

function readArg(open: string, close: string) {
if (value[index] !== open) {
throw new Error(i18n.NO_PARENTHESES);
}

index++;

let body = '';
let openBrackets = 0;

for (; index < value.length; index++) {
const char = value[index];

if (char === close && openBrackets === 0) {
index++;
return body;
} else if (char === close) {
openBrackets--;
} else if (char === open) {
openBrackets++;
}

body += char;
}

return '';
}

const timelineTitle = readArg(PREFIX, ']');
const timelineUrl = readArg('(', ')');
const match = `[${timelineTitle}](${timelineUrl})`;

return eat(match)({
type: ID,
match,
});
};

tokenizeTimeline.locator = (value: string, fromIndex: number) => {
return value.indexOf(PREFIX, fromIndex);
};

tokenizers.timeline = tokenizeTimeline;
methods.splice(methods.indexOf('url'), 0, ID);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export interface TimelineSerializerProps {
match: string;
}

export const TimelineSerializer = ({ match }: TimelineSerializerProps) => match;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';

export const NO_PARENTHESES = i18n.translate(
'xpack.cases.markdownEditor.plugins.timeline.noParenthesesErrorMsg',
{
defaultMessage: 'Expected left parentheses',
}
);
4 changes: 4 additions & 0 deletions x-pack/plugins/cases/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
"requiredPlugins":[
"actions",
"esUiShared",
"lens",
"features",
"kibanaReact",
"kibanaUtils",
"triggersActionsUi"
],
"requiredBundles": [
"savedObjects"
],
"server":true,
"ui":true,
"version":"8.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
createWithKibanaMock,
} from '../kibana_react.mock';

export const KibanaServices = { get: jest.fn(), getKibanaVersion: jest.fn(() => '8.0.0') };
export const KibanaServices = {
get: jest.fn(),
getKibanaVersion: jest.fn(() => '8.0.0'),
getConfig: jest.fn(() => null),
};
export const useKibana = jest.fn().mockReturnValue({
services: createStartServicesMock(),
});
Expand Down
Loading