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

[EuiNotificationEvent] Spread className and rest props #6208

Merged
merged 4 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { GuideSectionTypes } from '../../components';
import { Link } from 'react-router-dom';
import { EuiNotificationEventMeta } from '../../../../src/components/notification/notification_event_meta';
import {
EuiNotificationEvent,
EuiText,
Expand Down Expand Up @@ -91,7 +90,6 @@ export const NotificationEventExample = {
],
props: {
EuiNotificationEvent,
EuiNotificationEventMeta,
EuiContextMenuItem,
EuiPrimaryActionProps,
},
Expand Down Expand Up @@ -192,7 +190,6 @@ export const NotificationEventExample = {
),
props: {
EuiNotificationEvent,
EuiNotificationEventMeta,
EuiContextMenuItem,
EuiPrimaryActionProps,
},
Expand All @@ -219,7 +216,6 @@ export const NotificationEventExample = {
),
props: {
EuiNotificationEvent,
EuiNotificationEventMeta,
EuiContextMenuItem,
EuiPrimaryActionProps,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

exports[`EuiNotificationEvent is rendered 1`] = `
<article
aria-label="aria-label"
aria-labelledby="generated-id"
class="euiNotificationEvent"
class="euiNotificationEvent className"
data-test-subj="test subject string"
>
<div
class="euiNotificationEvent__content"
Expand Down
7 changes: 6 additions & 1 deletion src/components/notification/notification_event.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import React from 'react';
import { mount, render } from 'enzyme';
import { EuiNotificationEvent } from './notification_event';
import { EuiContextMenuPanel, EuiContextMenuItem } from '../context_menu';
import { findTestSubject, takeMountedSnapshot } from '../../test';
import {
findTestSubject,
takeMountedSnapshot,
requiredProps,
} from '../../test';

describe('EuiNotificationEvent', () => {
test('is rendered', () => {
Expand All @@ -21,6 +25,7 @@ describe('EuiNotificationEvent', () => {
time="1 min ago"
title="title"
messages={['message']}
{...requiredProps}
/>
);

Expand Down
24 changes: 21 additions & 3 deletions src/components/notification/notification_event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
* Side Public License, v 1.
*/

import React, { FunctionComponent, ReactElement, createElement } from 'react';
import React, {
FunctionComponent,
ReactElement,
createElement,
HTMLAttributes,
} from 'react';
import classNames from 'classnames';

import { CommonProps } from '../common';

import {
EuiNotificationEventMeta,
EuiNotificationEventMetaProps,
Expand Down Expand Up @@ -35,7 +43,9 @@ export type EuiNotificationEventProps = Omit<
Omit<
EuiNotificationEventReadButtonProps,
'onClick' | 'color' | 'eventName' | 'isRead' | 'id'
> & {
> &
CommonProps &
Omit<HTMLAttributes<HTMLDivElement>, 'title'> & {
/**
* A unique identifier
*/
Expand Down Expand Up @@ -104,9 +114,12 @@ export const EuiNotificationEvent: FunctionComponent<EuiNotificationEventProps>
onClickTitle,
onClickPrimaryAction,
headingLevel = 'h2',
className,
...rest
}) => {
const classes = classNames('euiNotificationEvent', {
'euiNotificationEvent--withReadState': typeof isRead === 'boolean',
className,
});

const classesTitle = classNames('euiNotificationEvent__title', {
Expand All @@ -122,7 +135,12 @@ export const EuiNotificationEvent: FunctionComponent<EuiNotificationEventProps>
};

return (
<article aria-labelledby={randomHeadingId} className={classes} key={id}>
<article
aria-labelledby={randomHeadingId}
className={classes}
key={id}
{...rest}
>
{typeof isRead === 'boolean' && (
<div className="euiNotificationEvent__readButton">
{!!onRead ? (
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/6208.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed bug where `className` and `rest` props were not being passed to the `EuiNotificationEvent`