@dhis2-ui/header-bar 8.4.17 → 8.5.0-beta.2

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.
Files changed (53) hide show
  1. package/build/cjs/__e2e__/header-bar.stories.e2e.js +40 -0
  2. package/build/cjs/__e2e__/stories/common.js +99 -32
  3. package/build/cjs/__e2e__/stories/with-debug-info-edge-cases.js +45 -0
  4. package/build/cjs/__e2e__/stories/with-update-available-notification.js +38 -0
  5. package/build/cjs/apps.js +1 -1
  6. package/build/cjs/debug-info/debug-info-menu-item.js +67 -0
  7. package/build/cjs/debug-info/debug-info-modal.js +59 -0
  8. package/build/cjs/debug-info/debug-info-table.js +47 -0
  9. package/build/cjs/debug-info/use-debug-info.js +28 -0
  10. package/build/cjs/features/the_headerbar_should_display_app_update_notification/index.js +34 -0
  11. package/build/cjs/features/the_headerbar_should_display_app_update_notification.feature +22 -0
  12. package/build/cjs/features/the_headerbar_should_display_debug_version_infos/index.js +69 -0
  13. package/build/cjs/features/the_headerbar_should_display_debug_version_infos.feature +52 -0
  14. package/build/cjs/header-bar-context.js +46 -0
  15. package/build/cjs/header-bar.js +22 -11
  16. package/build/cjs/header-bar.stories.js +70 -72
  17. package/build/cjs/locales/en/translations.json +12 -1
  18. package/build/cjs/profile/use-on-doc-click.js +30 -0
  19. package/build/cjs/profile/use-on-doc-click.test.js +42 -0
  20. package/build/cjs/profile-menu/index.js +18 -0
  21. package/build/cjs/{profile → profile-menu}/profile-header.js +0 -0
  22. package/build/cjs/{profile → profile-menu}/profile-menu.js +23 -15
  23. package/build/cjs/profile-menu/update-notification.js +70 -0
  24. package/build/cjs/profile.js +52 -62
  25. package/build/es/__e2e__/header-bar.stories.e2e.js +5 -3
  26. package/build/es/__e2e__/stories/common.js +96 -33
  27. package/build/es/__e2e__/stories/with-debug-info-edge-cases.js +22 -0
  28. package/build/es/__e2e__/stories/with-update-available-notification.js +19 -0
  29. package/build/es/apps.js +1 -1
  30. package/build/es/debug-info/debug-info-menu-item.js +48 -0
  31. package/build/es/debug-info/debug-info-modal.js +41 -0
  32. package/build/es/debug-info/debug-info-table.js +35 -0
  33. package/build/es/debug-info/use-debug-info.js +15 -0
  34. package/build/es/features/the_headerbar_should_display_app_update_notification/index.js +31 -0
  35. package/build/es/features/the_headerbar_should_display_app_update_notification.feature +22 -0
  36. package/build/es/features/the_headerbar_should_display_debug_version_infos/index.js +66 -0
  37. package/build/es/features/the_headerbar_should_display_debug_version_infos.feature +52 -0
  38. package/build/es/header-bar-context.js +25 -0
  39. package/build/es/header-bar.js +21 -11
  40. package/build/es/header-bar.stories.js +65 -71
  41. package/build/es/locales/en/translations.json +12 -1
  42. package/build/es/profile/use-on-doc-click.js +20 -0
  43. package/build/es/profile/use-on-doc-click.test.js +38 -0
  44. package/build/es/profile-menu/index.js +1 -0
  45. package/build/es/{profile → profile-menu}/profile-header.js +0 -0
  46. package/build/es/{profile → profile-menu}/profile-menu.js +23 -17
  47. package/build/es/profile-menu/update-notification.js +51 -0
  48. package/build/es/profile.js +49 -64
  49. package/package.json +15 -13
  50. package/build/cjs/features/the_headerbar_displays_instance_and_app_infos/index.js +0 -15
  51. package/build/cjs/features/the_headerbar_displays_instance_and_app_infos.feature +0 -29
  52. package/build/es/features/the_headerbar_displays_instance_and_app_infos/index.js +0 -12
  53. package/build/es/features/the_headerbar_displays_instance_and_app_infos.feature +0 -29
