cozy-bar 8.6.0 → 8.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-bar",
3
- "version": "8.6.0",
3
+ "version": "8.7.2",
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/cozy-bar.js",
6
6
  "author": "Cozy Cloud <contact@cozycloud.cc> (https://cozy.io/)",
@@ -85,7 +85,7 @@
85
85
  "redux-logger": "3.0.6",
86
86
  "semantic-release": "15.13.24",
87
87
  "style-loader": "0.23.1",
88
- "stylus": "0.54.7",
88
+ "stylus": "0.57.0",
89
89
  "stylus-loader": "3.0.2",
90
90
  "svg-sprite-loader": "4.1.6",
91
91
  "url-loader": "1.1.2",
@@ -98,17 +98,18 @@
98
98
  "@cozy/minilog": "^1.0.0",
99
99
  "cozy-client": "^27.17.0",
100
100
  "cozy-device-helper": "^1.16.1",
101
- "cozy-flags": "2.4.1",
101
+ "cozy-flags": "^2.8.5",
102
102
  "cozy-interapp": "0.4.9",
103
103
  "cozy-realtime": "^4.0.5",
104
104
  "cozy-ui": "^51.8.0",
105
105
  "hammerjs": "2.0.8",
106
106
  "lodash.debounce": "4.0.8",
107
+ "lodash.set": "^4.3.2",
107
108
  "lodash.unionwith": "4.6.0",
108
109
  "prop-types": "15.7.2",
109
110
  "react-autosuggest": "9.4.3",
110
111
  "react-redux": "5.1.1",
111
- "redux": "3.7.2",
112
+ "redux": "4.1.2",
112
113
  "redux-persist": "5.10.0",
113
114
  "redux-thunk": "2.3.0",
114
115
  "semver-compare": "^1.0.0"
@@ -1,15 +1,18 @@
1
1
  import React from 'react'
2
+ import { isFlagshipApp } from 'cozy-device-helper'
3
+
4
+ import flag from 'cozy-flags'
2
5
 
3
6
  import IconCozyHome from './IconCozyHome'
4
7
 
