cozy-ui-plus 13.0.17 → 13.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/AppSections/Sections.js +114 -0
  3. package/dist/AppTile/index.js +30 -0
  4. package/dist/Contacts/AddModal/ContactAddressDialog/locales/index.js +78 -0
  5. package/dist/Contacts/AddModal/ContactForm/locales/index.js +231 -0
  6. package/dist/Contacts/AddModal/CustomLabelDialog/locales/index.js +48 -0
  7. package/dist/Contacts/AddModal/locales/index.js +43 -1
  8. package/dist/Contacts/GroupsSelect/locales/index.js +66 -0
  9. package/dist/Contacts/Header/locales/index.js +48 -0
  10. package/dist/ContactsList/locales/withContactsListLocales.js +18 -0
  11. package/dist/ContactsListModal/withContactsListLocales.js +37 -1
  12. package/dist/Dialogs/AuthentificationDialog/withSpecificDialogsLocales.js +57 -0
  13. package/dist/Intent/IntentDialogOpener/index.js +6 -1
  14. package/dist/Intent/IntentIframe/index.js +19 -3
  15. package/dist/Paywall/locales/withPaywallLocales.js +324 -0
  16. package/dist/Qualification/QualificationModal/locales/index.js +21 -0
  17. package/dist/Storage/locales/index.js +24 -0
  18. package/dist/src/Contacts/AddModal/ContactAddressDialog/locales/index.d.ts +6 -0
  19. package/dist/src/Contacts/AddModal/ContactForm/locales/index.d.ts +6 -0
  20. package/dist/src/Contacts/AddModal/CustomLabelDialog/locales/index.d.ts +6 -0
  21. package/dist/src/Contacts/AddModal/locales/index.d.ts +6 -0
  22. package/dist/src/Contacts/GroupsSelect/locales/index.d.ts +6 -0
  23. package/dist/src/Contacts/Header/locales/index.d.ts +6 -0
  24. package/dist/src/ContactsList/locales/withContactsListLocales.d.ts +6 -0
  25. package/dist/src/ContactsListModal/withContactsListLocales.d.ts +6 -0
  26. package/dist/src/Dialogs/AuthentificationDialog/withSpecificDialogsLocales.d.ts +6 -0
  27. package/dist/src/Intent/IntentDialogOpener/index.d.ts +1 -0
  28. package/dist/src/Qualification/QualificationModal/locales/index.d.ts +6 -0
  29. package/dist/src/Storage/locales/index.d.ts +6 -0
  30. package/package.json +6 -6
  31. package/src/AppSections/Sections.jsx +6 -0
  32. package/src/AppSections/locales/de.json +37 -0
  33. package/src/AppSections/locales/es.json +37 -0
  34. package/src/AppSections/locales/it.json +37 -0
  35. package/src/AppTile/index.jsx +4 -1
  36. package/src/AppTile/locales/de.json +9 -0
  37. package/src/AppTile/locales/es.json +9 -0
  38. package/src/AppTile/locales/it.json +9 -0
  39. package/src/Contacts/AddModal/ContactAddressDialog/locales/de.json +25 -0
  40. package/src/Contacts/AddModal/ContactAddressDialog/locales/es.json +25 -0
  41. package/src/Contacts/AddModal/ContactAddressDialog/locales/index.jsx +6 -0
  42. package/src/Contacts/AddModal/ContactAddressDialog/locales/it.json +25 -0
  43. package/src/Contacts/AddModal/ContactForm/locales/de.json +76 -0
  44. package/src/Contacts/AddModal/ContactForm/locales/es.json +76 -0
  45. package/src/Contacts/AddModal/ContactForm/locales/index.jsx +6 -0
  46. package/src/Contacts/AddModal/ContactForm/locales/it.json +76 -0
  47. package/src/Contacts/AddModal/CustomLabelDialog/locales/de.json +15 -0
  48. package/src/Contacts/AddModal/CustomLabelDialog/locales/es.json +15 -0
  49. package/src/Contacts/AddModal/CustomLabelDialog/locales/index.jsx +6 -0
  50. package/src/Contacts/AddModal/CustomLabelDialog/locales/it.json +15 -0
  51. package/src/Contacts/AddModal/locales/de.json +13 -0
  52. package/src/Contacts/AddModal/locales/es.json +13 -0
  53. package/src/Contacts/AddModal/locales/fr.json +1 -1
  54. package/src/Contacts/AddModal/locales/index.jsx +6 -0
  55. package/src/Contacts/AddModal/locales/it.json +13 -0
  56. package/src/Contacts/GroupsSelect/locales/de.json +21 -0
  57. package/src/Contacts/GroupsSelect/locales/es.json +21 -0
  58. package/src/Contacts/GroupsSelect/locales/index.jsx +6 -0
  59. package/src/Contacts/GroupsSelect/locales/it.json +21 -0
  60. package/src/Contacts/Header/locales/de.json +15 -0
  61. package/src/Contacts/Header/locales/es.json +15 -0
  62. package/src/Contacts/Header/locales/index.jsx +6 -0
  63. package/src/Contacts/Header/locales/it.json +15 -0
  64. package/src/ContactsList/locales/de.json +5 -0
  65. package/src/ContactsList/locales/es.json +5 -0
  66. package/src/ContactsList/locales/it.json +5 -0
  67. package/src/ContactsList/locales/withContactsListLocales.jsx +6 -0
  68. package/src/ContactsListModal/locales/de.json +11 -0
  69. package/src/ContactsListModal/locales/es.json +11 -0
  70. package/src/ContactsListModal/locales/it.json +11 -0
  71. package/src/ContactsListModal/withContactsListLocales.jsx +7 -1
  72. package/src/Dialogs/AuthentificationDialog/locales/de.json +18 -0
  73. package/src/Dialogs/AuthentificationDialog/locales/es.json +18 -0
  74. package/src/Dialogs/AuthentificationDialog/locales/it.json +18 -0
  75. package/src/Dialogs/AuthentificationDialog/withSpecificDialogsLocales.jsx +6 -0
  76. package/src/Intent/IntentDialogOpener/Readme.md +4 -0
  77. package/src/Intent/IntentDialogOpener/index.jsx +4 -0
  78. package/src/Intent/IntentDialogOpener/index.spec.jsx +23 -2
  79. package/src/Intent/IntentIframe/Readme.md +8 -0
  80. package/src/Intent/IntentIframe/index.jsx +19 -7
  81. package/src/Intent/IntentIframe/index.spec.jsx +40 -3
  82. package/src/Paywall/locales/de.json +107 -0
  83. package/src/Paywall/locales/es.json +107 -0
  84. package/src/Paywall/locales/it.json +107 -0
  85. package/src/Paywall/locales/withPaywallLocales.jsx +6 -0
  86. package/src/Qualification/QualificationModal/locales/de.json +6 -0
  87. package/src/Qualification/QualificationModal/locales/es.json +6 -0
  88. package/src/Qualification/QualificationModal/locales/index.jsx +6 -0
  89. package/src/Qualification/QualificationModal/locales/it.json +6 -0
  90. package/src/Storage/locales/de.json +7 -0
  91. package/src/Storage/locales/es.json +7 -0
  92. package/src/Storage/locales/index.jsx +6 -0
  93. package/src/Storage/locales/it.json +7 -0
