-
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
Conversation
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security Posture) |
return <span>{number.toLocaleString('en-US')}</span>; | ||
} | ||
|
||
return ( | ||
<EuiToolTip content={number.toLocaleString('en-US')}> | ||
<span> | ||
{number.toLocaleString('en-US', { |
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.
- Using hard-coded locale is problematic. I suggest still using
FormattedNumber
and only passing thenotation
prop if the number is large enough. - You changed logic for existing usages of
CompactFormattedNumber
- please make sure this is fine.
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.
oh yeah i forgot to remove the locales argument.
<FormattedNumber>
does not work, thats why we didn't use it in the findings either.
the findings page use @elastic/numeral
instead, but its API is limited and didn't match the formats used in the designs or our previous formatting. i would argue it should be switched to use this component as well instead.
I'll remove the locales parameter, when its undefined the host's locale will be used. ty for the catch
export type CspCounterCardProps = Pick<EuiCardProps, 'onClick' | 'id'> & | ||
Pick<EuiStatProps, 'title' | 'description' | 'titleColor' | 'isLoading'>; | ||
|
||
export const CspCounterCard = ({ counter }: { counter: CspCounterCardProps }) => { |
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.
There is no need for a container counter
object - I suggest omitting the top level counter
prop and simply accept here the "internal" props (i.e. onClick
, id
, title
, etc)
@@ -56,9 +63,60 @@ export const CloudSummarySection = ({ | |||
navToFindings({ 'result.evaluation': RULE_FAILED }); | |||
}; | |||
|
|||
const counters: CspCounterCardProps[] = useMemo( |
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 just writing this in the declarative JSX instead of creating a variable and then using it:
<EuiFlexItem key={DASHBOARD_COUNTER_CARDS.CLUSTERS_EVALUATED}>
<CspCounterCard
counter={{
id: DASHBOARD_COUNTER_CARDS.CLUSTERS_EVALUATED,
title: <CompactFormattedNumber number={complianceData.clusters.length} />,
description: i18n.translate(
'xpack.csp.dashboard.summarySection.counterCard.clustersEvaluatedDescription',
{ defaultMessage: 'Clusters Evaluated' }
),
}}
/>
</EuiFlexItem>
/* Rest of the cards */
I prefer it this way since you immediately "see" the layout when you look at the JSX, instead of jumping back and forth between counters
definition and the JSX
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.
I guess its subjective, I prefer to have the JSX as clean as possible. "seeing" the layout is very important to me as well, I find it easier when things are clean and compact, I'm looking at it as a "list of counter cards" and keep the properties mess outside
.euiCard__title { | ||
display: none; | ||
} |
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.
Hiding the title with CSS is hacky, I suggest instead to utilize the EuiCard
title
and children
props properly and completely dump EuiStat
:
export const CspCounterCard = ({ counter }: { counter: CspCounterCardProps }) => {
const { euiTheme } = useEuiTheme();
return (
<EuiCard
title={
<EuiTitle size="xxxs">
<h6>{counter.description}</h6>
</EuiTitle>
}
hasBorder
onClick={counter.onClick}
paddingSize="m"
layout="horizontal"
css={css`
position: relative;
:hover .euiIcon {
color: ${euiTheme.colors.primary};
transition: ${euiTheme.animation.normal};
}
`}
data-test-subj={counter.id}
>
<EuiText color={counter.titleColor}>
<EuiTitle size="xs">
<h3>{counter.title}</h3>
</EuiTitle>
</EuiText>
{counter.onClick && (
<EuiIcon
type="link"
css={css`
position: absolute;
top: ${euiTheme.size.m};
right: ${euiTheme.size.m};
`}
/>
)}
</EuiCard>
);
};
In addition, I suggest flipping title
and description
so that title
will be the actual title of the card.
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.
great change, thanks!
|
||
render( | ||
<TestProvider | ||
core={{ |
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.
You don't need this core
override
}, | ||
}} | ||
> | ||
{/* <ComplianceDashboard />*/} |
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.
Remove
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); |
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.
You don't need to reset the mocks, you are not mocking anything in the tests here
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 comment
The 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 comment
The 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
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @JordanSh |
|
||
export const CspCounterCard = ({ counter }: { counter: CspCounterCardProps }) => { | ||
export const CspCounterCard = (counter: CspCounterCardProps) => { |
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 })
hasBorder | ||
onClick={counter.onClick} | ||
paddingSize="m" | ||
textAlign="left" | ||
layout="vertical" |
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.
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
* main: [Lens] Rearrange options (elastic#144891) [Actionable Observability] Integrate alert search bar on rule details page (elastic#144718) [Security Solution] [Exceptions] Adds options to create a shared exception list and to create a single item from the manage exceptions view (elastic#144575) [Actionable Observability] Add context.alertDetailsUrl to connector template for Uptime > Monitor status & Uptime TLS rules (elastic#144740) [Security Solution] [Feat] Add Bulk Events to Timeline. (elastic#142737) [TIP] Env specific cypress config (elastic#144894) skip flaky suite (elastic#144885) [Enterprise Search] Fixes Search Index page to go blank when connection lost (elastic#144022) [Cloud Posture] track findings pages (elastic#144822) [ContentManagement] Inspector flyout (elastic#144240) [Cloud Posture] Dashboard Redesign - data counter cards (elastic#144565) [TIP] Run e2e pipeline on CI (elastic#144776) [Guided onboarding] Config updates for the Security guide (elastic#144844) Cleanup unused code for claiming tasks by id (elastic#144408) Ping the response-ops team whenever a new connector type is registered (elastic#144736)
Summary
Resolves #143865
Resolves #143857
Added new counter components based on the dashboard redesign, full feature list can be found in the mentioned tasks
Screen.Recording.2022-11-03.at.20.31.56.mov