@dhis2-ui/header-bar 10.16.1 → 10.16.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -16
- package/src/__e2e__/header-bar.e2e.stories.js +26 -0
- package/src/__e2e__/stories/common.js +226 -0
- package/src/__e2e__/stories/custom-application-title.js +19 -0
- package/src/__e2e__/stories/default.js +13 -0
- package/src/__e2e__/stories/me-with-avatar.js +27 -0
- package/src/__e2e__/stories/modulesWithSpecialCharacters.js +229 -0
- package/src/__e2e__/stories/online-status-message.js +49 -0
- package/src/__e2e__/stories/pwa-enabled.js +17 -0
- package/src/__e2e__/stories/user-has-all-authority.js +20 -0
- package/src/__e2e__/stories/user-has-no-authorities.js +20 -0
- package/src/__e2e__/stories/user-has-web-interpretation-and-messaging-authority.js +22 -0
- package/src/__e2e__/stories/user-has-web-interpretation-authority.js +22 -0
- package/src/__e2e__/stories/user-has-web-messaging-authority.js +22 -0
- package/src/__e2e__/stories/with-debug-info-edge-cases.js +51 -0
- package/src/__e2e__/stories/with-special-app-name-character.js +23 -0
- package/src/__e2e__/stories/with-update-available-notification.js +39 -0
- package/src/__e2e__/stories/zero-unread-interpretations.js +19 -0
- package/src/__e2e__/stories/zero-unread-messages.js +19 -0
- package/src/apps.js +276 -0
- package/src/debug-info/debug-info-menu-item.js +72 -0
- package/src/debug-info/debug-info-modal.js +47 -0
- package/src/debug-info/debug-info-table.js +51 -0
- package/src/debug-info/use-debug-info.js +15 -0
- package/src/features/common/index.js +14 -0
- package/src/features/the_headerbar_can_display_online_status/the_headerbar_displays_online_status.js +158 -0
- package/src/features/the_headerbar_can_display_online_status.feature +57 -0
- package/src/features/the_headerbar_conditionally_renders_notification_icons/the_headerbar_conditionally_renders_notification_icons.js +43 -0
- package/src/features/the_headerbar_conditionally_renders_notification_icons.feature +26 -0
- package/src/features/the_headerbar_contains_a_menu_to_all_apps/common.js +5 -0
- package/src/features/the_headerbar_contains_a_menu_to_all_apps/the_app_menu_closes_when_the_user_clicks_outside.js +9 -0
- package/src/features/the_headerbar_contains_a_menu_to_all_apps/the_headerbar_contains_a_menu_icon.js +5 -0
- package/src/features/the_headerbar_contains_a_menu_to_all_apps/the_user_will_be_offered_a_menu_with_5_apps.js +16 -0
- package/src/features/the_headerbar_contains_a_menu_to_all_apps.feature +21 -0
- package/src/features/the_headerbar_contains_a_profile_menu/common.js +14 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_a_text_icon_if_the_user_does_not_have_an_avatar.js +30 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_headerbar_shows_an_image_icon_if_the_user_has_an_avatar.js +23 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_menu_is_closed_by_default.js +1 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_menu_opens.js +14 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_profile_menu_closes_when_the_user_clicks_outside.js +5 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_user_can_edit_his_profile.js +7 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_his_account.js +7 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_about_dhis2_page.js +7 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_help_page.js +7 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_user_can_go_to_the_settings.js +7 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_user_can_log_out.js +53 -0
- package/src/features/the_headerbar_contains_a_profile_menu/the_user_name_and_email_are_displayed.js +22 -0
- package/src/features/the_headerbar_contains_a_profile_menu.feature +73 -0
- package/src/features/the_headerbar_displays_a_link_to_interpretations_and_an_unread_count/the_headerbar_displays_a_link_to_the_interpretations.js +5 -0
- package/src/features/the_headerbar_displays_a_link_to_interpretations_and_an_unread_count/there_are_no_unread_interpretations.js +9 -0
- package/src/features/the_headerbar_displays_a_link_to_interpretations_and_an_unread_count/there_are_some_unread_interpretations.js +12 -0
- package/src/features/the_headerbar_displays_a_link_to_interpretations_and_an_unread_count.feature +13 -0
- package/src/features/the_headerbar_displays_a_link_to_messages_and_an_unread_count/the_headerbar_displays_a_link_to_the_messages.js +5 -0
- package/src/features/the_headerbar_displays_a_link_to_messages_and_an_unread_count/there_are_no_unread_messages.js +9 -0
- package/src/features/the_headerbar_displays_a_link_to_messages_and_an_unread_count/there_are_some_unread_messages.js +7 -0
- package/src/features/the_headerbar_displays_a_link_to_messages_and_an_unread_count.feature +13 -0
- package/src/features/the_headerbar_should_contain_a_logo_that_links_to_the_homepage/headerbar_contains_logo.js +12 -0
- package/src/features/the_headerbar_should_contain_a_logo_that_links_to_the_homepage.feature +6 -0
- package/src/features/the_headerbar_should_display_app_update_notification/index.js +52 -0
- package/src/features/the_headerbar_should_display_app_update_notification.feature +22 -0
- package/src/features/the_headerbar_should_display_debug_version_infos/index.js +130 -0
- package/src/features/the_headerbar_should_display_debug_version_infos.feature +52 -0
- package/src/features/the_headerbar_should_display_the_title_provided_by_the_backend_and_the_app/the_headerbar_displays_the_custom_title.js +11 -0
- package/src/features/the_headerbar_should_display_the_title_provided_by_the_backend_and_the_app.feature +5 -0
- package/src/features/the_search_should_escape_regexp_character/common.js +6 -0
- package/src/features/the_search_should_escape_regexp_character/the_modules_do_not_contain_items_with_special_chars.js +23 -0
- package/src/features/the_search_should_escape_regexp_character/the_user_searches_for_an_app_with_a_regex_character.js +29 -0
- package/src/features/the_search_should_escape_regexp_character.feature +48 -0
- package/src/header-bar-context.js +28 -0
- package/src/header-bar.js +145 -0
- package/src/header-bar.prod.stories.js +303 -0
- package/src/index.js +1 -0
- package/src/join-path.js +4 -0
- package/src/locales/ar/translations.json +24 -0
- package/src/locales/ar_IQ/translations.json +24 -0
- package/src/locales/bn/translations.json +12 -0
- package/src/locales/ckb/translations.json +23 -0
- package/src/locales/cs/translations.json +24 -0
- package/src/locales/da/translations.json +24 -0
- package/src/locales/en/translations.json +25 -0
- package/src/locales/en_US/translations.json +25 -0
- package/src/locales/es/translations.json +25 -0
- package/src/locales/es_419/translations.json +24 -0
- package/src/locales/fr/translations.json +25 -0
- package/src/locales/hi_IN/translations.json +25 -0
- package/src/locales/id/translations.json +24 -0
- package/src/locales/index.js +88 -0
- package/src/locales/km/translations.json +24 -0
- package/src/locales/lo/translations.json +24 -0
- package/src/locales/my/translations.json +24 -0
- package/src/locales/nb/translations.json +24 -0
- package/src/locales/nl/translations.json +24 -0
- package/src/locales/or/translations.json +12 -0
- package/src/locales/prs/translations.json +24 -0
- package/src/locales/ps/translations.json +24 -0
- package/src/locales/pt/translations.json +25 -0
- package/src/locales/pt_BR/translations.json +24 -0
- package/src/locales/ro/translations.json +23 -0
- package/src/locales/ru/translations.json +24 -0
- package/src/locales/si/translations.json +24 -0
- package/src/locales/sv/translations.json +24 -0
- package/src/locales/tet/translations.json +24 -0
- package/src/locales/tg/translations.json +24 -0
- package/src/locales/uk/translations.json +24 -0
- package/src/locales/ur/translations.json +24 -0
- package/src/locales/uz_Latn/translations.json +23 -0
- package/src/locales/uz_UZ_Cyrl/translations.json +24 -0
- package/src/locales/uz_UZ_Latn/translations.json +24 -0
- package/src/locales/vi/translations.json +24 -0
- package/src/locales/zh/translations.json +25 -0
- package/src/locales/zh_CN/translations.json +24 -0
- package/src/logo-image.js +71 -0
- package/src/logo.js +45 -0
- package/src/notification-icon.js +91 -0
- package/src/notifications.js +63 -0
- package/src/online-status.js +40 -0
- package/src/online-status.styles.js +91 -0
- package/src/profile/use-on-doc-click.js +23 -0
- package/src/profile/use-on-doc-click.test.js +40 -0
- package/src/profile-menu/index.js +1 -0
- package/src/profile-menu/profile-header.js +118 -0
- package/src/profile-menu/profile-menu.js +176 -0
- package/src/profile-menu/update-notification.js +67 -0
- package/src/profile.js +101 -0
- package/src/title.js +23 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useDataQuery, useConfig } from '@dhis2/app-runtime'
|
|
2
|
+
import { colors } from '@dhis2/ui-constants'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import React, { useEffect, useMemo } from 'react'
|
|
5
|
+
import Apps from './apps.js'
|
|
6
|
+
import { HeaderBarContextProvider } from './header-bar-context.js'
|
|
7
|
+
import { joinPath } from './join-path.js'
|
|
8
|
+
import i18n from './locales/index.js'
|
|
9
|
+
import { Logo } from './logo.js'
|
|
10
|
+
import { Notifications } from './notifications.js'
|
|
11
|
+
import { OnlineStatus } from './online-status.js'
|
|
12
|
+
import Profile from './profile.js'
|
|
13
|
+
import { Title } from './title.js'
|
|
14
|
+
|
|
15
|
+
const query = {
|
|
16
|
+
title: {
|
|
17
|
+
resource: 'systemSettings/applicationTitle',
|
|
18
|
+
},
|
|
19
|
+
help: {
|
|
20
|
+
resource: 'systemSettings/helpPageLink',
|
|
21
|
+
},
|
|
22
|
+
user: {
|
|
23
|
+
resource: 'me',
|
|
24
|
+
params: {
|
|
25
|
+
fields: ['authorities', 'avatar', 'email', 'name', 'settings'],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
apps: {
|
|
29
|
+
resource: 'action::menu/getModules',
|
|
30
|
+
},
|
|
31
|
+
notifications: {
|
|
32
|
+
resource: 'me/dashboard',
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const HeaderBar = ({
|
|
37
|
+
appName,
|
|
38
|
+
className,
|
|
39
|
+
updateAvailable,
|
|
40
|
+
onApplyAvailableUpdate,
|
|
41
|
+
skipI18n,
|
|
42
|
+
}) => {
|
|
43
|
+
const { appName: configAppName, baseUrl, pwaEnabled } = useConfig()
|
|
44
|
+
const { loading, error, data } = useDataQuery(query)
|
|
45
|
+
|
|
46
|
+
const apps = useMemo(() => {
|
|
47
|
+
const getPath = (path) =>
|
|
48
|
+
path.startsWith('http:') || path.startsWith('https:')
|
|
49
|
+
? path
|
|
50
|
+
: joinPath(baseUrl, 'api', path)
|
|
51
|
+
|
|
52
|
+
return data?.apps.modules.map((app) => ({
|
|
53
|
+
...app,
|
|
54
|
+
icon: getPath(app.icon),
|
|
55
|
+
defaultAction: getPath(app.defaultAction),
|
|
56
|
+
}))
|
|
57
|
+
}, [data, baseUrl])
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!loading && !error && !skipI18n) {
|
|
61
|
+
// This is the "legacy" way of localising the header bar, which is necesasry for external (non-platform) apps
|
|
62
|
+
// For platform apps, setting i18n is handled by the app-shell so this logic is redundant (and running it twice caused issues)
|
|
63
|
+
// For external apps, this logic is kept for backwards compatibility, but they also have the option of passing `skipI18n`
|
|
64
|
+
// and initialising i18n in the consumer
|
|
65
|
+
const locale = data?.user?.settings?.keyUiLocale || 'en'
|
|
66
|
+
i18n.setDefaultNamespace('default')
|
|
67
|
+
i18n.changeLanguage(locale)
|
|
68
|
+
}
|
|
69
|
+
}, [data?.user?.settings?.keyUiLocale, error, loading, skipI18n])
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<HeaderBarContextProvider
|
|
73
|
+
updateAvailable={updateAvailable}
|
|
74
|
+
onApplyAvailableUpdate={onApplyAvailableUpdate}
|
|
75
|
+
>
|
|
76
|
+
<header className={className}>
|
|
77
|
+
<div className="main">
|
|
78
|
+
{!loading && !error && (
|
|
79
|
+
<>
|
|
80
|
+
<Logo />
|
|
81
|
+
|
|
82
|
+
<Title
|
|
83
|
+
app={appName || configAppName}
|
|
84
|
+
instance={data.title.applicationTitle}
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<div className="right-control-spacer" />
|
|
88
|
+
|
|
89
|
+
{pwaEnabled && <OnlineStatus />}
|
|
90
|
+
|
|
91
|
+
<Notifications
|
|
92
|
+
interpretations={
|
|
93
|
+
data.notifications.unreadInterpretations
|
|
94
|
+
}
|
|
95
|
+
messages={
|
|
96
|
+
data.notifications
|
|
97
|
+
.unreadMessageConversations
|
|
98
|
+
}
|
|
99
|
+
userAuthorities={data.user.authorities}
|
|
100
|
+
/>
|
|
101
|
+
<Apps apps={apps} />
|
|
102
|
+
|
|
103
|
+
<Profile
|
|
104
|
+
name={data.user.name}
|
|
105
|
+
email={data.user.email}
|
|
106
|
+
avatarId={data.user.avatar?.id}
|
|
107
|
+
helpUrl={data.help.helpPageLink}
|
|
108
|
+
/>
|
|
109
|
+
</>
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
{pwaEnabled && !loading && !error && <OnlineStatus dense />}
|
|
114
|
+
|
|
115
|
+
<style jsx>{`
|
|
116
|
+
.main {
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: row;
|
|
119
|
+
align-items: center;
|
|
120
|
+
justify-content: space-between;
|
|
121
|
+
background-color: #2c6693;
|
|
122
|
+
color: ${colors.white};
|
|
123
|
+
height: 48px;
|
|
124
|
+
}
|
|
125
|
+
.right-control-spacer {
|
|
126
|
+
margin-inline-start: auto;
|
|
127
|
+
}
|
|
128
|
+
`}</style>
|
|
129
|
+
</header>
|
|
130
|
+
</HeaderBarContextProvider>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
HeaderBar.propTypes = {
|
|
135
|
+
appName: PropTypes.string,
|
|
136
|
+
className: PropTypes.string,
|
|
137
|
+
/**
|
|
138
|
+
* `skipI18n` skips initalising internationalisation in the UI component
|
|
139
|
+
* This is useful for app-platform apps, as the platform already sets i18n, so it can skip i18n (and avoid race conditions).
|
|
140
|
+
* For non-platform apps, they can continue relying on this logic running for backwards compatibility.
|
|
141
|
+
* */
|
|
142
|
+
skipI18n: PropTypes.bool,
|
|
143
|
+
updateAvailable: PropTypes.bool,
|
|
144
|
+
onApplyAvailableUpdate: PropTypes.func,
|
|
145
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { CustomDataProvider } from '@dhis2/app-runtime'
|
|
2
|
+
import React, { useEffect, useState } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
createDecoratorProvider,
|
|
5
|
+
mockOfflineInterface,
|
|
6
|
+
providerConfig,
|
|
7
|
+
} from './__e2e__/stories/common.js'
|
|
8
|
+
import { OnlineStatusMessageUpdate } from './__e2e__/stories/online-status-message.js'
|
|
9
|
+
import { HeaderBar } from './header-bar.js'
|
|
10
|
+
import i18n from './locales/index.js'
|
|
11
|
+
|
|
12
|
+
const subtitle = 'The common navigation bar used in all DHIS2 apps'
|
|
13
|
+
|
|
14
|
+
const description = `
|
|
15
|
+
The header bar is mandatory for all apps. This creates a stable, understandable point of reference for the user across all kinds of different apps. It must always be displayed fixed to the top of the screen. Do not interfere or obstruct interaction with the header bar.
|
|
16
|
+
|
|
17
|
+
The header bar is included automatically with the App Shell and should not need any configuration.
|
|
18
|
+
|
|
19
|
+
#### Theme
|
|
20
|
+
|
|
21
|
+
The header bar can be themeed to suit the brand/color of your DHIS2 instance. The color of the text/icons will be automatically adjusted based on the selected color.
|
|
22
|
+
|
|
23
|
+
\`\`\`js
|
|
24
|
+
import { HeaderBar } from '@dhis2/ui'
|
|
25
|
+
\`\`\`
|
|
26
|
+
`
|
|
27
|
+
|
|
28
|
+
const customData = {
|
|
29
|
+
'systemSettings/applicationTitle': {
|
|
30
|
+
applicationTitle: 'Foobar',
|
|
31
|
+
},
|
|
32
|
+
'systemSettings/helpPageLink': {
|
|
33
|
+
helpPageLink: '//custom-help-page-link',
|
|
34
|
+
},
|
|
35
|
+
me: {
|
|
36
|
+
name: 'John Doe',
|
|
37
|
+
email: 'john_doe@dhis2.org',
|
|
38
|
+
settings: {
|
|
39
|
+
keyUiLocale: 'en',
|
|
40
|
+
},
|
|
41
|
+
authorities: ['ALL'],
|
|
42
|
+
},
|
|
43
|
+
'action::menu/getModules': {
|
|
44
|
+
modules: [
|
|
45
|
+
{
|
|
46
|
+
name: 'dhis-web-dashboard',
|
|
47
|
+
namespace: '/dhis-web-dashboard',
|
|
48
|
+
defaultAction: '../dhis-web-dashboard/index.action',
|
|
49
|
+
displayName: 'Dashboard',
|
|
50
|
+
icon: '../icons/dhis-web-dashboard.png',
|
|
51
|
+
description: '',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'dhis-web-data-visualizer',
|
|
55
|
+
namespace: '/dhis-web-data-visualizer',
|
|
56
|
+
defaultAction: '../dhis-web-data-visualizer/index.action',
|
|
57
|
+
displayName: 'Data Visualizer',
|
|
58
|
+
icon: '../icons/dhis-web-data-visualizer.png',
|
|
59
|
+
description: '',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'dhis-web-capture',
|
|
63
|
+
namespace: '/dhis-web-capture',
|
|
64
|
+
defaultAction: '../dhis-web-capture/index.action',
|
|
65
|
+
displayName: 'Capture',
|
|
66
|
+
icon: '../icons/dhis-web-capture.png',
|
|
67
|
+
description: '',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'dhis-web-maintenance',
|
|
71
|
+
namespace: '/dhis-web-maintenance',
|
|
72
|
+
defaultAction: '../dhis-web-maintenance/index.action',
|
|
73
|
+
displayName: 'Maintenance',
|
|
74
|
+
icon: '../icons/dhis-web-maintenance.png',
|
|
75
|
+
description: '',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'dhis-web-maps',
|
|
79
|
+
namespace: '/dhis-web-maps',
|
|
80
|
+
defaultAction: '../dhis-web-maps/index.action',
|
|
81
|
+
displayName: 'Maps',
|
|
82
|
+
icon: '../icons/dhis-web-maps.png',
|
|
83
|
+
description: '',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'dhis-web-event-reports',
|
|
87
|
+
namespace: '/dhis-web-event-reports',
|
|
88
|
+
defaultAction: '../dhis-web-event-reports/index.action',
|
|
89
|
+
displayName: 'Event Reports',
|
|
90
|
+
icon: '../icons/dhis-web-event-reports.png',
|
|
91
|
+
description: '',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'dhis-web-interpretation',
|
|
95
|
+
namespace: '/dhis-web-interpretation',
|
|
96
|
+
defaultAction: '../dhis-web-interpretation/index.action',
|
|
97
|
+
displayName: 'Interpretations',
|
|
98
|
+
icon: '../icons/dhis-web-interpretation.png',
|
|
99
|
+
description: '',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'dhis-web-import-export',
|
|
103
|
+
namespace: '/dhis-web-import-export',
|
|
104
|
+
defaultAction: '../dhis-web-import-export/index.action',
|
|
105
|
+
displayName: 'Import/Export',
|
|
106
|
+
icon: '../icons/dhis-web-import-export.png',
|
|
107
|
+
description: '',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'WHO Metadata browser',
|
|
111
|
+
namespace: 'WHO Metadata browser',
|
|
112
|
+
defaultAction:
|
|
113
|
+
'https://debug.dhis2.org/dev/api/apps/WHO-Metadata-browser/index.html',
|
|
114
|
+
displayName: '',
|
|
115
|
+
icon: 'https://debug.dhis2.org/dev/api/apps/WHO-Metadata-browser/icons/medicine-48.png',
|
|
116
|
+
description: '',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'Dashboard Classic',
|
|
120
|
+
namespace: 'Dashboard Classic',
|
|
121
|
+
defaultAction:
|
|
122
|
+
'https://debug.dhis2.org/dev/api/apps/Dashboard-Classic/index.html',
|
|
123
|
+
displayName: 'Dashboard Classic',
|
|
124
|
+
icon: 'https://debug.dhis2.org/dev/api/apps/Dashboard-Classic/icon.png',
|
|
125
|
+
description: 'DHIS2 Legacy Dashboard App',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
'me/dashboard': {
|
|
130
|
+
unreadInterpretations: 10,
|
|
131
|
+
unreadMessageConversations: 5,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const customLogoData = {
|
|
136
|
+
...customData,
|
|
137
|
+
'staticContent/logo_banner': {
|
|
138
|
+
images: {
|
|
139
|
+
png: 'https://via.placeholder.com/150x50',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const customLocaleData = {
|
|
145
|
+
...customData,
|
|
146
|
+
'systemSettings/applicationTitle': {
|
|
147
|
+
applicationTitle: 'Le Gros Foobar',
|
|
148
|
+
},
|
|
149
|
+
me: {
|
|
150
|
+
...customData.me,
|
|
151
|
+
settings: {
|
|
152
|
+
keyUiLocale: 'fr',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
'action::menu/getModules': {
|
|
156
|
+
modules: customData['action::menu/getModules'].modules.map((mod) => ({
|
|
157
|
+
...mod,
|
|
158
|
+
displayName: `Le ${mod.displayName}`,
|
|
159
|
+
})),
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const customAuthoritiesData = {
|
|
164
|
+
...customData,
|
|
165
|
+
me: {
|
|
166
|
+
...customData.me,
|
|
167
|
+
authorities: ['M_dhis-web-messaging'],
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export default {
|
|
172
|
+
title: 'Header Bar',
|
|
173
|
+
component: HeaderBar,
|
|
174
|
+
parameters: {
|
|
175
|
+
componentSubtitle: subtitle,
|
|
176
|
+
docs: { description: { component: description } },
|
|
177
|
+
},
|
|
178
|
+
decorators: [createDecoratorProvider()],
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const Default = () => (
|
|
182
|
+
<CustomDataProvider data={customData}>
|
|
183
|
+
<HeaderBar appName="Example!" />
|
|
184
|
+
</CustomDataProvider>
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
export const CustomLogoWideDimension = () => (
|
|
188
|
+
<CustomDataProvider data={customLogoData}>
|
|
189
|
+
<HeaderBar appName="Example!" />
|
|
190
|
+
</CustomDataProvider>
|
|
191
|
+
)
|
|
192
|
+
CustomLogoWideDimension.storyName = 'Custom Logo (wide dimension)'
|
|
193
|
+
|
|
194
|
+
export const NonEnglishUserLocale = () => (
|
|
195
|
+
<CustomDataProvider data={customLocaleData}>
|
|
196
|
+
<HeaderBar appName="Exemple!" />
|
|
197
|
+
</CustomDataProvider>
|
|
198
|
+
)
|
|
199
|
+
NonEnglishUserLocale.storyName = 'Non-english user locale'
|
|
200
|
+
|
|
201
|
+
export const NonEnglishUserLocaleIgnoringI18n = () => {
|
|
202
|
+
const [language, setLanguage] = useState()
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
console.log('custom effect to set language from consumer')
|
|
205
|
+
|
|
206
|
+
i18n.setDefaultNamespace('default')
|
|
207
|
+
i18n.changeLanguage('es')
|
|
208
|
+
setLanguage('es')
|
|
209
|
+
}, [])
|
|
210
|
+
|
|
211
|
+
return language ? (
|
|
212
|
+
<CustomDataProvider data={customLocaleData}>
|
|
213
|
+
<HeaderBar appName="Exemple!" skipI18n />
|
|
214
|
+
</CustomDataProvider>
|
|
215
|
+
) : null
|
|
216
|
+
}
|
|
217
|
+
NonEnglishUserLocaleIgnoringI18n.storyName =
|
|
218
|
+
'Custom locale initialisation (spanish) from the consumer'
|
|
219
|
+
|
|
220
|
+
export const NoAuthorityForInterpretationsApp = () => (
|
|
221
|
+
<CustomDataProvider data={customAuthoritiesData}>
|
|
222
|
+
<HeaderBar appName="Example!" />
|
|
223
|
+
</CustomDataProvider>
|
|
224
|
+
)
|
|
225
|
+
NoAuthorityForInterpretationsApp.storyName =
|
|
226
|
+
'No authority for interpretations app'
|
|
227
|
+
|
|
228
|
+
export const Loading = () => (
|
|
229
|
+
<CustomDataProvider options={{ loadForever: true }}>
|
|
230
|
+
<HeaderBar appName="Example!" />
|
|
231
|
+
</CustomDataProvider>
|
|
232
|
+
)
|
|
233
|
+
Loading.storyName = 'Loading...'
|
|
234
|
+
|
|
235
|
+
export const Error = () => (
|
|
236
|
+
<CustomDataProvider data={{}}>
|
|
237
|
+
<HeaderBar appName="Exemple!" />
|
|
238
|
+
</CustomDataProvider>
|
|
239
|
+
)
|
|
240
|
+
Error.storyName = 'Error!'
|
|
241
|
+
|
|
242
|
+
export const WithOnlineStatus = () => (
|
|
243
|
+
<CustomDataProvider data={customData}>
|
|
244
|
+
<HeaderBar appName="Exemple!" />
|
|
245
|
+
</CustomDataProvider>
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
WithOnlineStatus.decorators = [
|
|
249
|
+
createDecoratorProvider({ ...providerConfig, pwaEnabled: true }),
|
|
250
|
+
]
|
|
251
|
+
|
|
252
|
+
WithOnlineStatus.parameters = {
|
|
253
|
+
docs: {
|
|
254
|
+
description: {
|
|
255
|
+
story: 'An online status badge will be shown in apps that set \
|
|
256
|
+
`pwa: { enabled: true }` in `d2.config.js`. The status \
|
|
257
|
+
indicator uses a different layout on viewports smaller \
|
|
258
|
+
than 480px.',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export const WithUpdateNotification = () => (
|
|
264
|
+
<CustomDataProvider data={customData}>
|
|
265
|
+
<HeaderBar appName="Data Visualizer" updateAvailable={true} />
|
|
266
|
+
</CustomDataProvider>
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
export const WithOnlineStatusMessage = () => (
|
|
270
|
+
<CustomDataProvider data={customData}>
|
|
271
|
+
<HeaderBar appName="Exemple!" />
|
|
272
|
+
<OnlineStatusMessageUpdate />
|
|
273
|
+
</CustomDataProvider>
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
export const RTLHeader = () => (
|
|
277
|
+
<CustomDataProvider data={customData}>
|
|
278
|
+
<div dir="rtl">
|
|
279
|
+
<HeaderBar appName="Example!" />
|
|
280
|
+
</div>
|
|
281
|
+
</CustomDataProvider>
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
WithOnlineStatusMessage.decorators = [
|
|
285
|
+
createDecoratorProvider(
|
|
286
|
+
{
|
|
287
|
+
...providerConfig,
|
|
288
|
+
pwaEnabled: true,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
...mockOfflineInterface,
|
|
292
|
+
latestIsConnected: false,
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
]
|
|
296
|
+
|
|
297
|
+
WithOnlineStatusMessage.parameters = {
|
|
298
|
+
docs: {
|
|
299
|
+
description: {
|
|
300
|
+
story: 'When online status is updated, the status indicator will show react node sent as the message',
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HeaderBar } from './header-bar.js'
|
package/src/join-path.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "البحث في التطبيقات",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "",
|
|
4
|
+
"DHIS2 version unknown": "",
|
|
5
|
+
"{{appName}} version unknown": "",
|
|
6
|
+
"App {{appVersion}}": "",
|
|
7
|
+
"App version unknown": "",
|
|
8
|
+
"Debug info": "",
|
|
9
|
+
"Close": "إغلاق",
|
|
10
|
+
"Copy debug info": "",
|
|
11
|
+
"Interpretations": "التفسيرات",
|
|
12
|
+
"Messages": "الرسائل",
|
|
13
|
+
"Online": "متصل",
|
|
14
|
+
"Offline": "غير متصل",
|
|
15
|
+
"Edit profile": "تعديل ملف التعريف",
|
|
16
|
+
"Settings": "الإعدادات",
|
|
17
|
+
"Account": "الحساب",
|
|
18
|
+
"Help": "مساعدة",
|
|
19
|
+
"About DHIS2": "حول DHIS2",
|
|
20
|
+
"Logout": "تسجيل الخروج",
|
|
21
|
+
"New {{appName}} version available": "",
|
|
22
|
+
"New app version available": "",
|
|
23
|
+
"Click to reload": ""
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "",
|
|
4
|
+
"DHIS2 version unknown": "",
|
|
5
|
+
"{{appName}} version unknown": "",
|
|
6
|
+
"App {{appVersion}}": "",
|
|
7
|
+
"App version unknown": "",
|
|
8
|
+
"Debug info": "",
|
|
9
|
+
"Close": "إغلاق",
|
|
10
|
+
"Copy debug info": "",
|
|
11
|
+
"Interpretations": "التفسيرات",
|
|
12
|
+
"Messages": "الرسائل",
|
|
13
|
+
"Online": "متصل",
|
|
14
|
+
"Offline": "غير متصل",
|
|
15
|
+
"Edit profile": "",
|
|
16
|
+
"Settings": "",
|
|
17
|
+
"Account": "",
|
|
18
|
+
"Help": "",
|
|
19
|
+
"About DHIS2": "",
|
|
20
|
+
"Logout": "",
|
|
21
|
+
"New {{appName}} version available": "",
|
|
22
|
+
"New app version available": "",
|
|
23
|
+
"Click to reload": ""
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "",
|
|
4
|
+
"DHIS2 version unknown": "",
|
|
5
|
+
"{{appName}} version unknown": "",
|
|
6
|
+
"App {{appVersion}}": "",
|
|
7
|
+
"App version unknown": "",
|
|
8
|
+
"Debug info": "",
|
|
9
|
+
"Close": "داخستن",
|
|
10
|
+
"Copy debug info": "",
|
|
11
|
+
"Last online {{relativeTime}}": "",
|
|
12
|
+
"Online": "ئۆنڵاین",
|
|
13
|
+
"Offline": "ئۆفڵاین",
|
|
14
|
+
"Edit profile": "",
|
|
15
|
+
"Settings": "ريكخستن",
|
|
16
|
+
"Account": "",
|
|
17
|
+
"Help": "هاوكاري",
|
|
18
|
+
"About DHIS2": "",
|
|
19
|
+
"Logout": "",
|
|
20
|
+
"New {{appName}} version available": "",
|
|
21
|
+
"New app version available": "",
|
|
22
|
+
"Click to reload": ""
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "Hledat aplikace",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "DHIS2 {{dhis2Version}}",
|
|
4
|
+
"DHIS2 version unknown": "Verze DHIS2 neznámá",
|
|
5
|
+
"{{appName}} version unknown": "Neznámá verze aplikace {{appName}}",
|
|
6
|
+
"App {{appVersion}}": "Aplikace {{appVersion}}",
|
|
7
|
+
"App version unknown": "Verze aplikace neznámá",
|
|
8
|
+
"Debug info": "Informace o ladění",
|
|
9
|
+
"Close": "Zavřít",
|
|
10
|
+
"Copy debug info": "Zkopírovat informace o ladění",
|
|
11
|
+
"Interpretations": "Interpretace",
|
|
12
|
+
"Messages": "Zprávy",
|
|
13
|
+
"Online": "Online",
|
|
14
|
+
"Offline": "Offline",
|
|
15
|
+
"Edit profile": "Upravit profil",
|
|
16
|
+
"Settings": "Nastavení",
|
|
17
|
+
"Account": "Účet",
|
|
18
|
+
"Help": "Nápověda",
|
|
19
|
+
"About DHIS2": "O DHIS2",
|
|
20
|
+
"Logout": "Odhlásit",
|
|
21
|
+
"New {{appName}} version available": "K dispozici je nová verze aplikace {{appName}}",
|
|
22
|
+
"New app version available": "K dispozici nová verze aplikace",
|
|
23
|
+
"Click to reload": "Kliknutím znovu načtete"
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "Search apps",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "",
|
|
4
|
+
"DHIS2 version unknown": "",
|
|
5
|
+
"{{appName}} version unknown": "",
|
|
6
|
+
"App {{appVersion}}": "",
|
|
7
|
+
"App version unknown": "",
|
|
8
|
+
"Debug info": "",
|
|
9
|
+
"Close": "Close",
|
|
10
|
+
"Copy debug info": "",
|
|
11
|
+
"Interpretations": "Interpretations",
|
|
12
|
+
"Messages": "Messages",
|
|
13
|
+
"Online": "Online",
|
|
14
|
+
"Offline": "Offline",
|
|
15
|
+
"Edit profile": "",
|
|
16
|
+
"Settings": "Settings",
|
|
17
|
+
"Account": "Account",
|
|
18
|
+
"Help": "Help",
|
|
19
|
+
"About DHIS2": "",
|
|
20
|
+
"Logout": "",
|
|
21
|
+
"New {{appName}} version available": "",
|
|
22
|
+
"New app version available": "",
|
|
23
|
+
"Click to reload": ""
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "Search apps",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "DHIS2 {{dhis2Version}}",
|
|
4
|
+
"DHIS2 version unknown": "DHIS2 version unknown",
|
|
5
|
+
"{{appName}} version unknown": "{{appName}} version unknown",
|
|
6
|
+
"App {{appVersion}}": "App {{appVersion}}",
|
|
7
|
+
"App version unknown": "App version unknown",
|
|
8
|
+
"Debug info": "Debug info",
|
|
9
|
+
"Close": "Close",
|
|
10
|
+
"Copy debug info": "Copy debug info",
|
|
11
|
+
"Interpretations": "Interpretations",
|
|
12
|
+
"Messages": "Messages",
|
|
13
|
+
"Online": "Online",
|
|
14
|
+
"Offline": "Offline",
|
|
15
|
+
"Edit profile": "Edit profile",
|
|
16
|
+
"Settings": "Settings",
|
|
17
|
+
"Account": "Account",
|
|
18
|
+
"Help": "Help",
|
|
19
|
+
"About DHIS2": "About DHIS2",
|
|
20
|
+
"Logout": "Logout",
|
|
21
|
+
"New {{appName}} version available": "New {{appName}} version available",
|
|
22
|
+
"New app version available": "New app version available",
|
|
23
|
+
"Click to reload": "Click to reload",
|
|
24
|
+
"Profile menu": "Profile menu"
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "",
|
|
4
|
+
"DHIS2 version unknown": "",
|
|
5
|
+
"{{appName}} version unknown": "",
|
|
6
|
+
"App {{appVersion}}": "",
|
|
7
|
+
"App version unknown": "",
|
|
8
|
+
"Debug info": "",
|
|
9
|
+
"Close": "बंद करे",
|
|
10
|
+
"Copy debug info": "",
|
|
11
|
+
"Interpretations": "",
|
|
12
|
+
"Messages": "",
|
|
13
|
+
"Online": "",
|
|
14
|
+
"Offline": "",
|
|
15
|
+
"Edit profile": "",
|
|
16
|
+
"Settings": "",
|
|
17
|
+
"Account": "",
|
|
18
|
+
"Help": "",
|
|
19
|
+
"About DHIS2": "",
|
|
20
|
+
"Logout": "",
|
|
21
|
+
"New {{appName}} version available": "",
|
|
22
|
+
"New app version available": "",
|
|
23
|
+
"Click to reload": "",
|
|
24
|
+
"Profile menu": ""
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Search apps": "Buscar una aplicación",
|
|
3
|
+
"DHIS2 {{dhis2Version}}": "DHIS2 {{dhis2Version}}",
|
|
4
|
+
"DHIS2 version unknown": "Versión desconocida de DHIS2",
|
|
5
|
+
"{{appName}} version unknown": "{{appName}} versión desconocida",
|
|
6
|
+
"App {{appVersion}}": "App {{appVersion}}",
|
|
7
|
+
"App version unknown": "Versión desconocida de la aplicación",
|
|
8
|
+
"Debug info": "Información de depuración",
|
|
9
|
+
"Close": "Cerrar",
|
|
10
|
+
"Copy debug info": "Copiar la información de depuración",
|
|
11
|
+
"Interpretations": "Interpretaciones",
|
|
12
|
+
"Messages": "Mensajes",
|
|
13
|
+
"Online": "Conectado",
|
|
14
|
+
"Offline": "Desconectado",
|
|
15
|
+
"Edit profile": "Editar perfil",
|
|
16
|
+
"Settings": "Configuración",
|
|
17
|
+
"Account": "Cuenta",
|
|
18
|
+
"Help": "Ayuda",
|
|
19
|
+
"About DHIS2": "Sobre DHIS2",
|
|
20
|
+
"Logout": "Cerrar sesión",
|
|
21
|
+
"New {{appName}} version available": "Nueva versión de {{appName}} disponible",
|
|
22
|
+
"New app version available": "Nueva versión de la aplicación disponible",
|
|
23
|
+
"Click to reload": "Clic para recargar",
|
|
24
|
+
"Profile menu": ""
|
|
25
|
+
}
|