@@ -0,0 +1,13 @@
1
+ {
2
+ "Contacts": {
3
+ "AddModal": {
4
+ "error": {
5
+ "save": "Se ha producido un error al guardar el contacto. Inténtelo de nuevo"
6
+ },
7
+ "edit-contact": "Editar el contacto",
8
+ "create_contact": "Crear un contacto",
9
+ "cancel": "Cancelar",
10
+ "save": "Guardar"
11
+ }
12
+ }
13
+ }
@@ -4,7 +4,7 @@
4
4
  "error": {
5
5
  "save": "Une erreur est survenue lors de l'enregistrement du contact, veuillez réessayer"
6
6
  },
7
- "edit-contact": "Edit contact",
7
+ "edit-contact": "Modifier le contact",
8
8
  "create_contact": "Créer un contact",
9
9
  "cancel": "Annuler",
10
10
  "save": "Enregistrer"
@@ -1,11 +1,17 @@
1
+ import de from './de.json'
1
2
  import en from './en.json'
3
+ import es from './es.json'
2
4
  import fr from './fr.json'
5
+ import it from './it.json'
3
6
  import ru from './ru.json'
4
7
  import vi from './vi.json'
5
8
 
6
9
  export const locales = {
10
+ de,
7
11
  en,
12
+ es,
8
13
  fr,
14
+ it,
9
15
  ru,
10
16
  vi
11
17
  }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Contacts": {
