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

Use new header icon badge for newsfeed button #77946

Merged
merged 5 commits into from
Sep 21, 2020
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
134 changes: 70 additions & 64 deletions src/plugins/newsfeed/public/components/flyout_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
EuiText,
EuiBadge,
EuiHeaderAlert,
EuiPortal,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { NewsfeedContext } from './newsfeed_header_nav_button';
Expand All @@ -42,70 +43,75 @@ export const NewsfeedFlyout = () => {
const closeFlyout = useCallback(() => setFlyoutVisible(false), [setFlyoutVisible]);

return (
<EuiFlyout
onClose={closeFlyout}
size="s"
aria-labelledby="flyoutSmallTitle"
className="kbnNews__flyout"
data-test-subj="NewsfeedFlyout"
>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s">
<h2 id="flyoutSmallTitle">
<FormattedMessage
id="newsfeed.flyoutList.whatsNewTitle"
defaultMessage="What's new at Elastic"
/>
</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody className={'kbnNews__flyoutAlerts'}>
{!newsFetchResult ? (
<NewsLoadingPrompt />
) : newsFetchResult.feedItems.length > 0 ? (
newsFetchResult.feedItems.map((item: NewsfeedItem) => {
return (
<EuiHeaderAlert
key={item.hash}
title={item.title}
text={item.description}
data-test-subj="newsHeadAlert"
action={
<EuiLink target="_blank" href={item.linkUrl} external>
{item.linkText}
</EuiLink>
}
date={item.publishOn.format('DD MMMM YYYY')}
badge={item.badge ? <EuiBadge color="hollow">{item.badge}</EuiBadge> : undefined}
<EuiPortal>
<EuiFlyout
onClose={closeFlyout}
size="s"
aria-labelledby="flyoutSmallTitle"
className="kbnNews__flyout"
data-test-subj="NewsfeedFlyout"
>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s">
<h2 id="flyoutSmallTitle">
<FormattedMessage
id="newsfeed.flyoutList.whatsNewTitle"
defaultMessage="What's new at Elastic"
/>
);
})
) : (
<NewsEmptyPrompt />
)}
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButtonEmpty iconType="cross" onClick={closeFlyout} flush="left">
<FormattedMessage id="newsfeed.flyoutList.closeButtonLabel" defaultMessage="Close" />
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{newsFetchResult ? (
<EuiText color="subdued" size="s">
<p>
<FormattedMessage
id="newsfeed.flyoutList.versionTextLabel"
defaultMessage="{version}"
values={{ version: `Version ${newsFetchResult.kibanaVersion}` }}
/>
</p>
</EuiText>
) : null}
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutFooter>
</EuiFlyout>
</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody className={'kbnNews__flyoutAlerts'}>
{!newsFetchResult ? (
<NewsLoadingPrompt />
) : newsFetchResult.feedItems.length > 0 ? (
newsFetchResult.feedItems.map((item: NewsfeedItem) => {
return (
<EuiHeaderAlert
key={item.hash}
title={item.title}
text={item.description}
data-test-subj="newsHeadAlert"
action={
<EuiLink target="_blank" href={item.linkUrl} external>
{item.linkText}
</EuiLink>
}
date={item.publishOn.format('DD MMMM YYYY')}
badge={item.badge ? <EuiBadge color="hollow">{item.badge}</EuiBadge> : undefined}
/>
);
})
) : (
<NewsEmptyPrompt />
)}
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButtonEmpty iconType="cross" onClick={closeFlyout} flush="left">
<FormattedMessage
id="newsfeed.flyoutList.closeButtonLabel"
defaultMessage="Close"
/>
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{newsFetchResult ? (
<EuiText color="subdued" size="s">
<p>
<FormattedMessage
id="newsfeed.flyoutList.versionTextLabel"
defaultMessage="{version}"
values={{ version: `Version ${newsFetchResult.kibanaVersion}` }}
/>
</p>
</EuiText>
) : null}
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutFooter>
</EuiFlyout>
</EuiPortal>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import React, { useState, Fragment, useEffect } from 'react';
import * as Rx from 'rxjs';
import { EuiHeaderSectionItemButton, EuiIcon, EuiNotificationBadge } from '@elastic/eui';
import { EuiHeaderSectionItemButton, EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { NewsfeedFlyout } from './flyout_list';
import { FetchResult } from '../types';

Expand Down Expand Up @@ -65,15 +66,19 @@ export const NewsfeedNavButton = ({ apiFetchResult }: Props) => {
aria-controls="keyPadMenu"
aria-expanded={flyoutVisible}
aria-haspopup="true"
aria-label="Newsfeed menu"
aria-label={
showBadge
? i18n.translate('newsfeed.headerButton.unreadAriaLabel', {
defaultMessage: 'Newsfeed menu - unread items available',
})
: i18n.translate('newsfeed.headerButton.readAriaLabel', {
defaultMessage: 'Newsfeed menu - all items read',
})
}
notification={showBadge ? true : null}
onClick={showFlyout}
>
<EuiIcon type="cheer" size="m" />
{showBadge ? (
<EuiNotificationBadge className="euiHeaderNotification" data-test-subj="showBadgeNews">
&#9642;
</EuiNotificationBadge>
) : null}
</EuiHeaderSectionItemButton>
{flyoutVisible ? <NewsfeedFlyout /> : null}
</Fragment>
Expand Down
3 changes: 2 additions & 1 deletion test/functional/page_objects/newsfeed_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { FtrProviderContext } from '../ftr_provider_context';

export function NewsfeedPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const find = getService('find');
const retry = getService('retry');
const flyout = getService('flyout');
const testSubjects = getService('testSubjects');
Expand Down Expand Up @@ -49,7 +50,7 @@ export function NewsfeedPageProvider({ getService, getPageObjects }: FtrProvider
}

async getRedButtonSign() {
return await testSubjects.exists('showBadgeNews');
return await find.existsByCssSelector('.euiHeaderSectionItemButton__notification--dot');
}

async getNewsfeedList() {
Expand Down