Skip to content

Commit 60a9058

Browse files
committed
make viewer nested entries appear nicer
1 parent 34e70ef commit 60a9058

3 files changed

Lines changed: 15 additions & 23 deletions

File tree

x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/exception_entries.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ const MyActionButton = styled(EuiFlexItem)`
5252
align-self: flex-end;
5353
`;
5454

55+
const MyNestedValueContainer = styled.div`
56+
margin-left: ${({ theme }) => theme.eui.euiSizeL};
57+
`;
58+
59+
const MyNestedValue = styled.span`
60+
margin-left: ${({ theme }) => theme.eui.euiSizeS};
61+
`;
62+
5563
interface ExceptionEntriesComponentProps {
5664
entries: FormattedEntry[];
5765
disableDelete: boolean;
@@ -78,10 +86,10 @@ const ExceptionEntriesComponent = ({
7886
render: (value: string | null, data: FormattedEntry) => {
7987
if (value != null && data.isNested) {
8088
return (
81-
<>
82-
<EuiIconTip type="grabHorizontal" size="m" />
83-
{value}
84-
</>
89+
<MyNestedValueContainer>
90+
<EuiIconTip type="nested" size="s" />
91+
<MyNestedValue>{value}</MyNestedValue>
92+
</MyNestedValueContainer>
8593
);
8694
} else {
8795
return value ?? getEmptyValue();

x-pack/plugins/security_solution/public/common/components/exceptions/viewer/helpers.test.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ describe('Exception viewer helpers', () => {
106106
value: undefined,
107107
},
108108
{
109-
fieldName: 'host.name.host.name',
109+
fieldName: 'host.name',
110110
isNested: true,
111111
operator: 'is',
112112
value: 'some host name',
113113
},
114114
{
115-
fieldName: 'host.name.host.name',
115+
fieldName: 'host.name',
116116
isNested: true,
117117
operator: 'is one of',
118118
value: ['some host name'],
@@ -135,19 +135,6 @@ describe('Exception viewer helpers', () => {
135135

136136
expect(formattedEntry).toEqual(expected);
137137
});
138-
139-
test('it formats as expected when "isNested" is "true"', () => {
140-
const payload = getEntryMatchMock();
141-
const formattedEntry = formatEntry({ isNested: true, parent: 'parent', item: payload });
142-
const expected: FormattedEntry = {
143-
fieldName: 'parent.host.name',
144-
isNested: true,
145-
operator: 'is',
146-
value: 'some host name',
147-
};
148-
149-
expect(formattedEntry).toEqual(expected);
150-
});
151138
});
152139

153140
describe('#getDescriptionListContent', () => {

x-pack/plugins/security_solution/public/common/components/exceptions/viewer/helpers.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ import * as i18n from '../translations';
2020
*/
2121
export const formatEntry = ({
2222
isNested,
23-
parent,
2423
item,
2524
}: {
2625
isNested: boolean;
27-
parent?: string;
2826
item: BuilderEntry;
2927
}): FormattedEntry => {
3028
const operator = getExceptionOperatorSelect(item);
3129
const value = getEntryValue(item);
3230

3331
return {
34-
fieldName: isNested ? `${parent}.${item.field}` : item.field ?? '',
32+
fieldName: item.field ?? '',
3533
operator: operator.message,
3634
value,
3735
isNested,
@@ -57,7 +55,6 @@ export const getFormattedEntries = (entries: BuilderEntry[]): FormattedEntry[] =
5755
(acc, nestedEntry) => {
5856
const formattedEntry = formatEntry({
5957
isNested: true,
60-
parent: item.field,
6158
item: nestedEntry,
6259
});
6360
return [...acc, { ...formattedEntry }];

0 commit comments

Comments
 (0)