@@ -1,73 +1,58 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
5
2
  import { UserAvatar } from '@dhis2-ui/user-avatar';
6
3
  import PropTypes from 'prop-types';
7
- import React from 'react';
8
- import { ProfileMenu } from './profile/profile-menu.js';
9
- export default class Profile extends React.Component {
10
- constructor() {
11
- super(...arguments);
12
-
13
- _defineProperty(this, "state", {
14
- show: false
15
- });
16
-
17
- _defineProperty(this, "onDocClick", evt => {
18
- if (this.elContainer && !this.elContainer.contains(evt.target)) {
19
- this.setState({
20
- show: false
21
- });
22
- }
23
- });
24
-
25
- _defineProperty(this, "handleToggle", () => this.setState({
26
- show: !this.state.show
27
- }));
28
- }
29
-
30
- componentDidMount() {
31
- document.addEventListener('click', this.onDocClick);
32
- }
33
-
34
- componentWillUnmount() {
35
- document.removeEventListener('click', this.onDocClick);
36
- }
37
-
38
- render() {
39
- const {
40
- name,
41
- email,
42
- avatarId,
43
- helpUrl
44
- } = this.props;
45
- return /*#__PURE__*/React.createElement("div", {
46
- ref: c => this.elContainer = c,
47
- "data-test": "headerbar-profile",
48
- className: "jsx-2642719072" + " " + "headerbar-profile"
49
- }, /*#__PURE__*/React.createElement("button", {
50
- onClick: this.handleToggle,
51
- className: "jsx-2642719072" + " " + "headerbar-profile-btn"
52
- }, /*#__PURE__*/React.createElement(UserAvatar, {
53
- avatarId: avatarId,
54
- name: name,
55
- dataTest: "headerbar-profile-icon",
56
- medium: true
57
- })), this.state.show ? /*#__PURE__*/React.createElement(ProfileMenu, {
58
- avatarId: avatarId,
59
- name: name,
60
- email: email,
61
- helpUrl: helpUrl
62
- }) : null, /*#__PURE__*/React.createElement(_JSXStyle, {
63
- id: "2642719072"
64
- }, [".headerbar-profile.jsx-2642719072{position:relative;width:36px;height:36px;min-width:36px;min-height:36px;margin:2px 12px 0 24px;}", ".headerbar-profile-btn.jsx-2642719072{background:transparent;padding:0;border:0;cursor:pointer;width:100%;height:100%;}", ".headerbar-profile-btn.jsx-2642719072:focus{outline:1px dotted white;}"]));
65
- }
4
+ import React, { useCallback, useRef, useState } from 'react';
5
+ import { DebugInfoModal } from './debug-info/debug-info-modal.js';
6
+ import { ProfileMenu } from './profile-menu/index.js';
7
+ import { useOnDocClick } from './profile/use-on-doc-click.js';
8
+
9
+ const Profile = _ref => {
10
+ let {
11
+ name,
12
+ email,
13
+ avatarId,
14
+ helpUrl
15
+ } = _ref;
16
+ const [showProfileMenu, setShowProfileMenu] = useState(false);
17
+ const [showDebugInfoModal, setShowDebugInfoModal] = useState(false);
18
+ const hideProfileMenu = useCallback(() => setShowProfileMenu(false), [setShowProfileMenu]);
19
+ const toggleProfileMenu = useCallback(() => setShowProfileMenu(show => !show), [setShowProfileMenu]);
20
+ const containerRef = useRef(null);
21
+ useOnDocClick(containerRef, hideProfileMenu);
22
+ return /*#__PURE__*/React.createElement("div", {
23
+ ref: containerRef,
24
+ "data-test": "headerbar-profile",
25
+ className: "jsx-2213392235" + " " + "headerbar-profile"
26
+ }, /*#__PURE__*/React.createElement("button", {
27
+ onClick: toggleProfileMenu,
28
+ className: "jsx-2213392235" + " " + "headerbar-profile-btn"
29
+ }, /*#__PURE__*/React.createElement(UserAvatar, {
30
+ avatarId: avatarId,
31
+ name: name,
32
+ dataTest: "headerbar-profile-icon",
33
+ medium: true
34
+ })), showProfileMenu && /*#__PURE__*/React.createElement(ProfileMenu, {
35
+ avatarId: avatarId,
36
+ name: name,
37
+ email: email,
38
+ helpUrl: helpUrl,
39
+ hideProfileMenu: hideProfileMenu,
40
+ showDebugInfoModal: () => {
41
+ setShowDebugInfoModal(true);
42
+ }
43
+ }), showDebugInfoModal && /*#__PURE__*/React.createElement(DebugInfoModal, {
44
+ onClose: () => {
45
+ setShowDebugInfoModal(false);
46
+ }
47
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
48
+ id: "2213392235"
49
+ }, [".headerbar-profile.jsx-2213392235{position:relative;width:36px;height:36px;min-width:36px;min-height:36px;margin:2px 12px 0 24px;}", ".headerbar-profile-btn.jsx-2213392235{background:transparent;padding:0;border:0;cursor:pointer;width:100%;height:100%;}", ".headerbar-profile-btn.jsx-2213392235:focus{outline:1px dotted white;}"]));
50
+ };
66
51
 
67
- }
68
52
  Profile.propTypes = {
69
53
  name: PropTypes.string.isRequired,
70
54
  avatarId: PropTypes.string,
71
55
  email: PropTypes.string,
72
56
  helpUrl: PropTypes.string
73
- };
57
+ };
58
+ export default Profile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/header-bar",
3
- "version": "8.4.17",
3
+ "version": "8.5.0-beta.2",
4
4
  "description": "UI HeaderBar",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,19 +33,21 @@
