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.
- package/dist/cozy-bar.min.js +4 -4
- package/dist/cozy-bar.min.js.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -493
- package/transpiled/assets/icons/16/icon-storage-16.svg +0 -3
- package/transpiled/assets/icons/24/icon-arrow-left.svg +0 -3
- package/transpiled/assets/icons/32/icon-claudy.svg +0 -1
- package/transpiled/assets/icons/apps/icon-collect.svg +0 -25
- package/transpiled/assets/icons/apps/icon-drive.svg +0 -17
- package/transpiled/assets/icons/apps/icon-market-soon.svg +0 -25
- package/transpiled/assets/icons/apps/icon-photos.svg +0 -19
- package/transpiled/assets/icons/apps/icon-soon.svg +0 -21
- package/transpiled/assets/icons/apps/icon-store.svg +0 -19
- package/transpiled/assets/icons/claudyActions/icon-bills.svg +0 -6
- package/transpiled/assets/icons/claudyActions/icon-laptop.svg +0 -7
- package/transpiled/assets/icons/claudyActions/icon-phone.svg +0 -8
- package/transpiled/assets/icons/claudyActions/icon-question-mark.svg +0 -6
- package/transpiled/assets/icons/comingsoon/icon-bank.svg +0 -12
- package/transpiled/assets/icons/comingsoon/icon-sante.svg +0 -12
- package/transpiled/assets/icons/comingsoon/icon-store.svg +0 -6
- package/transpiled/assets/icons/icon-cozy.svg +0 -3
- package/transpiled/assets/icons/icon-shield.svg +0 -3
- package/transpiled/assets/icons/spinner.svg +0 -4
- package/transpiled/assets/sprites/icon-apps.svg +0 -1
- package/transpiled/assets/sprites/icon-cozy-home.svg +0 -16
- package/transpiled/components/Apps/AppItem.js +0 -134
- package/transpiled/components/Apps/AppItemPlaceholder.js +0 -14
- package/transpiled/components/Apps/AppNavButtons.js +0 -108
- package/transpiled/components/Apps/AppsContent.js +0 -124
- package/transpiled/components/Apps/ButtonCozyHome.js +0 -25
- package/transpiled/components/Apps/ButtonCozyHome.spec.jsx +0 -53
- package/transpiled/components/Apps/IconCozyHome.js +0 -67
- package/transpiled/components/Apps/index.js +0 -102
- package/transpiled/components/Banner.js +0 -76
- package/transpiled/components/Bar.js +0 -329
- package/transpiled/components/Bar.spec.jsx +0 -133
- package/transpiled/components/Claudy.js +0 -123
- package/transpiled/components/ClaudyIcon.js +0 -16
- package/transpiled/components/Drawer.js +0 -367
- package/transpiled/components/Drawer.spec.jsx +0 -98
- package/transpiled/components/SearchBar.js +0 -407
- package/transpiled/components/Settings/SettingsContent.js +0 -128
- package/transpiled/components/Settings/StorageData.js +0 -24
- package/transpiled/components/Settings/helper.js +0 -9
- package/transpiled/components/Settings/index.js +0 -225
- package/transpiled/components/StorageIcon.js +0 -16
- package/transpiled/components/SupportModal.js +0 -86
- package/transpiled/components/__snapshots__/Bar.spec.jsx.snap +0 -302
- package/transpiled/config/claudyActions.json +0 -20
- package/transpiled/config/persistWhitelist.json +0 -4
- package/transpiled/cozy-bar.css +0 -5905
- package/transpiled/dom.js +0 -84
- package/transpiled/index.js +0 -246
- package/transpiled/index.spec.jsx +0 -34
- package/transpiled/lib/api/helpers.js +0 -12
- package/transpiled/lib/api/index.js +0 -175
- package/transpiled/lib/exceptions.js +0 -156
- package/transpiled/lib/expiringMemoize.js +0 -17
- package/transpiled/lib/icon.js +0 -154
- package/transpiled/lib/intents.js +0 -17
- package/transpiled/lib/logger.js +0 -10
- package/transpiled/lib/middlewares/appsI18n.js +0 -64
- package/transpiled/lib/realtime.js +0 -76
- package/transpiled/lib/reducers/apps.js +0 -291
- package/transpiled/lib/reducers/apps.spec.js +0 -59
- package/transpiled/lib/reducers/content.js +0 -68
- package/transpiled/lib/reducers/context.js +0 -138
- package/transpiled/lib/reducers/index.js +0 -59
- package/transpiled/lib/reducers/locale.js +0 -27
- package/transpiled/lib/reducers/settings.js +0 -253
- package/transpiled/lib/reducers/theme.js +0 -64
- package/transpiled/lib/reducers/unserializable.js +0 -31
- package/transpiled/lib/stack-client.js +0 -442
- package/transpiled/lib/stack.js +0 -122
- package/transpiled/lib/store/index.js +0 -42
- package/transpiled/locales/de.json +0 -57
- package/transpiled/locales/en.json +0 -57
- package/transpiled/locales/es.json +0 -57
- package/transpiled/locales/fr.json +0 -57
- package/transpiled/locales/it.json +0 -57
- package/transpiled/locales/ja.json +0 -57
- package/transpiled/locales/nl_NL.json +0 -57
- package/transpiled/locales/pl.json +0 -57
- package/transpiled/locales/ru.json +0 -57
- package/transpiled/locales/sq.json +0 -57
- package/transpiled/locales/zh_CN.json +0 -57
- package/transpiled/proptypes/index.js +0 -11
- package/transpiled/queries/index.js +0 -19
- package/transpiled/styles/apps.css +0 -248
- package/transpiled/styles/banner.css +0 -64
- package/transpiled/styles/bar.css +0 -106
- package/transpiled/styles/base.css +0 -21
- package/transpiled/styles/claudy.css +0 -98
- package/transpiled/styles/drawer.css +0 -126
- package/transpiled/styles/index.styl +0 -33
- package/transpiled/styles/indicators.css +0 -58
- package/transpiled/styles/nav.css +0 -81
- package/transpiled/styles/navigation_item.css +0 -34
- package/transpiled/styles/searchbar.css +0 -156
- package/transpiled/styles/settings.css +0 -34
- package/transpiled/styles/storage.css +0 -22
- package/transpiled/styles/supportModal.css +0 -20
- package/transpiled/styles/theme.styl +0 -25
|
@@ -1,102 +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 AppsContent from "./AppsContent";
|
|
15
|
-
import AppNavButtons from "./AppNavButtons";
|
|
16
|
-
|
|
17
|
-
var Apps = /*#__PURE__*/function (_Component) {
|
|
18
|
-
_inherits(Apps, _Component);
|
|
19
|
-
|
|
20
|
-
var _super = _createSuper(Apps);
|
|
21
|
-
|
|
22
|
-
function Apps(props) {
|
|
23
|
-
var _this;
|
|
24
|
-
|
|
25
|
-
_classCallCheck(this, Apps);
|
|
26
|
-
|
|
27
|
-
_this = _super.call(this, props);
|
|
28
|
-
|
|
29
|
-
_defineProperty(_assertThisInitialized(_this), "onClickOutside", function (event) {
|
|
30
|
-
if (_this.state.opened) {
|
|
31
|
-
// if it's not a cozy-bar nav popup, close the opened popup
|
|
32
|
-
if (!_this.rootRef.contains(event.target) && !_this.modalContainer.contains(event.target)) {
|
|
33
|
-
_this.setState({
|
|
34
|
-
opened: false
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
event.stopPropagation();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "toggleMenu", function () {
|
|
43
|
-
_this.setState({
|
|
44
|
-
opened: !_this.state.opened
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
_this.state = {
|
|
49
|
-
opened: false
|
|
50
|
-
};
|
|
51
|
-
return _this;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_createClass(Apps, [{
|
|
55
|
-
key: "componentDidMount",
|
|
56
|
-
value: function componentDidMount() {
|
|
57
|
-
document.body.addEventListener('click', this.onClickOutside);
|
|
58
|
-
this.modalContainer = document.getElementById('cozy-bar-modal-dom-place');
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "componentWillUnmount",
|
|
62
|
-
value: function componentWillUnmount() {
|
|
63
|
-
document.body.removeEventListener('click', this.onClickOutside);
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "render",
|
|
67
|
-
// data-tutorial attribute allows to be targeted in an application tutorial
|
|
68
|
-
value: function render() {
|
|
69
|
-
var _this2 = this;
|
|
70
|
-
|
|
71
|
-
var _this$props = this.props,
|
|
72
|
-
appName = _this$props.appName,
|
|
73
|
-
appNamePrefix = _this$props.appNamePrefix,
|
|
74
|
-
appSlug = _this$props.appSlug,
|
|
75
|
-
iconPath = _this$props.iconPath,
|
|
76
|
-
isPublic = _this$props.isPublic;
|
|
77
|
-
var opened = this.state.opened;
|
|
78
|
-
return /*#__PURE__*/React.createElement("nav", {
|
|
79
|
-
className: "coz-nav coz-nav-apps",
|
|
80
|
-
ref: function ref(_ref) {
|
|
81
|
-
_this2.rootRef = _ref;
|
|
82
|
-
}
|
|
83
|
-
}, /*#__PURE__*/React.createElement(AppNavButtons, {
|
|
84
|
-
appName: appName,
|
|
85
|
-
appNamePrefix: appNamePrefix,
|
|
86
|
-
appSlug: appSlug,
|
|
87
|
-
iconPath: iconPath,
|
|
88
|
-
handleClick: this.toggleMenu,
|
|
89
|
-
opened: opened,
|
|
90
|
-
isPublic: isPublic
|
|
91
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
className: "coz-nav-pop coz-nav-pop--apps",
|
|
93
|
-
id: "coz-nav-pop--apps",
|
|
94
|
-
"aria-hidden": !opened
|
|
95
|
-
}, /*#__PURE__*/React.createElement(AppsContent, null)));
|
|
96
|
-
}
|
|
97
|
-
}]);
|
|
98
|
-
|
|
99
|
-
return Apps;
|
|
100
|
-
}(Component);
|
|
101
|
-
|
|
102
|
-
export default Apps;
|
|
@@ -1,76 +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
|
-
|
|
8
|
-
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); }; }
|
|
9
|
-
|
|
10
|
-
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; } }
|
|
11
|
-
|
|
12
|
-
import React, { Component } from 'react';
|
|
13
|
-
import { ButtonLink } from "cozy-ui/transpiled/react/Button";
|
|
14
|
-
import { translate } from "cozy-ui/transpiled/react/I18n";
|
|
15
|
-
|
|
16
|
-
var Banner = /*#__PURE__*/function (_Component) {
|
|
17
|
-
_inherits(Banner, _Component);
|
|
18
|
-
|
|
19
|
-
var _super = _createSuper(Banner);
|
|
20
|
-
|
|
21
|
-
function Banner(props) {
|
|
22
|
-
var _this;
|
|
23
|
-
|
|
24
|
-
_classCallCheck(this, Banner);
|
|
25
|
-
|
|
26
|
-
_this = _super.call(this, props);
|
|
27
|
-
_this.state = {
|
|
28
|
-
unmounted: true
|
|
29
|
-
};
|
|
30
|
-
_this.animate = _this.animate.bind(_assertThisInitialized(_this));
|
|
31
|
-
return _this;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
_createClass(Banner, [{
|
|
35
|
-
key: "animate",
|
|
36
|
-
value: function animate() {
|
|
37
|
-
var _this2 = this;
|
|
38
|
-
|
|
39
|
-
// To animate we have to use a setTimeout to
|
|
40
|
-
// force a CSS class update and trigger CSS animation
|
|
41
|
-
return setTimeout(function () {
|
|
42
|
-
_this2.setState(function () {
|
|
43
|
-
return {
|
|
44
|
-
unmounted: false
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
}, 100);
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
key: "componentDidMount",
|
|
51
|
-
value: function componentDidMount() {
|
|
52
|
-
this.animate();
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "render",
|
|
56
|
-
value: function render() {
|
|
57
|
-
var _this$props = this.props,
|
|
58
|
-
t = _this$props.t,
|
|
59
|
-
code = _this$props.code,
|
|
60
|
-
links = _this$props.links;
|
|
61
|
-
var unmounted = this.state.unmounted;
|
|
62
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
63
|
-
className: "coz-bar-banner".concat(unmounted ? ' unmounted' : '')
|
|
64
|
-
}, /*#__PURE__*/React.createElement("p", null, t("banner.".concat(code, ".description"))), /*#__PURE__*/React.createElement(ButtonLink, {
|
|
65
|
-
className: "coz-bar-banner-button",
|
|
66
|
-
size: "tiny",
|
|
67
|
-
href: links,
|
|
68
|
-
label: t("banner.".concat(code, ".CTA"))
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
}]);
|
|
72
|
-
|
|
73
|
-
return Banner;
|
|
74
|
-
}(Component);
|
|
75
|
-
|
|
76
|
-
export default translate()(Banner);
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
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
|
-
/* global __PIWIK_TRACKER_URL__ __PIWIK_SITEID__ __PIWIK_DIMENSION_ID_APP__ */
|
|
16
|
-
import React, { Component } from 'react';
|
|
17
|
-
import { connect } from 'react-redux';
|
|
18
|
-
import { translate } from "cozy-ui/transpiled/react/I18n";
|
|
19
|
-
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
|
-
import { shouldEnableTracking, getTracker, configureTracker } from "cozy-ui/transpiled/react/helpers/tracker";
|
|
21
|
-
import { isMobileApp } from 'cozy-device-helper';
|
|
22
|
-
import { ButtonCozyHome } from "./Apps/ButtonCozyHome";
|
|
23
|
-
import Banner from "./Banner";
|
|
24
|
-
import Drawer from "./Drawer";
|
|
25
|
-
import Settings from "./Settings";
|
|
26
|
-
import Apps from "./Apps";
|
|
27
|
-
import SearchBar from "./SearchBar";
|
|
28
|
-
import Claudy from "./Claudy";
|
|
29
|
-
import SupportModal from "./SupportModal";
|
|
30
|
-
import { getTheme, hasFetched, getContent, isCurrentApp, fetchApps as _fetchApps, fetchContext as _fetchContext, fetchSettingsData as _fetchSettingsData, shouldEnableClaudy, getWebviewContext } from "../lib/reducers";
|
|
31
|
-
/* Generated with node_modules/.bin/svgr src/assets/sprites/icon-apps.svg */
|
|
32
|
-
|
|
33
|
-
function SvgIconApps(props) {
|
|
34
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
35
|
-
width: 16,
|
|
36
|
-
height: 16
|
|
37
|
-
}, props), /*#__PURE__*/React.createElement("path", {
|
|
38
|
-
d: "M0 0h4v4H0V0zm0 6h4v4H0V6zm0 6h4v4H0v-4zM6 0h4v4H6V0zm0 6h4v4H6V6zm0 6h4v4H6v-4zm6-12h4v4h-4V0zm0 6h4v4h-4V6zm0 6h4v4h-4v-4z",
|
|
39
|
-
fillRule: "evenodd"
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export var Bar = /*#__PURE__*/function (_Component) {
|
|
44
|
-
_inherits(Bar, _Component);
|
|
45
|
-
|
|
46
|
-
var _super = _createSuper(Bar);
|
|
47
|
-
|
|
48
|
-
function Bar(props) {
|
|
49
|
-
var _this;
|
|
50
|
-
|
|
51
|
-
_classCallCheck(this, Bar);
|
|
52
|
-
|
|
53
|
-
_this = _super.call(this, props);
|
|
54
|
-
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "toggleDrawer", function () {
|
|
56
|
-
// don't allow to toggle the drawer if claudy opened or is opening
|
|
57
|
-
if (_this.state.claudyOpened || _this.state.claudyFired) return;
|
|
58
|
-
var drawerVisible = !_this.state.drawerVisible; // don't wait for transitionend if displaying
|
|
59
|
-
|
|
60
|
-
if (drawerVisible) _this.props.onDrawer(drawerVisible);
|
|
61
|
-
|
|
62
|
-
_this.setState({
|
|
63
|
-
drawerVisible: drawerVisible
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
_defineProperty(_assertThisInitialized(_this), "toggleClaudy", function () {
|
|
68
|
-
var isFromDrawer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
69
|
-
if (!_this.props.claudyEnabled) return;
|
|
70
|
-
var _this$state = _this.state,
|
|
71
|
-
usageTracker = _this$state.usageTracker,
|
|
72
|
-
claudyOpened = _this$state.claudyOpened;
|
|
73
|
-
|
|
74
|
-
if (isFromDrawer && !claudyOpened) {
|
|
75
|
-
// if opened from drawer
|
|
76
|
-
// reset to toggle via the Claudy component
|
|
77
|
-
return _this.setState({
|
|
78
|
-
claudyFired: true
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (_this.state.claudyFired) _this.setState({
|
|
83
|
-
claudyFired: false
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
if (usageTracker) {
|
|
87
|
-
usageTracker.push(['trackEvent', 'Claudy', claudyOpened ? 'close' : 'open', 'claudy']);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
_this.setState({
|
|
91
|
-
claudyOpened: !claudyOpened
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
_defineProperty(_assertThisInitialized(_this), "toggleSupport", function () {
|
|
96
|
-
var supportDisplayed = _this.state.supportDisplayed;
|
|
97
|
-
|
|
98
|
-
_this.setState({
|
|
99
|
-
supportDisplayed: !supportDisplayed
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
_defineProperty(_assertThisInitialized(_this), "renderLeft", function () {
|
|
104
|
-
var _this$props = _this.props,
|
|
105
|
-
t = _this$props.t,
|
|
106
|
-
isPublic = _this$props.isPublic,
|
|
107
|
-
webviewContext = _this$props.webviewContext;
|
|
108
|
-
|
|
109
|
-
if (webviewContext) {
|
|
110
|
-
return /*#__PURE__*/React.createElement(ButtonCozyHome, {
|
|
111
|
-
webviewContext: webviewContext
|
|
112
|
-
});
|
|
113
|
-
} // data-tutorial attribute allows to be targeted in an application tutorial
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return !isPublic ? /*#__PURE__*/React.createElement("button", {
|
|
117
|
-
type: "button",
|
|
118
|
-
className: "coz-bar-btn coz-bar-burger",
|
|
119
|
-
onClick: _this.toggleDrawer,
|
|
120
|
-
"data-tutorial": "apps-mobile"
|
|
121
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
122
|
-
icon: SvgIconApps,
|
|
123
|
-
width: 16,
|
|
124
|
-
height: 16,
|
|
125
|
-
color: "currentColor"
|
|
126
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
127
|
-
className: "coz-bar-hidden"
|
|
128
|
-
}, t('drawer'))) : null;
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
_defineProperty(_assertThisInitialized(_this), "renderRight", function () {
|
|
132
|
-
var isPublic = _this.props.isPublic;
|
|
133
|
-
return !isPublic ? /*#__PURE__*/React.createElement(Settings, {
|
|
134
|
-
toggleSupport: _this.toggleSupport,
|
|
135
|
-
onLogOut: _this.props.onLogOut
|
|
136
|
-
}) : null;
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
_this.state = {
|
|
140
|
-
claudyFired: false,
|
|
141
|
-
// true to fire claudy (used by the drawer)
|
|
142
|
-
claudyOpened: false,
|
|
143
|
-
drawerVisible: false,
|
|
144
|
-
usageTracker: null,
|
|
145
|
-
supportDisplayed: false,
|
|
146
|
-
searchBarEnabled: props.isDrive && !props.isPublic && !isMobileApp()
|
|
147
|
-
};
|
|
148
|
-
_this.fetchApps = _this.fetchApps.bind(_assertThisInitialized(_this));
|
|
149
|
-
_this.fetchInitialData = _this.fetchInitialData.bind(_assertThisInitialized(_this));
|
|
150
|
-
_this.handleTokenRefreshed = _this.handleTokenRefreshed.bind(_assertThisInitialized(_this));
|
|
151
|
-
return _this;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
_createClass(Bar, [{
|
|
155
|
-
key: "componentDidMount",
|
|
156
|
-
value: function componentDidMount() {
|
|
157
|
-
if (shouldEnableTracking()) {
|
|
158
|
-
this.initPiwikTracker();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
this.fetchInitialData();
|
|
162
|
-
var cozyClient = this.props.cozyClient;
|
|
163
|
-
cozyClient.on('tokenRefreshed', this.handleTokenRefreshed);
|
|
164
|
-
}
|
|
165
|
-
}, {
|
|
166
|
-
key: "componentWillUnmount",
|
|
167
|
-
value: function componentWillUnmount() {
|
|
168
|
-
var cozyClient = this.props.cozyClient;
|
|
169
|
-
cozyClient.removeListener('tokenRefreshed', this.handleTokenRefreshed);
|
|
170
|
-
}
|
|
171
|
-
}, {
|
|
172
|
-
key: "componentDidUpdate",
|
|
173
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
174
|
-
if (!this.props.hasFetchedApps && this.state.drawerVisible && prevState.drawerVisible !== this.state.drawerVisible) {
|
|
175
|
-
this.fetchApps();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}, {
|
|
179
|
-
key: "handleTokenRefreshed",
|
|
180
|
-
value: function handleTokenRefreshed() {
|
|
181
|
-
this.fetchInitialData();
|
|
182
|
-
}
|
|
183
|
-
}, {
|
|
184
|
-
key: "initPiwikTracker",
|
|
185
|
-
value: function initPiwikTracker() {
|
|
186
|
-
var trackerInstance = getTracker("\"https://matomo.cozycloud.cc\"", 8, false, false);
|
|
187
|
-
configureTracker({
|
|
188
|
-
appDimensionId: 1,
|
|
189
|
-
app: 'Cozy Bar',
|
|
190
|
-
heartbeat: 0
|
|
191
|
-
});
|
|
192
|
-
this.setState({
|
|
193
|
-
usageTracker: trackerInstance
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "fetchApps",
|
|
198
|
-
value: function fetchApps() {
|
|
199
|
-
this.props.fetchApps();
|
|
200
|
-
}
|
|
201
|
-
}, {
|
|
202
|
-
key: "fetchInitialData",
|
|
203
|
-
value: function fetchInitialData() {
|
|
204
|
-
if (this.props.isPublic) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
this.props.fetchContext();
|
|
209
|
-
this.props.fetchSettingsData(false);
|
|
210
|
-
this.fetchApps();
|
|
211
|
-
}
|
|
212
|
-
}, {
|
|
213
|
-
key: "renderCenter",
|
|
214
|
-
value: function renderCenter() {
|
|
215
|
-
var _this$props2 = this.props,
|
|
216
|
-
appName = _this$props2.appName,
|
|
217
|
-
appNamePrefix = _this$props2.appNamePrefix,
|
|
218
|
-
appSlug = _this$props2.appSlug,
|
|
219
|
-
iconPath = _this$props2.iconPath,
|
|
220
|
-
isPublic = _this$props2.isPublic;
|
|
221
|
-
return /*#__PURE__*/React.createElement(Apps, {
|
|
222
|
-
appName: appName,
|
|
223
|
-
appNamePrefix: appNamePrefix,
|
|
224
|
-
appSlug: appSlug,
|
|
225
|
-
iconPath: iconPath,
|
|
226
|
-
isPublic: isPublic
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}, {
|
|
230
|
-
key: "render",
|
|
231
|
-
value: function render() {
|
|
232
|
-
var _this2 = this;
|
|
233
|
-
|
|
234
|
-
var _this$state2 = this.state,
|
|
235
|
-
claudyFired = _this$state2.claudyFired,
|
|
236
|
-
claudyOpened = _this$state2.claudyOpened,
|
|
237
|
-
drawerVisible = _this$state2.drawerVisible,
|
|
238
|
-
searchBarEnabled = _this$state2.searchBarEnabled,
|
|
239
|
-
supportDisplayed = _this$state2.supportDisplayed,
|
|
240
|
-
usageTracker = _this$state2.usageTracker;
|
|
241
|
-
var _this$props3 = this.props,
|
|
242
|
-
theme = _this$props3.theme,
|
|
243
|
-
themeOverrides = _this$props3.themeOverrides,
|
|
244
|
-
barLeft = _this$props3.barLeft,
|
|
245
|
-
barRight = _this$props3.barRight,
|
|
246
|
-
barCenter = _this$props3.barCenter,
|
|
247
|
-
barSearch = _this$props3.barSearch,
|
|
248
|
-
claudyEnabled = _this$props3.claudyEnabled,
|
|
249
|
-
onDrawer = _this$props3.onDrawer,
|
|
250
|
-
isPublic = _this$props3.isPublic,
|
|
251
|
-
onLogOut = _this$props3.onLogOut,
|
|
252
|
-
userActionRequired = _this$props3.userActionRequired;
|
|
253
|
-
var pColor = themeOverrides.primaryColor,
|
|
254
|
-
pctColor = themeOverrides.primaryContrastTextColor;
|
|
255
|
-
var pStyle = pColor ? {
|
|
256
|
-
'--cozBarThemePrimaryColor': pColor
|
|
257
|
-
} : {};
|
|
258
|
-
var pctStyle = pctColor ? {
|
|
259
|
-
'--cozBarThemePrimaryContrastTextColor': pctColor
|
|
260
|
-
} : {};
|
|
261
|
-
|
|
262
|
-
var themeStyle = _objectSpread({}, pStyle, pctStyle);
|
|
263
|
-
|
|
264
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
265
|
-
className: "coz-bar-wrapper coz-theme-".concat(theme),
|
|
266
|
-
style: themeStyle
|
|
267
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
268
|
-
id: "cozy-bar-modal-dom-place"
|
|
269
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
270
|
-
className: "coz-bar-container"
|
|
271
|
-
}, barLeft || this.renderLeft(), barCenter || this.renderCenter(), /*#__PURE__*/React.createElement("div", {
|
|
272
|
-
className: "u-flex-grow"
|
|
273
|
-
}, barSearch || (searchBarEnabled ? /*#__PURE__*/React.createElement(SearchBar, null) : null)), barRight || this.renderRight(), !isPublic ? /*#__PURE__*/React.createElement(Drawer, {
|
|
274
|
-
visible: drawerVisible,
|
|
275
|
-
onClose: this.toggleDrawer,
|
|
276
|
-
onClaudy: claudyEnabled && function () {
|
|
277
|
-
return _this2.toggleClaudy(true);
|
|
278
|
-
} || false,
|
|
279
|
-
isClaudyLoading: claudyFired,
|
|
280
|
-
drawerListener: function drawerListener() {
|
|
281
|
-
return onDrawer(drawerVisible);
|
|
282
|
-
},
|
|
283
|
-
toggleSupport: this.toggleSupport,
|
|
284
|
-
onLogOut: onLogOut
|
|
285
|
-
}) : null, claudyEnabled && /*#__PURE__*/React.createElement(Claudy, {
|
|
286
|
-
usageTracker: usageTracker,
|
|
287
|
-
claudyFired: claudyFired,
|
|
288
|
-
onToggle: function onToggle() {
|
|
289
|
-
return _this2.toggleClaudy(false);
|
|
290
|
-
},
|
|
291
|
-
opened: claudyOpened
|
|
292
|
-
}), supportDisplayed && /*#__PURE__*/React.createElement(SupportModal, {
|
|
293
|
-
onClose: this.toggleSupport
|
|
294
|
-
})), userActionRequired && /*#__PURE__*/React.createElement(Banner, userActionRequired));
|
|
295
|
-
}
|
|
296
|
-
}]);
|
|
297
|
-
|
|
298
|
-
return Bar;
|
|
299
|
-
}(Component);
|
|
300
|
-
export var mapStateToProps = function mapStateToProps(state) {
|
|
301
|
-
return {
|
|
302
|
-
theme: getTheme(state).name,
|
|
303
|
-
themeOverrides: getTheme(state).overrides,
|
|
304
|
-
barLeft: getContent(state, 'left'),
|
|
305
|
-
barRight: getContent(state, 'right'),
|
|
306
|
-
barCenter: getContent(state, 'center'),
|
|
307
|
-
barSearch: getContent(state, 'search'),
|
|
308
|
-
isDrive: isCurrentApp(state, {
|
|
309
|
-
slug: 'drive'
|
|
310
|
-
}),
|
|
311
|
-
claudyEnabled: shouldEnableClaudy(state),
|
|
312
|
-
hasFetchedApps: hasFetched(state),
|
|
313
|
-
webviewContext: getWebviewContext(state)
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
export var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
317
|
-
return {
|
|
318
|
-
fetchApps: function fetchApps() {
|
|
319
|
-
return dispatch(_fetchApps());
|
|
320
|
-
},
|
|
321
|
-
fetchContext: function fetchContext() {
|
|
322
|
-
return dispatch(_fetchContext());
|
|
323
|
-
},
|
|
324
|
-
fetchSettingsData: function fetchSettingsData(displayBusy) {
|
|
325
|
-
return dispatch(_fetchSettingsData(displayBusy));
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
export default translate()(connect(mapStateToProps, mapDispatchToProps)(Bar));
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { shallow } from 'enzyme'
|
|
3
|
-
import { isFlagshipApp, isMobileApp } from 'cozy-device-helper'
|
|
4
|
-
import toJson from 'enzyme-to-json'
|
|
5
|
-
import reducers from 'lib/reducers'
|
|
6
|
-
import CozyClient from 'cozy-client'
|
|
7
|
-
|
|
8
|
-
import { Bar, mapStateToProps, mapDispatchToProps } from './Bar'
|
|
9
|
-
|
|
10
|
-
jest.mock('cozy-device-helper', () => ({
|
|
11
|
-
...require.requireActual('cozy-device-helper'),
|
|
12
|
-
isMobileApp: jest.fn(),
|
|
13
|
-
isFlagshipApp: jest.fn()
|
|
14
|
-
}))
|
|
15
|
-
|
|
16
|
-
describe('Bar', () => {
|
|
17
|
-
let props, client
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
jest.resetAllMocks()
|
|
20
|
-
jest.spyOn(Bar.prototype, 'fetchApps')
|
|
21
|
-
isMobileApp.mockReturnValue(false)
|
|
22
|
-
client = new CozyClient({})
|
|
23
|
-
props = {
|
|
24
|
-
fetchContext: jest.fn().mockResolvedValue({}),
|
|
25
|
-
fetchApps: jest.fn().mockResolvedValue([]),
|
|
26
|
-
fetchSettingsData: jest.fn().mockResolvedValue({}),
|
|
27
|
-
theme: 'default',
|
|
28
|
-
themeOverrides: {},
|
|
29
|
-
t: x => x,
|
|
30
|
-
cozyClient: client
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
afterEach(() => {
|
|
35
|
-
Bar.prototype.fetchApps.mockRestore()
|
|
36
|
-
isFlagshipApp.mockClear()
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should fetch data when mounted', () => {
|
|
40
|
-
shallow(<Bar {...props} />)
|
|
41
|
-
expect(props.fetchContext).toHaveBeenCalled()
|
|
42
|
-
expect(props.fetchApps).toHaveBeenCalled()
|
|
43
|
-
expect(props.fetchSettingsData).toHaveBeenCalled()
|
|
44
|
-
expect(Bar.prototype.fetchApps).toHaveBeenCalled()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('should not fetch data if public', () => {
|
|
48
|
-
shallow(<Bar {...props} isPublic={true} />)
|
|
49
|
-
expect(props.fetchContext).not.toHaveBeenCalled()
|
|
50
|
-
expect(props.fetchApps).not.toHaveBeenCalled()
|
|
51
|
-
expect(props.fetchSettingsData).not.toHaveBeenCalled()
|
|
52
|
-
expect(Bar.prototype.fetchApps).not.toHaveBeenCalled()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('should not fetch apps if hasFetchedApps is true', () => {
|
|
56
|
-
const barWrapper = shallow(<Bar {...props} hasFetchedApps={true} />)
|
|
57
|
-
jest.resetAllMocks()
|
|
58
|
-
barWrapper.setState({ drawerVisible: true }) // to call componentdidUpdate
|
|
59
|
-
expect(props.fetchApps).not.toHaveBeenCalled()
|
|
60
|
-
expect(Bar.prototype.fetchApps).not.toHaveBeenCalled()
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('should re-fetch apps if apps are not fetched and drawer opens', () => {
|
|
64
|
-
const barWrapper = shallow(<Bar {...props} />)
|
|
65
|
-
expect(Bar.prototype.fetchApps).toHaveBeenCalledTimes(1)
|
|
66
|
-
expect(props.fetchApps).toHaveBeenCalledTimes(1)
|
|
67
|
-
barWrapper.setState({ drawerVisible: true })
|
|
68
|
-
expect(props.fetchApps).toHaveBeenCalledTimes(2)
|
|
69
|
-
expect(Bar.prototype.fetchApps).toHaveBeenCalledTimes(2)
|
|
70
|
-
barWrapper.setState({ drawerVisible: true, usageTracker: {} })
|
|
71
|
-
expect(props.fetchApps).toHaveBeenCalledTimes(2)
|
|
72
|
-
expect(Bar.prototype.fetchApps).toHaveBeenCalledTimes(2)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('should change theme', () => {
|
|
76
|
-
const barWrapper = shallow(<Bar {...props} theme="primary" />)
|
|
77
|
-
expect(toJson(barWrapper)).toMatchSnapshot()
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('should change allow theme overrides', () => {
|
|
81
|
-
const barWrapper = shallow(
|
|
82
|
-
<Bar
|
|
83
|
-
{...props}
|
|
84
|
-
theme="primary"
|
|
85
|
-
themeOverrides={{ primaryColor: 'red' }}
|
|
86
|
-
/>
|
|
87
|
-
)
|
|
88
|
-
expect(toJson(barWrapper)).toMatchSnapshot()
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('should display the Searchbar', () => {
|
|
92
|
-
const barWrapper = shallow(<Bar {...props} isDrive isPublic={false} />)
|
|
93
|
-
expect(toJson(barWrapper)).toMatchSnapshot()
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('should not display searchbar if we are on mobile', () => {
|
|
97
|
-
isMobileApp.mockReturnValue(true)
|
|
98
|
-
const barWrapper = shallow(<Bar {...props} isDrive isPublic={false} />)
|
|
99
|
-
expect(toJson(barWrapper)).toMatchSnapshot()
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should not display searchbar if we are not on Cozy Drive', () => {
|
|
103
|
-
isMobileApp.mockReturnValue(true)
|
|
104
|
-
const barWrapper = shallow(
|
|
105
|
-
<Bar {...props} isDrive={false} isPublic={false} />
|
|
106
|
-
)
|
|
107
|
-
expect(toJson(barWrapper)).toMatchSnapshot()
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('should not display searchbar if we are not on a public page', () => {
|
|
111
|
-
isMobileApp.mockReturnValue(true)
|
|
112
|
-
const barWrapper = shallow(<Bar {...props} isDrive isPublic={true} />)
|
|
113
|
-
expect(toJson(barWrapper)).toMatchSnapshot()
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('should have correct state props provided by the store with the initial state', () => {
|
|
117
|
-
const initialState = reducers(undefined, {})
|
|
118
|
-
expect(mapStateToProps(initialState)).toMatchSnapshot()
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('should have correct dispatch props provided by the store', () => {
|
|
122
|
-
expect(mapDispatchToProps(jest.fn())).toMatchSnapshot()
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('should call re-fetch data when token is refreshed', () => {
|
|
126
|
-
shallow(<Bar {...props} isDrive={false} isPublic={false} />)
|
|
127
|
-
client.emit('tokenRefreshed')
|
|
128
|
-
expect(props.fetchContext).toHaveBeenCalledTimes(2)
|
|
129
|
-
expect(props.fetchApps).toHaveBeenCalledTimes(2)
|
|
130
|
-
expect(props.fetchSettingsData).toHaveBeenCalledTimes(2)
|
|
131
|
-
expect(Bar.prototype.fetchApps).toHaveBeenCalledTimes(2)
|
|
132
|
-
})
|
|
133
|
-
})
|