-
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.
[Security Solution] expanded flyout - right section - json tab implem…
…entation (#152935)
- Loading branch information
1 parent
54c4d8c
commit b23e57b
Showing
10 changed files
with
163 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
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
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/security_solution/public/flyout/right/tabs/json_tab.stories.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,42 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import type { Story } from '@storybook/react'; | ||
import { RightPanelContext } from '../context'; | ||
import { JsonTab } from './json_tab'; | ||
|
||
export default { | ||
component: JsonTab, | ||
title: 'Flyout/JsonTab', | ||
}; | ||
|
||
export const Default: Story<void> = () => { | ||
const contextValue = { | ||
searchHit: { | ||
some_field: 'some_value', | ||
}, | ||
} as unknown as RightPanelContext; | ||
|
||
return ( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
}; | ||
|
||
export const Error: Story<void> = () => { | ||
const contextValue = { | ||
searchHit: null, | ||
} as unknown as RightPanelContext; | ||
|
||
return ( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
x-pack/plugins/security_solution/public/flyout/right/tabs/json_tab.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,48 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { RightPanelContext } from '../context'; | ||
import { JsonTab } from './json_tab'; | ||
import { JSON_TAB_ERROR_TEST_ID, JSON_TAB_CONTENT_TEST_ID } from './test_ids'; | ||
|
||
describe('<JsonTab />', () => { | ||
it('should render code block component', () => { | ||
const contextValue = { | ||
searchHit: { | ||
some_field: 'some_value', | ||
}, | ||
} as unknown as RightPanelContext; | ||
|
||
const { getByTestId } = render( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
|
||
expect(getByTestId(JSON_TAB_CONTENT_TEST_ID)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render error message on invalid searchHit', () => { | ||
const contextValue = { | ||
searchHit: null, | ||
} as unknown as RightPanelContext; | ||
|
||
const { getByTestId, getByText } = render( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
|
||
expect(getByTestId(JSON_TAB_ERROR_TEST_ID)).toBeInTheDocument(); | ||
expect(getByText('Unable to display document information')).toBeInTheDocument(); | ||
expect( | ||
getByText('There was an error displaying the document fields and values') | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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
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
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/security_solution/public/flyout/right/tabs/translations.ts
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,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 { i18n } from '@kbn/i18n'; | ||
|
||
export const ERROR_TITLE = i18n.translate( | ||
'xpack.securitySolution.flyout.documentDetails.errorTitle', | ||
{ | ||
defaultMessage: 'Unable to display document information', | ||
} | ||
); | ||
|
||
export const ERROR_MESSAGE = i18n.translate( | ||
'xpack.securitySolution.flyout.documentDetails.errorMessage', | ||
{ defaultMessage: 'There was an error displaying the document fields and values' } | ||
); |