cozy-bar 8.4.2 → 8.4.3

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 (103) hide show
  1. package/dist/cozy-bar.min.js +4 -4
  2. package/dist/cozy-bar.min.js.map +1 -1
  3. package/package.json +2 -2
  4. package/CHANGELOG.md +0 -493
  5. package/transpiled/assets/icons/16/icon-storage-16.svg +0 -3
  6. package/transpiled/assets/icons/24/icon-arrow-left.svg +0 -3
  7. package/transpiled/assets/icons/32/icon-claudy.svg +0 -1
  8. package/transpiled/assets/icons/apps/icon-collect.svg +0 -25
  9. package/transpiled/assets/icons/apps/icon-drive.svg +0 -17
  10. package/transpiled/assets/icons/apps/icon-market-soon.svg +0 -25
  11. package/transpiled/assets/icons/apps/icon-photos.svg +0 -19
  12. package/transpiled/assets/icons/apps/icon-soon.svg +0 -21
  13. package/transpiled/assets/icons/apps/icon-store.svg +0 -19
  14. package/transpiled/assets/icons/claudyActions/icon-bills.svg +0 -6
  15. package/transpiled/assets/icons/claudyActions/icon-laptop.svg +0 -7
  16. package/transpiled/assets/icons/claudyActions/icon-phone.svg +0 -8
  17. package/transpiled/assets/icons/claudyActions/icon-question-mark.svg +0 -6
  18. package/transpiled/assets/icons/comingsoon/icon-bank.svg +0 -12
  19. package/transpiled/assets/icons/comingsoon/icon-sante.svg +0 -12
  20. package/transpiled/assets/icons/comingsoon/icon-store.svg +0 -6
  21. package/transpiled/assets/icons/icon-cozy.svg +0 -3
  22. package/transpiled/assets/icons/icon-shield.svg +0 -3
  23. package/transpiled/assets/icons/spinner.svg +0 -4
  24. package/transpiled/assets/sprites/icon-apps.svg +0 -1
  25. package/transpiled/assets/sprites/icon-cozy-home.svg +0 -16
  26. package/transpiled/components/Apps/AppItem.js +0 -134
  27. package/transpiled/components/Apps/AppItemPlaceholder.js +0 -14
  28. package/transpiled/components/Apps/AppNavButtons.js +0 -108
  29. package/transpiled/components/Apps/AppsContent.js +0 -124
  30. package/transpiled/components/Apps/ButtonCozyHome.js +0 -25
  31. package/transpiled/components/Apps/ButtonCozyHome.spec.jsx +0 -53
  32. package/transpiled/components/Apps/IconCozyHome.js +0 -67
  33. package/transpiled/components/Apps/index.js +0 -102
  34. package/transpiled/components/Banner.js +0 -76
  35. package/transpiled/components/Bar.js +0 -329
  36. package/transpiled/components/Bar.spec.jsx +0 -133
  37. package/transpiled/components/Claudy.js +0 -123
  38. package/transpiled/components/ClaudyIcon.js +0 -16
  39. package/transpiled/components/Drawer.js +0 -367
  40. package/transpiled/components/Drawer.spec.jsx +0 -98
  41. package/transpiled/components/SearchBar.js +0 -407
  42. package/transpiled/components/Settings/SettingsContent.js +0 -128
  43. package/transpiled/components/Settings/StorageData.js +0 -24
  44. package/transpiled/components/Settings/helper.js +0 -9
  45. package/transpiled/components/Settings/index.js +0 -225
  46. package/transpiled/components/StorageIcon.js +0 -16
  47. package/transpiled/components/SupportModal.js +0 -86
  48. package/transpiled/components/__snapshots__/Bar.spec.jsx.snap +0 -302
  49. package/transpiled/config/claudyActions.json +0 -20
  50. package/transpiled/config/persistWhitelist.json +0 -4
  51. package/transpiled/cozy-bar.css +0 -5905
  52. package/transpiled/dom.js +0 -84
  53. package/transpiled/index.js +0 -246
  54. package/transpiled/index.spec.jsx +0 -34
  55. package/transpiled/lib/api/helpers.js +0 -12
  56. package/transpiled/lib/api/index.js +0 -175
  57. package/transpiled/lib/exceptions.js +0 -156
  58. package/transpiled/lib/expiringMemoize.js +0 -17
  59. package/transpiled/lib/icon.js +0 -154
  60. package/transpiled/lib/intents.js +0 -17
  61. package/transpiled/lib/logger.js +0 -10
  62. package/transpiled/lib/middlewares/appsI18n.js +0 -64
  63. package/transpiled/lib/realtime.js +0 -76
  64. package/transpiled/lib/reducers/apps.js +0 -291
  65. package/transpiled/lib/reducers/apps.spec.js +0 -59
  66. package/transpiled/lib/reducers/content.js +0 -68
  67. package/transpiled/lib/reducers/context.js +0 -138
  68. package/transpiled/lib/reducers/index.js +0 -59
  69. package/transpiled/lib/reducers/locale.js +0 -27
  70. package/transpiled/lib/reducers/settings.js +0 -253
  71. package/transpiled/lib/reducers/theme.js +0 -64
  72. package/transpiled/lib/reducers/unserializable.js +0 -31
  73. package/transpiled/lib/stack-client.js +0 -442
  74. package/transpiled/lib/stack.js +0 -122
  75. package/transpiled/lib/store/index.js +0 -42
  76. package/transpiled/locales/de.json +0 -57
  77. package/transpiled/locales/en.json +0 -57
  78. package/transpiled/locales/es.json +0 -57
  79. package/transpiled/locales/fr.json +0 -57
  80. package/transpiled/locales/it.json +0 -57
  81. package/transpiled/locales/ja.json +0 -57
  82. package/transpiled/locales/nl_NL.json +0 -57
  83. package/transpiled/locales/pl.json +0 -57
  84. package/transpiled/locales/ru.json +0 -57
  85. package/transpiled/locales/sq.json +0 -57
  86. package/transpiled/locales/zh_CN.json +0 -57
  87. package/transpiled/proptypes/index.js +0 -11
  88. package/transpiled/queries/index.js +0 -19
  89. package/transpiled/styles/apps.css +0 -248
  90. package/transpiled/styles/banner.css +0 -64
  91. package/transpiled/styles/bar.css +0 -106
  92. package/transpiled/styles/base.css +0 -21
  93. package/transpiled/styles/claudy.css +0 -98
  94. package/transpiled/styles/drawer.css +0 -126
  95. package/transpiled/styles/index.styl +0 -33
  96. package/transpiled/styles/indicators.css +0 -58
  97. package/transpiled/styles/nav.css +0 -81
  98. package/transpiled/styles/navigation_item.css +0 -34
  99. package/transpiled/styles/searchbar.css +0 -156
  100. package/transpiled/styles/settings.css +0 -34
  101. package/transpiled/styles/storage.css +0 -22
  102. package/transpiled/styles/supportModal.css +0 -20
  103. package/transpiled/styles/theme.styl +0 -25
