Skip to content

Commit

Permalink
[SIEM] Fixes timeline notes overflowing the modal (#37134)
Browse files Browse the repository at this point in the history
## [SIEM] Fixes timeline notes overflowing the modal (#37134)

Beginning in Chrome 74 (see elastic/eui#1902), the timeline notes modal can overflow in some browsers, per the _Before_ gif below.

This fix uses `EuiModal` and other `EUI` components to address the overflow issue across all the browsers tested in the gifs below:

### Before (Chrome `74.0`)

![01-before-chrome](https://user-images.githubusercontent.com/4459398/58355997-4d7d4d00-7e33-11e9-864b-7e77d0635116.gif)

### After (Chrome `74.0`)

![02-after-chrome-74 0](https://user-images.githubusercontent.com/4459398/58356028-6128b380-7e33-11e9-8c7d-3022e45b1f41.gif)

### After (Firefox `67.0`)

![03-after-firefox-67 0](https://user-images.githubusercontent.com/4459398/58356056-6ede3900-7e33-11e9-92ca-a6dd8e0b804b.gif)

### After (Safari `12.1.1`)

![04-after-safari-12 1 1](https://user-images.githubusercontent.com/4459398/58356123-a947d600-7e33-11e9-80ab-d6b3d3c601c0.gif)

### After (IE`11.0.9600`)

![05-after-ie-11](https://user-images.githubusercontent.com/4459398/58356131-aea52080-7e33-11e9-989e-51aab7c4e9da.gif)

https://github.com/elastic/ingest-dev/issues/442
  • Loading branch information
andrew-goldstein committed May 28, 2019
1 parent 14b266e commit 1ada4b6
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('NewNote', () => {
.find('button[role="tab"]')
.first()
.text()
).toEqual(i18n.NOTE(1));
).toEqual(i18n.NOTE);
});

test('it renders a tab labeled "Preview (Markdown)"', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export const NewNote = pure<{
const tabs = [
{
id: 'note',
name: i18n.NOTE(1),
name: i18n.NOTE,
content: (
<TextArea
autoFocus
aria-label={i18n.NOTE(1)}
aria-label={i18n.NOTE}
data-test-subj="add-a-note"
fullWidth={true}
height={noteInputHeight}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/siem/public/components/notes/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Column {
export const columns: Column[] = [
{
field: 'note',
name: i18n.NOTE(1),
name: i18n.NOTE,
sortable: true,
truncateText: false,
render: (_, { created, note, user }) => (
Expand Down
23 changes: 19 additions & 4 deletions x-pack/plugins/siem/public/components/notes/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiTitle } from '@elastic/eui';
import { EuiIcon, EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
import moment from 'moment';
import * as React from 'react';
import { pure } from 'recompose';
Expand All @@ -13,6 +13,7 @@ import styled from 'styled-components';
import { Note } from '../../lib/note';

import * as i18n from './translations';
import { CountBadge } from '../page';

/** Performs IO to update (or add a new) note */
export type UpdateNote = (note: Note) => void;
Expand Down Expand Up @@ -46,16 +47,30 @@ export const search = {
};

const TitleText = styled.h3`
margin: 0 5px;
cursor: default;
user-select: none;
`;

/** Displays a count of the existing notes */
export const NotesCount = pure<{
noteIds: string[];
}>(({ noteIds }) => (
<EuiTitle size="s">
<TitleText>{i18n.NOTE(noteIds.length)}</TitleText>
</EuiTitle>
<EuiFlexGroup alignItems="center" gutterSize="none">
<EuiFlexItem grow={false}>
<EuiIcon color="text" size="l" type="editorComment" />
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiTitle size="s">
<TitleText>{i18n.NOTES}</TitleText>
</EuiTitle>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<CountBadge color="hollow">{noteIds.length}</CountBadge>
</EuiFlexItem>
</EuiFlexGroup>
));

/** Creates a new instance of a `note` */
Expand Down
38 changes: 16 additions & 22 deletions x-pack/plugins/siem/public/components/notes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*/

import {
EuiHorizontalRule,
// @ts-ignore
EuiInMemoryTable,
EuiModalBody,
EuiModalHeader,
EuiPanel,
EuiSpacer,
} from '@elastic/eui';
import * as React from 'react';
import styled from 'styled-components';
Expand All @@ -32,10 +34,6 @@ interface State {
newNote: string;
}

const AddNoteContainer = styled.div`
margin-bottom: 5px;
`;

const NotesPanel = styled(EuiPanel)`
height: ${NOTES_PANEL_HEIGHT}px;
width: ${NOTES_PANEL_WIDTH}px;
Expand All @@ -45,11 +43,6 @@ const NotesPanel = styled(EuiPanel)`
}
`;

const NotesContainer = styled.div`
display: flex;
flex-direction: column;
`;

const InMemoryTable = styled(EuiInMemoryTable)`
overflow-x: hidden;
overflow-y: auto;
Expand All @@ -69,18 +62,19 @@ export class Notes extends React.PureComponent<Props, State> {

return (
<NotesPanel>
<NotesContainer>
<EuiModalHeader>
<NotesCount noteIds={noteIds} />
<EuiHorizontalRule margin="m" />
<AddNoteContainer>
<AddNote
associateNote={associateNote}
getNewNoteId={getNewNoteId}
newNote={this.state.newNote}
updateNewNote={this.updateNewNote}
updateNote={updateNote}
/>
</AddNoteContainer>
</EuiModalHeader>

<EuiModalBody>
<AddNote
associateNote={associateNote}
getNewNoteId={getNewNoteId}
newNote={this.state.newNote}
updateNewNote={this.updateNewNote}
updateNote={updateNote}
/>
<EuiSpacer size="s" />
<InMemoryTable
data-test-subj="notes-table"
items={getNotesByIds(noteIds)}
Expand All @@ -89,7 +83,7 @@ export class Notes extends React.PureComponent<Props, State> {
search={search}
sorting={true}
/>
</NotesContainer>
</EuiModalBody>
</NotesPanel>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const NoteCardBody = pure<{ rawNote: string }>(({ rawNote }) => (
hoverContent={
<HoverActionsContainer data-test-subj="hover-actions-container">
<EuiToolTip content={i18n.COPY_TO_CLIPBOARD}>
<WithCopyToClipboard text={rawNote} titleSummary={i18n.NOTE(1).toLowerCase()} />
<WithCopyToClipboard text={rawNote} titleSummary={i18n.NOTE.toLowerCase()} />
</EuiToolTip>
</HoverActionsContainer>
}
Expand Down
12 changes: 7 additions & 5 deletions x-pack/plugins/siem/public/components/notes/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ export const ADDED_A_NOTE = i18n.translate('xpack.siem.notes.addedANoteLabel', {
defaultMessage: 'Added a Note',
});

export const NOTE = (totalCount: number) =>
i18n.translate('xpack.siem.notes.noteTitle', {
values: { totalCount },
defaultMessage: '{totalCount, plural, =1 {Note} other {Notes}}',
});
export const NOTE = i18n.translate('xpack.siem.notes.noteLabel', {
defaultMessage: 'Note',
});

export const NOTES = i18n.translate('xpack.siem.notes.notesTitle', {
defaultMessage: 'Notes',
});

export const PREVIEW_MARKDOWN = i18n.translate('xpack.siem.notes.previewMarkdownTitle', {
defaultMessage: 'Preview (Markdown)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
*/

export const NOTES_PANEL_WIDTH = 1024;
export const NOTES_PANEL_HEIGHT = 633;
export const NOTES_PANEL_HEIGHT = 750;
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -9271,7 +9271,6 @@
"xpack.siem.notes.addNoteButtonLabel": "Add Note",
"xpack.siem.notes.cancelButtonLabel": "キャンセル",
"xpack.siem.notes.copyToClipboardButtonLabel": "クリップボードにコピー",
"xpack.siem.notes.noteTitle": "{totalCount, plural, =1 {Note} other {Notes}}",
"xpack.siem.notes.previewMarkdownTitle": "Preview (Markdown)",
"xpack.siem.notes.search.FilterByUserOrNotePlaceholder": "Filter by User or Note",
"xpack.siem.open.timeline.cancelButton": "キャンセル",
Expand Down

0 comments on commit 1ada4b6

Please sign in to comment.