5
8
  export const ButtonCozyHome = ({ webviewContext, homeHref }) => {
6
- if (webviewContext)
9
+ if (isFlagshipApp() || flag('flagship.debug'))
7
10
  return (
8
11
  <a
9
12
  onClick={() => {
10
13
  webviewContext.call('backToHome')
11
14
  }}
12
- className="coz-nav-apps-btns-home"
15
+ className="coz-nav-apps-btns-home --is-flagship"
13
16
  >
14
17
  <IconCozyHome className="coz-nav-apps-btns-home-svg" />
15
18
  </a>
@@ -1,7 +1,9 @@
1
1
  import React from 'react'
2
2
  import { shallow } from 'enzyme'
3
+ import { ButtonCozyHome } from './ButtonCozyHome'
4
+ import { isFlagshipApp } from 'cozy-device-helper'
3
5
 
4
- import { ButtonCozyHome } from 'components/Apps/ButtonCozyHome'
6
+ jest.mock('cozy-device-helper')
5
7
 
6
8
  const homeHref = 'foo'
7
9
  const expectedCall = 'backToHome'
@@ -11,6 +13,7 @@ const webviewContext = {
11
13
 
12
14
  describe('ButtonCozyHome', () => {
13
15
  it('should render a span with no props', () => {
16
+ isFlagshipApp.mockImplementation(() => false)
14
17
  const render = shallow(<ButtonCozyHome />)
15
18
  const element = render.getElement()
16
19
 
@@ -18,6 +21,7 @@ describe('ButtonCozyHome', () => {
18
21
  })
19
22
 
20
23
  it('should render an anchor with correct href when homeHref', () => {
24
+ isFlagshipApp.mockImplementation(() => false)
21
25
  const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
22
26
  const element = render.getElement()
23
27
 
@@ -25,14 +29,16 @@ describe('ButtonCozyHome', () => {
25
29
  expect(element.props.href).toBe(homeHref)
26
30
  })
27
31
 
28
- it('should render an anchor when webviewContext', () => {
32
+ it('should render an anchor when isFlagshipApp', () => {
33
+ isFlagshipApp.mockImplementation(() => true)
29
34
  const render = shallow(<ButtonCozyHome webviewContext={webviewContext} />)
30
35
  const element = render.getElement()
31
36
 
32
37
  expect(element.type).toBe('a')
33
38
  })
34
39
 
35
- it('should give priority to anchor if both webviewContext and homeHref are present', () => {
40
+ it('should give priority to anchor if both isFlagshipApp and homeHref are present', () => {
41
+ isFlagshipApp.mockImplementation(() => true)
36
42
  const render = shallow(
37
43
  <ButtonCozyHome homeHref={homeHref} webviewContext={webviewContext} />
38
44
  )
@@ -42,6 +48,7 @@ describe('ButtonCozyHome', () => {
42
48
  })
43
49
 
44
50
  it('should call the correct context method on click', () => {
51
+ isFlagshipApp.mockImplementation(() => true)
45
52
  const render = shallow(
46
53
  <ButtonCozyHome homeHref={homeHref} webviewContext={webviewContext} />
47
54
  )
@@ -10,7 +10,8 @@ import {
10
10
  getTracker,
11
11
  configureTracker
12
12
  } from 'cozy-ui/react/helpers/tracker'
13
- import { isMobileApp } from 'cozy-device-helper'
13
+ import { isFlagshipApp, isMobileApp } from 'cozy-device-helper'
14
+ import flag from 'cozy-flags'
14
15
 
15
16
  import { ButtonCozyHome } from 'components/Apps/ButtonCozyHome'
16
17
  import Banner from 'components/Banner'
@@ -167,7 +168,7 @@ export class Bar extends Component {
167
168
  renderLeft = () => {
168
169
  const { t, isPublic, webviewContext } = this.props
169
170
 
170
- if (webviewContext) {
171
+ if (isFlagshipApp() || flag('flagship.debug')) {
171
172
  return <ButtonCozyHome webviewContext={webviewContext} />
172
173
  }
173
174
 
package/src/lib/logger.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import flag from 'cozy-flags'
2
2
  import _minilog from '@cozy/minilog'
3
+ import set from 'lodash.set'
4
+
5
+ set(window, `cozy.debug.flagship`, () => flag('flagship.debug', true))
3
6
 
4
7
  const minilog = window.minilog || _minilog
5
8
  const logger = minilog('cozy-bar')
@@ -50,6 +50,14 @@
50
50
  margin-right: .75rem;
51
51
  }
52
52
 
53
+ [role=banner] .coz-nav-apps-btns-home.--is-flagship {
54
+ align-items: center;
55
+ display: flex;
56
+ height: 100%;
57
+ margin: 0;
58
+ padding: 0 1rem;
59
+ }
60
+
53
61
 
54
62
  [role=banner] .coz-nav-apps-btns-home-svg {
55
63
  max-width: 2rem;
@@ -1,13 +1,15 @@
1
1
  import React from 'react';
2
+ import { isFlagshipApp } from 'cozy-device-helper';
3
+ import flag from 'cozy-flags';
2
4
  import IconCozyHome from "./IconCozyHome";
3
5
  export var ButtonCozyHome = function ButtonCozyHome(_ref) {
4
6
  var webviewContext = _ref.webviewContext,
5
7
  homeHref = _ref.homeHref;
6
- if (webviewContext) return /*#__PURE__*/React.createElement("a", {
8
+ if (isFlagshipApp() || flag('flagship.debug')) return /*#__PURE__*/React.createElement("a", {
7
9
  onClick: function onClick() {
8
10
  webviewContext.call('backToHome');
9
11
  },
10
- className: "coz-nav-apps-btns-home"
12
+ className: "coz-nav-apps-btns-home --is-flagship"
11
13
  }, /*#__PURE__*/React.createElement(IconCozyHome, {
12
14
  className: "coz-nav-apps-btns-home-svg"
13
15
  }));
@@ -1,7 +1,9 @@
1
1
  import React from 'react'
2
2
  import { shallow } from 'enzyme'
3
+ import { ButtonCozyHome } from './ButtonCozyHome'
4
+ import { isFlagshipApp } from 'cozy-device-helper'
3
5
 
4
- import { ButtonCozyHome } from 'components/Apps/ButtonCozyHome'
6
+ jest.mock('cozy-device-helper')
5
7
 
6
8
  const homeHref = 'foo'
7
9
  const expectedCall = 'backToHome'
@@ -11,6 +13,7 @@ const webviewContext = {
11
13
 
12
14
  describe('ButtonCozyHome', () => {
13
15
  it('should render a span with no props', () => {
16
+ isFlagshipApp.mockImplementation(() => false)
14
17
  const render = shallow(<ButtonCozyHome />)
15
18
  const element = render.getElement()
16
19
 
@@ -18,6 +21,7 @@ describe('ButtonCozyHome', () => {
18
21
  })
19
22
 
20
23
  it('should render an anchor with correct href when homeHref', () => {
24
+ isFlagshipApp.mockImplementation(() => false)
21
25
  const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
22
26
  const element = render.getElement()
23
27
 
@@ -25,14 +29,16 @@ describe('ButtonCozyHome', () => {
25
29
  expect(element.props.href).toBe(homeHref)
26
30
  })
27
31
 
28
- it('should render an anchor when webviewContext', () => {
32
+ it('should render an anchor when isFlagshipApp', () => {
33
+ isFlagshipApp.mockImplementation(() => true)
29
34
  const render = shallow(<ButtonCozyHome webviewContext={webviewContext} />)
30
35
  const element = render.getElement()
31
36
 
32
37
  expect(element.type).toBe('a')
33
38
  })
34
39
 
35
- it('should give priority to anchor if both webviewContext and homeHref are present', () => {
40
+ it('should give priority to anchor if both isFlagshipApp and homeHref are present', () => {
41
+ isFlagshipApp.mockImplementation(() => true)
36
42
  const render = shallow(
37
43
  <ButtonCozyHome homeHref={homeHref} webviewContext={webviewContext} />
38
44
  )
@@ -42,6 +48,7 @@ describe('ButtonCozyHome', () => {
42
48
  })
43
49
 
44
50
  it('should call the correct context method on click', () => {
51
+ isFlagshipApp.mockImplementation(() => true)
45
52
  const render = shallow(
46
53
  <ButtonCozyHome homeHref={homeHref} webviewContext={webviewContext} />
47
54
  )
@@ -18,7 +18,8 @@ import { connect } from 'react-redux';
18
18
  import { translate } from "cozy-ui/transpiled/react/I18n";
19
19
  import Icon from "cozy-ui/transpiled/react/Icon";
20
20
  import { shouldEnableTracking, getTracker, configureTracker } from "cozy-ui/transpiled/react/helpers/tracker";
21
- import { isMobileApp } from 'cozy-device-helper';
21
+ import { isFlagshipApp, isMobileApp } from 'cozy-device-helper';
22
+ import flag from 'cozy-flags';
22
23
  import { ButtonCozyHome } from "./Apps/ButtonCozyHome";
23
24
  import Banner from "./Banner";
24
25
  import Drawer from "./Drawer";
@@ -106,7 +107,7 @@ export var Bar = /*#__PURE__*/function (_Component) {
106
107
  isPublic = _this$props.isPublic,
107
108
  webviewContext = _this$props.webviewContext;
108
109
 
109
- if (webviewContext) {
110
+ if (isFlagshipApp() || flag('flagship.debug')) {
110
111
  return /*#__PURE__*/React.createElement(ButtonCozyHome, {
111
112
  webviewContext: webviewContext
112
113
  });
@@ -420,6 +420,14 @@
420
420
  margin-right: .75rem;
421
421
  }
422
422
 
423
+ [role=banner] .coz-nav-apps-btns-home.--is-flagship {
424
+ align-items: center;
425
+ display: flex;
426
+ height: 100%;
427
+ margin: 0;
428
+ padding: 0 1rem;
429
+ }
430
+
423
431
 
424
432
  [role=banner] .coz-nav-apps-btns-home-svg {
425
433
  max-width: 2rem;
@@ -1,5 +1,9 @@
1
1
  import flag from 'cozy-flags';
2
2
  import _minilog from '@cozy/minilog';
3
+ import set from 'lodash.set';
4
+ set(window, "cozy.debug.flagship", function () {
5
+ return flag('flagship.debug', true);
6
+ });
3
7
  var minilog = window.minilog || _minilog;
4
8
  var logger = minilog('cozy-bar');
5
9
 
@@ -50,6 +50,14 @@
50
50
  margin-right: .75rem;
51
51
  }
52
52
 
53
+ [role=banner] .coz-nav-apps-btns-home.--is-flagship {
54
+ align-items: center;
55
+ display: flex;
56
+ height: 100%;
57
+ margin: 0;
58
+ padding: 0 1rem;
59
+ }
60
+
53
61
 
54
62
  [role=banner] .coz-nav-apps-btns-home-svg {
55
63
  max-width: 2rem;