cozy-ui 60.9.1 → 60.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [60.10.0](https://github.com/cozy/cozy-ui/compare/v60.9.1...v60.10.0) (2022-01-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Update cozy-intent and device helper ([87d612c](https://github.com/cozy/cozy-ui/commit/87d612c))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Inject webviewService into BarContext ([b6c269f](https://github.com/cozy/cozy-ui/commit/b6c269f))
|
|
12
|
+
* Update BarContext testing ([15803f4](https://github.com/cozy/cozy-ui/commit/15803f4))
|
|
13
|
+
* Upgrade cozy-intent to latest ([8653ad1](https://github.com/cozy/cozy-ui/commit/8653ad1))
|
|
14
|
+
|
|
1
15
|
## [60.9.1](https://github.com/cozy/cozy-ui/compare/v60.9.0...v60.9.1) (2022-01-27)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -162,6 +176,7 @@
|
|
|
162
176
|
|
|
163
177
|
* cozy-intent@1.1.2 or later is now required
|
|
164
178
|
otherwise, AppLinker will crash
|
|
179
|
+
* Wrap your App in the WebviewIntentProvider (via import { WebviewIntentProvider } from 'cozy-intent)
|
|
165
180
|
|
|
166
181
|
## [58.5.1](https://github.com/cozy/cozy-ui/compare/v58.5.0...v58.5.1) (2022-01-07)
|
|
167
182
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "60.
|
|
3
|
+
"version": "60.10.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"commitlint-config-cozy": "0.6.0",
|
|
90
90
|
"copyfiles": "2.1.1",
|
|
91
91
|
"cozy-client": "^27.5.1",
|
|
92
|
-
"cozy-device-helper": "^1.16.
|
|
92
|
+
"cozy-device-helper": "^1.16.1",
|
|
93
93
|
"cozy-doctypes": "^1.69.0",
|
|
94
94
|
"cozy-harvest-lib": "^6.7.3",
|
|
95
|
-
"cozy-intent": "^1.
|
|
95
|
+
"cozy-intent": "^1.6.0",
|
|
96
96
|
"cozy-sharing": "^3.10.0",
|
|
97
97
|
"css-loader": "0.28.11",
|
|
98
98
|
"cssnano": "4.1.11",
|
|
@@ -6,16 +6,29 @@ import { CozyProvider } from 'cozy-client'
|
|
|
6
6
|
import { Provider } from 'react-redux'
|
|
7
7
|
import { WebviewIntentProvider } from 'cozy-intent'
|
|
8
8
|
|
|
9
|
-
const BarContextProvider =
|
|
10
|
-
|
|
9
|
+
const BarContextProvider = ({
|
|
10
|
+
children,
|
|
11
|
+
store,
|
|
12
|
+
client,
|
|
13
|
+
f,
|
|
14
|
+
t,
|
|
15
|
+
lang,
|
|
16
|
+
webviewService
|
|
17
|
+
}) => {
|
|
18
|
+
if (!children) return null
|
|
19
|
+
|
|
11
20
|
return (
|
|
12
|
-
<Provider store={
|
|
13
|
-
<CozyProvider client={
|
|
14
|
-
<I18nContext.Provider
|
|
15
|
-
value={{ f: props.f, t: props.t, lang: props.lang }}
|
|
16
|
-
>
|
|
21
|
+
<Provider store={store}>
|
|
22
|
+
<CozyProvider client={client}>
|
|
23
|
+
<I18nContext.Provider value={{ f, t, lang }}>
|
|
17
24
|
<BreakpointsProvider>
|
|
18
|
-
|
|
25
|
+
{webviewService ? (
|
|
26
|
+
<WebviewIntentProvider webviewService={webviewService}>
|
|
27
|
+
{children}
|
|
28
|
+
</WebviewIntentProvider>
|
|
29
|
+
) : (
|
|
30
|
+
children
|
|
31
|
+
)}
|
|
19
32
|
</BreakpointsProvider>
|
|
20
33
|
</I18nContext.Provider>
|
|
21
34
|
</CozyProvider>
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { Provider, useStore } from 'react-redux'
|
|
3
|
+
import configureStore from 'redux-mock-store'
|
|
4
|
+
import { render } from '@testing-library/react'
|
|
2
5
|
|
|
6
|
+
import { useWebviewIntent } from 'cozy-intent'
|
|
3
7
|
import CozyClient, {
|
|
4
8
|
createMockClient,
|
|
5
9
|
CozyProvider,
|
|
6
10
|
useClient
|
|
7
11
|
} from 'cozy-client'
|
|
8
|
-
import configureStore from 'redux-mock-store'
|
|
9
|
-
import { Provider, useStore } from 'react-redux'
|
|
10
|
-
import { isFlagshipApp } from 'cozy-device-helper'
|
|
11
12
|
|
|
12
13
|
import BarContextProvider from '.'
|
|
13
14
|
import I18n, { useI18n, translate } from '../I18n'
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}))
|
|
18
|
-
|
|
16
|
+
const mockWebviewService = { foo: 'bar' }
|
|
17
|
+
const mockVoidWebviewService = 'No context'
|
|
19
18
|
const locales = { helloworld: 'Hello World !' }
|
|
20
19
|
const localesBar = { a: 'b' }
|
|
21
20
|
|
|
@@ -29,6 +28,20 @@ const DumbHelloWorld = translate()(({ t, f, lang }) => (
|
|
|
29
28
|
</div>
|
|
30
29
|
))
|
|
31
30
|
|
|
31
|
+
const IntentComponent = () => {
|
|
32
|
+
let webviewIntent
|
|
33
|
+
let render
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
webviewIntent = useWebviewIntent()
|
|
37
|
+
render = webviewIntent.foo
|
|
38
|
+
} catch {
|
|
39
|
+
render = mockVoidWebviewService
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return <main>{render}</main>
|
|
43
|
+
}
|
|
44
|
+
|
|
32
45
|
const MockedBar = props => {
|
|
33
46
|
const client = new CozyClient({})
|
|
34
47
|
return (
|
|
@@ -40,53 +53,146 @@ const MockedBar = props => {
|
|
|
40
53
|
)
|
|
41
54
|
}
|
|
42
55
|
|
|
43
|
-
const App = () => {
|
|
56
|
+
const App = ({ children, webviewService }) => {
|
|
44
57
|
const { t, f, lang } = useI18n()
|
|
45
58
|
const client = useClient()
|
|
46
59
|
const store = useStore()
|
|
60
|
+
|
|
47
61
|
return (
|
|
48
62
|
<MockedBar>
|
|
49
|
-
<BarContextProvider
|
|
50
|
-
|
|
63
|
+
<BarContextProvider
|
|
64
|
+
t={t}
|
|
65
|
+
f={f}
|
|
66
|
+
lang={lang}
|
|
67
|
+
client={client}
|
|
68
|
+
store={store}
|
|
69
|
+
webviewService={webviewService}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
51
72
|
</BarContextProvider>
|
|
52
73
|
</MockedBar>
|
|
53
74
|
)
|
|
54
75
|
}
|
|
55
76
|
|
|
56
77
|
describe('BarContextProvider', () => {
|
|
78
|
+
afterAll(() => {
|
|
79
|
+
window.cozy = undefined
|
|
80
|
+
})
|
|
81
|
+
|
|
57
82
|
it('should provide the right (aka app not the one from the bar) t/f/store/client to the DumbHelloWorld', () => {
|
|
58
83
|
const client = createMockClient({})
|
|
59
84
|
const mockStore = configureStore()
|
|
60
85
|
const store = mockStore(x => x)
|
|
61
|
-
|
|
86
|
+
|
|
87
|
+
const { queryByText } = render(
|
|
88
|
+
<Provider store={store}>
|
|
89
|
+
<CozyProvider client={client}>
|
|
90
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
91
|
+
<App>
|
|
92
|
+
<DumbHelloWorld />
|
|
93
|
+
</App>
|
|
94
|
+
</I18n>
|
|
95
|
+
</CozyProvider>
|
|
96
|
+
</Provider>
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
expect(queryByText('<div>Hello World !<br>6 Jan<br>en</div>')).toBeDefined()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('should render nothing when no children is provided', () => {
|
|
103
|
+
const { container } = render(<BarContextProvider />)
|
|
104
|
+
expect(container.firstChild).toBeNull()
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should work without a cozy-intent context', () => {
|
|
108
|
+
// Set App Amirale context
|
|
109
|
+
window.cozy.isFlagshipApp = true
|
|
110
|
+
|
|
111
|
+
const client = createMockClient({})
|
|
112
|
+
const mockStore = configureStore()
|
|
113
|
+
const store = mockStore(x => x)
|
|
114
|
+
|
|
115
|
+
const { queryByText } = render(
|
|
62
116
|
<Provider store={store}>
|
|
63
117
|
<CozyProvider client={client}>
|
|
64
118
|
<I18n lang="en" dictRequire={() => locales}>
|
|
65
|
-
<App
|
|
119
|
+
<App>
|
|
120
|
+
<IntentComponent />
|
|
121
|
+
</App>
|
|
66
122
|
</I18n>
|
|
67
123
|
</CozyProvider>
|
|
68
124
|
</Provider>
|
|
69
125
|
)
|
|
70
|
-
|
|
126
|
+
|
|
127
|
+
expect(queryByText(mockVoidWebviewService)).toBeInTheDocument()
|
|
71
128
|
})
|
|
72
129
|
|
|
73
|
-
it('should try to provide a cozy-intent context',
|
|
130
|
+
it('should not try to provide a cozy-intent context if one is provided', () => {
|
|
131
|
+
// Set App Amirale context
|
|
132
|
+
window.cozy.isFlagshipApp = true
|
|
133
|
+
|
|
74
134
|
const client = createMockClient({})
|
|
75
135
|
const mockStore = configureStore()
|
|
76
136
|
const store = mockStore(x => x)
|
|
77
|
-
|
|
137
|
+
|
|
138
|
+
const { queryByText } = render(
|
|
139
|
+
<Provider store={store}>
|
|
140
|
+
<CozyProvider client={client}>
|
|
141
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
142
|
+
<App webviewService={mockWebviewService}>
|
|
143
|
+
<IntentComponent />
|
|
144
|
+
</App>
|
|
145
|
+
</I18n>
|
|
146
|
+
</CozyProvider>
|
|
147
|
+
</Provider>
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
expect(queryByText(mockWebviewService.foo)).toBeInTheDocument()
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('should work without a cozy-intent context', () => {
|
|
154
|
+
// Set Web context
|
|
155
|
+
window.cozy.isFlagshipApp = false
|
|
156
|
+
|
|
157
|
+
const client = createMockClient({})
|
|
158
|
+
const mockStore = configureStore()
|
|
159
|
+
const store = mockStore(x => x)
|
|
160
|
+
|
|
161
|
+
const { queryByText } = render(
|
|
162
|
+
<Provider store={store}>
|
|
163
|
+
<CozyProvider client={client}>
|
|
164
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
165
|
+
<App>
|
|
166
|
+
<IntentComponent />
|
|
167
|
+
</App>
|
|
168
|
+
</I18n>
|
|
169
|
+
</CozyProvider>
|
|
170
|
+
</Provider>
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
expect(queryByText(mockVoidWebviewService)).toBeInTheDocument()
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('should not try to provide a cozy-intent context if one is provided', () => {
|
|
177
|
+
// Set Web context
|
|
178
|
+
window.cozy.isFlagshipApp = false
|
|
179
|
+
|
|
180
|
+
const client = createMockClient({})
|
|
181
|
+
const mockStore = configureStore()
|
|
182
|
+
const store = mockStore(x => x)
|
|
183
|
+
|
|
184
|
+
const { queryByText } = render(
|
|
78
185
|
<Provider store={store}>
|
|
79
186
|
<CozyProvider client={client}>
|
|
80
187
|
<I18n lang="en" dictRequire={() => locales}>
|
|
81
|
-
<App
|
|
188
|
+
<App webviewService={mockWebviewService}>
|
|
189
|
+
<IntentComponent />
|
|
190
|
+
</App>
|
|
82
191
|
</I18n>
|
|
83
192
|
</CozyProvider>
|
|
84
193
|
</Provider>
|
|
85
194
|
)
|
|
86
195
|
|
|
87
|
-
|
|
88
|
-
// This is an easy way to test that the provider is working, albeit brittle
|
|
89
|
-
// A full test would need to mock cozy-intent, post-me and react-native
|
|
90
|
-
expect(isFlagshipApp).toHaveBeenCalled()
|
|
196
|
+
expect(queryByText(mockWebviewService.foo)).not.toBeInTheDocument()
|
|
91
197
|
})
|
|
92
198
|
})
|
|
@@ -5,19 +5,28 @@ import { CozyProvider } from 'cozy-client';
|
|
|
5
5
|
import { Provider } from 'react-redux';
|
|
6
6
|
import { WebviewIntentProvider } from 'cozy-intent';
|
|
7
7
|
|
|
8
|
-
var BarContextProvider = function BarContextProvider(
|
|
9
|
-
|
|
8
|
+
var BarContextProvider = function BarContextProvider(_ref) {
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
store = _ref.store,
|
|
11
|
+
client = _ref.client,
|
|
12
|
+
f = _ref.f,
|
|
13
|
+
t = _ref.t,
|
|
14
|
+
lang = _ref.lang,
|
|
15
|
+
webviewService = _ref.webviewService;
|
|
16
|
+
if (!children) return null;
|
|
10
17
|
return React.createElement(Provider, {
|
|
11
|
-
store:
|
|
18
|
+
store: store
|
|
12
19
|
}, React.createElement(CozyProvider, {
|
|
13
|
-
client:
|
|
20
|
+
client: client
|
|
14
21
|
}, React.createElement(I18nContext.Provider, {
|
|
15
22
|
value: {
|
|
16
|
-
f:
|
|
17
|
-
t:
|
|
18
|
-
lang:
|
|
23
|
+
f: f,
|
|
24
|
+
t: t,
|
|
25
|
+
lang: lang
|
|
19
26
|
}
|
|
20
|
-
}, React.createElement(BreakpointsProvider, null, React.createElement(WebviewIntentProvider,
|
|
27
|
+
}, React.createElement(BreakpointsProvider, null, webviewService ? React.createElement(WebviewIntentProvider, {
|
|
28
|
+
webviewService: webviewService
|
|
29
|
+
}, children) : children))));
|
|
21
30
|
};
|
|
22
31
|
|
|
23
32
|
export default BarContextProvider;
|