-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Expandable flyout - Rule preview contents (#163027)
## Summary This PR is part 2 of adding a rule preview panel to the expandable flyout. PR (#161999) adds the preview skeleton, and this PR populates the actual content related to rule details: Expandable flyout: - Updated title to include `created by` and `updated by` timestamps, and rule switch button - Added contents for about, define, schedule and actions (if any) - Added a hook to fetch data for rule switch button - logic mimics rule details page (`~/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx`) Rule & detections: - Added `isPanelView` option allow rendering rule details in smaller font, so that it can fit in panel view - Minor UI updates to gutter sizes and spacing to accommodate long text - Extracted `createdBy` and `updatedBy` to `~/security_solution/public/detections/components/rules/rule_info` to be shared between rule details page and flyout ![image](https://github.com/elastic/kibana/assets/18648970/bbccbec6-f5f2-4ac5-8715-9caf357283ee) **How to test** - add `xpack.securitySolution.enableExperimental: ['securityFlyoutEnabled']` to the `kibana.dev.json` file - go to the Alerts page, and click on the expand detail button on any row of the table - click on Overview, About, view Rule Summary, the rule preview panel should pop up ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
1 parent
37a53b6
commit c28cb61
Showing
24 changed files
with
572 additions
and
125 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
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
68 changes: 68 additions & 0 deletions
68
x-pack/plugins/security_solution/public/detections/components/rules/rule_info/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,68 @@ | ||
/* | ||
* 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 { CreatedBy, UpdatedBy } from '.'; | ||
import { render } from '@testing-library/react'; | ||
import { TestProviders } from '../../../../common/mock'; | ||
|
||
describe('Rule related info', () => { | ||
describe('<CreatedBy />', () => { | ||
it('should render created correctly when by and date are passed', () => { | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<CreatedBy | ||
createdBy="test" | ||
createdAt="2023-01-01T22:01:00.000Z" | ||
data-test-subj="createdBy" | ||
/> | ||
</TestProviders> | ||
); | ||
expect(getByTestId('createdBy')).toHaveTextContent( | ||
'Created by: test on Jan 1, 2023 @ 22:01:00.000' | ||
); | ||
}); | ||
|
||
it('should render created unknown when created by is not available', () => { | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<CreatedBy createdAt="2023-01-01T22:01:00.000Z" data-test-subj="createdBy" /> | ||
</TestProviders> | ||
); | ||
expect(getByTestId('createdBy')).toHaveTextContent( | ||
'Created by: Unknown on Jan 1, 2023 @ 22:01:00.000' | ||
); | ||
}); | ||
}); | ||
describe('<UpdatedBy />', () => { | ||
it('should render updated by correctly when by and date are passed', () => { | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<UpdatedBy | ||
updatedBy="test" | ||
updatedAt="2023-01-01T22:01:00.000Z" | ||
data-test-subj="updatedBy" | ||
/> | ||
</TestProviders> | ||
); | ||
expect(getByTestId('updatedBy')).toHaveTextContent( | ||
'Updated by: test on Jan 1, 2023 @ 22:01:00.000' | ||
); | ||
}); | ||
|
||
it('should render updated by correctly when updated by is not available', () => { | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<UpdatedBy updatedAt="2023-01-01T22:01:00.000Z" data-test-subj="updatedBy" /> | ||
</TestProviders> | ||
); | ||
expect(getByTestId('updatedBy')).toHaveTextContent( | ||
'Updated by: Unknown on Jan 1, 2023 @ 22:01:00.000' | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.