3
+ "AddModal": {
4
+ "error": {
5
+ "save": "Si è verificato un errore durante il salvataggio del contatto, riprova"
6
+ },
7
+ "edit-contact": "Modifica contatto",
8
+ "create_contact": "Crea un contatto",
9
+ "cancel": "Annulla",
10
+ "save": "Salva"
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "Contacts": {
3
+ "GroupsSelect": {
4
+ "create": "Gruppe erstellen",
5
+ "name": "Name der Gruppe",
6
+ "already_exists": "Die Gruppe %{name} existiert bereits.",
7
+ "manage": "Gruppen",
8
+ "filter": {
9
+ "all-groups": "Alle Gruppen"
10
+ },
11
+ "created": {
12
+ "success": "Die Gruppe wurde erfolgreich erstellt.",
13
+ "error": "Die Gruppe konnte nicht erstellt werden."
14
+ },
15
+ "renamed": {
16
+ "success": "Die Gruppe wurde erfolgreich umbenannt.",
17
+ "error": "Die Gruppe konnte nicht umbenannt werden."
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "Contacts": {
3
+ "GroupsSelect": {
4
+ "create": "Crear un grupo",
5
+ "name": "Nombre del grupo",
6
+ "already_exists": "El grupo %{name} ya existe.",
7
+ "manage": "Grupos",
8
+ "filter": {
9
+ "all-groups": "Todos los grupos"
10
+ },
11
+ "created": {
12
+ "success": "El grupo se ha creado correctamente.",
13
+ "error": "No se ha podido crear el grupo."
14
+ },
15
+ "renamed": {
16
+ "success": "El grupo se ha renombrado correctamente.",
17
+ "error": "No se ha podido renombrar el grupo."
18
+ }
19
+ }
20
+ }
21
+ }
@@ -1,11 +1,17 @@
1
+ import de from './de.json'
1
2
  import en from './en.json'
3
+ import es from './es.json'
2
4
  import fr from './fr.json'
5
+ import it from './it.json'
3
6
  import ru from './ru.json'
4
7
  import vi from './vi.json'
5
8
 
6
9
  export const locales = {
10
+ de,
7
11
  en,
12
+ es,
8
13
  fr,
14
+ it,
9
15
  ru,
10
16
  vi
11
17
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ "Contacts": {
3
+ "GroupsSelect": {
4
+ "create": "Crea un gruppo",
5
+ "name": "Nome del gruppo",
6
+ "already_exists": "Il gruppo %{name} esiste già.",
7
+ "manage": "Gruppi",
8
+ "filter": {
9
+ "all-groups": "Tutti i gruppi"
10
+ },
11
+ "created": {
12
+ "success": "Il gruppo è stato creato correttamente.",
13
+ "error": "Impossibile creare il gruppo."
14
+ },
15
+ "renamed": {
16
+ "success": "Il gruppo è stato rinominato correttamente.",
17
+ "error": "Impossibile rinominare il gruppo."
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Contacts": {
3
+ "Header": {
4
+ "create": "Erstellen",
5
+ "filter": {
6
+ "no-group": "Erstellen Sie Kontaktgruppen, um das Ordnen und Teilen zu erleichtern!"
7
+ },
8
+ "import": {
9
+ "title": "Importieren",
10
+ "store": "Aus anderen Quellen",
11
+ "vcard": "Aus einer vCard-Datei"
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Contacts": {
3
+ "Header": {
4
+ "create": "Crear",
5
+ "filter": {
6
+ "no-group": "¡Cree grupos de contactos para facilitar su organización y el uso compartido!"
7
+ },
8
+ "import": {
9
+ "title": "Importar",
10
+ "store": "Desde otras fuentes",
11
+ "vcard": "Desde un archivo vCard"
12
+ }
13
+ }
14
+ }
15
+ }
@@ -1,11 +1,17 @@
1
+ import de from './de.json'
1
2
  import en from './en.json'
3
+ import es from './es.json'
2
4
  import fr from './fr.json'
5
+ import it from './it.json'
3
6
  import ru from './ru.json'
4
7
  import vi from './vi.json'
5
8
 
6
9
  export const locales = {
10
+ de,
7
11
  en,
12
+ es,
8
13
  fr,
14
+ it,
9
15
  ru,
10
16
  vi
11
17
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Contacts": {
3
+ "Header": {
4
+ "create": "Crea",
5
+ "filter": {
6
+ "no-group": "Crea gruppi di contatti per organizzarli e condividerli più facilmente!"
7
+ },
8
+ "import": {
9
+ "title": "Importa",
10
+ "store": "Da altre fonti",
11
+ "vcard": "Da un file vCard"
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "empty": "LEER",
3
+ "me": "ich",
4
+ "favorite": "Favoriten"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "empty": "VACÍO",
3
+ "me": "yo",
4
+ "favorite": "favoritos"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "empty": "VUOTO",
3
+ "me": "io",
4
+ "favorite": "preferiti"
5
+ }
@@ -1,13 +1,19 @@
1
1
  import { withOnlyLocales } from 'twake-i18n'
2
2
 
3
+ import de from './de.json'
3
4
  import en from './en.json'
5
+ import es from './es.json'
4
6
  import fr from './fr.json'
7
+ import it from './it.json'
5
8
  import ru from './ru.json'
6
9
  import vi from './vi.json'
7
10
 
8
11
  export const locales = {
12
+ de,
9
13
  en,
14
+ es,
10
15
  fr,
16
+ it,
11
17
  ru,
12
18
  vi
13
19
  }
@@ -0,0 +1,11 @@
1
+ {
2
+ "cancel": "Abbrechen",
3
+ "save": "Speichern",
4
+ "newContact": "Neuer Kontakt",
5
+ "coordinates": "Kontaktdaten",
6
+ "givenName": "Vorname",
7
+ "familyName": "Nachname",
8
+ "addContact": "Kontakt hinzufügen",
9
+ "searchContact": "Kontakt suchen",
10
+ "emptyContact": "Kein Kontakt"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "cancel": "Cancelar",
3
+ "save": "Guardar",
4
+ "newContact": "Nuevo contacto",
5
+ "coordinates": "Datos de contacto",
6
+ "givenName": "Nombre",
7
+ "familyName": "Apellidos",
8
+ "addContact": "Añadir un contacto",
9
+ "searchContact": "Buscar un contacto",
10
+ "emptyContact": "Ningún contacto"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "cancel": "Annulla",
3
+ "save": "Salva",
4
+ "newContact": "Nuovo contatto",
5
+ "coordinates": "Recapiti",
6
+ "givenName": "Nome",
7
+ "familyName": "Cognome",
8
+ "addContact": "Aggiungi un contatto",
9
+ "searchContact": "Cerca un contatto",
10
+ "emptyContact": "Nessun contatto"
11
+ }
@@ -1,11 +1,17 @@
1
1
  import { withLocales } from 'twake-i18n'
2
2
 
3
+ import de from './locales/de.json'
3
4
  import en from './locales/en.json'
5
+ import es from './locales/es.json'
4
6
  import fr from './locales/fr.json'
7
+ import it from './locales/it.json'
5
8
 
6
9
  export const locales = {
10
+ de,
7
11
  en,
8
- fr
12
+ es,
13
+ fr,
14
+ it
9
15
  }
10
16
 
11
17
  export const withContactsListLocales = withLocales(locales)
@@ -0,0 +1,18 @@
1
+ {
2
+ "cancel": "Abbrechen",
3
+ "allow": "Erlauben",
4
+ "authentification-dialog": {
5
+ "title": "Anmeldung",
6
+ "title-oidc": "Twake Pass",
7
+ "subtitle": "Bitte bestätigen Sie aus Sicherheitsgründen Ihre Identität",
8
+ "label": "Twake-Passwort",
9
+ "label-oidc": "Twake Pass-Passwort",
10
+ "abort": "Verlassen",
11
+ "unlock": "Entsperren",
12
+ "forgotten-password": "Ich habe mein Passwort vergessen",
13
+ "errors": {
14
+ "invalid_password": "Falsches Passwort, bitte versuchen Sie es erneut.",
15
+ "server_error": "Auf dem Server ist ein Fehler aufgetreten. Bitte laden Sie die Seite neu."
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "cancel": "Cancelar",
3
+ "allow": "Permitir",
4
+ "authentification-dialog": {
5
+ "title": "Inicio de sesión",
6
+ "title-oidc": "Twake Pass",
7
+ "subtitle": "Por seguridad, confirme su identidad",
8
+ "label": "Contraseña de Twake",
9
+ "label-oidc": "Contraseña de Twake Pass",
10
+ "abort": "Salir",
11
+ "unlock": "Desbloquear",
12
+ "forgotten-password": "He olvidado mi contraseña",
13
+ "errors": {
14
+ "invalid_password": "Contraseña incorrecta. Inténtelo de nuevo.",
15
+ "server_error": "Se ha producido un error en el servidor. Vuelva a cargar la página."
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "cancel": "Annulla",
3
+ "allow": "Consenti",
4
+ "authentification-dialog": {
5
+ "title": "Accesso",
6
+ "title-oidc": "Twake Pass",
7
+ "subtitle": "Per sicurezza, conferma la tua identità",
8
+ "label": "Password di Twake",
9
+ "label-oidc": "Password di Twake Pass",
10
+ "abort": "Esci",
11
+ "unlock": "Sblocca",
12
+ "forgotten-password": "Ho dimenticato la password",
13
+ "errors": {
14
+ "invalid_password": "Password errata, riprova.",
15
+ "server_error": "Si è verificato un errore del server. Ricarica la pagina."
16
+ }
17
+ }
18
+ }
@@ -1,13 +1,19 @@
1
1
  import { withOnlyLocales } from 'twake-i18n'
2
2
 
3
+ import de from './locales/de.json'
3
4
  import en from './locales/en.json'
5
+ import es from './locales/es.json'
4
6
  import fr from './locales/fr.json'
7
+ import it from './locales/it.json'
5
8
  import ru from './locales/ru.json'
6
9
  import vi from './locales/vi.json'
7
10
 
8
11
  export const locales = {
12
+ de,
9
13
  en,
14
+ es,
10
15
  fr,
16
+ it,
11
17
  ru,
12
18
  vi
13
19
  }
@@ -30,6 +30,10 @@ Set `waitForReadyToUse` to keep the intent hidden behind the loading spinner
30
30
  until its service sends the `readyToUse` signal. This option is disabled by
31
31
  default because older intent services do not send this signal.
32
32
 
33
+ Set `onResult` to receive the results a service hands over while it stays
34
+ open. The dialog is not closed: `onComplete` is still called when the intent
35
+ ends.
36
+
33
37
  Set `options.theme.type` to `light` or `dark` to force that theme on the
34
38
  dialog, close button and loading surface as well as passing it to the intent
35
39
  service. Any other value or no value keeps the caller's theme.
@@ -24,6 +24,7 @@ const IntentDialogOpener = props => {
24
24
  onComplete,
25
25
  onDismiss,
26
26
  onReadyToUse,
27
+ onResult,
27
28
  waitForReadyToUse,
28
29
  iframeProps,
29
30
  Component,
@@ -76,6 +77,7 @@ const IntentDialogOpener = props => {
76
77
  onCancel={handleDismiss}
77
78
  onTerminate={handleComplete}
78
79
  onReadyToUse={onReadyToUse}
80
+ onResult={onResult}
79
81
  waitForReadyToUse={waitForReadyToUse}
80
82
  iframeProps={iframeProps}
81
83
  />
@@ -96,6 +98,8 @@ IntentDialogOpener.propTypes = {
96
98
  onDismiss: PropTypes.func,
97
99
  /** Called when the intent service signals it is ready to use */
98
100
  onReadyToUse: PropTypes.func,
101
+ /** Called with each result the intent service sends while it stays open */
102
+ onResult: PropTypes.func,
99
103
  /** Keep the loading state until the intent service signals it is ready to use */
100
104
  waitForReadyToUse: PropTypes.bool,
101
105
  /** Action you want to execute */
@@ -13,10 +13,12 @@ jest.mock('cozy-ui/transpiled/react/Dialog', () => ({ children }) => (
13
13
 
14
14
  jest.mock('../IntentIframe', () => ({
15
15
  __esModule: true,
16
- default: ({ waitForReadyToUse }) => (
17
- <div
16
+ default: ({ waitForReadyToUse, onResult }) => (
17
+ <button
18
+ type="button"
18
19
  data-testid="intent-iframe"
19
20
  data-wait-for-ready-to-use={waitForReadyToUse}
21
+ onClick={() => onResult?.({ id: '1' })}
20
22
  />
21
23
  ),
22
24
  iframeProps: require('prop-types').shape({})
@@ -41,4 +43,23 @@ describe('IntentDialogOpener', () => {
41
43
  'true'
42
44
  )
43
45
  })
46
+
47
+ it('gives the results of the intent and stays open', () => {
48
+ const onResult = jest.fn()
49
+ const { getByRole, getByTestId, queryByTestId } = render(
50
+ <IntentDialogOpener
51
+ action="OPEN"
52
+ doctype="io.cozy.ai.chat.conversations"
53
+ onResult={onResult}
54
+ >
55
+ <button type="button">Open</button>
56
+ </IntentDialogOpener>
57
+ )
58
+
59
+ fireEvent.click(getByRole('button', { name: 'Open' }))
60
+ fireEvent.click(getByTestId('intent-iframe'))
61
+
62
+ expect(onResult).toHaveBeenCalledWith({ id: '1' })
63
+ expect(queryByTestId('intent-iframe')).toBeInTheDocument()
64
+ })
44
65
  })
@@ -27,6 +27,14 @@ Set `waitForReadyToUse` to keep the intent hidden behind the loading spinner
27
27
  until its service sends the `readyToUse` signal. This option is disabled by
28
28
  default because older intent services do not send this signal.
29
29
 
30
+ Set `onResult` to receive the results a service hands over while it stays
31
+ open, with `service.sendResult(result)`. `onTerminate` still receives the one
32
+ that ends the intent.
33
+
34
+ When `data` changes while the intent is open, the new data are sent to its
35
+ service, which gets them with `service.onData()`: the intent is not started
36
+ again.
37
+
30
38
  Set `data.theme.type` to `light` or `dark` to force that theme on the
31
39
  loading surface and pass it to the intent service. Any other value or no value
32
40
  keeps the caller's theme.
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
3
  import get from 'lodash/get'
4
+ import isEqual from 'lodash/isEqual'
4
5
  import PropTypes from 'prop-types'
5
6
  import React from 'react'
6
7
 
@@ -37,16 +38,18 @@ class IntentIframe extends React.Component {
37
38
  create = intents.create
38
39
  }
39
40
 
40
- create(action, type, {
41
+ this.intent = create(action, type, {
41
42
  ...DEFAULT_DATA,
42
43
  ...data
44
+ }).start(this.intentViewer, {
45
+ onReady: this.onFrameLoaded,
46
+ onHideCross: this.props.onHideCross,
47
+ onShowCross: this.props.onShowCross,
48
+ onReadyToUse: this.onReadyToUse,
49
+ onResult: this.props.onResult
43
50
  })
44
- .start(this.intentViewer, {
45
- onReady: this.onFrameLoaded,
46
- onHideCross: this.props.onHideCross,
47
- onShowCross: this.props.onShowCross,
48
- onReadyToUse: this.onReadyToUse
49
- })
51
+
52
+ this.intent
50
53
  .then(result => {
51
54
  // eslint-disable-next-line promise/always-return
52
55
  result ? onTerminate && onTerminate(result) : onCancel()
@@ -58,6 +61,14 @@ class IntentIframe extends React.Component {
58
61
  })
59
62
  }
60
63
 
64
+ componentDidUpdate(prevProps) {
65
+ // A service that stays open gets the new data, an older cozy-interapp
66
+ // cannot send them
67
+ if (!isEqual(prevProps.data, this.props.data)) {
68
+ this.intent?.sendData?.({ ...DEFAULT_DATA, ...this.props.data })
69
+ }
70
+ }
71
+
61
72
  onFrameLoaded = () => {
62
73
  this.setState({ frameLoaded: true }, () => {
63
74
  if (!this.props.waitForReadyToUse || this.state.readyToUse) {
@@ -136,6 +147,7 @@ IntentIframe.propTypes = {
136
147
  onHideCross: PropTypes.func,
137
148
  onShowCross: PropTypes.func,
138
149
  onReadyToUse: PropTypes.func,
150
+ onResult: PropTypes.func,
139
151
  waitForReadyToUse: PropTypes.bool
140
152
  }
141
153
 
@@ -9,37 +9,49 @@ jest.mock('cozy-ui/transpiled/react/Spinner', () => () => (
9
9
 
10
10
  function setup({ data, startError = null, waitForReadyToUse = false } = {}) {
11
11
  let startOptions
12
+ const sendData = jest.fn()
12
13
  const start = jest.fn((element, options) => {
13
14
  startOptions = options
14
15
  element.appendChild(document.createElement('iframe'))
15
- return startError ? Promise.reject(startError) : new Promise(() => {})
16
+ const started = startError
17
+ ? Promise.reject(startError)
18
+ : new Promise(() => {})
19
+ started.sendData = sendData
20
+ return started
16
21
  })
17
22
  const create = jest.fn(() => ({ start }))
18
23
  const onError = jest.fn()
19
24
  const onReadyToUse = jest.fn()
25
+ const onResult = jest.fn()
20
26
  const setIsLoading = jest.fn()
21
27
 
22
- const result = render(
28
+ const makeIframe = iframeData => (
23
29
  <IntentIframe
24
30
  action="PICK"
25
31
  client={{}}
26
32
  create={create}
27
- data={data}
33
+ data={iframeData}
28
34
  iframeProps={{ setIsLoading }}
29
35
  onCancel={jest.fn()}
30
36
  onError={onError}
31
37
  onReadyToUse={onReadyToUse}
38
+ onResult={onResult}
32
39
  onTerminate={jest.fn()}
33
40
  type="io.cozy.files"
34
41
  waitForReadyToUse={waitForReadyToUse}
35
42
  />
36
43
  )
44
+ const result = render(makeIframe(data))
37
45
 
38
46
  return {
39
47
  ...result,
48
+ rerenderWithData: newData => result.rerender(makeIframe(newData)),
49
+ create,
50
+ sendData,
40
51
  getStartOptions: () => startOptions,
41
52
  onError,
42
53
  onReadyToUse,
54
+ onResult,
43
55
  setIsLoading
44
56
  }
45
57
  }
@@ -53,6 +65,21 @@ describe('IntentIframe', () => {
53
65
  jest.restoreAllMocks()
54
66
  })
55
67
 
68
+ it('sends new data to the open intent, without starting it again', () => {
69
+ const { create, sendData, rerenderWithData } = setup({
70
+ data: { content: 'Bonjour' }
71
+ })
72
+
73
+ rerenderWithData({ content: 'Bonjour' })
74
+ expect(sendData).not.toHaveBeenCalled()
75
+
76
+ rerenderWithData({ content: 'Au revoir' })
77
+ expect(sendData).toHaveBeenCalledWith(
78
+ expect.objectContaining({ content: 'Au revoir' })
79
+ )
80
+ expect(create).toHaveBeenCalledTimes(1)
81
+ })
82
+
56
83
  it('keeps the iframe rendered behind the spinner until it is ready to use', () => {
57
84
  const {
58
85
  container,
@@ -106,6 +133,16 @@ describe('IntentIframe', () => {
106
133
  expect(setIsLoading).toHaveBeenCalledTimes(1)
107
134
  })
108
135
 
136
+ it('gives the results the service sends while the intent goes on', () => {
137
+ const { container, getStartOptions, onResult } = setup()
138
+
139
+ act(() => getStartOptions().onReady())
140
+ act(() => getStartOptions().onResult({ id: '1' }))
141
+
142
+ expect(onResult).toHaveBeenCalledWith({ id: '1' })
143
+ expect(container.querySelector('iframe')).toBeInTheDocument()
144
+ })
145
+
109
146
  it('shows intent errors instead of waiting for readyToUse', async () => {
110
147
  const error = new Error('Intent failed')
111
148
  const { container, onError, queryByTestId, setIsLoading } = setup({