-
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] Compliance by CIS section table #145114
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
4892f6f
init
JordanSh 17aafaf
layout done
JordanSh cd404f4
layout fine tuning
JordanSh 2ea6c1a
Merge branch 'main' of https://github.com/elastic/kibana into new-csp…
JordanSh 1be7828
base component created
JordanSh ed8605f
working on number abbv
JordanSh 322a336
ui progress
JordanSh cbe7151
ui progress
JordanSh 80787e7
added query
JordanSh 8f05630
added tests
JordanSh e23bca1
merge
JordanSh 99177fa
minor changes
JordanSh 602cf74
added empty state test
JordanSh 506e009
init
JordanSh 6c612d9
init
JordanSh 351a5db
progress on layout
JordanSh 4c3e3c6
working on compact versions of components
JordanSh bad5f3d
merge
JordanSh 9f2cc87
progress on layout
JordanSh ea7ffde
progress on layout
JordanSh 3e6a698
progress
JordanSh 4b5cc0b
fixed tests errors
JordanSh 20953a5
added counter tooltips
JordanSh 280a000
cleanups
JordanSh 9dc250d
cleanups and i18n fix
JordanSh d306a6f
using progress element
JordanSh 0ac1d48
using flex items to draw the progress bar
JordanSh 2d7343e
cleanups
JordanSh 9cdd8df
merge
JordanSh 44d8529
typo
JordanSh 70a0d76
i18n
JordanSh ba1cc45
fixed tests that broke cause of changes
JordanSh 7eaf563
added ts ignore
JordanSh a7601de
ignore
JordanSh 6ceea02
Merge branch 'main' of https://github.com/elastic/kibana into cis-sec…
JordanSh cd1fb8f
removed eui vars from table component
JordanSh 8b2c48b
fix type
JordanSh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,44 +7,50 @@ | |
|
||
import React, { useMemo } from 'react'; | ||
import { | ||
EuiBasicTable, | ||
EuiBasicTableColumn, | ||
EuiButtonEmpty, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiInMemoryTable, | ||
EuiLink, | ||
EuiText, | ||
EuiToolTip, | ||
useEuiTheme, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { statusColors } from '../../../common/constants'; | ||
import { ComplianceDashboardData, GroupedFindingsEvaluation } from '../../../../common/types'; | ||
import { CompactFormattedNumber } from '../../../components/compact_formatted_number'; | ||
|
||
export interface RisksTableProps { | ||
data: ComplianceDashboardData['groupedFindingsEvaluation']; | ||
maxItems: number; | ||
onCellClick: (name: string) => void; | ||
onViewAllClick: () => void; | ||
viewAllButtonTitle: string; | ||
compact?: boolean; | ||
} | ||
|
||
export const getTopRisks = ( | ||
groupedFindingsEvaluation: ComplianceDashboardData['groupedFindingsEvaluation'], | ||
maxItems: number | ||
) => { | ||
const filtered = groupedFindingsEvaluation.filter((x) => x.totalFailed > 0); | ||
const sorted = filtered.slice().sort((first, second) => second.totalFailed - first.totalFailed); | ||
const sorted = groupedFindingsEvaluation | ||
.slice() | ||
.sort((first, second) => first.postureScore - second.postureScore); | ||
|
||
return sorted.slice(0, maxItems); | ||
}; | ||
|
||
export const RisksTable = ({ | ||
data: resourcesTypes, | ||
data: cisSectionsEvaluations, | ||
maxItems, | ||
onCellClick, | ||
onViewAllClick, | ||
viewAllButtonTitle, | ||
compact, | ||
}: RisksTableProps) => { | ||
const { euiTheme } = useEuiTheme(); | ||
|
||
const columns: Array<EuiBasicTableColumn<GroupedFindingsEvaluation>> = useMemo( | ||
() => [ | ||
{ | ||
|
@@ -62,49 +68,87 @@ export const RisksTable = ({ | |
), | ||
}, | ||
{ | ||
field: 'totalFailed', | ||
field: 'postureScore', | ||
width: '115px', | ||
name: compact | ||
? '' | ||
: i18n.translate('xpack.csp.dashboard.risksTable.findingsColumnLabel', { | ||
defaultMessage: 'Findings', | ||
: i18n.translate('xpack.csp.dashboard.risksTable.complianceColumnLabel', { | ||
defaultMessage: 'Compliance', | ||
}), | ||
render: ( | ||
totalFailed: GroupedFindingsEvaluation['totalFailed'], | ||
resource: GroupedFindingsEvaluation | ||
) => ( | ||
<> | ||
<EuiText size="s" color="danger"> | ||
<CompactFormattedNumber number={resource.totalFailed} /> | ||
</EuiText> | ||
<EuiText size="s"> | ||
{'/'} | ||
<CompactFormattedNumber number={resource.totalFindings} /> | ||
</EuiText> | ||
</> | ||
render: (postureScore: GroupedFindingsEvaluation['postureScore'], data) => ( | ||
<EuiFlexGroup | ||
gutterSize="none" | ||
alignItems="center" | ||
justifyContent="flexEnd" | ||
style={{ gap: euiTheme.size.s }} | ||
> | ||
<EuiFlexItem> | ||
<EuiToolTip | ||
content={i18n.translate( | ||
'xpack.csp.complianceDashboard.complianceByCisSection.complianceColumnTooltip', | ||
{ | ||
defaultMessage: '{passed}/{total}', | ||
values: { passed: data.totalPassed, total: data.totalFindings }, | ||
} | ||
)} | ||
> | ||
<EuiFlexGroup | ||
gutterSize="none" | ||
style={{ | ||
height: euiTheme.size.xs, | ||
borderRadius: euiTheme.border.radius.medium, | ||
overflow: 'hidden', | ||
gap: 1, | ||
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.
|
||
}} | ||
> | ||
<EuiFlexItem | ||
style={{ | ||
flex: data.totalFailed, | ||
background: statusColors.failed, | ||
}} | ||
/> | ||
<EuiFlexItem | ||
style={{ | ||
flex: data.totalPassed, | ||
background: statusColors.passed, | ||
}} | ||
/> | ||
</EuiFlexGroup> | ||
</EuiToolTip> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="xs" style={{ fontWeight: euiTheme.font.weight.bold }}>{`${ | ||
postureScore?.toFixed(0) || 0 | ||
}%`}</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
), | ||
}, | ||
], | ||
[compact, onCellClick] | ||
[ | ||
compact, | ||
euiTheme.border.radius.medium, | ||
euiTheme.font.weight.bold, | ||
euiTheme.size.s, | ||
euiTheme.size.xs, | ||
onCellClick, | ||
] | ||
); | ||
|
||
const items = useMemo(() => getTopRisks(resourcesTypes, maxItems), [resourcesTypes, maxItems]); | ||
const sortedByComplianceScore = getTopRisks(cisSectionsEvaluations, maxItems); | ||
|
||
return ( | ||
<EuiFlexGroup direction="column" justifyContent="spaceBetween" gutterSize="none"> | ||
<EuiFlexItem> | ||
<EuiBasicTable<GroupedFindingsEvaluation> | ||
rowHeader="name" | ||
items={items} | ||
<EuiInMemoryTable<GroupedFindingsEvaluation> | ||
items={sortedByComplianceScore} | ||
columns={columns} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<div> | ||
<EuiButtonEmpty onClick={onViewAllClick} iconType="search"> | ||
<FormattedMessage | ||
id="xpack.csp.dashboard.risksTable.viewAllButtonTitle" | ||
defaultMessage="View all failed findings" | ||
/> | ||
{viewAllButtonTitle} | ||
</EuiButtonEmpty> | ||
</div> | ||
</EuiFlexItem> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this is tested in previous case too