-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cloud Posture] Dashboard Redesign - data counter cards #144565
Changes from 4 commits
4892f6f
17aafaf
cd404f4
2ea6c1a
1be7828
ed8605f
322a336
cbe7151
80787e7
8f05630
e23bca1
99177fa
602cf74
8737c28
8649448
5d86a1f
b277484
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,48 +7,43 @@ | |
|
||
import React from 'react'; | ||
import { css } from '@emotion/react'; | ||
import { EuiCard, EuiIcon, EuiStat, useEuiTheme } from '@elastic/eui'; | ||
import type { EuiStatProps, EuiCardProps } from '@elastic/eui'; | ||
import { EuiCard, EuiIcon, EuiText, EuiTitle, useEuiTheme } from '@elastic/eui'; | ||
import type { EuiTextProps, EuiCardProps } from '@elastic/eui'; | ||
|
||
export type CspCounterCardProps = Pick<EuiCardProps, 'onClick' | 'id'> & | ||
Pick<EuiStatProps, 'title' | 'description' | 'titleColor' | 'isLoading'>; | ||
export type CspCounterCardProps = Pick<EuiCardProps, 'onClick' | 'id' | 'title' | 'description'> & { | ||
descriptionColor?: EuiTextProps['color']; | ||
}; | ||
|
||
export const CspCounterCard = ({ counter }: { counter: CspCounterCardProps }) => { | ||
export const CspCounterCard = (counter: CspCounterCardProps) => { | ||
const { euiTheme } = useEuiTheme(); | ||
|
||
return ( | ||
<EuiCard | ||
title="" | ||
title={ | ||
<EuiTitle size="xxxs"> | ||
<h6>{counter.title}</h6> | ||
</EuiTitle> | ||
} | ||
hasBorder | ||
onClick={counter.onClick} | ||
paddingSize="m" | ||
textAlign="left" | ||
layout="vertical" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the default and can be omitted as we don't really care about the layout since we don't use an icon, we only care about the text alignment |
||
css={css` | ||
position: relative; | ||
|
||
.euiCard__title { | ||
display: none; | ||
} | ||
|
||
:hover .euiIcon { | ||
color: ${euiTheme.colors.primary}; | ||
transition: ${euiTheme.animation.normal}; | ||
} | ||
`} | ||
data-test-subj={counter.id} | ||
> | ||
<EuiStat | ||
descriptionElement="h5" | ||
titleSize="s" | ||
isLoading={counter.isLoading} | ||
description={counter.description} | ||
title={counter.title || 0} | ||
titleColor={counter.titleColor} | ||
css={css` | ||
display: flex; | ||
flex-direction: column; | ||
gap: ${euiTheme.size.m}; | ||
`} | ||
/> | ||
<EuiText color={counter.descriptionColor}> | ||
<EuiTitle size="xs"> | ||
<h3>{counter.description}</h3> | ||
</EuiTitle> | ||
</EuiText> | ||
{counter.onClick && ( | ||
<EuiIcon | ||
type="link" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
*/ | ||
|
||
import React from 'react'; | ||
import { coreMock } from '@kbn/core/public/mocks'; | ||
import { render } from '@testing-library/react'; | ||
import { expectIdsInDoc } from '../../../test/utils'; | ||
import { DASHBOARD_COUNTER_CARDS } from '../test_subjects'; | ||
|
@@ -16,28 +15,9 @@ import { TestProvider } from '../../../test/test_provider'; | |
import { screen } from '@testing-library/react'; | ||
|
||
describe('<CloudSummarySection />', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect tests here to verify the rest of the functionality of the section (risks table, score chart, etc.) If you consider this out of scope please open a task There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah i'll add those tests here on every new component task, its already listed in the tasks |
||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
const renderCloudSummarySection = (alterMockData = {}) => { | ||
const mockCore = coreMock.createStart(); | ||
|
||
render( | ||
<TestProvider | ||
core={{ | ||
...mockCore, | ||
application: { | ||
...mockCore.application, | ||
capabilities: { | ||
...mockCore.application.capabilities, | ||
// This is required so that the `noDataConfig` view will show the action button | ||
navLinks: { integrations: true }, | ||
}, | ||
}, | ||
}} | ||
> | ||
{/* <ComplianceDashboard />*/} | ||
<TestProvider> | ||
<CloudSummarySection complianceData={{ ...mockDashboardData, ...alterMockData }} /> | ||
</TestProvider> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider de-structuring props in the arguments:
({ title, onClick, id, description, descriptionColor })