Skip to content

Commit

Permalink
[ Siem Migrations ] Upsell Siem Migrations Start (#212607)
Browse files Browse the repository at this point in the history
## Summary

This PR adds the Upsell section for SIEM Migration Start section.

- [Design
Source](https://www.figma.com/design/BD9GZZz6y8pfSbubAt5H2W/%5B8.18%5D-GenAI-Powered-SIEM-Migration%3A-Rule-translation?node-id=63-81202&p=f&t=8x9RlFegceXzwYQf-0)

SIEM migrations has below requirements in ESS and Serverless and if
these requirements are not met, We show the upsell sections.

- ESS
   - `Enterprise` license.
- Serverless
   - `Complete` Product tier

## Demo

|Instance|Demo|
|---|---|
|Serverless|<video
src="https://github.com/user-attachments/assets/58d3ce98-7108-4d74-9f5c-e270804f2666"/>|
|ESS|<video
src="https://github.com/user-attachments/assets/85b650a7-fa11-4855-9927-aab89a2ed8ef"/>|




### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [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/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...
  • Loading branch information
logeekal authored Feb 28, 2025
1 parent bdc4790 commit 44a184c
Show file tree
Hide file tree
Showing 26 changed files with 612 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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 { render, screen } from '@testing-library/react';
import { SiemMigrationStartUpsellSection } from './siem_migrations_start';

describe('SiemMigrationStartUpsellSection', () => {
it('should render the component with all sections correctly', () => {
render(
<SiemMigrationStartUpsellSection
title="title"
upgradeMessage="upgradeMessage"
upgradeHref="https://upgrade.Href"
/>
);

expect(screen.getByTestId('siemMigrationStartUpsellSection')).toBeVisible();

expect(screen.getByTestId('siemMigrationStartUpsellTitle')).toBeVisible();
expect(screen.getByTestId('siemMigrationStartUpsellTitle')).toHaveTextContent('title');

expect(screen.getByTestId('siemMigrationStartUpsellMessage')).toBeVisible();
expect(screen.getByTestId('siemMigrationStartUpsellMessage')).toHaveTextContent(
'upgradeMessage'
);

expect(screen.getByTestId('siemMigrationStartUpsellHref')).toBeVisible();
expect(screen.getByTestId('siemMigrationStartUpsellHref')).toHaveAttribute(
'href',
'https://upgrade.Href'
);
});

it('should render the component without upgradeHref', () => {
render(<SiemMigrationStartUpsellSection title="title" upgradeMessage="upgradeMessage" />);

expect(screen.queryByTestId('SiemMigrationStartUpsellHref')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 { EuiButton, EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui';
import React from 'react';

export const SiemMigrationStartUpsellSection = React.memo(function SiemMigrationStartUpsellSection({
title,
upgradeMessage,
upgradeHref,
}: {
title: React.ReactNode;
upgradeMessage: React.ReactNode;
upgradeHref?: string;
}) {
return (
<>
<EuiPanel data-test-subj="siemMigrationStartUpsellSection" paddingSize="none" hasBorder>
<EuiCallOut
data-test-subj="siemMigrationStartUpsellTitle"
title={title}
color="warning"
iconType="lock"
>
<EuiFlexGroup>
<EuiFlexItem grow={true}>
<EuiText size="s" data-test-subj="siemMigrationStartUpsellMessage">
{upgradeMessage}
</EuiText>
</EuiFlexItem>
{upgradeHref ? (
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="siemMigrationStartUpsellHref"
href={upgradeHref}
color="warning"
fill
>
{'Manage License'}
</EuiButton>
</EuiFlexItem>
) : null}
</EuiFlexGroup>
</EuiCallOut>
</EuiPanel>
</>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export type UpsellingSectionId =
| 'endpoint_custom_notification'
| 'cloud_security_posture_integration_installation'
| 'ruleDetailsEndpointExceptions'
| 'automatic_import';
| 'automatic_import'
| 'siem_migrations_start';

export type UpsellingMessageId =
| 'investigation_guide'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ export const CenteredLoadingSpinner = React.memo<CenteredLoadingSpinnerProps>(
[topOffset, euiTheme]
);

return <EuiLoadingSpinner {...euiLoadingSpinnerProps} style={style} />;
return (
<EuiLoadingSpinner
data-test-subj="centeredLoadingSpinner"
{...euiLoadingSpinnerProps}
style={style}
/>
);
}
);
CenteredLoadingSpinner.displayName = 'CenteredLoadingSpinner';
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { UpsellingService } from '@kbn/security-solution-upselling/service';
import { calculateBounds } from '@kbn/data-plugin/common';
import { alertingPluginMock } from '@kbn/alerting-plugin/public/mocks';
import { createTelemetryServiceMock } from '../telemetry/telemetry_service.mock';
import { createSiemMigrationsMock } from '../../mock/mock_siem_migrations_service';

const mockUiSettings: Record<string, unknown> = {
[DEFAULT_TIME_RANGE]: { from: 'now-15m', to: 'now', mode: 'quick' },
Expand Down Expand Up @@ -128,6 +129,7 @@ export const createStartServicesMock = (
const mockSetHeaderActionMenu = jest.fn();
const timelineDataService = dataPluginMock.createStartContract();
const alerting = alertingPluginMock.createStartContract();
const siemMigrations = createSiemMigrationsMock();

/*
* Below mocks are needed by unified field list
Expand Down Expand Up @@ -258,6 +260,7 @@ export const createStartServicesMock = (
upselling: new UpsellingService(),
timelineDataService,
alerting,
siemMigrations,
} as unknown as StartServices;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from './timeline_results';
export * from './utils';
export * from './create_store';
export * from './create_react_query_wrapper';
export * from './mock_siem_migrations_service';
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 { createTelemetryServiceMock } from '../lib/telemetry/telemetry_service.mock';

const createRuleMigrationStorageMock = () => {
return {
get: jest.fn(),
set: jest.fn(),
remove: jest.fn(),
};
};

export const createSiemMigrationsMock = () => {
return {
rules: {
getLatestStats$: jest.fn(),
getMissingCapabilities: jest.fn(),
hasMissingCapabilities: jest.fn(),
isAvailable: jest.fn(),
startPolling: jest.fn(),
createRuleMigration: jest.fn(),
upsertMigrationResources: jest.fn(),
startRuleMigration: jest.fn(),
getRuleMigrationStats: jest.fn(),
getRuleMigrationsStats: jest.fn(),
getMissingResources: jest.fn(),
getIntegrations: jest.fn(),
connectorIdStorage: createRuleMigrationStorageMock(),
traceOptionsStorage: createRuleMigrationStorageMock(),
telemetry: createTelemetryServiceMock(),
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ export const aiConnectorCardConfig: OnboardingCardConfig<AIConnectorCardMetadata
)
),
checkComplete: checkAiConnectorsCardComplete,
licenseTypeRequired: 'enterprise',
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const startMigrationCardConfig: OnboardingCardConfig<StartMigrationCardMe
id: OnboardingCardId.siemMigrationsStart,
title: START_MIGRATION_CARD_TITLE,
icon: () => getCardIcon(OnboardingCardId.siemMigrationsStart),
licenseTypeRequired: 'enterprise',
Component: React.lazy(
() =>
import(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const RuleMigrationsPanels = React.memo<RuleMigrationsPanelsProps>(
);

return (
<EuiFlexGroup direction="column" gutterSize="m">
<EuiFlexGroup data-test-subj="ruleMigrationPanelGroup" direction="column" gutterSize="m">
<EuiFlexItem grow={false}>
{!isConnectorsCardComplete && (
<>
Expand Down
Loading

0 comments on commit 44a184c

Please sign in to comment.