Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4e5a2fa
refactor(headerbar profile): use functional component instead of class
Mohammer5 Oct 6, 2021
6185b5d
feat(headerbar): add instance- & app-infos to profile menu
Mohammer5 Oct 7, 2021
42db34e
docs(headerbar): add story with instance- & app-infos in profile menu
Mohammer5 Oct 7, 2021
6c0b8c0
refactor(headerbar use instance info): simplify hook
Mohammer5 Oct 7, 2021
400b810
refactor(headerbar instance infos): adjust styles according to sugges…
Mohammer5 Oct 7, 2021
b54ddb9
chore: fix linter issues
Mohammer5 Oct 14, 2021
c299272
test(header bar): add tests for "useInstanceInfo" & "useOnDocClick" h…
Mohammer5 Oct 14, 2021
1de06c6
fix(profile menu): remove comma between app name and app version
Mohammer5 Oct 20, 2021
0a83b93
fix(profile menu): remove hover style from instance and app info menu…
Mohammer5 Oct 20, 2021
21532f1
refactor(headerbar instance infos): omit "version" word in instance info
Mohammer5 Oct 21, 2021
cfbd4f1
refactor(instance and app infos): make user-selectable & add data-tes…
Mohammer5 Oct 22, 2021
434c04d
test(instance and app infos): add cypress tests
Mohammer5 Oct 22, 2021
5237b5c
chore(linter and prettier): fix issues
Mohammer5 Oct 22, 2021
054eaa2
Merge remote-tracking branch 'origin/master' into LIBS-176
amcgee Sep 22, 2022
b712041
feat: use context to fetch version info, add copy action
amcgee Sep 22, 2022
bf95076
feat: support update notification in profile menu
amcgee Sep 22, 2022
3bf79b1
chore: fix linting errors
amcgee Sep 22, 2022
df44aa6
chore: fix cypress tests
amcgee Sep 22, 2022
e5c962d
chore: use MenuDivider instead of custom border
amcgee Sep 22, 2022
b32723f
chore: use dense menu items
amcgee Sep 22, 2022
caa0025
fix: revert merge regression
amcgee Sep 22, 2022
b26adba
chore: revert unintended i18n change (probably needs to be re-extract…
amcgee Sep 23, 2022
a461dad
style: formatting
amcgee Sep 23, 2022
84bb0c6
fix: update css, use styled jsx
amcgee Sep 26, 2022
9793e2f
chore: fix i18n variable substitution
amcgee Sep 26, 2022
027d18b
style: formatting
amcgee Sep 26, 2022
034fe96
feat: add debug info modal
amcgee Sep 28, 2022
091e322
style: formatting
amcgee Sep 28, 2022
dabca36
chore: add cypress tests
amcgee Oct 3, 2022
7cbbdb9
fix: support app version with missing app name
amcgee Oct 3, 2022
8fd4bff
style: format
amcgee Oct 3, 2022
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
2 changes: 1 addition & 1 deletion collections/forms/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ msgid "Please provide a string"
msgstr "Please provide a string"

msgid "Please provide a valid url"
msgstr "Please provide a valid url"
msgstr "Please provide a valid url"
2 changes: 2 additions & 0 deletions collections/ui/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ import { HeaderBar } from '@dhis2/ui'
|---|---|---|---|---|
|appName|string||||
|className|string||||
|updateAvailable|boolean||||
|onApplyAvailableUpdate|function||||

### Logo

Expand Down
2 changes: 2 additions & 0 deletions components/header-bar/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ import { HeaderBar } from '@dhis2-ui/header-bar'
|---|---|---|---|---|
|appName|string||||
|className|string||||
|updateAvailable|boolean||||
|onApplyAvailableUpdate|function||||
10 changes: 8 additions & 2 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: 2021-09-02T19:24:35.672Z\n"
"PO-Revision-Date: 2021-09-02T19:24:35.672Z\n"
"POT-Creation-Date: 2022-09-26T11:25:27.498Z\n"
"PO-Revision-Date: 2022-09-26T11:25:27.498Z\n"

msgid "Search apps"
msgstr "Search apps"
Expand Down Expand Up @@ -37,3 +37,9 @@ msgstr "About DHIS2"

msgid "Logout"
msgstr "Logout"

msgid "New {{appName}} version available"
msgstr "New {{appName}} version available"

msgid "Click to reload"
msgstr "Click to reload"
8 changes: 2 additions & 6 deletions components/header-bar/src/__e2e__/header-bar.stories.e2e.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { HeaderBar } from '../index.js'

export default {
title: 'HeaderBarTesting',
component: HeaderBar,
}
import { HeaderBar as component } from '../index.js'

export default { title: 'HeaderBarTesting', component }
export { Default } from './stories/default.js'
export { ShowOnlineStatus } from './stories/show-online-status.js'
export { PWAEnabled } from './stories/pwa-enabled.js'
Expand Down
121 changes: 87 additions & 34 deletions components/header-bar/src/__e2e__/stories/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable react/display-name */
import { CustomDataProvider, Provider } from '@dhis2/app-runtime'
import React from 'react'
import { CustomDataProvider, Provider, useAlerts } from '@dhis2/app-runtime'
import PropTypes from 'prop-types'
import React, { useEffect } from 'react'

export const defaultModules = [
{
Expand Down Expand Up @@ -312,37 +313,6 @@ export const modulesWithSpecialCharacters = [
export const applicationTitle = 'Foobar'

export const dataProviderData = {
'system/info': {
contextPath: 'https://debug.dhis2.org/dev',
userAgent:
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
calendar: 'iso8601',
dateFormat: 'yyyy-mm-dd',
serverDate: '2021-10-06T08:06:15.256',
serverTimeZoneId: 'Etc/UTC',
serverTimeZoneDisplayName: 'Coordinated Universal Time',
lastAnalyticsTableSuccess: '2021-09-18T10:24:03.536',
intervalSinceLastAnalyticsTableSuccess: '429 h, 42 m, 11 s',
lastAnalyticsTableRuntime: '520835',
lastSystemMonitoringSuccess: '2019-03-26T17:07:15.418',
version: '2.38-SNAPSHOT',
revision: '6607c3c',
buildTime: '2021-10-05T17:13:00.000',
jasperReportsVersion: '6.3.1',
environmentVariable: 'DHIS2_HOME',
databaseInfo: {
spatialSupport: true,
},
encryption: false,
emailConfigured: false,
redisEnabled: false,
systemId: 'eed3d451-4ff5-4193-b951-ffcc68954299',
systemName: 'DHIS 2 Demo - Sierra Leone',
instanceBaseUrl: 'https://debug.dhis2.org/dev',
clusterHostname: '',
isMetadataVersionEnabled: true,
metadataSyncEnabled: false,
},
'systemSettings/applicationTitle': {
applicationTitle,
},
Expand Down Expand Up @@ -379,10 +349,93 @@ export const createDecoratorCustomDataProviderHeaderBar = (
}

export const providerConfig = {
appName: 'TestApp',
appVersion: {
full: '101.2.3-beta.4',
major: 101,
minor: 2,
patch: 3,
tag: 'beta.4',
},
serverVersion: {
full: '2.39.2.1-SNAPSHOT',
major: 2,
minor: 39,
patch: 2,
hotfix: 1,
tag: 'SNAPSHOT',
},
systemInfo: {
contextPath: 'https://debug.dhis2.org/dev',
userAgent:
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
calendar: 'iso8601',
dateFormat: 'yyyy-mm-dd',
serverDate: '2021-10-06T08:06:15.256',
serverTimeZoneId: 'Etc/UTC',
serverTimeZoneDisplayName: 'Coordinated Universal Time',
lastAnalyticsTableSuccess: '2021-09-18T10:24:03.536',
intervalSinceLastAnalyticsTableSuccess: '429 h, 42 m, 11 s',
lastAnalyticsTableRuntime: '520835',
lastSystemMonitoringSuccess: '2019-03-26T17:07:15.418',
version: '2.39.2.1-SNAPSHOT',
revision: '6607c3c',
buildTime: '2021-10-05T17:13:00.000',
jasperReportsVersion: '6.3.1',
environmentVariable: 'DHIS2_HOME',
databaseInfo: {
spatialSupport: true,
},
encryption: false,
emailConfigured: false,
redisEnabled: false,
systemId: 'eed3d451-4ff5-4193-b951-ffcc68954299',
systemName: 'DHIS 2 Demo - Sierra Leone',
instanceBaseUrl: 'https://debug.dhis2.org/dev',
clusterHostname: '',
isMetadataVersionEnabled: true,
metadataSyncEnabled: false,
},
baseUrl: 'https://domain.tld/',
apiVersion: '',
}

const MockAlert = ({ alert }) => {
useEffect(() => {
if (alert.options?.duration) {
setTimeout(() => alert.remove(), alert.options?.duration)
}
}, [alert])
return (
<div style={{ backgroundColor: '#CCC', padding: 8 }}>
{alert.message}
</div>
)
}
MockAlert.propTypes = {
alert: PropTypes.shape({
message: PropTypes.string,
options: PropTypes.shape({ duration: PropTypes.number }),
remove: PropTypes.func,
}),
}
const MocklAlertStack = () => {
const alerts = useAlerts()

return (
<div style={{ position: 'absolute', bottom: 16, right: 16 }}>
{alerts.map((alert) => (
<MockAlert key={alert.id} alert={alert} />
))}
</div>
)
}

export const createDecoratorProvider = (config) => {
return (fn) => <Provider config={config || providerConfig}>{fn()}</Provider>
return (fn) => (
<Provider config={config || providerConfig}>
{fn()}
<MocklAlertStack />
</Provider>
)
}
2 changes: 1 addition & 1 deletion components/header-bar/src/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const Apps = ({ apps }) => {
useEffect(() => {
document.addEventListener('click', onDocClick)
return () => document.removeEventListener('click', onDocClick)
}, [])
}, [onDocClick])

return (
<div ref={containerEl} data-test="headerbar-apps">
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: The HeaderBar should display debug version infos

Scenario: The debug version infos are displayed in the profile menu
Given the HeaderBar is rendered with an app name and app version in runtime context
When the user opens the profile menu
Then the instance version should be displayed
And the apps's name and version should be displayed
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'

Given(
'the HeaderBar is rendered with an app name and app version in runtime context',
() => {
cy.visitStory('HeaderBarTesting', 'default')
}
)

When('the user opens the profile menu', () => {
cy.get('[data-test="headerbar-profile"] > button').click()
})

Then("the apps's name and version should be displayed", () => {
cy.get('[data-test="dhis2-ui-headerbar-appinfo"]').should(
'contain',
'TestApp 101.2.3-beta.4'
)
})

Then('the instance version should be displayed', () => {
cy.get('[data-test="dhis2-ui-headerbar-instanceinfo"]').should(
'contain',
'DHIS2 2.39.2.1-SNAPSHOT'
)
})
28 changes: 28 additions & 0 deletions components/header-bar/src/header-bar-context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import PropTypes from 'prop-types'
import React, { createContext, useContext } from 'react'

const headerBarContext = createContext({
updateAvailable: false,
onApplyAvailableUpdate: () => {},
})

export const HeaderBarContextProvider = ({
updateAvailable,
onApplyAvailableUpdate,
children,
}) => {
return (
<headerBarContext.Provider
value={{ updateAvailable, onApplyAvailableUpdate }}
>
{children}
</headerBarContext.Provider>
)
}
HeaderBarContextProvider.propTypes = {
children: PropTypes.node,
updateAvailable: PropTypes.bool,
onApplyAvailableUpdate: PropTypes.func,
}

export const useHeaderBarContext = () => useContext(headerBarContext)
Loading