From 1a226d73bd81e8482b6b73456874ebc7659e32b0 Mon Sep 17 00:00:00 2001
From: Joseph John Aas Cooper <33054985+cooper-joe@users.noreply.github.com>
Date: Thu, 20 Feb 2025 12:09:01 +0100
Subject: [PATCH] fix(headerbar): profile menu design changes
---
components/header-bar/i18n/en.pot | 34 ++--
.../src/__e2e__/stories/me-with-avatar.js | 1 +
.../src/debug-info/debug-info-menu-item.js | 41 +++--
..._headerbar_contains_a_profile_menu.feature | 8 +-
...con_if_the_user_does_not_have_an_avatar.js | 6 +-
...an_image_icon_if_the_user_has_an_avatar.js | 6 +-
.../the_user_can_edit_his_profile.js | 6 +-
...the_user_can_go_to_the_about_dhis2_page.js | 2 +-
.../the_user_can_go_to_the_help_page.js | 2 +-
.../the_user_can_log_out.js | 2 +-
...e_user_name_and_username_are_displayed.js} | 12 +-
.../index.js | 4 +-
components/header-bar/src/header-bar.js | 4 +-
.../header-bar/src/header-bar.prod.stories.js | 1 +
.../src/profile-menu/profile-header.js | 106 +++++------
.../src/profile-menu/profile-menu.js | 169 ++++++++++--------
.../src/profile-menu/update-notification.js | 58 ++++--
components/header-bar/src/profile.js | 6 +-
18 files changed, 255 insertions(+), 213 deletions(-)
rename components/header-bar/src/features/the_headerbar_contains_a_profile_menu/{the_user_name_and_email_are_displayed.js => the_user_name_and_username_are_displayed.js} (58%)
diff --git a/components/header-bar/i18n/en.pot b/components/header-bar/i18n/en.pot
index b24ee470f4..1c12896a8d 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: 2024-06-12T03:40:49.012Z\n"
-"PO-Revision-Date: 2024-06-12T03:40:49.013Z\n"
+"POT-Creation-Date: 2025-02-20T09:30:45.543Z\n"
+"PO-Revision-Date: 2025-02-20T09:30:45.547Z\n"
msgid "Search apps"
msgstr "Search apps"
@@ -47,32 +47,32 @@ msgstr "Online"
msgid "Offline"
msgstr "Offline"
-msgid "Edit profile"
-msgstr "Edit profile"
+msgid "Logged in as "
+msgstr "Logged in as "
msgid "Settings"
msgstr "Settings"
-msgid "Account"
-msgstr "Account"
+msgid "Account security"
+msgstr "Account security"
+
+msgid "My profile"
+msgstr "My profile"
msgid "Help"
msgstr "Help"
-msgid "About DHIS2"
-msgstr "About DHIS2"
-
-msgid "Logout"
-msgstr "Logout"
+msgid "System info"
+msgstr "System info"
-msgid "New {{appName}} version available"
-msgstr "New {{appName}} version available"
+msgid "Log out"
+msgstr "Log out"
-msgid "New app version available"
-msgstr "New app version available"
+msgid "New {{appName}} version available — Reload to update"
+msgstr "New {{appName}} version available — Reload to update"
-msgid "Click to reload"
-msgstr "Click to reload"
+msgid "New app version available — Reload to update"
+msgstr "New app version available — Reload to update"
msgid "header bar profile"
msgstr "header bar profile"
diff --git a/components/header-bar/src/__e2e__/stories/me-with-avatar.js b/components/header-bar/src/__e2e__/stories/me-with-avatar.js
index 0c41c255c3..33526161e3 100644
--- a/components/header-bar/src/__e2e__/stories/me-with-avatar.js
+++ b/components/header-bar/src/__e2e__/stories/me-with-avatar.js
@@ -14,6 +14,7 @@ MeWithAvatar.decorators = [
me: {
name: 'John Doe',
email: 'john_doe@dhis2.org',
+ username: 'john_doe',
settings: {
keyUiLocale: 'en',
},
diff --git a/components/header-bar/src/debug-info/debug-info-menu-item.js b/components/header-bar/src/debug-info/debug-info-menu-item.js
index 89e7cd759a..380b33a59d 100644
--- a/components/header-bar/src/debug-info/debug-info-menu-item.js
+++ b/components/header-bar/src/debug-info/debug-info-menu-item.js
@@ -1,5 +1,4 @@
-import { colors } from '@dhis2/ui-constants'
-import { MenuItem } from '@dhis2-ui/menu'
+import { colors, spacers } from '@dhis2/ui-constants'
import PropTypes from 'prop-types'
import React from 'react'
import i18n from '../locales/index.js'
@@ -42,27 +41,45 @@ export const DebugInfoMenuItem = ({ hideProfileMenu, showDebugInfoModal }) => {
)
return (
-
+ data-test="dhis2-ui-headerbar-debuginfo"
+ >
+ {debugInfoLabel}
+
+
)
}
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu.feature b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu.feature
index 56d423a8ac..5daf074d30 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu.feature
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu.feature
@@ -4,13 +4,13 @@ Feature: The HeaderBar contains a profile menu
Given the HeaderBar loads without an error and the user does not have an avatar
Then the headerbar contains a text icon of size 36px
When the user clicks on the text icon
- Then the profile menu contains a text icon of size 48px
+ Then the profile menu contains a text icon of size 36px
Scenario: The HeaderBar shows an image icon if the user has an avatar
Given the HeaderBar loads without an error and the user has an avatar
Then the headerbar contains an image icon of size 36px
When the user clicks on the image icon
- Then the profile menu contains an image icon of size 48px
+ Then the profile menu contains an image icon of size 36px
Scenario: The menu is closed by default
Given the HeaderBar loads without an error
@@ -21,11 +21,11 @@ Feature: The HeaderBar contains a profile menu
When the user clicks on the profile icons
Then the menu opens
- Scenario: The user name and email are displayed
+ Scenario: The user name and username are displayed
Given the HeaderBar loads without an error
When the user opens the menu
And contains the user name
- And contains the user email
+ And contains the user username
Scenario: The user can edit his profile
Given the HeaderBar loads without an error
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_a_text_icon_if_the_user_does_not_have_an_avatar.js b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_a_text_icon_if_the_user_does_not_have_an_avatar.js
index 9d6f4c6a90..d2db26d32c 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_a_text_icon_if_the_user_does_not_have_an_avatar.js
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_a_text_icon_if_the_user_does_not_have_an_avatar.js
@@ -20,11 +20,11 @@ When('the user clicks on the text icon', () => {
cy.get('[data-test="headerbar-profile-icon-text"]').click()
})
-Then(`the profile menu contains a text icon of size 48px`, () => {
+Then(`the profile menu contains a text icon of size 36px`, () => {
cy.fixture('HeaderBar/me').then(() => {
cy.get('[data-test="headerbar-profile-menu-icon-text"]')
.should('be.visible')
- .and('have.css', 'height', '48px')
- .and('have.css', 'width', '48px')
+ .and('have.css', 'height', '36px')
+ .and('have.css', 'width', '36px')
})
})
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_an_image_icon_if_the_user_has_an_avatar.js b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_an_image_icon_if_the_user_has_an_avatar.js
index 02012b8525..38afba7c4a 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_an_image_icon_if_the_user_has_an_avatar.js
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_an_image_icon_if_the_user_has_an_avatar.js
@@ -15,9 +15,9 @@ When('the user clicks on the image icon', () => {
cy.get('[data-test="headerbar-profile-icon-image"]').click()
})
-Then('the profile menu contains an image icon of size 48px', () => {
+Then('the profile menu contains an image icon of size 36px', () => {
cy.get('[data-test="headerbar-profile-menu-icon-image"]')
.should('be.visible')
- .and('have.css', 'height', '48px')
- .and('have.css', 'width', '48px')
+ .and('have.css', 'height', '36px')
+ .and('have.css', 'width', '36px')
})
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_edit_his_profile.js b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_edit_his_profile.js
index e3a3a867c9..e72978bc5b 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_edit_his_profile.js
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_edit_his_profile.js
@@ -1,7 +1,7 @@
import { Then } from '@badeball/cypress-cucumber-preprocessor'
Then('contains a link to edit the profile', () => {
- cy.get('[data-test="headerbar-profile-edit-profile-link"]').should(
- 'be.visible'
- )
+ cy.get('[data-test="headerbar-profile-menu"] > li').should((lis) => {
+ expect(lis.eq(3)).to.be.visible
+ })
})
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_about_dhis2_page.js b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_about_dhis2_page.js
index 496904bd08..80df88f688 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_about_dhis2_page.js
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_about_dhis2_page.js
@@ -2,6 +2,6 @@ import { Then } from '@badeball/cypress-cucumber-preprocessor'
Then('contains a link to the About DHIS2 page', () => {
cy.get('[data-test="headerbar-profile-menu"] > li').should((lis) => {
- expect(lis.eq(3)).to.be.visible
+ expect(lis.eq(5)).to.be.visible
})
})
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_help_page.js b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_help_page.js
index 26e3d0d87d..dd38a654a0 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_help_page.js
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_help_page.js
@@ -2,6 +2,6 @@ import { Then } from '@badeball/cypress-cucumber-preprocessor'
Then('contains a link to the help page', () => {
cy.get('[data-test="headerbar-profile-menu"] > li').should((lis) => {
- expect(lis.eq(2)).to.be.visible
+ expect(lis.eq(4)).to.be.visible
})
})
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_log_out.js b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_log_out.js
index 777a9b9a4b..11e8aa9b80 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_log_out.js
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_can_log_out.js
@@ -5,7 +5,7 @@ const logoutUrl = `${baseUrl}dhis-web-commons-security/logout.action`
Then('contains a link to log out the user', () => {
cy.get('[data-test="headerbar-profile-menu"] > li').should((lis) => {
- const menuItem = lis.eq(4)
+ const menuItem = lis.eq(7)
expect(menuItem).to.be.visible
expect(menuItem.find('a')).to.have.attr('href', logoutUrl)
})
diff --git a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_name_and_email_are_displayed.js b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_name_and_username_are_displayed.js
similarity index 58%
rename from components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_name_and_email_are_displayed.js
rename to components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_name_and_username_are_displayed.js
index e1701d8358..e662b63ee6 100644
--- a/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_name_and_email_are_displayed.js
+++ b/components/header-bar/src/features/the_headerbar_contains_a_profile_menu/the_user_name_and_username_are_displayed.js
@@ -7,16 +7,16 @@ Then('contains the user name', () => {
).then(([win, $name]) => {
console.log('win.dataProviderData', win.dataProviderData)
const { name } = win.dataProviderData.me
- expect($name.text()).to.equal(name)
+ expect($name.text()).to.contain(name)
})
})
-Then('contains the user email', () => {
+Then('contains the user username', () => {
cy.all(
() => cy.window(),
- () => cy.get('[data-test="headerbar-profile-user-email"]')
- ).then(([win, $email]) => {
- const { email } = win.dataProviderData.me
- expect($email.text()).to.equal(email)
+ () => cy.get('[data-test="headerbar-profile-user-subtitle"]')
+ ).then(([win, $username]) => {
+ const { username } = win.dataProviderData.me
+ expect($username.text()).to.equal(username)
})
})
diff --git a/components/header-bar/src/features/the_headerbar_should_display_app_update_notification/index.js b/components/header-bar/src/features/the_headerbar_should_display_app_update_notification/index.js
index 5ab56b45dd..ea8bb0e6ca 100644
--- a/components/header-bar/src/features/the_headerbar_should_display_app_update_notification/index.js
+++ b/components/header-bar/src/features/the_headerbar_should_display_app_update_notification/index.js
@@ -31,13 +31,13 @@ Then('the update notification should not be displayed', () => {
Then('the update notification should be displayed', () => {
cy.get('[data-test="dhis2-ui-headerbar-updatenotification"]')
.should('contain', 'New Data Visualizer version available')
- .should('contain', 'Click to reload')
+ .should('contain', 'Reload to update')
})
Then('the update notification should be displayed without app name', () => {
cy.get('[data-test="dhis2-ui-headerbar-updatenotification"]')
.should('contain', 'New app version available')
- .should('contain', 'Click to reload')
+ .should('contain', 'Reload to update')
})
When('the user clicks the update notification', () => {
diff --git a/components/header-bar/src/header-bar.js b/components/header-bar/src/header-bar.js
index 673c6b4ab9..7606f62604 100755
--- a/components/header-bar/src/header-bar.js
+++ b/components/header-bar/src/header-bar.js
@@ -22,7 +22,7 @@ const query = {
user: {
resource: 'me',
params: {
- fields: ['authorities', 'avatar', 'email', 'name', 'settings'],
+ fields: ['authorities', 'avatar', 'name', 'settings', 'username'],
},
},
apps: {
@@ -98,7 +98,7 @@ export const HeaderBar = ({