forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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 skeleton (elastic…
…#152047) - header with simple static title - 3 empty tabs (overview, table and json)
- Loading branch information
1 parent
2f1eb2c
commit 0f1c4e0
Showing
20 changed files
with
603 additions
and
2 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...y_solution/cypress/e2e/detection_alerts/expandable_flyout/alert_details_right_panel.cy.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,64 @@ | ||
/* | ||
* 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 { | ||
ALERT_DETAILS_FLYOUT_HEADER_TITLE, | ||
ALERT_DETAILS_FLYOUT_JSON_TAB, | ||
ALERT_DETAILS_FLYOUT_JSON_TAB_CONTENT, | ||
ALERT_DETAILS_FLYOUT_OVERVIEW_TAB, | ||
ALERT_DETAILS_FLYOUT_OVERVIEW_TAB_CONTENT, | ||
ALERT_DETAILS_FLYOUT_TABLE_TAB, | ||
ALERT_DETAILS_FLYOUT_TABLE_TAB_CONTENT, | ||
} from '../../../screens/alert_details_expandable_flyout'; | ||
import { | ||
expandFirstAlertExpandableFlyout, | ||
openJsonTab, | ||
openOverviewTab, | ||
openTableTab, | ||
} from '../../../tasks/alert_details_expandable_flyout'; | ||
import { cleanKibana } from '../../../tasks/common'; | ||
import { login, visit } from '../../../tasks/login'; | ||
import { createCustomRuleEnabled } from '../../../tasks/api_calls/rules'; | ||
import { getNewRule } from '../../../objects/rule'; | ||
import { ALERTS_URL } from '../../../urls/navigation'; | ||
import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule'; | ||
|
||
// Skipping these for now as the feature is protected behind a feature flag set to false by default | ||
// To run the tests locally, add 'securityFlyoutEnabled' in the Cypress config.ts here https://github.com/elastic/kibana/blob/main/x-pack/test/security_solution_cypress/config.ts#L50 | ||
describe.skip('Alert details expandable flyout right panel', { testIsolation: false }, () => { | ||
before(() => { | ||
cleanKibana(); | ||
login(); | ||
createCustomRuleEnabled(getNewRule()); | ||
visit(ALERTS_URL); | ||
waitForAlertsToPopulate(); | ||
expandFirstAlertExpandableFlyout(); | ||
}); | ||
|
||
it('should display title in the header', () => { | ||
cy.get(ALERT_DETAILS_FLYOUT_HEADER_TITLE) | ||
.should('be.visible') | ||
.and('have.text', 'Alert details'); | ||
}); | ||
|
||
it('should display 3 tabs in the right section', () => { | ||
cy.get(ALERT_DETAILS_FLYOUT_OVERVIEW_TAB).should('be.visible').and('have.text', 'Overview'); | ||
cy.get(ALERT_DETAILS_FLYOUT_TABLE_TAB).should('be.visible').and('have.text', 'Table'); | ||
cy.get(ALERT_DETAILS_FLYOUT_JSON_TAB).should('be.visible').and('have.text', 'JSON'); | ||
}); | ||
|
||
it('should display tab content when switching tabs in the right section', () => { | ||
openOverviewTab(); | ||
cy.get(ALERT_DETAILS_FLYOUT_OVERVIEW_TAB_CONTENT).should('be.visible'); | ||
|
||
openTableTab(); | ||
cy.get(ALERT_DETAILS_FLYOUT_TABLE_TAB_CONTENT).should('be.visible'); | ||
|
||
openJsonTab(); | ||
cy.get(ALERT_DETAILS_FLYOUT_JSON_TAB_CONTENT).should('be.visible'); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/security_solution/cypress/screens/alert_details_expandable_flyout.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,26 @@ | ||
/* | ||
* 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 { | ||
JSON_TAB_TEST_ID, | ||
OVERVIEW_TAB_TEST_ID, | ||
TABLE_TAB_TEST_ID, | ||
} from '../../public/flyout/right/test_ids'; | ||
import { | ||
JSON_TAB_CONTENT_TEST_ID, | ||
OVERVIEW_TAB_CONTENT_TEST_ID, | ||
TABLE_TAB_CONTENT_TEST_ID, | ||
} from '../../public/flyout/right/tabs/test_ids'; | ||
import { FLYOUT_HEADER_TITLE } from '../../public/flyout/right/components/test_ids'; | ||
|
||
export const ALERT_DETAILS_FLYOUT_HEADER_TITLE = `[data-test-subj="${FLYOUT_HEADER_TITLE}"]`; | ||
export const ALERT_DETAILS_FLYOUT_OVERVIEW_TAB = `[data-test-subj="${OVERVIEW_TAB_TEST_ID}"]`; | ||
export const ALERT_DETAILS_FLYOUT_TABLE_TAB = `[data-test-subj="${TABLE_TAB_TEST_ID}"]`; | ||
export const ALERT_DETAILS_FLYOUT_JSON_TAB = `[data-test-subj="${JSON_TAB_TEST_ID}"]`; | ||
export const ALERT_DETAILS_FLYOUT_OVERVIEW_TAB_CONTENT = `[data-test-subj="${OVERVIEW_TAB_CONTENT_TEST_ID}"]`; | ||
export const ALERT_DETAILS_FLYOUT_TABLE_TAB_CONTENT = `[data-test-subj="${TABLE_TAB_CONTENT_TEST_ID}"]`; | ||
export const ALERT_DETAILS_FLYOUT_JSON_TAB_CONTENT = `[data-test-subj="${JSON_TAB_CONTENT_TEST_ID}"]`; |
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/security_solution/cypress/tasks/alert_details_expandable_flyout.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,37 @@ | ||
/* | ||
* 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 { | ||
ALERT_DETAILS_FLYOUT_JSON_TAB, | ||
ALERT_DETAILS_FLYOUT_OVERVIEW_TAB, | ||
ALERT_DETAILS_FLYOUT_TABLE_TAB, | ||
} from '../screens/alert_details_expandable_flyout'; | ||
import { EXPAND_ALERT_BTN } from '../screens/alerts'; | ||
|
||
/** | ||
* Find the first alert row in the alerts table then click on the expand icon button to open the flyout | ||
*/ | ||
export const expandFirstAlertExpandableFlyout = () => { | ||
cy.get(EXPAND_ALERT_BTN).first().click(); | ||
}; | ||
|
||
/** | ||
* Open the Overview tab in the alert details expandable flyout right section | ||
*/ | ||
export const openOverviewTab = () => | ||
cy.get(ALERT_DETAILS_FLYOUT_OVERVIEW_TAB).should('be.visible').click(); | ||
|
||
/** | ||
* Open the Table tab in the alert details expandable flyout right section | ||
*/ | ||
export const openTableTab = () => | ||
cy.get(ALERT_DETAILS_FLYOUT_TABLE_TAB).should('be.visible').click(); | ||
|
||
/** | ||
* Open the Json tab in the alert details expandable flyout right section | ||
*/ | ||
export const openJsonTab = () => cy.get(ALERT_DETAILS_FLYOUT_JSON_TAB).should('be.visible').click(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# expandable flyout panels | ||
|
||
## Description | ||
|
||
This folder hosts the panels that are displayed in the expandable flyout (see `@kbn/expandable-flyout` package). | ||
|
||
> Remember to add any new panels to the `index.tsx` at the root of the `flyout` folder. These are passed to the `@kbn/expandable-flyout` package as `registeredPanels`. | ||
## Notes | ||
|
||
At the moment, we only have a single expandable flyout for the Security Solution plugin. This flyout will be used for all documents (signals, events, indicators, assets and findings). We're using a set of generic right/left/preview panels, hence the following folder structure: | ||
|
||
``` | ||
flyout | ||
│ index.tsx | ||
│ README.md | ||
│ | ||
└───right | ||
└───left | ||
└───preview | ||
``` | ||
|
||
If different right, left or preview panels are needed, we should refactor the folder structure as follows: | ||
|
||
``` | ||
flyout | ||
│ index.tsx | ||
│ README.md | ||
│ | ||
└───documents | ||
│ └───right | ||
│ └───left | ||
│ └───preview | ||
│ | ||
└───new_type | ||
│ └───right | ||
│ └───left | ||
│ └───preview | ||
│ | ||
└───other_new_type | ||
└───right | ||
└───left | ||
└───preview | ||
``` |
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,28 @@ | ||
/* | ||
* 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 { ExpandableFlyoutProps } from '@kbn/expandable-flyout'; | ||
import type { RightPanelProps } from './right'; | ||
import { RightPanel, RightPanelKey } from './right'; | ||
import { RightPanelProvider } from './right/context'; | ||
|
||
/** | ||
* List of all panels that will be used within the document details expandable flyout. | ||
* This needs to be passed to the expandable flyout registeredPanels property. | ||
*/ | ||
export const expandableFlyoutDocumentsPanels: ExpandableFlyoutProps['registeredPanels'] = [ | ||
{ | ||
key: RightPanelKey, | ||
width: 500, | ||
component: (props) => ( | ||
<RightPanelProvider {...(props as RightPanelProps).params}> | ||
<RightPanel path={props.path as RightPanelProps['path']} /> | ||
</RightPanelProvider> | ||
), | ||
}, | ||
]; |
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/security_solution/public/flyout/right/components/header_title.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,28 @@ | ||
/* | ||
* 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 { FC } from 'react'; | ||
import React, { memo } from 'react'; | ||
import { EuiSpacer, EuiTitle } from '@elastic/eui'; | ||
import { FLYOUT_HEADER_TITLE } from './test_ids'; | ||
import { HEADER_TITLE } from '../translations'; | ||
|
||
/** | ||
* Document details flyout right section header | ||
*/ | ||
export const HeaderTitle: FC = memo(() => { | ||
return ( | ||
<> | ||
<EuiTitle size="s" data-test-subj={FLYOUT_HEADER_TITLE}> | ||
<h4>{HEADER_TITLE}</h4> | ||
</EuiTitle> | ||
<EuiSpacer size="m" /> | ||
</> | ||
); | ||
}); | ||
|
||
HeaderTitle.displayName = 'HeaderTitle'; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/security_solution/public/flyout/right/components/test_ids.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,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 FLYOUT_HEADER_TITLE = 'securitySolutionDocumentDetailsFlyoutHeaderTitle'; |
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/security_solution/public/flyout/right/content.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,33 @@ | ||
/* | ||
* 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 { EuiFlyoutBody } from '@elastic/eui'; | ||
import type { VFC } from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import type { RightPanelPaths } from '.'; | ||
import { tabs } from './tabs'; | ||
|
||
export interface PanelContentProps { | ||
/** | ||
* Id of the tab selected in the parent component to display its content | ||
*/ | ||
selectedTabId: RightPanelPaths; | ||
} | ||
|
||
/** | ||
* Document details expandable flyout right section, that will display the content | ||
* of the overview, table and json tabs. | ||
*/ | ||
export const PanelContent: VFC<PanelContentProps> = ({ selectedTabId }) => { | ||
const selectedTabContent = useMemo(() => { | ||
return tabs.find((tab) => tab.id === selectedTabId)?.content; | ||
}, [selectedTabId]); | ||
|
||
return <EuiFlyoutBody>{selectedTabContent}</EuiFlyoutBody>; | ||
}; | ||
|
||
PanelContent.displayName = 'PanelContent'; |
48 changes: 48 additions & 0 deletions
48
x-pack/plugins/security_solution/public/flyout/right/context.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, { createContext, useContext } from 'react'; | ||
import type { RightPanelProps } from '.'; | ||
|
||
export interface RightPanelContext { | ||
/** | ||
* Id of the document | ||
*/ | ||
eventId: string; | ||
/** | ||
* Name of the index used in the parent's page | ||
*/ | ||
indexName: string; | ||
} | ||
|
||
export const RightPanelContext = createContext<RightPanelContext | undefined>(undefined); | ||
|
||
export type RightPanelProviderProps = { | ||
/** | ||
* React components to render | ||
*/ | ||
children: React.ReactNode; | ||
} & Partial<RightPanelProps['params']>; | ||
|
||
export const RightPanelProvider = ({ id, indexName, children }: RightPanelProviderProps) => { | ||
const contextValue = { | ||
eventId: id as string, | ||
indexName: indexName as string, | ||
}; | ||
|
||
return <RightPanelContext.Provider value={contextValue}>{children}</RightPanelContext.Provider>; | ||
}; | ||
|
||
export const useRightPanelContext = (): RightPanelContext => { | ||
const contextValue = useContext(RightPanelContext); | ||
|
||
if (!contextValue) { | ||
throw new Error('RightPanelContext can only be used within RightPanelContext provider'); | ||
} | ||
|
||
return contextValue; | ||
}; |
Oops, something went wrong.