Skip to content
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
42 changes: 27 additions & 15 deletions components/header-bar/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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: 2025-02-17T10:58:14.678Z\n"
"PO-Revision-Date: 2025-02-17T10:58:14.680Z\n"
"POT-Creation-Date: 2025-02-26T14:39:24.393Z\n"
"PO-Revision-Date: 2025-02-26T14:39:24.393Z\n"

msgid "Browse apps"
msgstr "Browse apps"
Expand All @@ -23,6 +23,18 @@ msgstr "Logout"
msgid "Back"
msgstr "Back"

msgid "to navigate"
msgstr "to navigate"

msgid "to select"
msgstr "to select"

msgid "to close"
msgstr "to close"

msgid "to go back one level"
msgstr "to go back one level"

msgid "Search apps"
msgstr "Search apps"

Expand Down Expand Up @@ -77,29 +89,29 @@ msgstr "Online"
msgid "Offline"
msgstr "Offline"

msgid "Edit profile"
msgstr "Edit profile"

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 "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"
2 changes: 1 addition & 1 deletion components/header-bar/src/__e2e__/stories/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const dataProviderData = {
},
me: {
name: 'John Doe',
email: 'john_doe@dhis2.org',
username: 'john_doe',
settings: {
keyUiLocale: 'en',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MeWithAvatar.decorators = [
...dataProviderData,
me: {
name: 'John Doe',
email: 'john_doe@dhis2.org',
username: 'john_doe',
settings: {
keyUiLocale: 'en',
},
Expand Down
41 changes: 29 additions & 12 deletions components/header-bar/src/debug-info/debug-info-menu-item.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -42,27 +41,45 @@ export const DebugInfoMenuItem = ({ hideProfileMenu, showDebugInfoModal }) => {
<style jsx>{`
.root {
color: ${colors.grey700};
font-style: italic;
font-size: 14px;
line-height: 17px;
font-size: 12px;
line-height: 15px;
}
.instance-info {
margin-bottom: 4px;
margin-block-end: ${spacers.dp4};
word-break: break-all;
}
.version {
white-space: no-wrap;
word-break: break-all;
}
.debug-info-menu-item {
padding: 0;
}
`}</style>
</div>
)

return (
<MenuItem
dense
<button
onClick={openDebugModal}
label={debugInfoLabel}
dataTest="dhis2-ui-headerbar-debuginfo"
/>
data-test="dhis2-ui-headerbar-debuginfo"
>
{debugInfoLabel}
<style jsx>{`
button {
width: 100%;
margin-block-start: ${spacers.dp4};
padding: ${spacers.dp8} ${spacers.dp12};
background-color: ${colors.grey050};
border: none;
border-block-start: 1px solid ${colors.grey300};
cursor: pointer;
text-align: left;
}
button:hover {
background-color: ${colors.grey200};
}
`}</style>
</button>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Original file line number Diff line number Diff line change
@@ -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
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Then('the instance version should show as unknown', () => {
})

When('the user clicks the debug info menu item', () => {
cy.get('[data-test="dhis2-ui-headerbar-debuginfo"] > a').click()
cy.get('[data-test="dhis2-ui-headerbar-debuginfo"]').click()
})

Then('the debug info modal should be shown', () => {
Expand Down
4 changes: 2 additions & 2 deletions components/header-bar/src/header-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const query = {
user: {
resource: 'me',
params: {
fields: ['authorities', 'avatar', 'email', 'name', 'settings'],
fields: ['authorities', 'avatar', 'name', 'settings', 'username'],
},
},
apps: {
Expand Down Expand Up @@ -114,7 +114,7 @@ export const HeaderBar = ({
</CommandPaletteContextProvider>
<Profile
name={data.user.name}
email={data.user.email}
username={data.user.username}
avatarId={data.user.avatar?.id}
helpUrl={data.help.helpPageLink}
/>
Expand Down
2 changes: 1 addition & 1 deletion components/header-bar/src/header-bar.prod.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const customData = {
},
me: {
name: 'John Doe',
email: 'john_doe@dhis2.org',
username: 'john_doe',
settings: {
keyUiLocale: 'en',
},
Expand Down
Loading
Loading