Home page "recent links" should communicate saved object type #21896 (#33694) (#33862)

* adds object type for screen order
* adds object type for pointer hovering
* Update src/legacy/ui/public/chrome/directives/header_global_nav/components/header.tsx

Co-Authored-By: rockfield <philipp.b@ya.ru>
This commit is contained in:
Philipp B 2019-03-26 20:48:06 +03:00 committed by GitHub
parent dceaa48d69
commit 6dc184fe64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,6 +54,7 @@ import { HeaderBreadcrumbs } from './header_breadcrumbs';
import { HeaderHelpMenu } from './header_help_menu';
import { HeaderNavControls } from './header_nav_controls';
import { i18n } from '@kbn/i18n';
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import chrome, { NavLink } from 'ui/chrome';
import { HelpExtension } from 'ui/chrome';
@ -88,10 +89,23 @@ function extendRecentlyAccessedHistoryItem(
const href = relativeToAbsolute(chrome.addBasePath(recentlyAccessed.link));
const navLink = navLinks.find(nl => href.startsWith(nl.subUrlBase));
let titleAndAriaLabel = recentlyAccessed.label;
if (navLink) {
const objectTypeForAriaAppendix = navLink.title;
titleAndAriaLabel = i18n.translate('common.ui.recentLinks.linkItem.screenReaderLabel', {
defaultMessage: '{recentlyAccessedItemLinklabel}, type: {pageType}',
values: {
recentlyAccessedItemLinklabel: recentlyAccessed.label,
pageType: objectTypeForAriaAppendix,
},
});
}
return {
...recentlyAccessed,
href,
euiIconType: navLink ? navLink.euiIconType : undefined,
title: titleAndAriaLabel,
};
}
@ -248,9 +262,8 @@ class HeaderUI extends Component<Props, State> {
}),
listItems: recentlyAccessed.map(item => ({
label: truncateRecentItemLabel(item.label),
// TODO: Add what type of app/saved object to title attr
title: `${item.label}`,
'aria-label': item.label,
title: item.title,
'aria-label': item.title,
href: item.href,
iconType: item.euiIconType,
})),