From 0df456cf56ce1159ccccf7cde3fd69455947a797 Mon Sep 17 00:00:00 2001 From: Chisom Chima <87203527+Chisomchima@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:14:11 +0100 Subject: [PATCH] chore: improve accessibility of headerbar notification icons and profile (#1469) --- components/header-bar/i18n/en.pot | 10 +++++++-- .../header-bar/src/notification-icon.js | 21 +++++++++++++++++-- components/header-bar/src/notifications.js | 12 +++++------ components/header-bar/src/profile.js | 3 +++ 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/components/header-bar/i18n/en.pot b/components/header-bar/i18n/en.pot index 8eb2ee283f..2d8598618c 100644 --- a/components/header-bar/i18n/en.pot +++ b/components/header-bar/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2023-01-18T16:13:05.063Z\n" -"PO-Revision-Date: 2023-01-18T16:13:05.063Z\n" +"POT-Creation-Date: 2024-03-29T07:26:07.540Z\n" +"PO-Revision-Date: 2024-03-29T07:26:07.540Z\n" msgid "Search apps" msgstr "Search apps" @@ -35,6 +35,12 @@ msgstr "Close" msgid "Copy debug info" msgstr "Copy debug info" +msgid "Interpretations" +msgstr "Interpretations" + +msgid "Messages" +msgstr "Messages" + msgid "Online" msgstr "Online" diff --git a/components/header-bar/src/notification-icon.js b/components/header-bar/src/notification-icon.js index 7619e8eeca..46f96db6ea 100755 --- a/components/header-bar/src/notification-icon.js +++ b/components/header-bar/src/notification-icon.js @@ -2,6 +2,7 @@ import { colors, theme, spacers } from '@dhis2/ui-constants' import { IconMessages24, IconMail24 } from '@dhis2/ui-icons' import PropTypes from 'prop-types' import React from 'react' +import i18n from './locales/index.js' function icon(kind) { if (kind === 'message') { @@ -11,8 +12,22 @@ function icon(kind) { } } -export const NotificationIcon = ({ count, href, kind, dataTestId }) => ( - +export const NotificationIcon = ({ + count, + href, + kind, + dataTestId, + title, + 'aria-label': ariaLabel, +}) => ( + {icon(kind)} {count > 0 && {count}} @@ -71,7 +86,9 @@ NotificationIcon.defaultProps = { } NotificationIcon.propTypes = { + 'aria-label': PropTypes.string.isRequired, href: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, count: PropTypes.number, dataTestId: PropTypes.string, kind: PropTypes.oneOf(['interpretation', 'message']), diff --git a/components/header-bar/src/notifications.js b/components/header-bar/src/notifications.js index cd416c82b8..737bf4cbee 100755 --- a/components/header-bar/src/notifications.js +++ b/components/header-bar/src/notifications.js @@ -2,15 +2,9 @@ import { useConfig } from '@dhis2/app-runtime' import PropTypes from 'prop-types' import React from 'react' import { joinPath } from './join-path.js' +import i18n from './locales/index.js' import { NotificationIcon } from './notification-icon.js' -/* - AUTHORITIES: - - ALL: superuser - - M_dhis-web-interpretation: access to interpretations app - - M_dhis-web-messaging: access to messaging app - */ - const hasAuthority = (userAuthorities, authId) => Array.isArray(userAuthorities) && userAuthorities.some( @@ -32,6 +26,8 @@ export const Notifications = ({ href={joinPath(baseUrl, 'dhis-web-interpretation')} kind="message" dataTestId="headerbar-interpretations" + title={i18n.t('Interpretations')} + aria-label={i18n.t('Interpretations')} /> )} @@ -42,6 +38,8 @@ export const Notifications = ({ href={joinPath(baseUrl, 'dhis-web-messaging')} kind="interpretation" dataTestId="headerbar-messages" + title={i18n.t('Messages')} + aria-label={i18n.t('Messages')} /> )} diff --git a/components/header-bar/src/profile.js b/components/header-bar/src/profile.js index 0719b619f1..2d8404ced2 100755 --- a/components/header-bar/src/profile.js +++ b/components/header-bar/src/profile.js @@ -2,6 +2,7 @@ import { UserAvatar } from '@dhis2-ui/user-avatar' import PropTypes from 'prop-types' import React, { useCallback, useRef, useState } from 'react' import { DebugInfoModal } from './debug-info/debug-info-modal.js' +import i18n from './locales/index.js' import { ProfileMenu } from './profile-menu/index.js' import { useOnDocClick } from './profile/use-on-doc-click.js' @@ -29,6 +30,8 @@ const Profile = ({ name, email, avatarId, helpUrl }) => {