[8.17] Only show data warning screen on Serverless (#201920) (#210383)

# Backport

This will backport the following commits from `main` to `8.17`:
- [Only show data warning screen on Serverless
(#201920)](https://github.com/elastic/kibana/pull/201920)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Charlotte Alexandra
Wilson","email":"CAWilson94@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-11-28T10:23:07Z","message":"Only
show data warning screen on Serverless (#201920)\n\n##
Summary\r\n\r\nThis PR
resolves\r\n[#11064](https://github.com/elastic/security-team/issues/11064),
where\r\nthe warning was previously shown in both serverless and
non-serverless\r\ninstances. A quick fix removed the message entirely,
and this update\r\nreintroduces it for serverless environments
only.\r\n\r\nThis PR adds a data warning specific to serverless
environments using\r\nupselling with the callout component from
serverless solution\r\ncomponents. The idea being to avoid adding a lot
of `if serverless`\r\nchecks throughout the component as
mentioned\r\nhttps://github.com/elastic/security-team/issues/11064#issuecomment-2461712849\r\n\r\n###
To Test \r\n\r\n**Start a serverless instance** using these
doccos:\r\nhttps://docs.elastic.dev/security-solution/dev-docs/serverless
or\r\nfollowing steps locally:\r\n\r\n1. Using VSCode, Reopen PR in
container. \r\n2. Start ElasticSearch: yarn es serverless --projectType
security --ssl\r\n--kill\r\n3. Start Kibana (this is the only way I can
make it work...): yarn start\r\n--serverless=security
--username=your_username --password=your_password\r\n\r\n**Test the
modal works as expected**: \r\n\r\n1. Remove / disable the
'entitytStoreDisable' flag here\r\n**/config/serverless.security.yml**
(I commented it out) for modal to\r\nthen show\r\n2. Go to dashboards -
Entity Analytics, hit the enable button and view\r\nmodal.\r\n\r\n###
Before
\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/43ac266d-9be1-47d3-874d-9edc9393fdd1)\r\n\r\n###
After
\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a7bf47fb-8737-478b-9782-fe6897980e03)\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e9ee5b4765f89f236916c9d2952006f78d6519a7","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","Team:
SecuritySolution","backport:prev-major","Team:Entity Analytics","8.17
candidate","backport:version","v9.1.0"],"title":"Only show data warning
screen on
Serverless","number":201920,"url":"https://github.com/elastic/kibana/pull/201920","mergeCommit":{"message":"Only
show data warning screen on Serverless (#201920)\n\n##
Summary\r\n\r\nThis PR
resolves\r\n[#11064](https://github.com/elastic/security-team/issues/11064),
where\r\nthe warning was previously shown in both serverless and
non-serverless\r\ninstances. A quick fix removed the message entirely,
and this update\r\nreintroduces it for serverless environments
only.\r\n\r\nThis PR adds a data warning specific to serverless
environments using\r\nupselling with the callout component from
serverless solution\r\ncomponents. The idea being to avoid adding a lot
of `if serverless`\r\nchecks throughout the component as
mentioned\r\nhttps://github.com/elastic/security-team/issues/11064#issuecomment-2461712849\r\n\r\n###
To Test \r\n\r\n**Start a serverless instance** using these
doccos:\r\nhttps://docs.elastic.dev/security-solution/dev-docs/serverless
or\r\nfollowing steps locally:\r\n\r\n1. Using VSCode, Reopen PR in
container. \r\n2. Start ElasticSearch: yarn es serverless --projectType
security --ssl\r\n--kill\r\n3. Start Kibana (this is the only way I can
make it work...): yarn start\r\n--serverless=security
--username=your_username --password=your_password\r\n\r\n**Test the
modal works as expected**: \r\n\r\n1. Remove / disable the
'entitytStoreDisable' flag here\r\n**/config/serverless.security.yml**
(I commented it out) for modal to\r\nthen show\r\n2. Go to dashboards -
Entity Analytics, hit the enable button and view\r\nmodal.\r\n\r\n###
Before
\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/43ac266d-9be1-47d3-874d-9edc9393fdd1)\r\n\r\n###
After
\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a7bf47fb-8737-478b-9782-fe6897980e03)\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e9ee5b4765f89f236916c9d2952006f78d6519a7"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201920","number":201920,"mergeCommit":{"message":"Only
show data warning screen on Serverless (#201920)\n\n##
Summary\r\n\r\nThis PR
resolves\r\n[#11064](https://github.com/elastic/security-team/issues/11064),
where\r\nthe warning was previously shown in both serverless and
non-serverless\r\ninstances. A quick fix removed the message entirely,
and this update\r\nreintroduces it for serverless environments
only.\r\n\r\nThis PR adds a data warning specific to serverless
environments using\r\nupselling with the callout component from
serverless solution\r\ncomponents. The idea being to avoid adding a lot
of `if serverless`\r\nchecks throughout the component as
mentioned\r\nhttps://github.com/elastic/security-team/issues/11064#issuecomment-2461712849\r\n\r\n###
To Test \r\n\r\n**Start a serverless instance** using these
doccos:\r\nhttps://docs.elastic.dev/security-solution/dev-docs/serverless
or\r\nfollowing steps locally:\r\n\r\n1. Using VSCode, Reopen PR in
container. \r\n2. Start ElasticSearch: yarn es serverless --projectType
security --ssl\r\n--kill\r\n3. Start Kibana (this is the only way I can
make it work...): yarn start\r\n--serverless=security
--username=your_username --password=your_password\r\n\r\n**Test the
modal works as expected**: \r\n\r\n1. Remove / disable the
'entitytStoreDisable' flag here\r\n**/config/serverless.security.yml**
(I commented it out) for modal to\r\nthen show\r\n2. Go to dashboards -
Entity Analytics, hit the enable button and view\r\nmodal.\r\n\r\n###
Before
\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/43ac266d-9be1-47d3-874d-9edc9393fdd1)\r\n\r\n###
After
\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a7bf47fb-8737-478b-9782-fe6897980e03)\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e9ee5b4765f89f236916c9d2952006f78d6519a7"}},{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Charlotte Alexandra Wilson <CAWilson94@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2025-02-11 02:38:34 +11:00 committed by GitHub
parent 41f1d2b174
commit 33a9b8a99b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 92 additions and 2 deletions

View file

@ -11,6 +11,7 @@ import type { Observable } from 'rxjs';
export type ContractComponents = Partial<{
GetStarted: React.ComponentType<{ indicesExist?: boolean }>;
DashboardsLandingCallout: React.ComponentType<{}>;
EnablementModalCallout: React.ComponentType<{}>;
}>;
export type SetComponents = (components: ContractComponents) => void;

View file

@ -6,6 +6,7 @@
*/
import React from 'react';
import { act } from 'react-dom/test-utils';
import { fireEvent, render, screen } from '@testing-library/react';
import { EntityStoreEnablementModal } from './enablement_modal';
import { TestProviders } from '../../../../common/mock';
@ -25,6 +26,11 @@ jest.mock('../../../hooks/use_missing_risk_engine_privileges', () => ({
useMissingRiskEnginePrivileges: () => mockUseMissingRiskEnginePrivileges(),
}));
const mockUseContractComponents = jest.fn(() => ({}));
jest.mock('../../../../common/hooks/use_contract_component', () => ({
useContractComponents: () => mockUseContractComponents(),
}));
const defaultProps = {
visible: true,
toggle: mockToggle,
@ -77,8 +83,10 @@ const missingRiskEnginePrivileges: RiskEngineMissingPrivilegesResponse = {
},
};
const renderComponent = (props = defaultProps) => {
return render(<EntityStoreEnablementModal {...props} />, { wrapper: TestProviders });
const renderComponent = async (props = defaultProps) => {
await act(async () => {
return render(<EntityStoreEnablementModal {...props} />, { wrapper: TestProviders });
});
};
describe('EntityStoreEnablementModal', () => {
@ -172,5 +180,16 @@ describe('EntityStoreEnablementModal', () => {
renderComponent();
expect(screen.getByTestId('callout-missing-risk-engine-privileges')).toBeInTheDocument();
});
it('should render additional charges message when available', async () => {
const EnablementModalCalloutMock = () => <span data-test-subj="enablement-modal-test" />;
mockUseContractComponents.mockReturnValue({
EnablementModalCallout: EnablementModalCalloutMock,
});
await renderComponent();
expect(screen.queryByTestId('enablement-modal-test')).toBeInTheDocument();
});
});
});

View file

@ -26,6 +26,7 @@ import {
import { css } from '@emotion/react';
import React, { useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { useContractComponents } from '../../../../common/hooks/use_contract_component';
import { TECHNICAL_PREVIEW, TECHNICAL_PREVIEW_TOOLTIP } from '../../../../common/translations';
import {
ENABLEMENT_DESCRIPTION_RISK_ENGINE_ONLY,
@ -72,6 +73,7 @@ export const EntityStoreEnablementModal: React.FC<EntityStoreEnablementModalProp
useEntityEnginePrivileges();
const riskEnginePrivileges = useMissingRiskEnginePrivileges();
const enablementOptions = enablements.riskScore || enablements.entityStore;
const { EnablementModalCallout } = useContractComponents();
if (!visible) {
return null;
@ -100,6 +102,7 @@ export const EntityStoreEnablementModal: React.FC<EntityStoreEnablementModalProp
<EuiModalBody>
<EuiFlexGroup direction="column">
<EuiFlexItem>{EnablementModalCallout && <EnablementModalCallout />}</EuiFlexItem>
<EuiFlexItem>
<EuiSwitch
label={

View file

@ -0,0 +1,21 @@
/*
* 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 { EuiText } from '@elastic/eui';
import { ADDITIONAL_CHARGES_MESSAGE } from '../../upselling/translations';
export const EnablementModalCallout: React.FC = () => {
return (
<div>
<EuiText>{ADDITIONAL_CHARGES_MESSAGE}</EuiText>
</div>
);
};
// eslint-disable-next-line import/no-default-export
export default EnablementModalCallout;

View file

@ -0,0 +1,19 @@
/*
* 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 { Services } from '../../common/services';
import { ServicesProvider } from '../../common/services';
import { EnablementModalCallout } from './lazy';
export const getEnablementModalCallout = (services: Services): React.ComponentType =>
function EnablementModalCalloutComponent() {
return (
<ServicesProvider services={services}>
<EnablementModalCallout />
</ServicesProvider>
);
};

View file

@ -0,0 +1,17 @@
/*
* 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, { lazy, Suspense } from 'react';
import { EuiLoadingSpinner } from '@elastic/eui';
const EnablementModalCalloutLazy = lazy(() => import('./enablement_modal_callout'));
export const EnablementModalCallout = () => (
<Suspense fallback={<EuiLoadingSpinner size="s" />}>
<EnablementModalCalloutLazy />
</Suspense>
);

View file

@ -23,6 +23,7 @@ import {
type ExperimentalFeatures,
} from '../common/experimental_features';
import { setOnboardingSettings } from './onboarding';
import { getEnablementModalCallout } from './components/enablement_modal_callout';
export class SecuritySolutionServerlessPlugin
implements
@ -69,6 +70,7 @@ export class SecuritySolutionServerlessPlugin
securitySolution.setComponents({
DashboardsLandingCallout: getDashboardsLandingCallout(services),
EnablementModalCallout: getEnablementModalCallout(services),
});
setOnboardingSettings(services);

View file

@ -18,3 +18,11 @@ export const UPGRADE_PRODUCT_MESSAGE = (requiredProduct: string) =>
},
}
);
export const ADDITIONAL_CHARGES_MESSAGE = i18n.translate(
'xpack.securitySolutionServerless.entityStoreEnablementCallout.additionalChargesMessage',
{
defaultMessage:
'Please be aware that activating these features may incur additional charges depending on your subscription plan. Review your plan details carefully to avoid unexpected costs before proceeding.',
}
);