@@ -1,123 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
- import React, { Component } from 'react';
14
- import { getIntents } from "../lib/stack";
15
-
16
- var Claudy = /*#__PURE__*/function (_Component) {
17
- _inherits(Claudy, _Component);
18
-
19
- var _super = _createSuper(Claudy);
20
-
21
- function Claudy(props, context) {
22
- var _this;
23
-
24
- _classCallCheck(this, Claudy);
25
-
26
- _this = _super.call(this, props);
27
-
28
- _defineProperty(_assertThisInitialized(_this), "toggle", function () {
29
- if (!_this.props.opened && !_this.intentWrapperRef.childNodes.length) {
30
- _this.setState({
31
- isLoading: true
32
- }); // init Claudy intent
33
-
34
-
35
- _this.intents.create('CLAUDY', 'io.cozy.settings', {
36
- exposeIntentFrameRemoval: true
37
- }).start(_this.intentWrapperRef, function () {
38
- _this.setState({
39
- isLoading: false,
40
- isActive: true
41
- });
42
-
43
- _this.props.onToggle(); // toggle claudy when the intent is loaded
44
-
45
- }).then(function (_ref) {
46
- var removeIntentIframe = _ref.removeIntentIframe;
47
-
48
- // exposeFrameRemoval intent event
49
- // remove the intent frame at the end of the menu closing transition
50
- var closedListener = function closedListener(e) {
51
- if (e.propertyName === 'transform') {
52
- removeIntentIframe();
53
-
54
- _this.setState({
55
- isActive: false
56
- });
57
-
58
- e.target.removeEventListener('transitionend', closedListener);
59
- }
60
- };
61
-
62
- _this.intentWrapperRef.addEventListener('transitionend', closedListener, false);
63
-
64
- _this.props.onToggle();
65
- });
66
- } else {
67
- _this.setState({
68
- isActive: !_this.state.isActive
69
- });
70
-
71
- _this.props.onToggle();
72
- }
73
- });
74
-
75
- _this.store = context.barStore;
76
- _this.state = {
77
- isLoading: false,
78
- isActive: false
79
- };
80
- _this.intents = getIntents();
81
- return _this;
82
- }
83
-
84
- _createClass(Claudy, [{
85
- key: "UNSAFE_componentWillReceiveProps",
86
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
87
- if (nextProps.claudyFired) this.toggle();
88
- }
89
- }, {
90
- key: "componentWillReceiveProps",
91
- value: function componentWillReceiveProps(nextProps) {
92
- return this.UNSAFE_componentWillReceiveProps(nextProps);
93
- }
94
- }, {
95
- key: "render",
96
- value: function render() {
97
- var _this2 = this;
98
-
99
- var opened = this.props.opened;
100
- var _this$state = this.state,
101
- isLoading = _this$state.isLoading,
102
- isActive = _this$state.isActive;
103
- return /*#__PURE__*/React.createElement("div", {
104
- className: "coz-claudy ".concat(opened ? 'coz-claudy--opened' : '')
105
- }, /*#__PURE__*/React.createElement("button", {
106
- type: "button",
107
- className: "coz-claudy-icon coz-bar-hide-sm",
108
- "data-claudy-opened": isActive,
109
- "data-claudy-loading": isLoading,
110
- onClick: this.toggle
111
- }), /*#__PURE__*/React.createElement("div", {
112
- className: "coz-claudy-intent-wrapper",
113
- ref: function ref(wrapper) {
114
- _this2.intentWrapperRef = wrapper;
115
- }
116
- }));
117
- }
118
- }]);
119
-
120
- return Claudy;
121
- }(Component);
122
-
123
- export default Claudy;
@@ -1,16 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
-
4
- function SvgIconClaudy(props) {
5
- return /*#__PURE__*/React.createElement("svg", _extends({
6
- viewBox: "0 0 32 32"
7
- }, props), /*#__PURE__*/React.createElement("path", {
8
- d: "M22 12h-7c-.6 0-1 .4-1 1s.4 1 1 1h7c.6 0 1-.4 1-1s-.4-1-1-1zm3-5H15c-.5 0-1 .4-1 1s.4 1 1 1h10c.5 0 1-.4 1-1s-.4-1-1-1z",
9
- fill: "none"
10
- }), /*#__PURE__*/React.createElement("path", {
11
- fill: "#FFF",
12
- d: "M31 1H9c-.6 0-1 .5-1 1v15c2.2 0 4.1 1.2 5.2 3H18v1.9c0 .6.4.7.8.4l3.3-2.3H31c.6 0 1-.5 1-1V2c0-.6-.4-1-1-1zm-9 13h-7c-.6 0-1-.4-1-1s.4-1 1-1h7c.6 0 1 .4 1 1s-.4 1-1 1zm3-5H15c-.6 0-1-.4-1-1s.5-1 1-1h10c.6 0 1 .4 1 1s-.5 1-1 1zM10.4 26.7c0 .1-.7 1.3-2.4 1.3-1.8 0-2.4-1.2-2.4-1.3-.1-.2 0-.5.2-.7.2-.1.5 0 .7.2 0 0 .4.7 1.6.7 1.1 0 1.5-.7 1.6-.7.1-.2.4-.3.7-.2.1.2.2.5 0 .7M12 23c0-2.2-1.8-4-4-4s-4 1.8-4 4c-2.2 0-4 1.8-4 4s1.8 4 4 4h8c2.2 0 4-1.8 4-4s-1.8-4-4-4"
13
- }));
14
- }
15
-
16
- export default SvgIconClaudy;
@@ -1,367 +0,0 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
-
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
-
13
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14
-
15
- import React, { Component } from 'react';
16
- import { connect } from 'react-redux';
17
- import Hammer from 'hammerjs';
18
- import AppsContent from "./Apps/AppsContent";
19
- import SettingsContent from "./Settings/SettingsContent";
20
- import { fetchSettingsData as _fetchSettingsData, getSettingsAppURL, getStorageData, logOut as _logOut } from "../lib/reducers";
21
-
22
- var Drawer = /*#__PURE__*/function (_Component) {
23
- _inherits(Drawer, _Component);
24
-
25
- var _super = _createSuper(Drawer);
26
-
27
- function Drawer(props) {
28
- var _this;
29
-
30
- _classCallCheck(this, Drawer);
31
-
32
- _this = _super.call(this, props);
33
-
34
- _defineProperty(_assertThisInitialized(_this), "onDrawerClick", function (event) {
35
- if (event.target === _this.wrapperRef) {
36
- _this.close();
37
- }
38
- });
39
-
40
- _defineProperty(_assertThisInitialized(_this), "onTransitionEnd", function () {
41
- if (_this.props.visible) {
42
- if (!_this.gesturesHandler) _this.attachGestures();
43
-
44
- _this.preventBackgroundScrolling();
45
- } else {
46
- _this.restoreBackgroundScrolling();
47
-
48
- _this.setState({
49
- isClosing: false
50
- });
51
- }
52
-
53
- _this.props.drawerListener();
54
- });
55
-
56
- _defineProperty(_assertThisInitialized(_this), "componentWillReceiveProps", /*#__PURE__*/function () {
57
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(nextProps) {
58
- return _regeneratorRuntime.wrap(function _callee$(_context) {
59
- while (1) {
60
- switch (_context.prev = _context.next) {
61
- case 0:
62
- _context.next = 2;
63
- return _this.UNSAFE_componentWillReceiveProps(nextProps);
64
-
65
- case 2:
66
- case "end":
67
- return _context.stop();
68
- }
69
- }
70
- }, _callee);
71
- }));
72
-
73
- return function (_x) {
74
- return _ref.apply(this, arguments);
75
- };
76
- }());
77
-
78
- _defineProperty(_assertThisInitialized(_this), "UNSAFE_componentWillReceiveProps", /*#__PURE__*/function () {
79
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(nextProps) {
80
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
81
- while (1) {
82
- switch (_context2.prev = _context2.next) {
83
- case 0:
84
- if (!(!_this.props.visible && nextProps.visible)) {
85
- _context2.next = 3;
86
- break;
87
- }
88
-
89
- _context2.next = 3;
90
- return _this.props.fetchSettingsData();
91
-
92
- case 3:
93
- case "end":
94
- return _context2.stop();
95
- }
96
- }
97
- }, _callee2);
98
- }));
99
-
100
- return function (_x2) {
101
- return _ref2.apply(this, arguments);
102
- };
103
- }());
104
-
105
- _defineProperty(_assertThisInitialized(_this), "close", function () {
106
- if (_this.state.isClosing) return;
107
-
108
- _this.detachGestures();
109
-
110
- _this.setState(function () {
111
- return {
112
- isClosing: true
113
- };
114
- });
115
-
116
- _this.turnTransitionsOn();
117
-
118
- _this.props.onClose();
119
-
120
- _this.asideRef.style.transform = '';
121
- });
122
-
123
- _this.state = {
124
- isScrolling: false,
125
- isClosing: false
126
- };
127
- _this.handleLogout = _this.handleLogout.bind(_assertThisInitialized(_this));
128
- return _this;
129
- }
130
-
131
- _createClass(Drawer, [{
132
- key: "componentDidMount",
133
- value: function () {
134
- var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
135
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
136
- while (1) {
137
- switch (_context3.prev = _context3.next) {
138
- case 0:
139
- this.turnTransitionsOn();
140
-
141
- case 1:
142
- case "end":
143
- return _context3.stop();
144
- }
145
- }
146
- }, _callee3, this);
147
- }));
148
-
149
- function componentDidMount() {
150
- return _componentDidMount.apply(this, arguments);
151
- }
152
-
153
- return componentDidMount;
154
- }()
155
- }, {
156
- key: "turnTransitionsOn",
157
- value: function turnTransitionsOn() {
158
- this.asideRef.classList.add('with-transition');
159
- this.asideRef.addEventListener('transitionend', this.onTransitionEnd);
160
- }
161
- }, {
162
- key: "turnTransitionsOff",
163
- value: function turnTransitionsOff() {
164
- this.asideRef.classList.remove('with-transition');
165
- this.asideRef.removeEventListener('transitionend', this.onTransitionEnd);
166
- }
167
- }, {
168
- key: "preventBackgroundScrolling",
169
- value: function preventBackgroundScrolling() {
170
- document.body.style.overflow = 'hidden';
171
- }
172
- }, {
173
- key: "restoreBackgroundScrolling",
174
- value: function restoreBackgroundScrolling() {
175
- document.body.style.overflow = 'auto';
176
- }
177
- }, {
178
- key: "detachGestures",
179
- value: function detachGestures() {
180
- this.gesturesHandler.destroy();
181
- this.gesturesHandler = null;
182
- }
183
- }, {
184
- key: "attachGestures",
185
- value: function attachGestures() {
186
- var _this2 = this;
187
-
188
- // IMPORTANT: on Chrome, the `overflow-y: scroll` property on .coz-drawer--apps prevented
189
- // swipe events to be dispatched correctly ; the `touch-action: pan-y` fixes the problem
190
- // see drawer.css
191
- this.gesturesHandler = new Hammer.Manager(document.documentElement, {
192
- // we listen in all directions so that we can catch panup/pandown events and let the user scroll
193
- recognizers: [[Hammer.Pan, {
194
- direction: Hammer.DIRECTION_ALL
195
- }]]
196
- }); // to be completely accurate, `maximumGestureDelta` should be the difference between the right of the aside and the
197
- // left of the page; but using the width is much easier to compute and accurate enough.
198
-
199
- var maximumGestureDistance = this.asideRef.getBoundingClientRect().width; // between 0 and 1, how far down the gesture must be to be considered complete upon release
200
-
201
- var minimumCloseDistance = 0.4; // a gesture faster than this will dismiss the menu, regardless of distance traveled
202
-
203
- var minimumCloseVelocity = 0.2;
204
- var currentGestureProgress = null;
205
- this.gesturesHandler.on('panstart', function (event) {
206
- if (_this2.state.isClosing) return;
207
-
208
- if (event.additionalEvent === 'panup' || event.additionalEvent === 'pandown') {
209
- _this2.setState({
210
- isScrolling: true
211
- });
212
- } else {
213
- _this2.turnTransitionsOff();
214
-
215
- currentGestureProgress = 0;
216
- }
217
- });
218
- this.gesturesHandler.on('pan', function (e) {
219
- if (_this2.state.isClosing || _this2.state.isScrolling) return;
220
- currentGestureProgress = -e.deltaX / maximumGestureDistance;
221
-
222
- _this2.applyTransformation(currentGestureProgress);
223
- });
224
- this.gesturesHandler.on('panend', function (e) {
225
- if (_this2.state.isClosing) return;
226
-
227
- if (_this2.state.isScrolling) {
228
- _this2.setState({
229
- isScrolling: false
230
- });
231
-
232
- return;
233
- } // Dismiss the menu if the swipe pan was bigger than the treshold,
234
- // or if it was a fast, leftward gesture
235
-
236
-
237
- var haveTravelledFarEnough = -e.deltaX / maximumGestureDistance >= minimumCloseDistance;
238
- var haveTravelledFastEnough = e.velocity < 0 && Math.abs(e.velocity) >= minimumCloseVelocity;
239
- var shouldDismiss = haveTravelledFarEnough || haveTravelledFastEnough;
240
-
241
- if (shouldDismiss) {
242
- _this2.close();
243
- } else {
244
- _this2.turnTransitionsOn();
245
-
246
- _this2.applyTransformation(0);
247
- }
248
- });
249
- }
250
- }, {
251
- key: "applyTransformation",
252
- value: function applyTransformation(progress) {
253
- // constrain between 0 and 1.1 (go a bit further than 1 to be hidden completely)
254
- progress = Math.min(1.1, Math.max(0, progress));
255
- this.asideRef.style.transform = 'translateX(-' + progress * 100 + '%)';
256
- }
257
- }, {
258
- key: "handleLogout",
259
- value: function () {
260
- var _handleLogout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
261
- var _this$props, onLogOut, logOut, res;
262
-
263
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
264
- while (1) {
265
- switch (_context4.prev = _context4.next) {
266
- case 0:
267
- _this$props = this.props, onLogOut = _this$props.onLogOut, logOut = _this$props.logOut;
268
-
269
- if (!(onLogOut && typeof onLogOut === 'function')) {
270
- _context4.next = 6;
271
- break;
272
- }
273
-
274
- res = onLogOut();
275
-
276
- if (!(res instanceof Promise)) {
277
- _context4.next = 6;
278
- break;
279
- }
280
-
281
- _context4.next = 6;
282
- return res;
283
-
284
- case 6:
285
- logOut();
286
-
287
- case 7:
288
- case "end":
289
- return _context4.stop();
290
- }
291
- }
292
- }, _callee4, this);
293
- }));
294
-
295
- function handleLogout() {
296
- return _handleLogout.apply(this, arguments);
297
- }
298
-
299
- return handleLogout;
300
- }()
301
- }, {
302
- key: "render",
303
- value: function render() {
304
- var _this3 = this;
305
-
306
- var _this$props2 = this.props,
307
- onClaudy = _this$props2.onClaudy,
308
- visible = _this$props2.visible,
309
- isClaudyLoading = _this$props2.isClaudyLoading,
310
- toggleSupport = _this$props2.toggleSupport,
311
- settingsAppURL = _this$props2.settingsAppURL,
312
- storageData = _this$props2.storageData;
313
- return /*#__PURE__*/React.createElement("div", {
314
- className: "coz-drawer-wrapper",
315
- onClick: this.onDrawerClick,
316
- "aria-hidden": visible ? 'false' : 'true',
317
- ref: function ref(node) {
318
- _this3.wrapperRef = node;
319
- }
320
- }, /*#__PURE__*/React.createElement("aside", {
321
- ref: function ref(node) {
322
- _this3.asideRef = node;
323
- }
324
- }, /*#__PURE__*/React.createElement("nav", {
325
- className: "coz-drawer--apps"
326
- }, /*#__PURE__*/React.createElement(AppsContent, {
327
- onAppSwitch: this.close
328
- })), /*#__PURE__*/React.createElement("hr", {
329
- className: "coz-sep-flex"
330
- }), /*#__PURE__*/React.createElement("nav", {
331
- className: "coz-drawer--settings"
332
- }, /*#__PURE__*/React.createElement(SettingsContent, {
333
- onLogOut: this.handleLogout,
334
- storageData: storageData,
335
- settingsAppURL: settingsAppURL,
336
- isClaudyLoading: isClaudyLoading,
337
- onClaudy: onClaudy,
338
- toggleSupport: toggleSupport,
339
- isDrawer: true
340
- }))));
341
- }
342
- }]);
343
-
344
- return Drawer;
345
- }(Component);
346
-
347
- export { Drawer };
348
-
349
- var mapStateToProps = function mapStateToProps(state) {
350
- return {
351
- storageData: getStorageData(state),
352
- settingsAppURL: getSettingsAppURL(state)
353
- };
354
- };
355
-
356
- var mapDispatchToProps = function mapDispatchToProps(dispatch) {
357
- return {
358
- fetchSettingsData: function fetchSettingsData() {
359
- return dispatch(_fetchSettingsData());
360
- },
361
- logOut: function logOut() {
362
- return dispatch(_logOut());
363
- }
364
- };
365
- };
366
-
367
- export default connect(mapStateToProps, mapDispatchToProps)(Drawer);
@@ -1,98 +0,0 @@
1
- import React from 'react'
2
- import { Provider } from 'react-redux'
3
-
4
- import I18n from 'cozy-ui/react/I18n'
5
- import { createStore } from 'lib/store'
6
- import enLocale from 'locales/en.json'
7
- import { render, screen, fireEvent, act } from '@testing-library/react'
8
- import { Drawer } from './Drawer'
9
-
10
- const sleep = duration => new Promise(resolve => setTimeout(resolve, duration))
11
-
12
- const fakeStore = createStore()
13
-
14
- const Wrapper = ({ children }) => {
15
- return (
16
- <Provider store={fakeStore}>
17
- <I18n dictRequire={() => enLocale} lang="en">
18
- {children}
19
- </I18n>
20
- </Provider>
21
- )
22
- }
23
-
24
- describe('bar', () => {
25
- describe('logout', () => {
26
- const findLogoutButton = () => {
27
- return screen.getByText('Sign out')
28
- }
29
- const setup = ({ onLogOut, logOut }) => {
30
- render(
31
- <Wrapper>
32
- <Drawer
33
- toggleSupport={jest.fn()}
34
- logOut={logOut}
35
- onLogOut={onLogOut}
36
- />
37
- </Wrapper>
38
- )
39
- }
40
-
41
- const clickLogout = () => {
42
- const logoutButton = findLogoutButton()
43
- fireEvent(
44
- logoutButton,
45
- new MouseEvent('click', {
46
- bubbles: true,
47
- cancelable: true
48
- })
49
- )
50
- }
51
-
52
- it('should await the onLogOut', async () => {
53
- let prom
54
- const callOrder = []
55
- const logOut = jest.fn().mockImplementation(() => {
56
- callOrder.push('logOut')
57
- })
58
- const onLogOut = jest.fn().mockImplementation(async () => {
59
- prom = sleep(100)
60
- callOrder.push('onLogOut')
61
- await prom
62
- })
63
-
64
- setup({ logOut, onLogOut })
65
-
66
- act(() => {
67
- clickLogout()
68
- })
69
-
70
- expect(logOut).not.toHaveBeenCalled()
71
- await prom
72
- await sleep(0)
73
- expect(logOut).toHaveBeenCalled()
74
- expect(onLogOut).toHaveBeenCalled()
75
- expect(callOrder).toEqual(['onLogOut', 'logOut'])
76
- })
77
-
78
- it('should work if onLogOut has not been passed', () => {
79
- const logOut = jest.fn()
80
- setup({ logOut })
81
- act(() => {
82
- clickLogout()
83
- })
84
- expect(logOut).toHaveBeenCalled()
85
- })
86
-
87
- it('should work if onLogOut does not return a promise', () => {
88
- const logOut = jest.fn()
89
- const onLogOut = jest.fn()
90
- setup({ logOut, onLogOut })
91
- act(() => {
92
- clickLogout()
93
- })
94
- expect(logOut).toHaveBeenCalled()
95
- expect(onLogOut).toHaveBeenCalled()
96
- })
97
- })
98
- })