Skip to content

[Feature branch] Notification#4513

Merged
elizabetdev merged 11 commits intomasterfrom
feature/notification
Mar 16, 2021
Merged

[Feature branch] Notification#4513
elizabetdev merged 11 commits intomasterfrom
feature/notification

Conversation

@elizabetdev
Copy link
Contributor

@elizabetdev elizabetdev commented Feb 11, 2021

Summary

This PR add a new component called EuiNotification Event and a new euiAnimation() method on the EuiHeaderSectionItemButton ref.

This work is essential to achieve a notification template similar to MVP Prototype.

Feature spec

You can find the feature spec: here.

Build Preview

You can find the preview here: here

Changelog and PR's

As part of #4433

  • Add notification event meta

As part of #4424

  • Add euiAnimation() method on the EuiHeaderSectionItemButton ref

As part of #4531

  • Add EuiNotificationEvent

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

elizabetdev and others added 2 commits February 11, 2021 16:46
* Add notification event meta

* WIP

* adding i18n

* Fixing axe error in docs example

* Adding context menus items

* contetx menu item anchor position

* Adding tests

* Update src/components/notification/notification_event_meta.tsx

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Improving code based on PR review

* More PR review

* Better description

* Update src/components/notification/notification_event_meta.tsx

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_events/notification_events.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Badge 100% width

* ES lint

* Read and unread states

* Make sure overflow menu stays in the top right

* Improving a11y

* Adding playground for event read button

* Removing EuiNotificationEventMeta from exported on index

* Add a behavior unit test, update context menu test to snapshot the menu items

* Update src/components/notification/notification_event_meta.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src/components/notification/notification_event_read_button.tsx

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
…utton (#4424)

* Adding animation and hasBackground props to EuiHeaderSectionItemButton

* A few improvements

* Docs props

* Removing hasBackground prop

* Using JS do hide and show on xs breakpoints

* Adding a snippet

* refactor animation prop into a ref method

* Snapshots. Trigger animation comments.

* Deleting unused css animation

* triggerAnimation explanation

* Cleaned up some logic and created a docs example specifically for the notifications

* re-enable the animation test

* Update src-docs/src/views/header/header_animate.js

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src-docs/src/views/header/header_example.js

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src-docs/src/views/header/header_alert.js

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src-docs/src/views/header/header_alert.js

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src-docs/src/views/header/header_animate.js

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* Update src-docs/src/views/header/header_example.js

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>

* renaming animate methods to euiAnimate

* euiAnimate into header example

* simplifying onClick closeFlyout

* Update src-docs/src/views/header/header_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: cchaos <caroline.horn@elastic.co>
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

* Notification events

* Looping  through  EuiNotificationEvent

* Adding props table and more methods

* wip

* Renaming event notifications to event messages

* onClickNoNewsTitles

* Toggle mark as read/unread

* Initial documentation

* Improving examples

* Fixing TS error

* Refactored EuiEventNotification context menu item creation

* improving data

* Notifications data

* Primary example buttons

* Reset data

* More docs

* snippets

* Adding tests

* Better messages explanation

* Better snippets

* Small fixes

* Missing prop explanation

* Adding heading level

* Adding flexible comp section

* More a11y

* Update src/components/notification/notification_event_messages.tsx

Co-authored-by: Michail Yasonik <michail@yasonik.com>

* Button messages ay11

* test

* Better descriptions

* Tests

* Adding icon arial label into notifications feed example

* i18n token

* i18n token

* i18 token again

* primaryAction description

* More description

* Update src/components/notification/notification_event_messages.tsx

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src/components/notification/notification_event_messages.tsx

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Addressing PR review

* More improvements

* Adding comment

* Excluding `eventName` at top level and changing title vs aria-label on read button

* Fix title

* Fixing tests and removing evenName from docs usage

* Fixing icon margin

* More tests and small fixes

* Moving read button from event meta comp to event comp

* Split primaryAction and primaryActionProps

* Exposing EuiPrimaryActionProps in props table

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update src-docs/src/views/notification_event/notification_event_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Messages length and more

* Fixing data test subj

* Renaming tsx examples to js

Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: Michail Yasonik <michail@yasonik.com>
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: cchaos <caroline.horn@elastic.co>
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

@elizabetdev elizabetdev marked this pull request as ready for review March 11, 2021 17:51
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Great job!! Can't wait to see this in action.

@elizabetdev elizabetdev requested a review from mshustov March 11, 2021 20:01
onOpenContextMenu ? () => onOpenContextMenu(id) : undefined
}
eventName={title}
onRead={() => onRead?.(id, isRead!)}
Copy link

@mshustov mshustov Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably isRead should be required then? or pass an optional flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you don't pass isRead, the read button won't appear. So that's why we can't make it required.

We discussed if it was possible for the MVP to have a way to save the read states and because was something that we were not completely sure it was decided to live it in open.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I deleted this line onRead={() => onRead?.(id, isRead!)}. After a refactor in #4433 the read button was left outside of the EuiNotificationEventMeta and this line was doing nothing.

Thanks, @restrry . It was a good catch!

iconType={iconType}
iconAriaLabel={iconAriaLabel}
time={time}
onOpenContextMenu={

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: onOpenContextMenu={onOpenContextMenu}
EuiNotificationEventMeta declares it as an optional field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to do this TS starts complaining:

Screenshot 2021-03-16 at 12 17 29

/*
* An array of strings that get individually wrapped in `<p>` tags
*/
messages: string[];
Copy link

@mshustov mshustov Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we require messages to be already translated? Let's mention it in the comment.
PS. the same for other text props.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In EUI we assume translating a string is a decision from the consumer app.

/>

{onClickTitle ? (
<EuiLink onClick={() => onClickTitle(id)} {...titleProps}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be configured with href?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. You need to create a logic to redirect to a page or external link.

<div className="euiNotificationEvent__readButton">
<EuiNotificationEventReadButton
isRead={isRead}
onClick={() => onRead?.(id, isRead)}
Copy link

@mshustov mshustov Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we verify whether it's defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being verified. 🎉

I checked with @chandlerprall if the onRead?. was verifying that.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4513/

@elizabetdev
Copy link
Contributor Author

elizabetdev commented Mar 16, 2021

Thanks, @restrry. I went through your comments and improved a few things. 🎉

If you have more suggestions don't hesitate to open an issue.

@elizabetdev elizabetdev merged commit 1d6fec1 into master Mar 16, 2021
@thompsongl thompsongl deleted the feature/notification branch November 1, 2021 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants