cozy-harvest-lib 14.1.0 → 14.2.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/.storybook/StoryContainer.tsx +47 -0
- package/.storybook/fixtures/AccountSelectorHeader.fixtures.ts +334 -0
- package/.storybook/main.ts +20 -0
- package/.storybook/preview-head.html +20 -0
- package/.storybook/preview.tsx +30 -0
- package/.storybook/public/Lato-Bold.immutable.woff2 +0 -0
- package/.storybook/public/Lato-Regular.immutable.woff2 +0 -0
- package/CHANGELOG.md +26 -0
- package/README.md +140 -4
- package/dist/components/AccountSelectBox/AccountSelectorHeader.js +1 -1
- package/dist/components/AccountSelectBox/AccountSelectorHeader.stories.js +31 -0
- package/dist/components/TriggerManager.js +11 -7
- package/dist/components/TriggerManager.spec.js +137 -75
- package/dist/helpers/konnectors.js +1 -1
- package/package.json +23 -4
- package/src/components/AccountSelectBox/AccountSelectorHeader.stories.ts +35 -0
- package/src/components/AccountSelectBox/AccountSelectorHeader.tsx +4 -3
- package/src/components/TriggerManager.jsx +10 -7
- package/src/components/TriggerManager.spec.jsx +52 -18
- package/src/cozy-ui.d.ts +15 -0
- package/src/helpers/konnectors.js +0 -1
- package/tsconfig.json +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react'
|
|
2
|
+
import { Provider as ReduxProvider } from 'react-redux'
|
|
3
|
+
|
|
4
|
+
import CozyClient, { CozyProvider as CozyClientProvider } from 'cozy-client'
|
|
5
|
+
import { useCozyDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
6
|
+
import I18n from 'cozy-ui/transpiled/react/I18n'
|
|
7
|
+
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
|
|
8
|
+
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'
|
|
9
|
+
import DialogContext from '../src/components/DialogContext'
|
|
10
|
+
import enLocale from '../src/locales/en.json'
|
|
11
|
+
|
|
12
|
+
const defaultClient = new CozyClient()
|
|
13
|
+
defaultClient.ensureStore()
|
|
14
|
+
|
|
15
|
+
export const StoryContainer = ({ children }: {children: ReactNode}) => {
|
|
16
|
+
return (
|
|
17
|
+
<CozyClientProvider client={defaultClient}>
|
|
18
|
+
<CozyTheme>
|
|
19
|
+
<BreakpointsProvider>
|
|
20
|
+
<DialogContextApp>
|
|
21
|
+
<I18n lang="en" dictRequire={() => enLocale}>
|
|
22
|
+
<ReduxProvider store={defaultClient.store}>
|
|
23
|
+
<div style={{position: "relative"}}>{children}</div>
|
|
24
|
+
</ReduxProvider>
|
|
25
|
+
</I18n>
|
|
26
|
+
</DialogContextApp>
|
|
27
|
+
</BreakpointsProvider>
|
|
28
|
+
</CozyTheme>
|
|
29
|
+
</CozyClientProvider>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const DialogContextApp = ({ children }: {children: ReactNode}) => {
|
|
34
|
+
const dialogContext = useCozyDialog({
|
|
35
|
+
size: 'l',
|
|
36
|
+
open: true,
|
|
37
|
+
onClose: null,
|
|
38
|
+
disableTitleAutoPadding: true
|
|
39
|
+
})
|
|
40
|
+
return (
|
|
41
|
+
<DialogContext.Provider value={dialogContext}>
|
|
42
|
+
{children}
|
|
43
|
+
</DialogContext.Provider>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
export const AccountSelectorHeaderFixtures = {
|
|
2
|
+
konnector: {
|
|
3
|
+
type: 'konnector',
|
|
4
|
+
id: 'io.cozy.konnectors/stub',
|
|
5
|
+
attributes: {
|
|
6
|
+
banksTransactionRegExp: '(someRegex)',
|
|
7
|
+
categories: ['insurance'],
|
|
8
|
+
checksum: '1337',
|
|
9
|
+
created_at: '2023-03-29T10:24:07.4799633+02:00',
|
|
10
|
+
data_types: ['bill'],
|
|
11
|
+
developer: {
|
|
12
|
+
name: 'John Doe',
|
|
13
|
+
url: 'https://john.doe.it'
|
|
14
|
+
},
|
|
15
|
+
editor: 'Cozy',
|
|
16
|
+
features: [
|
|
17
|
+
'LOGIN_OK',
|
|
18
|
+
'METADATA_DEDUP',
|
|
19
|
+
'IDENTITY',
|
|
20
|
+
'DOC_QUALIFICATION',
|
|
21
|
+
'HEALTH',
|
|
22
|
+
'CARBON_COPY',
|
|
23
|
+
'SENTRY_V2'
|
|
24
|
+
],
|
|
25
|
+
fields: {
|
|
26
|
+
login: {
|
|
27
|
+
max: 13,
|
|
28
|
+
min: 13,
|
|
29
|
+
type: 'text'
|
|
30
|
+
},
|
|
31
|
+
password: {
|
|
32
|
+
type: 'password'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
folders: [
|
|
36
|
+
{
|
|
37
|
+
defaultDir: '$administrative/$konnector/$account'
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
icon: 'icon.svg',
|
|
41
|
+
langs: ['fr'],
|
|
42
|
+
language: 'node',
|
|
43
|
+
locales: {
|
|
44
|
+
en: {
|
|
45
|
+
long_description: 'long description',
|
|
46
|
+
permissions: {
|
|
47
|
+
accounts: {
|
|
48
|
+
description: "Required to get the account's data"
|
|
49
|
+
},
|
|
50
|
+
'bank operations': {
|
|
51
|
+
description: 'Required to link bills to bank operations'
|
|
52
|
+
},
|
|
53
|
+
bills: {
|
|
54
|
+
description: 'Required to save the bills data'
|
|
55
|
+
},
|
|
56
|
+
carboncopy: {
|
|
57
|
+
description: 'Required for carbon copy documents'
|
|
58
|
+
},
|
|
59
|
+
files: {
|
|
60
|
+
description: 'Required to save the bills'
|
|
61
|
+
},
|
|
62
|
+
identities: {
|
|
63
|
+
description: 'Required to save your identity'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
short_description: 'Retrieves all your stub invoices'
|
|
67
|
+
},
|
|
68
|
+
fr: {
|
|
69
|
+
fields: {
|
|
70
|
+
login: {
|
|
71
|
+
label: 'Numéro de sécurité sociale',
|
|
72
|
+
placeholder: '13 chiffres'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
long_description: 'long description',
|
|
76
|
+
permissions: {
|
|
77
|
+
accounts: {
|
|
78
|
+
description: 'Utilisé pour obtenir les données du compte'
|
|
79
|
+
},
|
|
80
|
+
'bank operations': {
|
|
81
|
+
description:
|
|
82
|
+
'Utilisé pour lier les factures aux opérations bancaires'
|
|
83
|
+
},
|
|
84
|
+
bills: {
|
|
85
|
+
description: 'Utilisé pour sauvegarder les données des factures'
|
|
86
|
+
},
|
|
87
|
+
carboncopy: {
|
|
88
|
+
description:
|
|
89
|
+
"Utilisé pour certifier que vos fichiers sont copie conforme avec les documents d'origine"
|
|
90
|
+
},
|
|
91
|
+
files: {
|
|
92
|
+
description: 'Utilisé pour sauvegarder les factures'
|
|
93
|
+
},
|
|
94
|
+
identities: {
|
|
95
|
+
description: 'Utilisé pour sauvegarder votre identité'
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
short_description:
|
|
99
|
+
'Récupère dans votre Cozy les relevés de remboursements, votre attestations et vos messages'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
manifest_version: '2',
|
|
103
|
+
name: 'Stub',
|
|
104
|
+
permissions: {
|
|
105
|
+
'bank operations': {
|
|
106
|
+
type: 'io.cozy.bank.operations'
|
|
107
|
+
},
|
|
108
|
+
bills: {
|
|
109
|
+
type: 'io.cozy.bills'
|
|
110
|
+
},
|
|
111
|
+
files: {
|
|
112
|
+
type: 'io.cozy.files'
|
|
113
|
+
},
|
|
114
|
+
carbon_copy: {
|
|
115
|
+
type: 'io.cozy.certified.carbon_copy'
|
|
116
|
+
},
|
|
117
|
+
accounts: {
|
|
118
|
+
type: 'io.cozy.accounts'
|
|
119
|
+
},
|
|
120
|
+
identities: {
|
|
121
|
+
type: 'io.cozy.identities'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
slug: 'stub',
|
|
125
|
+
source: 'registry://stub/stable',
|
|
126
|
+
state: 'ready',
|
|
127
|
+
time_interval: [0, 24],
|
|
128
|
+
type: 'konnector',
|
|
129
|
+
updated_at: '2023-03-29T10:24:07.4799636+02:00',
|
|
130
|
+
vendor_link: 'https://stub.it',
|
|
131
|
+
version: '1.18.0'
|
|
132
|
+
},
|
|
133
|
+
meta: {
|
|
134
|
+
rev: '1'
|
|
135
|
+
},
|
|
136
|
+
links: {
|
|
137
|
+
self: '/konnectors/stub',
|
|
138
|
+
icon: '/konnectors/stub/icon/1',
|
|
139
|
+
permissions: '/permissions/konnectors/stub'
|
|
140
|
+
},
|
|
141
|
+
banksTransactionRegExp: '(someRegex)',
|
|
142
|
+
checksum:
|
|
143
|
+
'f7e732e7afc7f6b5f697c375aba570424aa6b28590b380203ef9849a071e87c7',
|
|
144
|
+
created_at: '2023-03-29T10:24:07.4799633+02:00',
|
|
145
|
+
editor: 'Cozy',
|
|
146
|
+
icon: 'icon.svg',
|
|
147
|
+
language: 'node',
|
|
148
|
+
manifest_version: '2',
|
|
149
|
+
name: 'Stub',
|
|
150
|
+
slug: 'stub',
|
|
151
|
+
source: 'registry://stub/stable',
|
|
152
|
+
state: 'ready',
|
|
153
|
+
updated_at: '2023-03-29T10:24:07.4799636+02:00',
|
|
154
|
+
vendor_link: 'https://stub.it',
|
|
155
|
+
version: '1',
|
|
156
|
+
_type: 'io.cozy.konnectors',
|
|
157
|
+
triggers: {
|
|
158
|
+
data: [
|
|
159
|
+
{
|
|
160
|
+
type: '@cron',
|
|
161
|
+
id: '1337',
|
|
162
|
+
attributes: {
|
|
163
|
+
_id: '1337',
|
|
164
|
+
_rev: '1',
|
|
165
|
+
domain: 'dev:8080',
|
|
166
|
+
prefix: 'dev1337',
|
|
167
|
+
type: '@cron',
|
|
168
|
+
worker: 'konnector',
|
|
169
|
+
arguments: '0 11 2 * * 3',
|
|
170
|
+
debounce: '',
|
|
171
|
+
options: null,
|
|
172
|
+
message: {
|
|
173
|
+
account: '1337',
|
|
174
|
+
konnector: 'stub',
|
|
175
|
+
folder_to_save: '1337'
|
|
176
|
+
},
|
|
177
|
+
current_state: {
|
|
178
|
+
trigger_id: '1337',
|
|
179
|
+
status: 'done',
|
|
180
|
+
last_success: '2023-06-23T10:37:40.6638338+02:00',
|
|
181
|
+
last_successful_job_id: '1337',
|
|
182
|
+
last_execution: '2023-06-23T10:37:40.6638338+02:00',
|
|
183
|
+
last_executed_job_id: '1337',
|
|
184
|
+
last_failure: '2023-04-26T09:10:39.4642864+02:00',
|
|
185
|
+
last_failed_job_id: '1337',
|
|
186
|
+
last_error: 'VENDOR_DOWN',
|
|
187
|
+
last_manual_execution: '2023-06-23T10:37:40.6638338+02:00',
|
|
188
|
+
last_manual_job_id: '1337'
|
|
189
|
+
},
|
|
190
|
+
cozyMetadata: {
|
|
191
|
+
doctypeVersion: '1',
|
|
192
|
+
metadataVersion: 1,
|
|
193
|
+
createdAt: '2023-03-29T10:25:41.8226664+02:00',
|
|
194
|
+
createdByApp: 'home',
|
|
195
|
+
updatedAt: '2023-03-29T10:25:41.8226664+02:00'
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
meta: {},
|
|
199
|
+
links: {
|
|
200
|
+
self: '/jobs/triggers/1337'
|
|
201
|
+
},
|
|
202
|
+
_id: '1337',
|
|
203
|
+
_rev: '1',
|
|
204
|
+
domain: 'dev:8080',
|
|
205
|
+
prefix: 'dev1337',
|
|
206
|
+
worker: 'konnector',
|
|
207
|
+
arguments: '0 11 2 * * 3',
|
|
208
|
+
debounce: '',
|
|
209
|
+
options: null,
|
|
210
|
+
_type: 'io.cozy.triggers'
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
account: {
|
|
216
|
+
id: '1337',
|
|
217
|
+
_id: '1337',
|
|
218
|
+
_type: 'io.cozy.accounts',
|
|
219
|
+
_rev: '1',
|
|
220
|
+
account_type: 'stub',
|
|
221
|
+
auth: {
|
|
222
|
+
credentials_encrypted: '1337',
|
|
223
|
+
login: '1 55 55 12 784 125'
|
|
224
|
+
},
|
|
225
|
+
cozyMetadata: {
|
|
226
|
+
createdAt: '2023-03-29T10:25:41.6712839+02:00',
|
|
227
|
+
createdByApp: 'home',
|
|
228
|
+
doctypeVersion: '',
|
|
229
|
+
metadataVersion: 1,
|
|
230
|
+
updatedAt: '2023-06-23T08:37:37.541Z',
|
|
231
|
+
updatedByApps: [
|
|
232
|
+
{
|
|
233
|
+
date: '2023-06-23T08:37:37.541Z'
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
date: '2023-03-29T10:25:41.6712839+02:00',
|
|
237
|
+
slug: 'home'
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
defaultFolderPath: '/Stub/1 55 55 12 784 125',
|
|
242
|
+
identifier: 'login',
|
|
243
|
+
name: '1 55 55 12 784 125',
|
|
244
|
+
state: 'LOGIN_SUCCESS'
|
|
245
|
+
},
|
|
246
|
+
accountsAndTriggers: [
|
|
247
|
+
{
|
|
248
|
+
account: {
|
|
249
|
+
id: '1337',
|
|
250
|
+
_id: '1337',
|
|
251
|
+
_type: 'io.cozy.accounts',
|
|
252
|
+
_rev: '1',
|
|
253
|
+
account_type: 'stub',
|
|
254
|
+
auth: {
|
|
255
|
+
credentials_encrypted: '1337',
|
|
256
|
+
login: '1 55 55 12 784 125'
|
|
257
|
+
},
|
|
258
|
+
cozyMetadata: {
|
|
259
|
+
createdAt: '2023-03-29T10:25:41.6712839+02:00',
|
|
260
|
+
createdByApp: 'home',
|
|
261
|
+
doctypeVersion: '',
|
|
262
|
+
metadataVersion: 1,
|
|
263
|
+
updatedAt: '2023-06-23T08:37:37.541Z',
|
|
264
|
+
updatedByApps: [
|
|
265
|
+
{
|
|
266
|
+
date: '2023-06-23T08:37:37.541Z'
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
date: '2023-03-29T10:25:41.6712839+02:00',
|
|
270
|
+
slug: 'home'
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
defaultFolderPath: '/Stub/1 55 55 12 784 125',
|
|
275
|
+
identifier: 'login',
|
|
276
|
+
name: '1 55 55 12 784 125',
|
|
277
|
+
state: 'LOGIN_SUCCESS'
|
|
278
|
+
},
|
|
279
|
+
trigger: {
|
|
280
|
+
type: '@cron',
|
|
281
|
+
id: '1337',
|
|
282
|
+
attributes: {
|
|
283
|
+
_id: '1337',
|
|
284
|
+
_rev: '1',
|
|
285
|
+
domain: 'dev:8080',
|
|
286
|
+
prefix: 'dev1337',
|
|
287
|
+
type: '@cron',
|
|
288
|
+
worker: 'konnector',
|
|
289
|
+
arguments: '0 11 2 * * 3',
|
|
290
|
+
debounce: '',
|
|
291
|
+
options: null,
|
|
292
|
+
message: {
|
|
293
|
+
account: '1337',
|
|
294
|
+
konnector: 'stub',
|
|
295
|
+
folder_to_save: '1337'
|
|
296
|
+
},
|
|
297
|
+
current_state: {
|
|
298
|
+
trigger_id: '1337',
|
|
299
|
+
status: 'done',
|
|
300
|
+
last_success: '2023-06-23T10:37:40.6638338+02:00',
|
|
301
|
+
last_successful_job_id: '1337',
|
|
302
|
+
last_execution: '2023-06-23T10:37:40.6638338+02:00',
|
|
303
|
+
last_executed_job_id: '1337',
|
|
304
|
+
last_failure: '2023-04-26T09:10:39.4642864+02:00',
|
|
305
|
+
last_failed_job_id: '1337',
|
|
306
|
+
last_error: 'VENDOR_DOWN',
|
|
307
|
+
last_manual_execution: '2023-06-23T10:37:40.6638338+02:00',
|
|
308
|
+
last_manual_job_id: '1337'
|
|
309
|
+
},
|
|
310
|
+
cozyMetadata: {
|
|
311
|
+
doctypeVersion: '1',
|
|
312
|
+
metadataVersion: 1,
|
|
313
|
+
createdAt: '2023-03-29T10:25:41.8226664+02:00',
|
|
314
|
+
createdByApp: 'home',
|
|
315
|
+
updatedAt: '2023-03-29T10:25:41.8226664+02:00'
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
meta: {},
|
|
319
|
+
links: {
|
|
320
|
+
self: '/jobs/triggers/1337'
|
|
321
|
+
},
|
|
322
|
+
_id: '1337',
|
|
323
|
+
_rev: '1',
|
|
324
|
+
domain: 'dev:8080',
|
|
325
|
+
prefix: 'dev1337',
|
|
326
|
+
worker: 'konnector',
|
|
327
|
+
arguments: '0 11 2 * * 3',
|
|
328
|
+
debounce: '',
|
|
329
|
+
options: null,
|
|
330
|
+
_type: 'io.cozy.triggers'
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/react-webpack5';
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
5
|
+
addons: [
|
|
6
|
+
"@storybook/addon-links",
|
|
7
|
+
"@storybook/addon-essentials",
|
|
8
|
+
"@storybook/addon-interactions",
|
|
9
|
+
],
|
|
10
|
+
framework: {
|
|
11
|
+
name: "@storybook/react-webpack5",
|
|
12
|
+
options: {},
|
|
13
|
+
},
|
|
14
|
+
docs: {
|
|
15
|
+
autodocs: true
|
|
16
|
+
},
|
|
17
|
+
staticDirs: ['./public'],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default config;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!-- This is the `head` of the preview iframe -->
|
|
2
|
+
<!-- Pull in static files served from your Static directory or the internet -->
|
|
3
|
+
|
|
4
|
+
<style>
|
|
5
|
+
@font-face {
|
|
6
|
+
font-family: Lato;
|
|
7
|
+
font-style: normal;
|
|
8
|
+
font-weight: normal;
|
|
9
|
+
src: url("/Lato-Regular.immutable.woff2") format("woff2");
|
|
10
|
+
font-display: fallback;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@font-face {
|
|
14
|
+
font-family: Lato;
|
|
15
|
+
font-style: normal;
|
|
16
|
+
font-weight: bold;
|
|
17
|
+
src: url("/Lato-Bold.immutable.woff2") format("woff2");
|
|
18
|
+
font-display: fallback;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Preview } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
import 'cozy-ui/dist/cozy-ui.min.css'
|
|
4
|
+
import 'cozy-ui/dist/cozy-ui.utils.min.css'
|
|
5
|
+
import 'cozy-ui/transpiled/react/stylesheet.css'
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { StoryContainer } from "./StoryContainer";
|
|
8
|
+
|
|
9
|
+
const preview: Preview = {
|
|
10
|
+
decorators: [
|
|
11
|
+
(Story) => (
|
|
12
|
+
<StoryContainer>
|
|
13
|
+
<div style={{position: "relative"}}>
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
</StoryContainer>
|
|
17
|
+
),
|
|
18
|
+
],
|
|
19
|
+
parameters: {
|
|
20
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
21
|
+
controls: {
|
|
22
|
+
matchers: {
|
|
23
|
+
color: /(background|color)$/i,
|
|
24
|
+
date: /Date$/,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default preview;
|
|
Binary file
|
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [14.2.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@14.1.1...cozy-harvest-lib@14.2.0) (2023-06-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **harvest:** Add first story ([990773d](https://github.com/cozy/cozy-libs/commit/990773d22d1155b166ef163efe1918cd7468229a))
|
|
12
|
+
* **harvest:** Convert Storybook to TS ([02b56a2](https://github.com/cozy/cozy-libs/commit/02b56a20e810e689e5405c32e7a23d8038bd7d35))
|
|
13
|
+
* **harvest:** Implement first Story ([1629b46](https://github.com/cozy/cozy-libs/commit/1629b46ef3ce599c47e3cedb63dee6be1f7fb66e))
|
|
14
|
+
* **harvest:** Install Storybook in the project ([9ec05a4](https://github.com/cozy/cozy-libs/commit/9ec05a4cbb2b97826291089bb2b2059cf74eafa0))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [14.1.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@14.1.0...cozy-harvest-lib@14.1.1) (2023-06-23)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* Do not display reconnection webview for USER_ACTION_NEEDED state ([a0c04fe](https://github.com/cozy/cozy-libs/commit/a0c04fea02d2f401bf4c2d9324236b8d2d29df03))
|
|
26
|
+
* Show accounts paywall for oAuth konnector ([e30c737](https://github.com/cozy/cozy-libs/commit/e30c7370e7e1ce41c8238acc3e97f53380935b74))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
6
32
|
# [14.1.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@14.0.0...cozy-harvest-lib@14.1.0) (2023-06-23)
|
|
7
33
|
|
|
8
34
|
|
package/README.md
CHANGED
|
@@ -155,10 +155,146 @@ ReactDOM.render(
|
|
|
155
155
|
)
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
# API
|
|
159
|
-
|
|
160
|
-
See the [Styleguidist](https://docs.cozy.io/cozy-libs/cozy-harvest-lib/).
|
|
161
|
-
|
|
162
158
|
# Doc and example about manifests
|
|
163
159
|
|
|
164
160
|
<https://docs.cozy.io/en/tutorials/konnector/#the-manifest>
|
|
161
|
+
|
|
162
|
+
# Working with Storybook
|
|
163
|
+
|
|
164
|
+
## Run Storybook
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
yarn storybook
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Build Storybook
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
yarn build-storybook
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Add a new story
|
|
177
|
+
|
|
178
|
+
Create a new file next to the component you want to add a story for, with the `.stories.{ts,tsx}` extension (depending if you need to write JSX or not in the story).
|
|
179
|
+
|
|
180
|
+
### For Javascript components
|
|
181
|
+
|
|
182
|
+
Storybook expects a component with typed props for better parameter inference, so if your component is not typed, you can still create an interface for the props in the story file.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
186
|
+
|
|
187
|
+
// Import with a different name to avoid conflict with the typed Button component
|
|
188
|
+
import _Button from './Button'
|
|
189
|
+
|
|
190
|
+
// Create a typed alias for the component with the same name and the same props
|
|
191
|
+
const Button = _Button as (props: {
|
|
192
|
+
onClick: () => void
|
|
193
|
+
title: string
|
|
194
|
+
disabled?: boolean
|
|
195
|
+
}) => JSX.Element
|
|
196
|
+
|
|
197
|
+
// Create a meta object for the story, this is mandatory
|
|
198
|
+
const meta: Meta<typeof Button> = {
|
|
199
|
+
// Make onClick an action for all stories so that you can see the click events in the Storybook UI
|
|
200
|
+
argTypes: {
|
|
201
|
+
onClick: { action: 'onClick' }
|
|
202
|
+
},
|
|
203
|
+
component: Button
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Export the meta object as default export so that Storybook can use it automatically
|
|
207
|
+
export default meta
|
|
208
|
+
|
|
209
|
+
// Create a typed alias for the StoryObj type corresponding to the component
|
|
210
|
+
type Story = StoryObj<typeof Button>
|
|
211
|
+
|
|
212
|
+
// Create as many stories as you want and cast them to the Story type
|
|
213
|
+
|
|
214
|
+
// This story will be named "Default" by Storybook
|
|
215
|
+
export const Default: Story = {
|
|
216
|
+
args: {
|
|
217
|
+
title: 'Foobar'
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export const Disabled: Story = {
|
|
222
|
+
// The story can have a custom name if you specify it here
|
|
223
|
+
name: 'Disabled state',
|
|
224
|
+
args: {
|
|
225
|
+
disabled: true,
|
|
226
|
+
title: 'Barfoo',
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### For Typescript components
|
|
232
|
+
|
|
233
|
+
If your component is already typed, you can import it directly and use it in the story. Everything else is the same as for Javascript components.
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
237
|
+
|
|
238
|
+
import Button from './Button'
|
|
239
|
+
|
|
240
|
+
const meta: Meta<typeof Button> = {
|
|
241
|
+
argTypes: {
|
|
242
|
+
onClick: { action: 'onClick' }
|
|
243
|
+
},
|
|
244
|
+
component: Button
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export default meta
|
|
248
|
+
|
|
249
|
+
type Story = StoryObj<typeof Button>
|
|
250
|
+
|
|
251
|
+
export const Default: Story = {
|
|
252
|
+
args: {
|
|
253
|
+
title: 'Foobar'
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export const Disabled: Story = {
|
|
258
|
+
name: 'Disabled state',
|
|
259
|
+
args: {
|
|
260
|
+
disabled: true,
|
|
261
|
+
title: 'Barfoo',
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Configure Storybook
|
|
267
|
+
|
|
268
|
+
The Storybook configuration is in the `.storybook` folder.
|
|
269
|
+
|
|
270
|
+
### Add a new addon
|
|
271
|
+
|
|
272
|
+
Addons are plugins that add features to Storybook. You can find a list of addons [here](https://storybook.js.org/addons/).
|
|
273
|
+
|
|
274
|
+
To add a new addon, install it with `yarn add -D` and add it to the `addons` array in `.storybook/main.js`.
|
|
275
|
+
|
|
276
|
+
### Add a new webpack loader
|
|
277
|
+
|
|
278
|
+
Webpack loaders are used to load files in Storybook. You can find a list of loaders [here](https://webpack.js.org/loaders/).
|
|
279
|
+
|
|
280
|
+
To add a new loader, install it with `yarn add -D` and add it to the `webpackFinal` function in `.storybook/main.js`.
|
|
281
|
+
|
|
282
|
+
### Add a new webpack plugin
|
|
283
|
+
|
|
284
|
+
Webpack plugins are used to modify the webpack configuration in Storybook. You can find a list of plugins [here](https://webpack.js.org/plugins/).
|
|
285
|
+
|
|
286
|
+
To add a new plugin, install it with `yarn add -D` and add it to the `webpackFinal` function in `.storybook/main.js`.
|
|
287
|
+
|
|
288
|
+
### Add a new webpack alias
|
|
289
|
+
|
|
290
|
+
Webpack aliases are used to create shortcuts to import files in Storybook. You can find more information about aliases [here](https://webpack.js.org/configuration/resolve/#resolvealias).
|
|
291
|
+
|
|
292
|
+
To add a new alias, add it to the `webpackFinal` function in `.storybook/main.js`.
|
|
293
|
+
|
|
294
|
+
### Configure the Storybook UI
|
|
295
|
+
|
|
296
|
+
The Storybook UI can be configured in `.storybook/preview.js` and `preview-head.html`.
|
|
297
|
+
|
|
298
|
+
## For more information about Storybook
|
|
299
|
+
|
|
300
|
+
See the [official documentation](https://storybook.js.org/docs/react/get-started/introduction).
|
|
@@ -26,7 +26,7 @@ export var AccountSelectorHeader = function AccountSelectorHeader(_ref) {
|
|
|
26
26
|
|
|
27
27
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DialogBackButton, {
|
|
28
28
|
onClick: function onClick() {
|
|
29
|
-
return replaceHistory("/accounts/".concat(account._id));
|
|
29
|
+
return replaceHistory("/accounts/".concat(String(account._id)));
|
|
30
30
|
}
|
|
31
31
|
}), /*#__PURE__*/React.createElement(DialogTitle, _extends({}, rest, {
|
|
32
32
|
className: cx('dialogTitleWithBack dialogTitleWithClose', // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AccountSelectorHeader } from './AccountSelectorHeader';
|
|
2
|
+
import { AccountSelectorHeaderFixtures } from '../../../.storybook/fixtures/AccountSelectorHeader.fixtures';
|
|
3
|
+
var meta = {
|
|
4
|
+
component: AccountSelectorHeader,
|
|
5
|
+
argTypes: {
|
|
6
|
+
replaceHistory: {
|
|
7
|
+
action: 'replaceHistory'
|
|
8
|
+
},
|
|
9
|
+
pushHistory: {
|
|
10
|
+
action: 'pushHistory'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
account: AccountSelectorHeaderFixtures.account,
|
|
15
|
+
accountsAndTriggers: AccountSelectorHeaderFixtures.accountsAndTriggers,
|
|
16
|
+
konnector: AccountSelectorHeaderFixtures.konnector
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export default meta;
|
|
20
|
+
export var WithAccountSelection = {
|
|
21
|
+
name: 'With account selection',
|
|
22
|
+
args: {
|
|
23
|
+
showAccountSelection: true
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export var WithoutAccountSelection = {
|
|
27
|
+
name: 'Without account selection',
|
|
28
|
+
args: {
|
|
29
|
+
showAccountSelection: false
|
|
30
|
+
}
|
|
31
|
+
};
|