33
33
  "styled-jsx": "^4"
34
34
  },
35
35
  "dependencies": {
36
+ "@dhis2-ui/box": "8.5.0-beta.2",
37
+ "@dhis2-ui/button": "8.5.0-beta.2",
38
+ "@dhis2-ui/card": "8.5.0-beta.2",
39
+ "@dhis2-ui/center": "8.5.0-beta.2",
40
+ "@dhis2-ui/divider": "8.5.0-beta.2",
41
+ "@dhis2-ui/input": "8.5.0-beta.2",
42
+ "@dhis2-ui/layer": "8.5.0-beta.2",
43
+ "@dhis2-ui/loader": "8.5.0-beta.2",
44
+ "@dhis2-ui/logo": "8.5.0-beta.2",
45
+ "@dhis2-ui/menu": "8.5.0-beta.2",
46
+ "@dhis2-ui/modal": "8.5.0-beta.2",
47
+ "@dhis2-ui/user-avatar": "8.5.0-beta.2",
36
48
  "@dhis2/prop-types": "^3.1.2",
37
- "@dhis2-ui/box": "8.4.17",
38
- "@dhis2-ui/card": "8.4.17",
39
- "@dhis2-ui/center": "8.4.17",
40
- "@dhis2-ui/divider": "8.4.17",
41
- "@dhis2-ui/input": "8.4.17",
42
- "@dhis2-ui/layer": "8.4.17",
43
- "@dhis2-ui/loader": "8.4.17",
44
- "@dhis2-ui/logo": "8.4.17",
45
- "@dhis2-ui/menu": "8.4.17",
46
- "@dhis2-ui/user-avatar": "8.4.17",
47
- "@dhis2/ui-constants": "8.4.17",
48
- "@dhis2/ui-icons": "8.4.17",
49
+ "@dhis2/ui-constants": "8.5.0-beta.2",
50
+ "@dhis2/ui-icons": "8.5.0-beta.2",
49
51
  "classnames": "^2.3.1",
50
52
  "moment": "^2.29.1",
51
53
  "prop-types": "^15.7.2"
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- var _steps = require("cypress-cucumber-preprocessor/steps");
4
-
5
- (0, _steps.Given)('the HeaderBar has been supplied with an app name and version', () => {});
6
- (0, _steps.Given)('the HeaderBar has not been supplied with an app version', () => {});
7
- (0, _steps.Given)("the HeaderBar's profile menu is visible", () => {});
8
- (0, _steps.Given)('the profile menu failed loading the instance infos', () => {});
9
- (0, _steps.Given)('the profile menu has successfully loaded the instance infos', () => {});
10
- (0, _steps.Given)('the profile menu is loading the instance infos', () => {});
11
- (0, _steps.Then)('a message stating that loading the instance infos has failed should be displayed', () => {});
12
- (0, _steps.Then)('a message stating that the instance infos are being loaded should be displayed', () => {});
13
- (0, _steps.Then)('the app infos should be displayed', () => {});
14
- (0, _steps.Then)('the app infos should not be displayed', () => {});
15
- (0, _steps.Then)('the instance infos should be displayed', () => {});
@@ -1,29 +0,0 @@
1
- Feature: The HeaderBar displays instance and app infos
2
-
3
- Scenario: The HeaderBar displays both instance and app infos
4
- Given the HeaderBar has been supplied with an app name and version
5
- And the HeaderBar's profile menu is visible
6
- And the profile menu has successfully loaded the instance infos
7
- Then the instance infos should be displayed
8
- And the app infos should be displayed
9
-
10
- Scenario: The HeaderBar displays app infos and an instance infos loading message
11
- Given the HeaderBar has been supplied with an app name and version
12
- And the HeaderBar's profile menu is visible
13
- And the profile menu is loading the instance infos
14
- Then the app infos should be displayed
15
- And a message stating that the instance infos are being loaded should be displayed
16
-
17
- Scenario: The HeaderBar displays app infos and an instance infos error message
18
- Given the HeaderBar has been supplied with an app name and version
19
- And the HeaderBar's profile menu is visible
20
- And the profile menu failed loading the instance infos
21
- Then the app infos should be displayed
22
- And a message stating that loading the instance infos has failed should be displayed
23
-
24
- Scenario: The HeaderBar displays only instance infos
25
- Given the HeaderBar has not been supplied with an app version
26
- And the HeaderBar's profile menu is visible
27
- And the profile menu has successfully loaded the instance infos
28
- Then the instance infos should be displayed
29
- And the app infos should not be displayed
@@ -1,12 +0,0 @@
1
- import { Given, Then } from 'cypress-cucumber-preprocessor/steps';
2
- Given('the HeaderBar has been supplied with an app name and version', () => {});
3
- Given('the HeaderBar has not been supplied with an app version', () => {});
4
- Given("the HeaderBar's profile menu is visible", () => {});
5
- Given('the profile menu failed loading the instance infos', () => {});
6
- Given('the profile menu has successfully loaded the instance infos', () => {});
7
- Given('the profile menu is loading the instance infos', () => {});
8
- Then('a message stating that loading the instance infos has failed should be displayed', () => {});
9
- Then('a message stating that the instance infos are being loaded should be displayed', () => {});
10
- Then('the app infos should be displayed', () => {});
11
- Then('the app infos should not be displayed', () => {});
12
- Then('the instance infos should be displayed', () => {});
@@ -1,29 +0,0 @@
1
- Feature: The HeaderBar displays instance and app infos
2
-
3
- Scenario: The HeaderBar displays both instance and app infos
4
- Given the HeaderBar has been supplied with an app name and version
5
- And the HeaderBar's profile menu is visible
6
- And the profile menu has successfully loaded the instance infos
7
- Then the instance infos should be displayed
8
- And the app infos should be displayed
9
-
10
- Scenario: The HeaderBar displays app infos and an instance infos loading message
11
- Given the HeaderBar has been supplied with an app name and version
12
- And the HeaderBar's profile menu is visible
13
- And the profile menu is loading the instance infos
14
- Then the app infos should be displayed
15
- And a message stating that the instance infos are being loaded should be displayed
16
-
17
- Scenario: The HeaderBar displays app infos and an instance infos error message
18
- Given the HeaderBar has been supplied with an app name and version
19
- And the HeaderBar's profile menu is visible
20
- And the profile menu failed loading the instance infos
21
- Then the app infos should be displayed
22
- And a message stating that loading the instance infos has failed should be displayed
23
-
24
- Scenario: The HeaderBar displays only instance infos
25
- Given the HeaderBar has not been supplied with an app version
26
- And the HeaderBar's profile menu is visible
27
- And the profile menu has successfully loaded the instance infos
28
- Then the instance infos should be displayed
29
- And the app infos should not be displayed