Skip to content

Commit

Permalink
[SIEM] Format bytes columns in timeline (#43147)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic authored Aug 16, 2019
1 parent 034fca7 commit 38ace24
Show file tree
Hide file tree
Showing 35 changed files with 510 additions and 15 deletions.
29 changes: 29 additions & 0 deletions x-pack/legacy/plugins/siem/public/components/bytes/index.test.tsx
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 x-pack/legacy/plugins/siem/public/components/bytes/index.tsx
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';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 38ace24

Please sign in to comment.