From 5bad1756a002bb0a2d590bd36a7bd29958a075a0 Mon Sep 17 00:00:00 2001 From: semd Date: Tue, 2 May 2023 18:50:20 +0200 Subject: [PATCH 01/11] security nav components from poc --- .../components/side_navigation/index.tsx | 22 +++ .../side_navigation/side_navigation.tsx | 44 ++++++ .../public/components/upselling/index.ts | 7 + .../upselling/pages/cases_upselling.tsx | 41 +++++ .../upselling/pages/rules_upselling.tsx | 58 +++++++ .../upselling/register_upsellings.tsx | 83 ++++++++++ .../public/hooks/use_link_props.ts | 65 ++++++++ .../public/hooks/use_side_nav_items.ts | 145 ++++++++++++++++++ .../serverless_security/public/plugin.ts | 8 +- .../serverless_security/public/services.tsx | 26 ++++ 10 files changed, 497 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/serverless_security/public/components/side_navigation/index.tsx create mode 100644 x-pack/plugins/serverless_security/public/components/side_navigation/side_navigation.tsx create mode 100644 x-pack/plugins/serverless_security/public/components/upselling/index.ts create mode 100644 x-pack/plugins/serverless_security/public/components/upselling/pages/cases_upselling.tsx create mode 100644 x-pack/plugins/serverless_security/public/components/upselling/pages/rules_upselling.tsx create mode 100644 x-pack/plugins/serverless_security/public/components/upselling/register_upsellings.tsx create mode 100644 x-pack/plugins/serverless_security/public/hooks/use_link_props.ts create mode 100644 x-pack/plugins/serverless_security/public/hooks/use_side_nav_items.ts create mode 100644 x-pack/plugins/serverless_security/public/services.tsx diff --git a/x-pack/plugins/serverless_security/public/components/side_navigation/index.tsx b/x-pack/plugins/serverless_security/public/components/side_navigation/index.tsx new file mode 100644 index 0000000000000..abd1716f9bf77 --- /dev/null +++ b/x-pack/plugins/serverless_security/public/components/side_navigation/index.tsx @@ -0,0 +1,22 @@ +/* + * 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 { CoreStart } from '@kbn/core/public'; +import { ServerlessSecurityPluginStartDependencies } from '../../types'; +import { SecuritySideNavigation } from './side_navigation'; +import { KibanaServicesProvider } from '../../services'; + +export const getSecuritySideNavigation = ( + core: CoreStart, + pluginsStart: ServerlessSecurityPluginStartDependencies +) => { + return ( + + + + ); +}; diff --git a/x-pack/plugins/serverless_security/public/components/side_navigation/side_navigation.tsx b/x-pack/plugins/serverless_security/public/components/side_navigation/side_navigation.tsx new file mode 100644 index 0000000000000..1f7ca7821d291 --- /dev/null +++ b/x-pack/plugins/serverless_security/public/components/side_navigation/side_navigation.tsx @@ -0,0 +1,44 @@ +/* + * 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 { EuiLoadingSpinner, useEuiTheme } from '@elastic/eui'; +import { SolutionNav } from '@kbn/shared-ux-page-solution-nav'; +import { SolutionSideNav } from '@kbn/security-solution-side-nav'; +import { + usePartitionFooterNavItems, + useSideNavItems, + useSideNavSelectedId, +} from '../../hooks/use_side_nav_items'; + +export const SecuritySideNavigation: React.FC = () => { + const { euiTheme } = useEuiTheme(); + const sideNavItems = useSideNavItems(); + const selectedId = useSideNavSelectedId(sideNavItems); + const [items, footerItems] = usePartitionFooterNavItems(sideNavItems); + + const isLoading = items.length === 0 && footerItems.length === 0; + + return isLoading ? ( + + ) : ( + + } + closeFlyoutButtonPosition={'inside'} + /> + ); +}; diff --git a/x-pack/plugins/serverless_security/public/components/upselling/index.ts b/x-pack/plugins/serverless_security/public/components/upselling/index.ts new file mode 100644 index 0000000000000..2327166cc1706 --- /dev/null +++ b/x-pack/plugins/serverless_security/public/components/upselling/index.ts @@ -0,0 +1,7 @@ +/* + * 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 { registerUpsellings } from './register_upsellings'; diff --git a/x-pack/plugins/serverless_security/public/components/upselling/pages/cases_upselling.tsx b/x-pack/plugins/serverless_security/public/components/upselling/pages/cases_upselling.tsx new file mode 100644 index 0000000000000..d75cc89556c40 --- /dev/null +++ b/x-pack/plugins/serverless_security/public/components/upselling/pages/cases_upselling.tsx @@ -0,0 +1,41 @@ +/* + * 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 { EuiEmptyPrompt, EuiLink } from '@elastic/eui'; +import { ServerlessSecuritySkus } from '../../../../common/config'; + +export const CasesUpselling: React.FC<{ projectSkus: ServerlessSecuritySkus }> = React.memo( + ({ projectSkus }) => { + const upsellingSku = projectSkus.includes('cloudEssentials') + ? 'Cloud Complete' + : 'Endpoint Complete'; + + return ( + This is a testing component for a Serverless upselling prompt.} + body={ + <> + Get {upsellingSku} to use Cases +
+
+