cozy-bar 15.0.1 → 15.2.0

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.
@@ -27,7 +27,8 @@ var ButtonCozyHome = function ButtonCozyHome(_ref) {
27
27
  onClick: function onClick() {
28
28
  webviewIntent.call('backToHome');
29
29
  },
30
- className: "coz-nav-apps-btns-home coz-nav-apps-btns-home--is-flagship"
30
+ className: "coz-nav-apps-btns-home coz-nav-apps-btns-home--is-flagship",
31
+ "data-testid": "buttonCozyHome"
31
32
  }, /*#__PURE__*/_react.default.createElement(_IconCozyHome.default, {
32
33
  className: "coz-nav-apps-btns-home-svg",
33
34
  isInvertedTheme: isInvertedTheme
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render, fireEvent } from '@testing-library/react'
3
3
  import { ButtonCozyHome } from './ButtonCozyHome'
4
4
  import { isFlagshipApp } from 'cozy-device-helper'
5
5
  import { useWebviewIntent } from 'cozy-intent'
@@ -9,51 +9,39 @@ jest.mock('cozy-intent', () => ({
9
9
  useWebviewIntent: jest.fn(() => ({ call: jest.fn() }))
10
10
  }))
11
11
 
12
- const homeHref = 'foo'
13
- const expectedCall = 'backToHome'
14
-
15
12
  describe('ButtonCozyHome', () => {
16
- it('should render a span with no props', () => {
17
- isFlagshipApp.mockImplementation(() => false)
18
- const render = shallow(<ButtonCozyHome />)
19
- const element = render.getElement()
13
+ it('renders a link with backToHome intent for flagship apps', () => {
14
+ isFlagshipApp.mockReturnValue(true)
20
15
 
21
- expect(element.type).toBe('span')
22
- })
16
+ const mockCall = jest.fn()
17
+ useWebviewIntent.mockImplementation(() => ({ call: mockCall }))
23
18
 
24
- it('should render an anchor with correct href when homeHref', () => {
25
- isFlagshipApp.mockImplementation(() => false)
26
- const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
27
- const element = render.getElement()
19
+ // We need to use a testid because
20
+ // - the a tag has no text to query it (just an icon)
21
+ // - an "a" tag without href is not seen as a link by queryByRole
22
+ const { getByTestId } = render(<ButtonCozyHome />)
23
+ const linkElement = getByTestId('buttonCozyHome')
28
24
 
29
- expect(element.type).toBe('a')
30
- expect(element.props.href).toBe(homeHref)
31
- })
25
+ fireEvent.click(linkElement)
32
26
 
33
- it('should render an anchor when isFlagshipApp', () => {
34
- isFlagshipApp.mockImplementation(() => true)
35
- const render = shallow(<ButtonCozyHome />)
36
- const element = render.getElement()
37
-
38
- expect(element.type).toBe('a')
27
+ expect(mockCall).toHaveBeenCalledWith('backToHome')
39
28
  })
40
29
 
41
- it('should give priority to anchor if both isFlagshipApp and homeHref are present', () => {
42
- isFlagshipApp.mockImplementation(() => true)
43
- const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
44
- const element = render.getElement()
30
+ it('renders a link with homeHref for non-flagship apps with homeHref', () => {
31
+ isFlagshipApp.mockReturnValue(false)
32
+
33
+ const { queryByRole } = render(<ButtonCozyHome homeHref="/home" />)
34
+ const linkElement = queryByRole('link')
45
35
 
46
- expect(element.type).toBe('a')
36
+ expect(linkElement).toHaveAttribute('href', '/home')
47
37
  })
48
38
 
49
- it('should call the correct context method on click', () => {
50
- isFlagshipApp.mockImplementation(() => true)
51
- const mockCall = jest.fn()
52
- useWebviewIntent.mockImplementation(() => ({ call: mockCall }))
53
- const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
39
+ it('renders a span without href for non-flagship apps without homeHref', () => {
40
+ isFlagshipApp.mockReturnValue(false)
54
41
 
55
- render.simulate('click')
42
+ const { queryByRole } = render(<ButtonCozyHome />)
43
+ const linkElement = queryByRole('link')
56
44
 
57
- expect(mockCall).toBeCalledWith(expectedCall)
45
+ expect(linkElement).toBeNull()
58
46
  })
59
47
  })
@@ -38,7 +38,8 @@ describe('Bar', () => {
38
38
  shouldDisplayOffers.mockReturnValue(false)
39
39
  useInstanceInfo.mockReturnValue({
40
40
  isLoaded: true,
41
- diskUsage: { data: { attributes: { used: 0 } } }
41
+ diskUsage: { data: { used: 0 } },
42
+ instance: { data: {} }
42
43
  })
43
44
  })
44
45
 
@@ -19,7 +19,8 @@ describe('bar', () => {
19
19
  jest.resetAllMocks()
20
20
  useInstanceInfo.mockReturnValue({
21
21
  isLoaded: true,
22
- diskUsage: { data: { attributes: { used: 0 } } }
22
+ diskUsage: { data: { used: 0 } },
23
+ instance: { data: {} }
23
24
  })
24
25
  })
25
26
 
@@ -25,6 +25,10 @@ var _ActionsItems = _interopRequireDefault(require("cozy-ui/transpiled/react/Act
25
25
 
26
26
  var _actions = require("./actions");
27
27
 
28
+ var _termsOfService = require("./actions/termsOfService");
29
+
30
+ var _legalNotice = require("./actions/legalNotice");
31
+
28
32
  var _useI18n2 = _interopRequireDefault(require("../useI18n"));
29
33
 
30
34
  var SettingsContent = function SettingsContent(_ref) {
@@ -37,7 +41,7 @@ var SettingsContent = function SettingsContent(_ref) {
37
41
  var _useI18n = (0, _useI18n2.default)(),
38
42
  t = _useI18n.t;
39
43
 
40
- var actions = (0, _Actions.makeActions)([_actions.profile, _actions.appearance, _actions.plans, _actions.storage, _actions.permissions, _Actions.divider, _actions.connectedDevices, _actions.connections, _Actions.divider, _actions.help, _actions.contact, _actions.logout], {
44
+ var actions = (0, _Actions.makeActions)([_actions.profile, _actions.appearance, _actions.plans, _actions.storage, _actions.permissions, _Actions.divider, _actions.connectedDevices, _actions.connections, _Actions.divider, _actions.help, _actions.contact, _legalNotice.legalNotice, _termsOfService.termsOfService, _actions.logout], {
41
45
  t: t,
42
46
  instanceInfo: instanceInfo,
43
47
  onLogOut: onLogOut
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.legalNotice = void 0;
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
+
16
+ var _react = _interopRequireWildcard(require("react"));
17
+
18
+ var _ActionsMenuItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem"));
19
+
20
+ var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
21
+
22
+ var _ListItemText = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemText"));
23
+
24
+ var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
25
+
26
+ var _Justice = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Justice"));
27
+
28
+ var _Openwith = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Openwith"));
29
+
30
+ var Component = (0, _react.forwardRef)(function (_ref, ref) {
31
+ var action = _ref.action,
32
+ props = (0, _objectWithoutProperties2.default)(_ref, ["action"]);
33
+ return /*#__PURE__*/_react.default.createElement(_ActionsMenuItem.default, (0, _extends2.default)({}, props, {
34
+ ref: ref
35
+ }), /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
36
+ icon: action.icon
37
+ })), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
38
+ primary: action.label
39
+ }), /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
40
+ icon: _Openwith.default
41
+ })));
42
+ });
43
+ Component.displayName = 'LegalNoticeAction';
44
+
45
+ var legalNotice = function legalNotice(_ref2) {
46
+ var t = _ref2.t,
47
+ instanceInfo = _ref2.instanceInfo;
48
+ var icon = _Justice.default;
49
+ var label = t('legalNotice');
50
+ return {
51
+ name: 'legalNotice',
52
+ icon: icon,
53
+ label: label,
54
+ displayCondition: function displayCondition() {
55
+ return !!instanceInfo.instance.data.legal_notice_url;
56
+ },
57
+ action: function action() {
58
+ window.open(instanceInfo.instance.data.legal_notice_url, '_blank', 'noopener, noreferrer');
59
+ },
60
+ Component: Component
61
+ };
62
+ };
63
+
64
+ exports.legalNotice = legalNotice;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.termsOfService = void 0;
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
+
16
+ var _react = _interopRequireWildcard(require("react"));
17
+
18
+ var _ActionsMenuItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem"));
19
+
20
+ var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
21
+
22
+ var _ListItemText = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemText"));
23
+
24
+ var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
25
+
26
+ var _Contract = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Contract"));
27
+
28
+ var _Openwith = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Openwith"));
29
+
30
+ var Component = (0, _react.forwardRef)(function (_ref, ref) {
31
+ var action = _ref.action,
32
+ props = (0, _objectWithoutProperties2.default)(_ref, ["action"]);
33
+ return /*#__PURE__*/_react.default.createElement(_ActionsMenuItem.default, (0, _extends2.default)({}, props, {
34
+ ref: ref
35
+ }), /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
36
+ icon: action.icon
37
+ })), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
38
+ primary: action.label
39
+ }), /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
40
+ icon: _Openwith.default
41
+ })));
42
+ });
43
+ Component.displayName = 'TermsOfServiceAction';
44
+
45
+ var termsOfService = function termsOfService(_ref2) {
46
+ var t = _ref2.t,
47
+ instanceInfo = _ref2.instanceInfo;
48
+ var icon = _Contract.default;
49
+ var label = t('termsOfService');
50
+ return {
51
+ name: 'termsOfService',
52
+ icon: icon,
53
+ label: label,
54
+ action: function action() {
55
+ window.open("https://files.cozycloud.cc/TOS".concat(instanceInfo.instance.data.tos ? "-".concat(instanceInfo.instance.data.tos) : '-201711', ".pdf"), '_blank', 'noopener, noreferrer');
56
+ },
57
+ Component: Component
58
+ };
59
+ };
60
+
61
+ exports.termsOfService = termsOfService;
package/dist/index.js CHANGED
@@ -72,5 +72,5 @@ var _BarProvider = _interopRequireDefault(require("./components/BarProvider"));
72
72
  var _reducers = require("./lib/reducers");
