Skip to content
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

Show surrounding documents when index pattern is available; Finding flyout UI polish #216

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 65 additions & 44 deletions public/pages/Findings/components/FindingDetailsFlyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
EuiAccordion,
EuiBadge,
EuiBadgeGroup,
EuiButton,
EuiButtonIcon,
EuiCodeBlock,
EuiFlexGroup,
Expand Down Expand Up @@ -63,13 +64,7 @@ export default class FindingDetailsFlyout extends Component<
};

renderRuleDetails = (rules: Query[] = []) => {
const {
allRules,
finding: { index, related_doc_ids, document_list },
} = this.props;
const documents = document_list;
const docId = related_doc_ids[0];
const document = documents.filter((doc) => doc.id === docId);
const { allRules } = this.props;
return rules.map((rule, key) => {
const fullRule = allRules[rule.id];
const severity = capitalizeFirstLetter(fullRule.level);
Expand Down Expand Up @@ -140,51 +135,75 @@ export default class FindingDetailsFlyout extends Component<
</EuiFormRow>

<EuiSpacer size={'l'} />
</EuiAccordion>
{rules.length > 1 && <EuiHorizontalRule />}
</div>
);
});
};

onViewSurroundingDocumentsClicked = () => {};
amsiglan marked this conversation as resolved.
Show resolved Hide resolved

renderFindingDocuments() {
const {
finding: { index, document_list, related_doc_ids },
} = this.props;
const documents = document_list;
const docId = related_doc_ids[0];
const matchedDocuments = documents.filter((doc) => doc.id === docId);
const document = matchedDocuments.length > 0 ? matchedDocuments[0].document : '';

return (
<>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem>
<EuiTitle size={'s'}>
<h3>Documents</h3>
</EuiTitle>
<EuiSpacer size={'s'} />

<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow
label={'Document ID'}
data-test-subj={'finding-details-flyout-rule-document-id'}
>
<EuiText>{docId || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton onClick={this.onViewSurroundingDocumentsClicked}>
View surrounding documents
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>

<EuiFlexItem>
<EuiFormRow
label={'Index'}
data-test-subj={'finding-details-flyout-rule-document-index'}
>
<EuiText>{index || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size={'s'} />

<EuiSpacer size={'m'} />
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow
label={'Document ID'}
data-test-subj={'finding-details-flyout-rule-document-id'}
>
<EuiText>{docId || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiFlexItem>

<EuiFormRow fullWidth={true}>
<EuiCodeBlock
language={'json'}
inline={false}
isCopyable={true}
readOnly={true}
data-test-subj={'finding-details-flyout-rule-document'}
>
{JSON.stringify(document, null, 4)}
</EuiCodeBlock>
<EuiFlexItem>
<EuiFormRow
label={'Index'}
data-test-subj={'finding-details-flyout-rule-document-index'}
>
<EuiText>{index || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiAccordion>
{rules.length > 1 && <EuiHorizontalRule />}
</div>
);
});
};
</EuiFlexItem>
</EuiFlexGroup>

<EuiSpacer size={'m'} />

<EuiFormRow fullWidth={true}>
<EuiCodeBlock
language="json"
isCopyable
data-test-subj={'finding-details-flyout-rule-document'}
>
{JSON.stringify(JSON.parse(document), null, 2)}
</EuiCodeBlock>
</EuiFormRow>
</>
);
}

render() {
const {
Expand Down Expand Up @@ -270,6 +289,8 @@ export default class FindingDetailsFlyout extends Component<
</EuiTitle>
<EuiSpacer size={'m'} />
{this.renderRuleDetails(queries)}
<EuiSpacer size="l" />
{this.renderFindingDocuments()}
</EuiFlyoutBody>
</EuiFlyout>
);
Expand Down