Skip to content

Commit

Permalink
added truncate option (#132202)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSh authored May 15, 2022
1 parent d2daf0d commit d864dc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 44 deletions.
1 change: 0 additions & 1 deletion x-pack/plugins/cloud_security_posture/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const RULE_FAILED = `failed`;
export const INTERNAL_FEATURE_FLAGS = {
showBenchmarks: true,
showManageRulesMock: false,
showRisksMock: false,
showFindingsGroupBy: true,
} as const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React, { useMemo } from 'react';
import {
EuiBasicTable,
EuiBasicTableColumn,
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
Expand All @@ -17,46 +18,6 @@ import {
import { ComplianceDashboardData, GroupedFindingsEvaluation } from '../../../../common/types';
import { CompactFormattedNumber } from '../../../components/compact_formatted_number';
import * as TEXT from '../translations';
import { INTERNAL_FEATURE_FLAGS } from '../../../../common/constants';

const mockData = [
{
name: 'pods',
totalFindings: 2,
totalPassed: 1,
totalFailed: 1,
},
{
name: 'etcd',
totalFindings: 5,
totalPassed: 0,
totalFailed: 5,
},
{
name: 'cluster',
totalFindings: 2,
totalPassed: 2,
totalFailed: 0,
},
{
name: 'system',
totalFindings: 10,
totalPassed: 6,
totalFailed: 4,
},
{
name: 'api',
totalFindings: 19100,
totalPassed: 2100,
totalFailed: 17000,
},
{
name: 'server',
totalFindings: 7,
totalPassed: 4,
totalFailed: 3,
},
];

export interface RisksTableProps {
data: ComplianceDashboardData['groupedFindingsEvaluation'];
Expand All @@ -81,13 +42,16 @@ export const RisksTable = ({
onCellClick,
onViewAllClick,
}: RisksTableProps) => {
const columns = useMemo(
const columns: Array<EuiBasicTableColumn<GroupedFindingsEvaluation>> = useMemo(
() => [
{
field: 'name',
truncateText: true,
name: TEXT.CIS_SECTION,
render: (name: GroupedFindingsEvaluation['name']) => (
<EuiLink onClick={() => onCellClick(name)}>{name}</EuiLink>
<EuiLink onClick={() => onCellClick(name)} className="eui-textTruncate">
{name}
</EuiLink>
),
},
{
Expand Down Expand Up @@ -119,7 +83,7 @@ export const RisksTable = ({
<EuiFlexItem>
<EuiBasicTable<GroupedFindingsEvaluation>
rowHeader="name"
items={INTERNAL_FEATURE_FLAGS.showRisksMock ? getTopRisks(mockData, maxItems) : items}
items={items}
columns={columns}
/>
</EuiFlexItem>
Expand Down

0 comments on commit d864dc8

Please sign in to comment.