-
Notifications
You must be signed in to change notification settings - Fork 883
[Feature notification] Add EuiNotificationEvent #4531
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
Merged
elizabetdev
merged 67 commits into
elastic:feature/notification
from
elizabetdev:notification-events-content
Mar 9, 2021
Merged
Changes from 38 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
2243a51
Notification events
elizabetdev d651459
Looping through EuiNotificationEvent
elizabetdev a424dab
Adding props table and more methods
elizabetdev 772012c
wip
elizabetdev aed40dc
Renaming event notifications to event messages
elizabetdev cbd4c0a
onClickNoNewsTitles
elizabetdev 49630c1
Toggle mark as read/unread
elizabetdev 6c0efac
Initial documentation
elizabetdev 7a2e13e
Improving examples
elizabetdev afee6bb
Fixing TS error
elizabetdev 6daed5b
Refactored EuiEventNotification context menu item creation
chandlerprall cdad6f8
improving data
elizabetdev 6f57571
Notifications data
elizabetdev e142a1a
Primary example buttons
elizabetdev 09868a3
Reset data
elizabetdev 89c7f79
More docs
elizabetdev 8cb9958
snippets
elizabetdev 7ea4356
Merge branch 'notification-events-content-context-menu-items' of http…
elizabetdev 0e94d78
Merge pull request #15 from miukimiu/chandlerprall-notification-event…
elizabetdev 6470f60
Adding tests
elizabetdev a5d2408
Better messages explanation
elizabetdev ce0a6cf
Better snippets
elizabetdev d83b6ea
Small fixes
elizabetdev ee2c76f
Missing prop explanation
elizabetdev a62b626
Adding heading level
elizabetdev 3f15f22
Adding flexible comp section
elizabetdev 499c6bb
More a11y
elizabetdev b933716
Update src/components/notification/notification_event_messages.tsx
elizabetdev 66a1bf9
Button messages ay11
elizabetdev f08e9c6
test
elizabetdev 397cf0c
Better descriptions
elizabetdev c552bc8
Tests
elizabetdev 911651e
Adding icon arial label into notifications feed example
elizabetdev 86f0fac
i18n token
elizabetdev afd3c97
i18n token
elizabetdev 953190a
i18 token again
elizabetdev 44f5b1e
primaryAction description
elizabetdev c986923
More description
elizabetdev bc46770
Update src/components/notification/notification_event_messages.tsx
elizabetdev 63e6144
Update src/components/notification/notification_event_messages.tsx
elizabetdev 9ed044f
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev d847ce7
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev ab552ec
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 2bc96f7
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 32bcec2
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 9b76651
Addressing PR review
elizabetdev 4dafc61
More improvements
elizabetdev dff649a
Adding comment
elizabetdev ed1351e
Excluding `eventName` at top level and changing title vs aria-label o…
d0a56fa
Fix title
583f47e
Merge pull request #16 from cchaos/notification-events-content
elizabetdev b7c1dc0
Fixing tests and removing evenName from docs usage
elizabetdev 4b3a095
Fixing icon margin
elizabetdev f73f685
More tests and small fixes
elizabetdev 62e2a31
Moving read button from event meta comp to event comp
elizabetdev 17f8c60
Split primaryAction and primaryActionProps
elizabetdev aa19641
Exposing EuiPrimaryActionProps in props table
elizabetdev 355131b
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev b6ee7e2
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 79576d6
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 23d2d7f
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 06b56bf
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev d876039
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 190ab23
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev 9bcb214
Messages length and more
elizabetdev 6a1732e
Fixing data test subj
elizabetdev 890f8c4
Renaming tsx examples to js
elizabetdev 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 hidden or 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 hidden or 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
55 changes: 55 additions & 0 deletions
55
src-docs/src/views/notification_event/notification_event.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import React, { useState } from 'react'; | ||
| import { EuiPanel } from '../../../../src/components/panel'; | ||
| import { EuiContextMenuItem } from '../../../../src/components/context_menu'; | ||
| import { EuiNotificationEvent } from '../../../../src/components/notification/notification_event'; | ||
|
|
||
| export default () => { | ||
| const [isRead, setIsRead] = useState(false); | ||
|
|
||
| const onRead = (id: string, isRead: boolean) => { | ||
| setIsRead(!isRead); | ||
| }; | ||
|
|
||
| const onOpenContextMenu = (id: string) => { | ||
| return [ | ||
| <EuiContextMenuItem | ||
| key="contextMenuItemA" | ||
| onClick={() => onRead(id, isRead)}> | ||
| {isRead ? 'Mark as unread' : 'Mark as read'} | ||
| </EuiContextMenuItem>, | ||
|
|
||
| <EuiContextMenuItem key="contextMenuItemB" onClick={() => {}}> | ||
| View messages like this | ||
| </EuiContextMenuItem>, | ||
|
|
||
| <EuiContextMenuItem key="contextMenuItemC" onClick={() => {}}> | ||
| Don’t notify me about this | ||
| </EuiContextMenuItem>, | ||
| ]; | ||
| }; | ||
|
|
||
| return ( | ||
| <EuiPanel paddingSize="none" hasShadow={true} style={{ maxWidth: '540px' }}> | ||
| <EuiNotificationEvent | ||
| id="report" | ||
| meta={{ | ||
| type: 'Report', | ||
| iconType: 'logoKibana', | ||
| iconAriaLabel: 'Kibana', | ||
| time: '1 min ago', | ||
| }} | ||
| title="[Error Monitoring Report] is generated" | ||
| primaryAction={{ | ||
| iconType: 'download', | ||
| label: 'Download', | ||
| }} | ||
| messages={['The reported was generated at 17:12:16 GMT+4']} | ||
| isRead={isRead} | ||
| onRead={onRead} | ||
| onOpenContextMenu={onOpenContextMenu} | ||
| onClickPrimaryAction={() => {}} | ||
| onClickTitle={() => {}} | ||
| /> | ||
| </EuiPanel> | ||
| ); | ||
| }; |
241 changes: 241 additions & 0 deletions
241
src-docs/src/views/notification_event/notification_event_example.js
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,241 @@ | ||
| import React, { Fragment } from 'react'; | ||
| import { renderToHtml } from '../../services'; | ||
| import { GuideSectionTypes } from '../../components'; | ||
| import { Link } from 'react-router-dom'; | ||
| import { EuiNotificationEventMeta } from '../../../../src/components/notification/notification_event_meta'; | ||
| import { | ||
| EuiNotificationEvent, | ||
| EuiText, | ||
| EuiContextMenuItem, | ||
| EuiSpacer, | ||
| EuiCode, | ||
| EuiAccordion, | ||
| EuiCodeBlock, | ||
| } from '../../../../src/components'; | ||
| import { notificationEventReadButtonConfig } from './playground'; | ||
| import { EuiNotificationEventPrimaryAction } from './props'; | ||
| import NotificationEventPropsMethods from './notification_event_props_methods'; | ||
|
|
||
| import NotificationEvent from './notification_event'; | ||
| const notificationEventSource = require('!!raw-loader!./notification_event'); | ||
| const notificationEventHtml = renderToHtml(NotificationEvent); | ||
|
|
||
| import NotificationEventFlexible from './notification_event_flexible'; | ||
| const notificationEventFlexibleSource = require('!!raw-loader!./notification_event_flexible'); | ||
| const notificationEventFlexibleHtml = renderToHtml(NotificationEventFlexible); | ||
|
|
||
| import NotificationsFeed from './notifications_feed'; | ||
| const notificationsFeedSource = require('!!raw-loader!./notifications_feed'); | ||
| const notificationsFeedHtml = renderToHtml(NotificationsFeed); | ||
|
|
||
| const notificationEventSnippet = `<EuiNotificationEvent | ||
| id={id} | ||
| meta={{ | ||
| type: 'Alert', | ||
| iconType: 'logoMaps', | ||
| iconAriaLabel: 'Maps', | ||
| time: '1 min ago', | ||
| }} | ||
| title={title} | ||
| isRead={isRead} | ||
| primaryAction={primaryAction} | ||
| messages={messages} | ||
| onRead={onRead} | ||
| onOpenContextMenu={onOpenContextMenu} | ||
| onClickPrimaryAction={onClickPrimaryAction} | ||
| onClickTitle={onClickTitle} | ||
| />`; | ||
|
|
||
| const notificationEventFeedSnippet = `// we're looping through an array of objects to render multiple EuiNotificationEvent | ||
| const notificationEvents = events.map((event) => ( | ||
| <EuiNotificationEvent | ||
| key={event.id} | ||
| id={event.id} | ||
| meta={event.meta} | ||
| title={event.title} | ||
| isRead={event.isRead} | ||
| primaryAction={event.primaryAction} | ||
| messages={event.messages} | ||
| onRead={onRead} | ||
| onOpenContextMenu={onOpenContextMenu} | ||
| onClickPrimaryAction={onClickPrimaryAction} | ||
| onClickTitle={onClickTitle} | ||
| /> | ||
| )); | ||
|
|
||
| // the multiple EuiNotificationEvent should live inside the same container | ||
| <div> | ||
| {notificationEvents} | ||
| </div> | ||
| `; | ||
|
|
||
| export const NotificationEventExample = { | ||
| title: 'Notification event', | ||
| beta: true, | ||
| isNew: true, | ||
| intro: ( | ||
| <EuiText> | ||
| <p> | ||
| Use <strong>EuiNotificationEvent</strong> to display notifications about | ||
| new events in your product like alerts, support, or news. This component | ||
| is meant to live inside a{' '} | ||
| <strong> | ||
| <Link to="/layout/flyout/">EuiFlyout</Link> | ||
| </strong>{' '} | ||
| so that users can quickly be informed or take action. | ||
| </p> | ||
| </EuiText> | ||
| ), | ||
| sections: [ | ||
| { | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: notificationEventSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: notificationEventHtml, | ||
| }, | ||
| ], | ||
| props: { | ||
| EuiNotificationEvent, | ||
| EuiNotificationEventMeta, | ||
| EuiNotificationEventPrimaryAction, | ||
| EuiContextMenuItem, | ||
| }, | ||
| snippet: notificationEventSnippet, | ||
| demo: <NotificationEvent />, | ||
| }, | ||
| { | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: notificationEventFlexibleSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: notificationEventFlexibleHtml, | ||
| }, | ||
| ], | ||
| title: 'A flexible component', | ||
| text: ( | ||
| <> | ||
| <EuiText> | ||
| <p> | ||
| The <strong>EuiNotificationEvent</strong> takes into account that | ||
| an event can be purely informative or actionable. It's | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| flexible enough and adapts the design according to the props | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| passed. | ||
| </p> | ||
| </EuiText> | ||
| <EuiSpacer /> | ||
| <NotificationEventPropsMethods /> | ||
| <EuiSpacer size="xs" /> | ||
| <EuiAccordion | ||
| id="propsSnippet" | ||
| buttonContent={<small>Code snippet</small>}> | ||
| <EuiSpacer size="xs" /> | ||
| <EuiCodeBlock language="ts" isCopyable paddingSize="s"> | ||
| {notificationEventSnippet} | ||
| </EuiCodeBlock> | ||
| </EuiAccordion> | ||
| <EuiSpacer /> | ||
| <EuiText> | ||
| <ul style={{ listStyleType: 'upper-alpha' }}> | ||
| <li> | ||
| <EuiCode>isRead</EuiCode>: Use this prop to show a button that | ||
| indicates the current <EuiCode>isRead</EuiCode> state of the | ||
| event. Use the <EuiCode>onRead</EuiCode> to allow users to | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| toggle between read and unread states. | ||
| </li> | ||
| <li> | ||
| <EuiCode>meta</EuiCode> (required): Provides important | ||
| information about the event, like when it was received, the type | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| of event, and its severity. Use the{' '} | ||
| <EuiCode>badgeColor</EuiCode> in conjunction with the{' '} | ||
| <EuiCode>severity</EuiCode> to better indicate the level of | ||
| urgency. You can also pass an icon/logo to help users quickly | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| identify an event. | ||
| </li> | ||
| <li> | ||
| <EuiCode>onContextMenu</EuiCode>: Use this prop when you have | ||
| multiple events, and you need to add individual actions to each | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| event. You can add filters based on the event type or a more | ||
| descriptive read/unread action as an alternative to the read | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| indicator. | ||
| </li> | ||
| <li> | ||
| <EuiCode>title</EuiCode> (required): The title of the | ||
| notification event. It should be descriptive enough so that | ||
| users don't need to navigate away. But use it in | ||
| conjunction with an <EuiCode>onClickTitle</EuiCode> to direct | ||
| users to the respective app in case they need more information | ||
| about the notification. | ||
| </li> | ||
| <li> | ||
| <EuiCode>messages</EuiCode>: Use this prop to provide more | ||
| details about the event. You can provide just one message or | ||
| multiple messages when the event executes in various steps. | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| </li> | ||
| <li> | ||
| <EuiCode>primaryAction</EuiCode>: Use this prop to provide a | ||
| call to action, like download a report or link to a page where | ||
| an action is required. Most of the time, the clickable title is | ||
| enough. | ||
| </li> | ||
| </ul> | ||
| </EuiText> | ||
| <EuiSpacer /> | ||
| <EuiText> | ||
| <p> | ||
| The following demo shows how you can combine different props to | ||
| create different types of events like a report, alert, or even | ||
|
elizabetdev marked this conversation as resolved.
Outdated
|
||
| news. | ||
| </p> | ||
| </EuiText> | ||
| </> | ||
| ), | ||
| props: { | ||
| EuiNotificationEvent, | ||
| EuiNotificationEventMeta, | ||
| EuiNotificationEventPrimaryAction, | ||
| EuiContextMenuItem, | ||
| }, | ||
| snippet: notificationEventSnippet, | ||
| demo: <NotificationEventFlexible />, | ||
| }, | ||
| { | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: notificationsFeedSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: notificationsFeedHtml, | ||
| }, | ||
| ], | ||
| title: 'Notifications feed', | ||
| text: ( | ||
| <p> | ||
| You can create a notifications feed by rendering multiple{' '} | ||
| <strong>EuiNotificationEvent</strong>. These components should live | ||
| inside a container without other components on the same level. This | ||
| way, we ensure that feed styles are applied correctly. Consuming | ||
| applications should implement all the logic to filter and save | ||
| read/unread states. | ||
| </p> | ||
| ), | ||
| props: { | ||
| EuiNotificationEvent, | ||
| EuiNotificationEventMeta, | ||
| EuiNotificationEventPrimaryAction, | ||
| EuiContextMenuItem, | ||
| }, | ||
| snippet: notificationEventFeedSnippet, | ||
| demo: <NotificationsFeed />, | ||
| }, | ||
| ], | ||
| playground: notificationEventReadButtonConfig, | ||
| }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.