73
73
 
74
74
  /* global __VERSION__ */
75
- var version = "\"15.0.1\"";
75
+ var version = "\"15.2.0\"";
76
76
  exports.version = version;
@@ -17,6 +17,8 @@ var _stack = _interopRequireDefault(require("../stack"));
17
17
 
18
18
  var _lodash = _interopRequireDefault(require("lodash.unionwith"));
19
19
 
20
+ var _cozyFlags = _interopRequireDefault(require("cozy-flags"));
21
+
20
22
  // constants
21
23
  var DELETE_APP = 'DELETE_APP';
22
24
  var RECEIVE_APP = 'RECEIVE_APP';
@@ -107,7 +109,7 @@ exports.setInfos = setInfos;
107
109
  var fetchApps = function fetchApps() {
108
110
  return /*#__PURE__*/function () {
109
111
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(dispatch) {
110
- var rawAppList, apps;
112
+ var rawAppList, excludedApps, apps;
111
113
  return _regenerator.default.wrap(function _callee$(_context) {
112
114
  while (1) {
113
115
  switch (_context.prev = _context.next) {
@@ -121,29 +123,32 @@ var fetchApps = function fetchApps() {
121
123
 
122
124
  case 4:
123
125
  rawAppList = _context.sent;
124
- apps = rawAppList.map(mapApp);
126
+ excludedApps = (0, _cozyFlags.default)('apps.hidden') || [];
127
+ apps = rawAppList.map(mapApp).filter(function (app) {
128
+ return !excludedApps.includes(app);
129
+ });
125
130
 
126
131
  if (rawAppList.length) {
127
- _context.next = 8;
132
+ _context.next = 9;
128
133
  break;
129
134
  }
130
135
 
131
136
  throw new Error('No installed apps found by the bar');
132
137
 
133
- case 8:
134
- _context.next = 10;
138
+ case 9:
139
+ _context.next = 11;
135
140
  return dispatch(setDefaultApp(apps));
136
141
 
137
- case 10:
138
- _context.next = 12;
142
+ case 11:
143
+ _context.next = 13;
139
144
  return dispatch(receiveAppList(apps));
140
145
 
141
- case 12:
142
- _context.next = 18;
146
+ case 13:
147
+ _context.next = 19;
143
148
  break;
144
149
 
145
- case 14:
146
- _context.prev = 14;
150
+ case 15:
151
+ _context.prev = 15;
147
152
  _context.t0 = _context["catch"](0);
148
153
  dispatch({
149
154
  type: FETCH_APPS_FAILURE
@@ -151,12 +156,12 @@ var fetchApps = function fetchApps() {
151
156
 
152
157
  console.warn(_context.t0.message ? _context.t0.message : _context.t0);
153
158
 
154
- case 18:
159
+ case 19:
155
160
  case "end":
156
161
  return _context.stop();
157
162
  }
158
163
  }
159
- }, _callee, null, [[0, 14]]);
164
+ }, _callee, null, [[0, 15]]);
160
165
  }));
161
166
 
162
167
  return function (_x) {
@@ -12,6 +12,8 @@
12
12
  "contact": "Contact us",
13
13
  "logout": "Log out",
14
14
  "soon": "soon",
15
+ "termsOfService": "Terms of Service",
16
+ "legalNotice": "Legal notice",
15
17
  "error_UnavailableStack": "The stack is unreachable (connection timed-out).",
16
18
  "error_UnauthorizedStack": "Some permissions are missing, the application can't access the requested resource on the stack.",
17
19
  "no_apps": "No applications found on the Cozy.",
@@ -12,6 +12,8 @@
12
12
  "contact": "Nous contacter",
13
13
  "logout": "Déconnexion",
14
14
  "soon": "à venir",
15
+ "termsOfService": "Conditions générales d’utilisation",
16
+ "legalNotice": "Mentions légales",
15
17
  "error_UnavailableStack": "Connexion à la stack impossible (connection timed-out)",
16
18
  "error_UnauthorizedStack": "Des permissions sont manquante, l'application ne peut accéder aux ressources demandées.",
17
19
  "no_apps": "Pas d'applications Cozy trouvées.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-bar",
3
- "version": "15.0.1",
3
+ "version": "15.2.0",
4
4
  "description": "cozy-bar.js library, a small lib provided by cozy-stack to inject the Cozy-bar component into each app",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy Cloud <contact@cozycloud.cc> (https://cozy.io/)",
@@ -42,17 +42,14 @@
42
42
  "babel-plugin-module-resolver": "^4.0.0",
43
43
  "babel-plugin-transform-define": "^2.0.0",
44
44
  "babel-preset-cozy-app": "^1.9.0",
45
- "cozy-client": "^48.12.1",
45
+ "cozy-client": "^51.1.0",
46
46
  "cozy-device-helper": "2.6.0",
47
47
  "cozy-flags": "^2.10.2",
48
- "cozy-intent": "^1.7.0",
48
+ "cozy-intent": "^2.29.1",
49
49
  "cozy-interapp": "0.4.9",
50
50
  "cozy-logger": "1.9.1",
51
51
  "cozy-realtime": "^4.0.5",
52
52
  "cozy-ui": "^111.12.0",
53
- "enzyme": "3.10.0",
54
- "enzyme-adapter-react-16": "1.3",
55
- "enzyme-to-json": "3.3.5",
56
53
  "eslint-config-cozy-app": "2.0.0",
57
54
  "identity-obj-proxy": "3.0.0",
58
55
  "jest": "24.9.0",
@@ -76,10 +73,10 @@
76
73
  },
77
74
  "peerDependencies": {
78
75
  "@cozy/minilog": ">=1.0.0",
79
- "cozy-client": ">=48.12.1",
76
+ "cozy-client": ">=51.1.0",
80
77
  "cozy-device-helper": ">=2.6.0",
81
78
  "cozy-flags": ">=2.10.2",
82
- "cozy-intent": ">=1.3.0",
79
+ "cozy-intent": ">=2.29.1",
83
80
  "cozy-interapp": ">=0.4.9",
84
81
  "cozy-realtime": ">=4.0.5",
85
82
  "cozy-ui": ">=111.12.0",