cozy-ui 70.5.1 → 70.6.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/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## [70.6.2](https://github.com/cozy/cozy-ui/compare/v70.6.1...v70.6.2) (2022-08-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **Permissions:** Display correct Icon names in readme ([3e38d4c](https://github.com/cozy/cozy-ui/commit/3e38d4c))
7
+
8
+ ## [70.6.1](https://github.com/cozy/cozy-ui/compare/v70.6.0...v70.6.1) (2022-08-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * To refresh the BottomSheet when the height of the content changes ([d5d66bf](https://github.com/cozy/cozy-ui/commit/d5d66bf))
14
+
15
+ # [70.6.0](https://github.com/cozy/cozy-ui/compare/v70.5.1...v70.6.0) (2022-08-09)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * Prevent `AppLinker` to call openApp when target link has same slug ([3c87b96](https://github.com/cozy/cozy-ui/commit/3c87b96))
21
+
22
+
23
+ ### Features
24
+
25
+ * Add `@testing-library/user-event` to devDependencies ([a5beaf0](https://github.com/cozy/cozy-ui/commit/a5beaf0))
26
+
1
27
  ## [70.5.1](https://github.com/cozy/cozy-ui/compare/v70.5.0...v70.5.1) (2022-08-08)
2
28
 
3
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "70.5.1",
3
+ "version": "70.6.2",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -76,6 +76,7 @@
76
76
  "@semantic-release/npm": "9.0.1",
77
77
  "@svgr/cli": "^5.4.0",
78
78
  "@testing-library/jest-dom": "^5.14.1",
79
+ "@testing-library/user-event": "^14.4.2",
79
80
  "@testing-library/react": "11.2.7",
80
81
  "@testing-library/react-hooks": "^3.2.1",
81
82
  "argos-cli": "^0.3.3",
@@ -2,23 +2,24 @@
2
2
 
3
3
  exports[`app icon should not crash if no href 1`] = `
4
4
  <div>
5
- <a
6
- onClick={[Function]}
7
- >
8
- Open
9
- Cozy Drive
10
- </a>
5
+ <div>
6
+ <a>
7
+ Open
8
+ Cozy Drive
9
+ </a>
10
+ </div>
11
11
  </div>
12
12
  `;
13
13
 
14
14
  exports[`app icon should render correctly 1`] = `
15
15
  <div>
16
- <a
17
- href="https://fake.link"
18
- onClick={null}
19
- >
20
- Open
21
- Cozy Drive
22
- </a>
16
+ <div>
17
+ <a
18
+ href="https://fake.link"
19
+ >
20
+ Open
21
+ Cozy Drive
22
+ </a>
23
+ </div>
23
24
  </div>
24
25
  `;
@@ -2,23 +2,24 @@
2
2
 
3
3
  exports[`app icon should not crash if no href 1`] = `
4
4
  <div>
5
- <a
6
- onClick={[Function]}
7
- >
8
- Open
9
- Cozy Drive
10
- </a>
5
+ <div>
6
+ <a>
7
+ Open
8
+ Cozy Drive
9
+ </a>
10
+ </div>
11
11
  </div>
12
12
  `;
13
13
 
14
14
  exports[`app icon should render correctly 1`] = `
15
15
  <div>
16
- <a
17
- href="https://fake.link"
18
- onClick={null}
19
- >
20
- Open
21
- Cozy Drive
22
- </a>
16
+ <div>
17
+ <a
18
+ href="https://fake.link"
19
+ >
20
+ Open
21
+ Cozy Drive
22
+ </a>
23
+ </div>
23
24
  </div>
24
25
  `;
@@ -7,25 +7,26 @@
7
7
  */
8
8
 
9
9
  import React from 'react'
10
- import { shallow } from 'enzyme'
10
+ import { render } from '@testing-library/react'
11
+ import userEvent from '@testing-library/user-event'
12
+
11
13
  import {
12
14
  isMobileApp,
13
15
  isMobile,
14
16
  openDeeplinkOrRedirect,
15
17
  startApp,
16
- isAndroid
18
+ isAndroid,
19
+ checkApp
17
20
  } from 'cozy-device-helper'
18
21
 
19
22
  import AppLinker from './index'
20
23
  import { generateUniversalLink } from './native'
21
24
  jest.useFakeTimers()
22
25
 
23
- const tMock = x => x
24
-
25
- class DeprecatedAppItem extends React.Component {
26
- render() {
27
- const { app, onAppSwitch } = this.props
28
- return (
26
+ const setup = ({ app, onAppSwitch }) => {
27
+ return {
28
+ user: userEvent.setup({ delay: null }),
29
+ ...render(
29
30
  <AppLinker
30
31
  onAppSwitch={onAppSwitch}
31
32
  slug={app.slug}
@@ -42,6 +43,7 @@ class DeprecatedAppItem extends React.Component {
42
43
  )
43
44
  }
44
45
  }
46
+
45
47
  jest.mock('./native', () => ({
46
48
  ...jest.requireActual('./native'),
47
49
  generateUniversalLink: jest.fn()
@@ -53,7 +55,8 @@ jest.mock('cozy-device-helper', () => ({
53
55
  isMobile: jest.fn(),
54
56
  openDeeplinkOrRedirect: jest.fn(),
55
57
  startApp: jest.fn().mockResolvedValue(),
56
- isAndroid: jest.fn()
58
+ isAndroid: jest.fn(),
59
+ checkApp: jest.fn()
57
60
  }))
58
61
 
59
62
  const app = {
@@ -62,7 +65,7 @@ const app = {
62
65
  }
63
66
 
64
67
  describe('app icon', () => {
65
- let spyConsoleError, spyConsoleWarn, openNativeFromNativeSpy, appSwitchMock
68
+ let spyConsoleError, spyConsoleWarn, appSwitchMock
66
69
 
67
70
  beforeEach(() => {
68
71
  isMobileApp.mockReturnValue(false)
@@ -70,7 +73,6 @@ describe('app icon', () => {
70
73
  spyConsoleError.mockImplementation(() => {})
71
74
  spyConsoleWarn = jest.spyOn(console, 'warn')
72
75
  spyConsoleWarn.mockImplementation(() => {})
73
- openNativeFromNativeSpy = jest.spyOn(AppLinker, 'openNativeFromNative')
74
76
  isMobileApp.mockReturnValue(false)
75
77
  isMobile.mockReturnValue(false)
76
78
  isAndroid.mockReturnValue(false)
@@ -84,20 +86,26 @@ describe('app icon', () => {
84
86
  })
85
87
 
86
88
  it('should render correctly', () => {
87
- const root = shallow(<DeprecatedAppItem t={tMock} app={app} />).dive()
88
- expect(root.getElement()).toMatchSnapshot()
89
+ const { container } = setup({ app })
90
+ expect(container).toMatchSnapshot()
89
91
  })
90
92
 
91
- it('should work for native -> native', () => {
92
- const root = shallow(
93
- <DeprecatedAppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
94
- ).dive()
95
- root.find('a').simulate('click')
93
+ it('should work for web -> web', async () => {
94
+ isMobileApp.mockReturnValue(false)
95
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
96
+ const link = container.querySelector('a')
97
+ await user.click(link)
96
98
  expect(appSwitchMock).not.toHaveBeenCalled()
99
+ expect(startApp).not.toHaveBeenCalled()
100
+ })
101
+
102
+ it('should work for native -> native', async () => {
97
103
  isMobileApp.mockReturnValue(true)
98
- root.setState({ nativeAppIsAvailable: true })
99
- root.find('a').simulate('click')
100
- expect(openNativeFromNativeSpy).toHaveBeenCalled()
104
+ checkApp.mockResolvedValue(true)
105
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
106
+ const link = container.querySelector('a')
107
+ await user.click(link)
108
+
101
109
  expect(startApp).toHaveBeenCalledWith({
102
110
  appId: 'io.cozy.drive.mobile',
103
111
  name: 'Cozy Drive',
@@ -106,13 +114,12 @@ describe('app icon', () => {
106
114
  expect(appSwitchMock).toHaveBeenCalled()
107
115
  })
108
116
 
109
- it('should work for web -> native for Android (custom schema)', () => {
117
+ it('should work for web -> native for Android (custom schema)', async () => {
110
118
  isMobile.mockReturnValue(true)
111
119
  isAndroid.mockResolvedValue(true)
112
- const root = shallow(
113
- <DeprecatedAppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
114
- ).dive()
115
- root.find('a').simulate('click', { preventDefault: () => {} })
120
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
121
+ const link = container.querySelector('a')
122
+ await user.click(link)
116
123
  expect(openDeeplinkOrRedirect).toHaveBeenCalledWith(
117
124
  'cozydrive://',
118
125
  expect.any(Function)
@@ -120,28 +127,26 @@ describe('app icon', () => {
120
127
  expect(appSwitchMock).toHaveBeenCalled()
121
128
  })
122
129
 
123
- it('should work for web -> native for iOS (universal link)', () => {
130
+ it('should work for web -> native for iOS (universal link)', async () => {
124
131
  isMobile.mockReturnValue(true)
125
- const root = shallow(
126
- <DeprecatedAppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
127
- ).dive()
128
- root.find('a').simulate('click', { preventDefault: () => {} })
132
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
133
+ const link = container.querySelector('a')
134
+ await user.click(link)
129
135
 
130
136
  expect(generateUniversalLink).toHaveBeenCalled()
131
137
  })
132
138
 
133
- it('should work for native -> web', () => {
139
+ it('should work for native -> web', async () => {
134
140
  isMobileApp.mockReturnValue(true)
135
- const root = shallow(
136
- <DeprecatedAppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
137
- ).dive()
138
- root.find('a').simulate('click')
141
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
142
+ const link = container.querySelector('a')
143
+ await user.click(link)
139
144
  expect(appSwitchMock).toHaveBeenCalled()
140
145
  })
141
146
 
142
147
  it('should not crash if no href', () => {
143
148
  isMobileApp.mockReturnValue(true)
144
- const root = shallow(
149
+ const { container } = render(
145
150
  <AppLinker onAppSwitch={appSwitchMock} slug={app.slug}>
146
151
  {({ onClick, href, name }) => (
147
152
  <div>
@@ -152,6 +157,6 @@ describe('app icon', () => {
152
157
  )}
153
158
  </AppLinker>
154
159
  )
155
- expect(root.getElement()).toMatchSnapshot()
160
+ expect(container).toMatchSnapshot()
156
161
  })
157
162
  })
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
+ import { withClient } from 'cozy-client'
3
4
 
4
5
  import {
5
6
  checkApp,
@@ -79,7 +80,7 @@ export class AppLinker extends React.Component {
79
80
  }
80
81
 
81
82
  static getOnClickHref(props, nativeAppIsAvailable, context, imgRef) {
82
- const { app, nativePath } = props
83
+ const { app, client, nativePath } = props
83
84
  const slug = AppLinker.getSlug(props)
84
85
  let href = props.href
85
86
  let onClick = null
@@ -87,23 +88,29 @@ export class AppLinker extends React.Component {
87
88
  const appInfo = NATIVE_APP_INFOS[slug]
88
89
 
89
90
  if (isFlagshipApp()) {
90
- const imgPayload =
91
- imgRef &&
92
- JSON.stringify({
93
- ...imgRef.getBoundingClientRect().toJSON()
94
- })
95
-
96
- return {
97
- onClick: event => {
98
- event.preventDefault()
99
-
100
- context
101
- ? context.call('openApp', href, app, imgPayload)
102
- : logger.error(
103
- `Failed to "openApp(${app})". WebviewService has the following falsy value "${context}" in AppLinker's context.`
104
- )
105
- },
106
- href: '#'
91
+ const { app: currentApp } = client
92
+ ? client.getInstanceOptions()
93
+ : undefined
94
+
95
+ if (currentApp === undefined || app.slug !== currentApp.slug) {
96
+ const imgPayload =
97
+ imgRef &&
98
+ JSON.stringify({
99
+ ...imgRef.getBoundingClientRect().toJSON()
100
+ })
101
+
102
+ return {
103
+ onClick: event => {
104
+ event.preventDefault()
105
+
106
+ context
107
+ ? context.call('openApp', href, app, imgPayload)
108
+ : logger.error(
109
+ `Failed to "openApp(${app})". WebviewService has the following falsy value "${context}" in AppLinker's context.`
110
+ )
111
+ },
112
+ href: '#'
113
+ }
107
114
  }
108
115
  }
109
116
 
@@ -234,7 +241,7 @@ AppLinker.propTypes = {
234
241
  }).isRequired
235
242
  }
236
243
 
237
- export default AppLinker
244
+ export default withClient(AppLinker)
238
245
  export {
239
246
  NATIVE_APP_INFOS,
240
247
  getUniversalLinkDomain,
@@ -1,23 +1,24 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render } from '@testing-library/react'
3
+ import userEvent from '@testing-library/user-event'
4
+
3
5
  import {
4
6
  isMobileApp,
5
7
  isMobile,
6
8
  openDeeplinkOrRedirect,
7
9
  startApp,
8
- isAndroid
10
+ isAndroid,
11
+ checkApp
9
12
  } from 'cozy-device-helper'
10
13
 
11
14
  import AppLinker from './index'
12
15
  import { generateUniversalLink } from './native'
13
16
  jest.useFakeTimers()
14
17
 
15
- const tMock = x => x
16
-
17
- class AppItem extends React.Component {
18
- render() {
19
- const { app, onAppSwitch } = this.props
20
- return (
18
+ const setup = ({ app, onAppSwitch }) => {
19
+ return {
20
+ user: userEvent.setup({ delay: null }),
21
+ ...render(
21
22
  <AppLinker onAppSwitch={onAppSwitch} href={'https://fake.link'} app={app}>
22
23
  {({ onClick, href, name }) => (
23
24
  <div>
@@ -30,6 +31,7 @@ class AppItem extends React.Component {
30
31
  )
31
32
  }
32
33
  }
34
+
33
35
  jest.mock('./native', () => ({
34
36
  ...jest.requireActual('./native'),
35
37
  generateUniversalLink: jest.fn()
@@ -41,7 +43,8 @@ jest.mock('cozy-device-helper', () => ({
41
43
  isMobile: jest.fn(),
42
44
  openDeeplinkOrRedirect: jest.fn(),
43
45
  startApp: jest.fn().mockResolvedValue(),
44
- isAndroid: jest.fn()
46
+ isAndroid: jest.fn(),
47
+ checkApp: jest.fn()
45
48
  }))
46
49
 
47
50
  const app = {
@@ -50,7 +53,7 @@ const app = {
50
53
  }
51
54
 
52
55
  describe('app icon', () => {
53
- let spyConsoleError, openNativeFromNativeSpy, appSwitchMock
56
+ let spyConsoleError, appSwitchMock
54
57
 
55
58
  beforeEach(() => {
56
59
  isMobileApp.mockReturnValue(false)
@@ -60,7 +63,6 @@ describe('app icon', () => {
60
63
  throw new Error(message)
61
64
  }
62
65
  })
63
- openNativeFromNativeSpy = jest.spyOn(AppLinker, 'openNativeFromNative')
64
66
  isMobileApp.mockReturnValue(false)
65
67
  isMobile.mockReturnValue(false)
66
68
  isAndroid.mockReturnValue(false)
@@ -73,20 +75,25 @@ describe('app icon', () => {
73
75
  })
74
76
 
75
77
  it('should render correctly', () => {
76
- const root = shallow(<AppItem t={tMock} app={app} />).dive()
77
- expect(root.getElement()).toMatchSnapshot()
78
+ const { container } = setup({ app })
79
+ expect(container).toMatchSnapshot()
78
80
  })
79
81
 
80
- it('should work for native -> native', () => {
81
- const root = shallow(
82
- <AppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
83
- ).dive()
84
- root.find('a').simulate('click')
82
+ it('should work for web -> web', async () => {
83
+ isMobileApp.mockReturnValue(false)
84
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
85
+ const link = container.querySelector('a')
86
+ await user.click(link)
85
87
  expect(appSwitchMock).not.toHaveBeenCalled()
88
+ expect(startApp).not.toHaveBeenCalled()
89
+ })
90
+
91
+ it('should work for native -> native', async () => {
86
92
  isMobileApp.mockReturnValue(true)
87
- root.setState({ nativeAppIsAvailable: true })
88
- root.find('a').simulate('click')
89
- expect(openNativeFromNativeSpy).toHaveBeenCalled()
93
+ checkApp.mockResolvedValue(true)
94
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
95
+ const link = container.querySelector('a')
96
+ await user.click(link)
90
97
  expect(startApp).toHaveBeenCalledWith({
91
98
  appId: 'io.cozy.drive.mobile',
92
99
  name: 'Cozy Drive',
@@ -95,13 +102,12 @@ describe('app icon', () => {
95
102
  expect(appSwitchMock).toHaveBeenCalled()
96
103
  })
97
104
 
98
- it('should work for web -> native for Android (custom schema) ', () => {
105
+ it('should work for web -> native for Android (custom schema) ', async () => {
99
106
  isMobile.mockReturnValue(true)
100
107
  isAndroid.mockResolvedValue(true)
101
- const root = shallow(
102
- <AppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
103
- ).dive()
104
- root.find('a').simulate('click', { preventDefault: () => {} })
108
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
109
+ const link = container.querySelector('a')
110
+ await user.click(link)
105
111
  expect(openDeeplinkOrRedirect).toHaveBeenCalledWith(
106
112
  'cozydrive://',
107
113
  expect.any(Function)
@@ -109,39 +115,39 @@ describe('app icon', () => {
109
115
  expect(appSwitchMock).toHaveBeenCalled()
110
116
  })
111
117
 
112
- it('should work for web -> native for iOS (universal link)', () => {
118
+ it('should work for web -> native for iOS (universal link)', async () => {
113
119
  isMobile.mockReturnValue(true)
114
- const root = shallow(
115
- <AppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
116
- ).dive()
117
- root.find('a').simulate('click', { preventDefault: () => {} })
120
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
121
+ const link = container.querySelector('a')
122
+ await user.click(link)
118
123
 
119
124
  expect(generateUniversalLink).toHaveBeenCalled()
120
125
  })
121
126
 
122
- it('should work for native -> web', () => {
127
+ it('should work for native -> web', async () => {
123
128
  isMobileApp.mockReturnValue(true)
124
- const root = shallow(
125
- <AppItem t={tMock} app={app} onAppSwitch={appSwitchMock} />
126
- ).dive()
127
- root.find('a').simulate('click')
129
+ const { container, user } = setup({ app, onAppSwitch: appSwitchMock })
130
+ const link = container.querySelector('a')
131
+ await user.click(link)
128
132
  expect(appSwitchMock).toHaveBeenCalled()
129
133
  })
130
134
 
131
135
  it('should not crash if no href', () => {
132
136
  isMobileApp.mockReturnValue(true)
133
137
  spyConsoleError.mockImplementation(() => {})
134
- const root = shallow(
138
+ const { container } = render(
135
139
  <AppLinker onAppSwitch={appSwitchMock} app={app}>
136
- {({ onClick, href, name }) => (
137
- <div>
138
- <a href={href} onClick={onClick}>
139
- Open {name}
140
- </a>
141
- </div>
142
- )}
140
+ {({ onClick, href, name }) => {
141
+ return (
142
+ <div>
143
+ <a href={href} onClick={onClick}>
144
+ Open {name}
145
+ </a>
146
+ </div>
147
+ )
148
+ }}
143
149
  </AppLinker>
144
150
  )
145
- expect(root.getElement()).toMatchSnapshot()
151
+ expect(container).toMatchSnapshot()
146
152
  })
147
153
  })
@@ -154,11 +154,10 @@ const BottomSheet = ({
154
154
  ANIMATION_DURATION,
155
155
  isClosable && isBottomPosition
156
156
  )
157
+ const innerContentHeight = innerContentRef?.current?.offsetHeight ?? 0
157
158
 
158
159
  useEffect(() => {
159
160
  const headerContent = headerContentRef.current
160
- const innerContent = innerContentRef.current
161
- const innerContentHeight = innerContent.offsetHeight
162
161
  const actionButtonsHeight = headerContent
163
162
  ? parseFloat(getComputedStyle(headerContent).getPropertyValue('height'))
164
163
  : 0
@@ -192,7 +191,7 @@ const BottomSheet = ({
192
191
  // Used so that the BottomSheet can be opened to the top without stopping at the content height
193
192
  setBottomSpacerHeight(bottomSpacerHeight)
194
193
  }, [
195
- innerContentRef,
194
+ innerContentHeight,
196
195
  toolbarProps,
197
196
  mediumHeightRatio,
198
197
  mediumHeight,
@@ -1,7 +1,7 @@
1
1
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/bill.svg` to regenerate;
2
2
  import React from 'react'
3
3
 
4
- function SvgBill(props) {
4
+ function SvgBillPermissions(props) {
5
5
  return (
6
6
  <svg viewBox="0 0 48 48" {...props}>
7
7
  <g fill="none" fillRule="evenodd">
@@ -22,4 +22,4 @@ function SvgBill(props) {
22
22
  )
23
23
  }
24
24
 
25
- export default SvgBill
25
+ export default SvgBillPermissions
@@ -1,7 +1,7 @@
1
1
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/calendar.svg` to regenerate;
2
2
  import React from 'react'
3
3
 
4
- function SvgCalendar(props) {
4
+ function SvgCalendarPermissions(props) {
5
5
  return (
6
6
  <svg viewBox="0 0 48 48" fill="none" {...props}>
7
7
  <rect y={4} width={48} height={44} rx={8} fill="#D1D5DB" />
@@ -17,4 +17,4 @@ function SvgCalendar(props) {
17
17
  )
18
18
  }
19
19
 
20
- export default SvgCalendar
20
+ export default SvgCalendarPermissions
@@ -1,7 +1,7 @@
1
1
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/certified.svg` to regenerate;
2
2
  import React from 'react'
3
3
 
4
- function SvgCertified(props) {
4
+ function SvgCertifiedPermissions(props) {
5
5
  return (
6
6
  <svg viewBox="0 0 48 48" {...props}>
7
7
  <g fill="none" fillRule="evenodd" transform="translate(6)">
@@ -19,4 +19,4 @@ function SvgCertified(props) {
19
19
  )
20
20
  }
21
21
 
22
- export default SvgCertified
22
+ export default SvgCertifiedPermissions
@@ -1,7 +1,7 @@
1
1
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/home.svg` to regenerate;
2
2
  import React from 'react'
3
3
 
4
- function SvgHome(props) {
4
+ function SvgHomePermissions(props) {
5
5
  return (
6
6
  <svg viewBox="0 0 48 48" {...props}>
7
7
  <g fill="none" fillRule="evenodd">
@@ -15,4 +15,4 @@ function SvgHome(props) {
15
15
  )
16
16
  }
17
17
 
18
- export default SvgHome
18
+ export default SvgHomePermissions
@@ -1,7 +1,7 @@
1
1
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/location.svg` to regenerate;
2
2
  import React from 'react'
3
3
 
4
- function SvgLocation(props) {
4
+ function SvgLocationPermissions(props) {
5
5
  return (
6
6
  <svg viewBox="0 0 16 16" {...props}>
7
7
  <path
@@ -13,4 +13,4 @@ function SvgLocation(props) {
13
13
  )
14
14
  }
15
15
 
16
- export default SvgLocation
16
+ export default SvgLocationPermissions
@@ -1,7 +1,7 @@
1
1
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/safe.svg` to regenerate;
2
2
  import React from 'react'
3
3
 
4
- function SvgSafe(props) {
4
+ function SvgSafePermissions(props) {
5
5
  return (
6
6
  <svg viewBox="0 0 48 48" {...props}>
7
7
  <g fill="none" fillRule="evenodd">
@@ -22,4 +22,4 @@ function SvgSafe(props) {
22
22
  )
23
23
  }
24
24
 
25
- export default SvgSafe
25
+ export default SvgSafePermissions
@@ -5745,7 +5745,7 @@ exports[`Icon should render examples: Icon 4`] = `
5745
5745
  <path stroke=\\"#5d6165\\" stroke-width=\\"2\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" d=\\"M35 41H13V17h22zM13 22h22m-22 6h22m-22 6h22M20 17v24\\"></path>
5746
5746
  </g>
5747
5747
  </svg>
5748
- <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">Bill</p>
5748
+ <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">BillPermissions</p>
5749
5749
  </div>
5750
5750
  <div class=\\"makeStyles-iconTile-108 u-ta-center u-mb-1\\"><svg viewBox=\\"0 0 48 48\\" fill=\\"none\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\">
5751
5751
  <path fill-rule=\\"evenodd\\" clip-rule=\\"evenodd\\" d=\\"M0 2.996A2.992 2.992 0 013.003 0h41.994A3 3 0 0148 2.996v33.008A3.006 3.006 0 0145.009 39H27L9 48v-9H3c-1.657 0-3-1.343-3-2.995V2.995z\\" fill=\\"#D6D8DA\\"></path>
@@ -5758,7 +5758,7 @@ exports[`Icon should render examples: Icon 4`] = `
5758
5758
  <path d=\\"M0 12a8 8 0 018-8h32a8 8 0 018 8v4H0v-4zm6 15a3 3 0 116 0 3 3 0 01-6 0zm3 7a3 3 0 100 6 3 3 0 000-6zm7-7a3 3 0 116 0 3 3 0 01-6 0zm3 7a3 3 0 100 6 3 3 0 000-6zm7-7a3 3 0 116 0 3 3 0 01-6 0zm3 7a3 3 0 100 6 3 3 0 000-6zm7-7a3 3 0 116 0 3 3 0 01-6 0zm3 7a3 3 0 100 6 3 3 0 000-6z\\" fill=\\"#5D6165\\"></path>
5759
5759
  <path d=\\"M12 0a3 3 0 00-3 3v6a3 3 0 106 0V3a3 3 0 00-3-3zm24 0a3 3 0 00-3 3v6a3 3 0 106 0V3a3 3 0 00-3-3z\\" fill=\\"#95999D\\"></path>
5760
5760
  </svg>
5761
- <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">Calendar</p>
5761
+ <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">CalendarPermissions</p>
5762
5762
  </div>
5763
5763
  <div class=\\"makeStyles-iconTile-108 u-ta-center u-mb-1\\"><svg viewBox=\\"0 0 48 48\\" fill=\\"none\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\">
5764
5764
  <path fill-rule=\\"evenodd\\" clip-rule=\\"evenodd\\" d=\\"M21 48C9.402 48 0 38.598 0 27S9.402 6 21 6v21h21c0 11.598-9.402 21-21 21z\\" fill=\\"#D6D8DA\\"></path>
@@ -5773,7 +5773,7 @@ exports[`Icon should render examples: Icon 4`] = `
5773
5773
  <circle cx=\\"18\\" cy=\\"18\\" r=\\"9\\" fill=\\"#D6D8DA\\"></circle>
5774
5774
  </g>
5775
5775
  </svg>
5776
- <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">Certified</p>
5776
+ <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">CertifiedPermissions</p>
5777
5777
  </div>
5778
5778
  <div class=\\"makeStyles-iconTile-108 u-ta-center u-mb-1\\"><svg viewBox=\\"0 0 48 48\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\">
5779
5779
  <g fill=\\"none\\" fill-rule=\\"evenodd\\">
@@ -5897,7 +5897,7 @@ exports[`Icon should render examples: Icon 4`] = `
5897
5897
  <path fill=\\"#d6d8da\\" d=\\"M14 33h8v14h-8z\\"></path>
5898
5898
  </g>
5899
5899
  </svg>
5900
- <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">Home</p>
5900
+ <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">HomePermissions</p>
5901
5901
  </div>
5902
5902
  <div class=\\"makeStyles-iconTile-108 u-ta-center u-mb-1\\"><svg viewBox=\\"0 0 48 48\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\">
5903
5903
  <g fill=\\"none\\" fill-rule=\\"evenodd\\">
@@ -5928,7 +5928,7 @@ exports[`Icon should render examples: Icon 4`] = `
5928
5928
  <div class=\\"makeStyles-iconTile-108 u-ta-center u-mb-1\\"><svg viewBox=\\"0 0 16 16\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\">
5929
5929
  <path d=\\"M8 0c3.99 0 7 2.866 7 6.667 0 4.782-6.508 9.089-6.784 9.27a.398.398 0 01-.432 0C7.507 15.756 1 11.45 1 6.667 1 2.866 4.01 0 8 0zm0 9a2.5 2.5 0 100-5 2.5 2.5 0 000 5z\\" fill=\\"#5d6165\\" fill-rule=\\"evenodd\\"></path>
5930
5930
  </svg>
5931
- <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">Location</p>
5931
+ <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">LocationPermissions</p>
5932
5932
  </div>
5933
5933
  <div class=\\"makeStyles-iconTile-108 u-ta-center u-mb-1\\"><svg viewBox=\\"0 0 48 48\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\">
5934
5934
  <g fill=\\"none\\" fill-rule=\\"evenodd\\">
@@ -6020,7 +6020,7 @@ exports[`Icon should render examples: Icon 4`] = `
6020
6020
  <path fill=\\"#5D6165\\" d=\\"M24 34a11.5 11.5 0 100-23 11.5 11.5 0 000 23zm-7.92-7.07l-2.25 1-.67-1.5 2.25-1a.82.82 0 11.67 1.5zm5.45 4.3l-.88 2.3-1.54-.59.89-2.3a.82.82 0 111.53.59zm-5.2-11.67a.82.82 0 01-1.06.47l-2.3-.88.59-1.54 2.3.89c.42.16.63.63.47 1.06zM27 21.16a3.29 3.29 0 11-6 2.68 3.29 3.29 0 016-2.68zm2.43 11.51l-1.5.67-1-2.25a.82.82 0 111.5-.67l1 2.25zM20.66 15c-.42.18-.9 0-1.09-.42l-1-2.25 1.5-.67 1 2.25c.19.42 0 .9-.41 1.09zm14.37 10.85l-.59 1.54-2.3-.89a.82.82 0 11.59-1.53l2.3.88zm-6.14-13.8l-.89 2.3a.82.82 0 11-1.53-.58l.88-2.3 1.54.59zm5.95 6.52l-2.25 1a.82.82 0 11-.67-1.5l2.25-1 .67 1.5z\\"></path>
6021
6021
  </g>
6022
6022
  </svg>
6023
- <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">Safe</p>
6023
+ <p class=\\"MuiTypography-root u-mt-half MuiTypography-body1 MuiTypography-colorTextPrimary\\">SafePermissions</p>
6024
6024
  </div>
6025
6025
  <div class=\\"makeStyles-iconTile-108 u-ta-center u-mb-1\\"><svg viewBox=\\"0 0 48 48\\" class=\\"styles__icon___23x3R\\" width=\\"16\\" height=\\"16\\">
6026
6026
  <g fill=\\"#5d6165\\" fill-rule=\\"evenodd\\">
@@ -19,6 +19,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
19
19
 
20
20
  import React from 'react';
21
21
  import PropTypes from 'prop-types';
22
+ import { withClient } from 'cozy-client';
22
23
  import { checkApp, startApp, isMobileApp, isMobile, openDeeplinkOrRedirect, isAndroid, isFlagshipApp } from 'cozy-device-helper';
23
24
  import { WebviewContext } from 'cozy-intent';
24
25
  import logger from 'cozy-logger';
@@ -150,6 +151,7 @@ export var AppLinker = /*#__PURE__*/function (_React$Component) {
150
151
  key: "getOnClickHref",
151
152
  value: function getOnClickHref(props, nativeAppIsAvailable, context, imgRef) {
152
153
  var app = props.app,
154
+ client = props.client,
153
155
  nativePath = props.nativePath;
154
156
  var slug = AppLinker.getSlug(props);
155
157
  var href = props.href;
@@ -158,14 +160,19 @@ export var AppLinker = /*#__PURE__*/function (_React$Component) {
158
160
  var appInfo = NATIVE_APP_INFOS[slug];
159
161
 
160
162
  if (isFlagshipApp()) {
161
- var imgPayload = imgRef && JSON.stringify(_objectSpread({}, imgRef.getBoundingClientRect().toJSON()));
162
- return {
163
- onClick: function onClick(event) {
164
- event.preventDefault();
165
- context ? context.call('openApp', href, app, imgPayload) : logger.error("Failed to \"openApp(".concat(app, ")\". WebviewService has the following falsy value \"").concat(context, "\" in AppLinker's context."));
166
- },
167
- href: '#'
168
- };
163
+ var _ref = client ? client.getInstanceOptions() : undefined,
164
+ currentApp = _ref.app;
165
+
166
+ if (currentApp === undefined || app.slug !== currentApp.slug) {
167
+ var imgPayload = imgRef && JSON.stringify(_objectSpread({}, imgRef.getBoundingClientRect().toJSON()));
168
+ return {
169
+ onClick: function onClick(event) {
170
+ event.preventDefault();
171
+ context ? context.call('openApp', href, app, imgPayload) : logger.error("Failed to \"openApp(".concat(app, ")\". WebviewService has the following falsy value \"").concat(context, "\" in AppLinker's context."));
172
+ },
173
+ href: '#'
174
+ };
175
+ }
169
176
  }
170
177
 
171
178
  if (usingNativeApp) {
@@ -290,5 +297,5 @@ AppLinker.propTypes = {
290
297
  })
291
298
  }).isRequired
292
299
  };
293
- export default AppLinker;
300
+ export default withClient(AppLinker);
294
301
  export { NATIVE_APP_INFOS, getUniversalLinkDomain, generateWebLink, generateUniversalLink };
@@ -75,6 +75,8 @@ var defaultSettings = {
75
75
  };
76
76
 
77
77
  var BottomSheet = function BottomSheet(_ref2) {
78
+ var _innerContentRef$curr, _innerContentRef$curr2;
79
+
78
80
  var toolbarProps = _ref2.toolbarProps,
79
81
  settings = _ref2.settings,
80
82
  backdrop = _ref2.backdrop,
@@ -177,10 +179,9 @@ var BottomSheet = function BottomSheet(_ref2) {
177
179
  useTimeoutWhen(function () {
178
180
  return handleClose();
179
181
  }, ANIMATION_DURATION, isClosable && isBottomPosition);
182
+ var innerContentHeight = (_innerContentRef$curr = innerContentRef === null || innerContentRef === void 0 ? void 0 : (_innerContentRef$curr2 = innerContentRef.current) === null || _innerContentRef$curr2 === void 0 ? void 0 : _innerContentRef$curr2.offsetHeight) !== null && _innerContentRef$curr !== void 0 ? _innerContentRef$curr : 0;
180
183
  useEffect(function () {
181
184
  var headerContent = headerContentRef.current;
182
- var innerContent = innerContentRef.current;
183
- var innerContentHeight = innerContent.offsetHeight;
184
185
  var actionButtonsHeight = headerContent ? parseFloat(getComputedStyle(headerContent).getPropertyValue('height')) : 0;
185
186
  var actionButtonsBottomMargin = headerContent ? parseFloat(getComputedStyle(headerContent).getPropertyValue('padding-bottom')) : 0;
186
187
  var maxHeight = computeMaxHeight(toolbarProps);
@@ -207,7 +208,7 @@ var BottomSheet = function BottomSheet(_ref2) {
207
208
  setInitPos(computedMediumHeight); // Used so that the BottomSheet can be opened to the top without stopping at the content height
208
209
 
209
210
  setBottomSpacerHeight(bottomSpacerHeight);
210
- }, [innerContentRef, toolbarProps, mediumHeightRatio, mediumHeight, showBackdrop, backdrop, isClosable]);
211
+ }, [innerContentHeight, toolbarProps, mediumHeightRatio, mediumHeight, showBackdrop, backdrop, isClosable]);
211
212
  return /*#__PURE__*/React.createElement(React.Fragment, null, getFlagshipMetadata().immersive && /*#__PURE__*/React.createElement("span", {
212
213
  style: styles.flagshipImmersive
213
214
  }), /*#__PURE__*/React.createElement(BackdropOrFragment, {
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/bill.svg` to regenerate;
3
3
  import React from 'react';
4
4
 
5
- function SvgBill(props) {
5
+ function SvgBillPermissions(props) {
6
6
  return /*#__PURE__*/React.createElement("svg", _extends({
7
7
  viewBox: "0 0 48 48"
8
8
  }, props), /*#__PURE__*/React.createElement("g", {
@@ -23,4 +23,4 @@ function SvgBill(props) {
23
23
  })));
24
24
  }
25
25
 
26
- export default SvgBill;
26
+ export default SvgBillPermissions;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/calendar.svg` to regenerate;
3
3
  import React from 'react';
4
4
 
5
- function SvgCalendar(props) {
5
+ function SvgCalendarPermissions(props) {
6
6
  return /*#__PURE__*/React.createElement("svg", _extends({
7
7
  viewBox: "0 0 48 48",
8
8
  fill: "none"
@@ -21,4 +21,4 @@ function SvgCalendar(props) {
21
21
  }));
22
22
  }
23
23
 
24
- export default SvgCalendar;
24
+ export default SvgCalendarPermissions;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/certified.svg` to regenerate;
3
3
  import React from 'react';
4
4
 
5
- function SvgCertified(props) {
5
+ function SvgCertifiedPermissions(props) {
6
6
  return /*#__PURE__*/React.createElement("svg", _extends({
7
7
  viewBox: "0 0 48 48"
8
8
  }, props), /*#__PURE__*/React.createElement("g", {
@@ -23,4 +23,4 @@ function SvgCertified(props) {
23
23
  })));
24
24
  }
25
25
 
26
- export default SvgCertified;
26
+ export default SvgCertifiedPermissions;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/home.svg` to regenerate;
3
3
  import React from 'react';
4
4
 
5
- function SvgHome(props) {
5
+ function SvgHomePermissions(props) {
6
6
  return /*#__PURE__*/React.createElement("svg", _extends({
7
7
  viewBox: "0 0 48 48"
8
8
  }, props), /*#__PURE__*/React.createElement("g", {
@@ -17,4 +17,4 @@ function SvgHome(props) {
17
17
  })));
18
18
  }
19
19
 
20
- export default SvgHome;
20
+ export default SvgHomePermissions;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/location.svg` to regenerate;
3
3
  import React from 'react';
4
4
 
5
- function SvgLocation(props) {
5
+ function SvgLocationPermissions(props) {
6
6
  return /*#__PURE__*/React.createElement("svg", _extends({
7
7
  viewBox: "0 0 16 16"
8
8
  }, props), /*#__PURE__*/React.createElement("path", {
@@ -12,4 +12,4 @@ function SvgLocation(props) {
12
12
  }));
13
13
  }
14
14
 
15
- export default SvgLocation;
15
+ export default SvgLocationPermissions;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  // Automatically created, please run `scripts/generate-svgr-icon.sh /Users/vdnj/Documents/CozyCloud/cozy-ui/assets/icons/ui/permissions/safe.svg` to regenerate;
3
3
  import React from 'react';
4
4
 
5
- function SvgSafe(props) {
5
+ function SvgSafePermissions(props) {
6
6
  return /*#__PURE__*/React.createElement("svg", _extends({
7
7
  viewBox: "0 0 48 48"
8
8
  }, props), /*#__PURE__*/React.createElement("g", {
@@ -20,4 +20,4 @@ function SvgSafe(props) {
20
20
  })));
21
21
  }
22
22
 
23
- export default SvgSafe;
23
+ export default SvgSafePermissions;