-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM] Format bytes columns in timeline (#43147)
- Loading branch information
1 parent
034fca7
commit 38ace24
Showing
35 changed files
with
510 additions
and
15 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
x-pack/legacy/plugins/siem/public/components/bytes/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { mount } from 'enzyme'; | ||
import * as React from 'react'; | ||
|
||
import { TestProviders } from '../../mock'; | ||
import { PreferenceFormattedBytes } from '../formatted_bytes'; | ||
|
||
import { Bytes } from '.'; | ||
|
||
describe('Bytes', () => { | ||
test('it renders the expected formatted bytes', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<Bytes contextId="test" eventId="abc" fieldName="network.bytes" value={`1234567`} /> | ||
</TestProviders> | ||
); | ||
expect( | ||
wrapper | ||
.find(PreferenceFormattedBytes) | ||
.first() | ||
.text() | ||
).toEqual('1.177MB'); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
x-pack/legacy/plugins/siem/public/components/bytes/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as React from 'react'; | ||
|
||
import { DefaultDraggable } from '../draggables'; | ||
import { PreferenceFormattedBytes } from '../formatted_bytes'; | ||
|
||
export const BYTES_FORMAT = 'bytes'; | ||
|
||
/** | ||
* Renders draggable text containing the value of a field representing a | ||
* duration of time, (e.g. `event.duration`) | ||
*/ | ||
export const Bytes = React.memo<{ | ||
contextId: string; | ||
eventId: string; | ||
fieldName: string; | ||
value?: string | null; | ||
}>(({ contextId, eventId, fieldName, value }) => ( | ||
<DefaultDraggable | ||
id={`${contextId}-${eventId}-${fieldName}-${value}`} | ||
name={name} | ||
field={fieldName} | ||
tooltipContent={null} | ||
value={value} | ||
> | ||
<PreferenceFormattedBytes value={`${value}`} /> | ||
</DefaultDraggable> | ||
)); | ||
|
||
Bytes.displayName = 'Bytes'; |
25 changes: 25 additions & 0 deletions
25
...iem/public/components/drag_and_drop/__snapshots__/drag_drop_context_wrapper.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.