Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cozy/cozy-libs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cozy-flags@2.10.1
Choose a base ref
...
head repository: cozy/cozy-libs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cozy-flags@2.10.2
Choose a head ref

Commits on Aug 4, 2022

  1. fix: Select action icon

    Merkur39 committed Aug 4, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    yorickvP Yorick
    Copy the full SHA
    033fce7 View commit details
  2. [skip ci] Publish

     - cozy-mespapiers-lib@1.1.15
    Cozy Bot committed Aug 4, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    yorickvP Yorick
    Copy the full SHA
    651e156 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    vcunat Vladimír Čunát
    Copy the full SHA
    73859b5 View commit details
  4. [skip ci] Publish

     - cozy-mespapiers-lib@1.2.0
    Cozy Bot committed Aug 4, 2022
    Copy the full SHA
    774aede View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c8e550f View commit details
  6. feat: Do not use the MoreOptions component anymore

    This component is no longer used temporarily,
    it will be used as soon as it offers more options
    than the PapersFab component
    Merkur39 committed Aug 4, 2022
    Copy the full SHA
    e51b29c View commit details
  7. feat: Limit max width of bitmap images

    For bitmap images, block the max width
    This prevents certain image width from being too large
    Merkur39 committed Aug 4, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    507a52b View commit details
  8. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7d9a296 View commit details
  9. [skip ci] Publish

     - cozy-mespapiers-lib@1.3.0
    Cozy Bot committed Aug 4, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    374a3a8 View commit details

Commits on Aug 5, 2022

  1. fix: Remove a reconnection step

    When the trigger is in a state which needs reconnection and when the
    user clicks on the "Reconnect" button, he still needed to click on a
    "reconnect" button one more time to display the BI webview.
    
    Now the BI webview is displayed directly.
    
    There are still some screens we don't want to display after the BI
    webview but this will be fixed in another PR
    doubleface authored and probot-auto-merge[bot] committed Aug 5, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    05d2cb6 View commit details
  2. fix: Remove unused request to BI connection

    This also removes a getTemporaryToken request which can save a lot of
    time visible by the user.
    
    We only used the id of the connection which we already have.
    doubleface authored and probot-auto-merge[bot] committed Aug 5, 2022
    Copy the full SHA
    be09798 View commit details
  3. [skip ci] Publish

     - cozy-harvest-lib@9.24.4
     - cozy-mespapiers-lib@1.3.1
    Cozy Bot committed Aug 5, 2022
    Copy the full SHA
    6143254 View commit details
  4. Copy the full SHA
    59a132f View commit details
  5. feat: Close OAuthWindow only on login success

    doubleface authored and probot-auto-merge[bot] committed Aug 5, 2022
    Copy the full SHA
    a8cf6a3 View commit details
  6. [skip ci] Publish

     - cozy-harvest-lib@9.25.0
     - cozy-mespapiers-lib@1.3.2
    Cozy Bot committed Aug 5, 2022
    Copy the full SHA
    9fe45cf View commit details

Commits on Aug 9, 2022

  1. Copy the full SHA
    88e246b View commit details
  2. Copy the full SHA
    8adf192 View commit details
  3. [skip ci] Publish

     - cozy-mespapiers-lib@1.4.0
    Cozy Bot committed Aug 9, 2022
    Copy the full SHA
    4456d69 View commit details
  4. Copy the full SHA
    ce13857 View commit details
  5. [skip ci] Publish

     - cozy-mespapiers-lib@1.5.0
    Cozy Bot committed Aug 9, 2022
    Copy the full SHA
    b9c2428 View commit details

Commits on Aug 10, 2022

  1. fix: Use correct image size

    The images used are usually 230x128
    Merkur39 committed Aug 10, 2022
    Copy the full SHA
    d290c39 View commit details
  2. [skip ci] Publish

     - cozy-mespapiers-lib@1.5.1
    Cozy Bot committed Aug 10, 2022
    Copy the full SHA
    1445850 View commit details

Commits on Aug 11, 2022

  1. Copy the full SHA
    2897f2c View commit details
  2. Copy the full SHA
    a77d785 View commit details
  3. [skip ci] Publish

     - cozy-mespapiers-lib@1.5.2
    Cozy Bot committed Aug 11, 2022
    Copy the full SHA
    bfc52cc View commit details

Commits on Aug 16, 2022

  1. feat: Add SearchResultLine component

    This component displays one line per file
    with an associated action button
    Merkur39 committed Aug 16, 2022
    Copy the full SHA
    d4c160c View commit details
  2. Copy the full SHA
    fdf384d View commit details
  3. fix: Open file action

    Merkur39 committed Aug 16, 2022
    Copy the full SHA
    2272ac3 View commit details
  4. [skip ci] Publish

     - cozy-mespapiers-lib@1.6.0
    Cozy Bot committed Aug 16, 2022
    Copy the full SHA
    095d6e7 View commit details

Commits on Aug 17, 2022

  1. docs: Update documentation

    Merkur39 committed Aug 17, 2022
    Copy the full SHA
    bbd56e2 View commit details
  2. [skip ci] Publish

     - cozy-mespapiers-lib@1.6.1
    Cozy Bot committed Aug 17, 2022
    Copy the full SHA
    ac49692 View commit details

Commits on Aug 18, 2022

  1. Copy the full SHA
    574e142 View commit details
  2. Copy the full SHA
    69220bf View commit details
  3. Copy the full SHA
    0692e64 View commit details
  4. Copy the full SHA
    53fc761 View commit details
  5. Copy the full SHA
    5580a69 View commit details
  6. feat: Add minLength constraint to InputMask

    It's possible to specify a minimum character length in an InputMask.
    Merkur39 committed Aug 18, 2022
    Copy the full SHA
    de6b122 View commit details
  7. Copy the full SHA
    43b8f09 View commit details
  8. [skip ci] Publish

     - cozy-mespapiers-lib@1.7.0
    Cozy Bot committed Aug 18, 2022
    Copy the full SHA
    8da718a View commit details

Commits on Aug 19, 2022

  1. Copy the full SHA
    75f17ec View commit details
  2. Copy the full SHA
    a0d85b1 View commit details
  3. Copy the full SHA
    51978d3 View commit details
  4. [skip ci] Publish

     - cozy-mespapiers-lib@1.8.0
    Cozy Bot committed Aug 19, 2022
    Copy the full SHA
    2e0b273 View commit details

Commits on Aug 22, 2022

  1. feat: Detect reconnect explicitely

    Before, we detected a reconnect with the presence of a connection id in
    the account. But if we use the creation BI webview to handle
    synchronizations, there will be a connection id in the account and the
    wrong url parameters will be used.
    
    Now we pass a "reconnect" parameter explicitiely
    doubleface authored and doubleface committed Aug 22, 2022
    Copy the full SHA
    b092392 View commit details
  2. feat: Use BI account creation webview to handle accounts synchonization

    The goal is to avoid to display the BI manage webview which allows
    modify, delete or create other BI connections of the user, which we
    cannot handle on cozy side at the moment.
    
    The user will need to enter it's own bank credentials before modifying
    accounts synchronization.
    
    The webview will close on its own.
    doubleface authored and doubleface committed Aug 22, 2022
    Copy the full SHA
    1b5e5ff View commit details
  3. feat: Handle cas with multiple bank ids

    We get the the bank id from the bi connection to not propose the full
    list of banks to the user each time he wants to update his
    synchronizations.
    doubleface authored and doubleface committed Aug 22, 2022
    Copy the full SHA
    9729626 View commit details
  4. [skip ci] Publish

     - cozy-harvest-lib@9.26.0
     - cozy-mespapiers-lib@1.8.1
    Cozy Bot committed Aug 22, 2022
    Copy the full SHA
    c161a91 View commit details
  5. fix: RefreshContracts now updates contracts in realtime

    The update of contracts was still done on the io.cozy.accounts and now
    the source to display the contracts is in io.cozy.bank.accounts.
    
    There were also some cases where the update of contracts was done
    multiple times and causes some 409 conflicts on accounts
    doubleface authored and doubleface committed Aug 22, 2022
    Copy the full SHA
    463e716 View commit details
  6. [skip ci] Publish

     - cozy-harvest-lib@9.26.1
     - cozy-mespapiers-lib@1.8.2
    Cozy Bot committed Aug 22, 2022
    Copy the full SHA
    cd08838 View commit details

Commits on Aug 23, 2022

  1. fix: Rename build job

    Current "test" job is responsible for running build, lint and tests, so
    its name is more about building the project than just testing it
    
    This commit renames it "build" to have a clearer intention
    Ldoppea committed Aug 23, 2022
    Copy the full SHA
    af6829a View commit details
Showing with 4,959 additions and 1,337 deletions.
  1. +1 −1 .travis.yml
  2. +12 −12 CODEOWNERS
  3. +8 −0 packages/babel-preset-cozy-app/CHANGELOG.md
  4. +2 −2 packages/babel-preset-cozy-app/README.md
  5. +2 −2 packages/babel-preset-cozy-app/package.json
  6. +8 −0 packages/browserslist-config-cozy/CHANGELOG.md
  7. +2 −2 packages/browserslist-config-cozy/README.md
  8. +1 −1 packages/browserslist-config-cozy/package.json
  9. +8 −0 packages/commitlint-config-cozy/CHANGELOG.md
  10. +2 −2 packages/commitlint-config-cozy/README.md
  11. +2 −2 packages/commitlint-config-cozy/package.json
  12. +35 −0 packages/cozy-authentication/CHANGELOG.md
  13. +2 −2 packages/cozy-authentication/README.md
  14. +4 −3 packages/cozy-authentication/package.json
  15. +46 −0 packages/cozy-codemods/CHANGELOG.md
  16. +3 −2 packages/cozy-codemods/package.json
  17. +3 −0 packages/cozy-codemods/src/transforms/__testfixtures__/transform-mui-styles-imports.input.js
  18. +1 −0 packages/cozy-codemods/src/transforms/__testfixtures__/transform-mui-styles-imports.output.js
  19. +2 −0 packages/cozy-codemods/src/transforms/__tests__/transform-mui-styles-imports.spec.js
  20. +25 −0 packages/cozy-codemods/src/transforms/transform-mui-styles-imports.js
  21. +35 −0 packages/cozy-device-helper/CHANGELOG.md
  22. +2 −2 packages/cozy-device-helper/package.json
  23. +18 −0 packages/cozy-device-helper/src/flagship.ts
  24. +31 −0 packages/cozy-doctypes/CHANGELOG.md
  25. +6 −5 packages/cozy-doctypes/package.json
  26. +17 −4 packages/cozy-doctypes/src/Document.js
  27. +8 −0 packages/cozy-flags/CHANGELOG.md
  28. +2 −2 packages/cozy-flags/package.json
  29. +183 −0 packages/cozy-harvest-lib/CHANGELOG.md
  30. +1 −1 packages/cozy-harvest-lib/README.md
  31. +8 −8 packages/cozy-harvest-lib/package.json
  32. +7 −0 packages/cozy-harvest-lib/src/components/DisconnectedAccountModal.spec.jsx
  33. +2 −1 packages/cozy-harvest-lib/src/components/EditAccountModal.jsx
  34. +17 −13 ...st-lib/src/components/KonnectorConfiguration/ConfigurationTab/BIContractActivationWindow.spec.jsx
  35. +19 −29 ...harvest-lib/src/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.jsx
  36. +11 −7 packages/cozy-harvest-lib/src/components/KonnectorConfiguration/ConfigurationTab/Contracts.jsx
  37. +30 −17 packages/cozy-harvest-lib/src/components/OAuthForm.jsx
  38. +14 −3 packages/cozy-harvest-lib/src/components/OAuthForm.spec.js
  39. +1 −3 packages/cozy-harvest-lib/src/components/OAuthWindow.jsx
  40. +13 −5 packages/cozy-harvest-lib/src/components/Routes.jsx
  41. +2 −13 packages/cozy-harvest-lib/src/components/__snapshots__/OAuthForm.spec.js.snap
  42. +5 −1 packages/cozy-harvest-lib/src/helpers/useKonnectorWithTriggers.js
  43. +3 −2 packages/cozy-harvest-lib/src/locales/en.json
  44. +3 −2 packages/cozy-harvest-lib/src/locales/fr.json
  45. +51 −71 packages/cozy-harvest-lib/src/services/biWebView.js
  46. +93 −130 packages/cozy-harvest-lib/src/services/biWebView.spec.js
  47. +18 −2 packages/cozy-harvest-lib/src/services/utils.js
  48. +15 −0 packages/cozy-harvest-lib/src/services/utils.spec.js
  49. +38 −0 packages/cozy-intent/CHANGELOG.md
  50. +3 −3 packages/cozy-intent/package.json
  51. +19 −7 packages/cozy-intent/src/api/models/methods.ts
  52. +1 −1 packages/cozy-intent/src/api/services/NativeService.ts
  53. +1 −1 packages/cozy-intent/src/api/services/WebviewService.ts
  54. +19 −0 packages/cozy-interapp/CHANGELOG.md
  55. +4 −3 packages/cozy-interapp/package.json
  56. +11 −0 packages/cozy-logger/CHANGELOG.md
  57. +3 −2 packages/cozy-logger/package.json
  58. +506 −0 packages/cozy-mespapiers-lib/CHANGELOG.md
  59. +17 −1 packages/cozy-mespapiers-lib/README.md
  60. +15 −1 packages/cozy-mespapiers-lib/babel.config.js
  61. +6 −2 packages/cozy-mespapiers-lib/docs/papersDefinitions.md
  62. +13 −13 packages/cozy-mespapiers-lib/package.json
  63. +15 −0 packages/cozy-mespapiers-lib/preprocess.js
  64. BIN packages/cozy-mespapiers-lib/src/assets/images/IlluIdCardExpirationDateHelp.png
  65. +1 −1 packages/cozy-mespapiers-lib/src/components/Actions/ActionMenuItemWrapper.jsx
  66. +3 −3 packages/cozy-mespapiers-lib/src/components/Actions/Items/createPaper.js
  67. +6 −4 packages/cozy-mespapiers-lib/src/components/Actions/Items/open.js
  68. +25 −0 packages/cozy-mespapiers-lib/src/components/Actions/Items/rename.js
  69. +6 −5 packages/cozy-mespapiers-lib/src/components/Actions/Items/select.js
  70. +28 −66 packages/cozy-mespapiers-lib/src/components/AppRouter.jsx
  71. +0 −58 packages/cozy-mespapiers-lib/src/components/AppRouter.spec.jsx
  72. +1 −1 packages/cozy-mespapiers-lib/src/components/CompositeHeader/CompositeHeader.jsx
  73. +9 −2 packages/cozy-mespapiers-lib/src/components/CompositeHeader/CompositeHeaderImage.jsx
  74. +1 −4 packages/cozy-mespapiers-lib/src/components/Contexts/ScannerI18nProvider.jsx
  75. +1 −23 packages/cozy-mespapiers-lib/src/components/Contexts/StepperDialogProvider.jsx
  76. +69 −0 packages/cozy-mespapiers-lib/src/components/Home/FilterButton.jsx
  77. +44 −36 packages/cozy-mespapiers-lib/src/components/Home/Home.jsx
  78. +4 −3 packages/cozy-mespapiers-lib/src/components/Home/HomeToolbar.jsx
  79. +6 −5 packages/cozy-mespapiers-lib/src/components/Home/helpers.js
  80. +41 −12 packages/cozy-mespapiers-lib/src/components/Home/helpers.spec.js
  81. +28 −0 packages/cozy-mespapiers-lib/src/components/Hooks/useReferencedContact.jsx
  82. +1 −1 packages/cozy-mespapiers-lib/src/components/ImportDropdown/ImportDropdownItems.jsx
  83. +1 −5 packages/cozy-mespapiers-lib/src/components/MesPapiersLib.jsx
  84. +1 −1 packages/cozy-mespapiers-lib/src/components/ModelSteps/AcquisitionResult.jsx
  85. +2 −2 packages/cozy-mespapiers-lib/src/components/ModelSteps/Contact.jsx
  86. +3 −2 packages/cozy-mespapiers-lib/src/components/ModelSteps/ContactList.jsx
  87. +12 −2 packages/cozy-mespapiers-lib/src/components/ModelSteps/ContactWrapper.jsx
  88. +68 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/ContactEditDialog.jsx
  89. +79 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/ContactEditItem.jsx
  90. +83 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/ContactEditList.jsx
  91. +66 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/ContactEditWrapper.jsx
  92. +134 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/InformationEditWrapper.jsx
  93. +28 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/PageEdit/PageEditDesktop.jsx
  94. +39 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/PageEdit/PageEditItems.jsx
  95. +23 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/PageEdit/PageEditMobile.jsx
  96. +73 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/PageEdit/index.jsx
  97. +113 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/helpers.js
  98. +427 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/helpers.spec.js
  99. +11 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/styles.styl
  100. +44 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/useCurrentEditInformations.jsx
  101. +121 −0 packages/cozy-mespapiers-lib/src/components/ModelSteps/Edit/useCurrentEditInformations.spec.jsx
  102. +11 −40 packages/cozy-mespapiers-lib/src/components/ModelSteps/Information.jsx
  103. +1 −1 packages/cozy-mespapiers-lib/src/components/ModelSteps/widgets/InputDateAdapter.jsx
  104. +23 −5 packages/cozy-mespapiers-lib/src/components/ModelSteps/widgets/InputTextAdapter.jsx
  105. +4 −0 packages/cozy-mespapiers-lib/src/components/MoreOptions/MoreOptions.jsx
  106. +1 −1 packages/cozy-mespapiers-lib/src/components/Multiselect/GhostButton.jsx
  107. +1 −6 packages/cozy-mespapiers-lib/src/components/Multiselect/MultiselectPaperList.jsx
  108. +4 −4 packages/cozy-mespapiers-lib/src/components/Multiselect/MultiselectView.jsx
  109. +1 −1 packages/cozy-mespapiers-lib/src/components/Multiselect/MultiselectViewActions.jsx
  110. +33 −33 packages/cozy-mespapiers-lib/src/components/OnboardedGuardedRoute.jsx
  111. +0 −105 packages/cozy-mespapiers-lib/src/components/OnboardedGuardedRoute.spec.jsx
  112. +1 −1 packages/cozy-mespapiers-lib/src/components/Papers/PaperCardItem.jsx
  113. +3 −5 packages/cozy-mespapiers-lib/src/components/Papers/PaperGroup.jsx
  114. +45 −21 packages/cozy-mespapiers-lib/src/components/Papers/PaperItem.jsx
  115. +43 −13 packages/cozy-mespapiers-lib/src/components/Papers/PaperItem.spec.jsx
  116. +6 −2 packages/cozy-mespapiers-lib/src/components/Papers/PaperLine.jsx
  117. +20 −2 packages/cozy-mespapiers-lib/src/components/Papers/PapersList.jsx
  118. +7 −11 packages/cozy-mespapiers-lib/src/components/Papers/PapersListWrapper.jsx
  119. +144 −0 packages/cozy-mespapiers-lib/src/components/Papers/Renaming/RenameInput.jsx
  120. +35 −0 packages/cozy-mespapiers-lib/src/components/Papers/Renaming/helpers.js
  121. +15 −7 packages/cozy-mespapiers-lib/src/components/Papers/helpers.js
  122. +4 −3 packages/cozy-mespapiers-lib/src/components/PapersFab/PapersFab.jsx
  123. +8 −4 packages/cozy-mespapiers-lib/src/components/Placeholders/FeaturedPlaceholdersList.jsx
  124. +4 −4 ...ges/cozy-mespapiers-lib/src/components/Placeholders/PlaceholderListModal/PlaceholderListModal.jsx
  125. +14 −6 packages/cozy-mespapiers-lib/src/components/Placeholders/PlaceholderListModal/PlaceholdersList.jsx
  126. +1 −1 ...es/cozy-mespapiers-lib/src/components/Placeholders/PlaceholderListModal/PlaceholdersList.spec.jsx
  127. +1 −1 packages/cozy-mespapiers-lib/src/components/SearchInput/SearchInput.jsx
  128. +49 −7 packages/cozy-mespapiers-lib/src/components/SearchResult/SearchResult.jsx
  129. +81 −0 packages/cozy-mespapiers-lib/src/components/SearchResult/SearchResultLine.jsx
  130. +25 −13 packages/cozy-mespapiers-lib/src/components/StepperDialog/CreatePaperModal.jsx
  131. +1 −1 packages/cozy-mespapiers-lib/src/components/StepperDialog/StepperDialog.jsx
  132. +5 −1 packages/cozy-mespapiers-lib/src/components/StepperDialog/StepperDialogWrapper.jsx
  133. +28 −28 packages/cozy-mespapiers-lib/src/components/Viewer/FileViewerWithQuery.jsx
  134. +9 −0 packages/cozy-mespapiers-lib/src/components/Viewer/FilesViewer.jsx
  135. +3 −3 packages/cozy-mespapiers-lib/src/components/Viewer/SelectFileButton.jsx
  136. +1 −0 packages/cozy-mespapiers-lib/src/constants/const.js
  137. +144 −41 packages/cozy-mespapiers-lib/src/constants/papersDefinitions.json
  138. +32 −0 packages/cozy-mespapiers-lib/src/helpers/findPlaceholders.js
  139. +96 −7 packages/cozy-mespapiers-lib/src/helpers/findPlaceholders.spec.js
  140. +40 −0 packages/cozy-mespapiers-lib/src/helpers/makeInputsInformationStep.js
  141. +55 −0 packages/cozy-mespapiers-lib/src/helpers/makeInputsInformationStep.spec.js
  142. +8 −0 packages/cozy-mespapiers-lib/src/helpers/queries.js
  143. +31 −2 packages/cozy-mespapiers-lib/src/locales/en.json
  144. +31 −2 packages/cozy-mespapiers-lib/src/locales/fr.json
  145. +24 −6 packages/cozy-mespapiers-lib/src/utils/input.js
  146. +49 −39 packages/cozy-mespapiers-lib/src/utils/input.spec.js
  147. +98 −0 packages/cozy-mespapiers-lib/test/mockPaperDefinitions.js
  148. +11 −0 packages/cozy-mjml/CHANGELOG.md
  149. +2 −1 packages/cozy-mjml/package.json
  150. +19 −0 packages/cozy-procedures/CHANGELOG.md
  151. +3 −2 packages/cozy-procedures/package.json
  152. +27 −0 packages/cozy-realtime/CHANGELOG.md
  153. +3 −3 packages/cozy-realtime/package.json
  154. +8 −0 packages/cozy-release/CHANGELOG.md
  155. +2 −2 packages/cozy-release/README.md
  156. +1 −1 packages/cozy-release/package.json
  157. +35 −0 packages/cozy-scanner/CHANGELOG.md
  158. +4 −3 packages/cozy-scanner/package.json
  159. +43 −0 packages/cozy-sharing/CHANGELOG.md
  160. +3 −3 packages/cozy-sharing/package.json
  161. +40 −0 packages/eslint-config-cozy-app/CHANGELOG.md
  162. +2 −2 packages/eslint-config-cozy-app/README.md
  163. +12 −13 packages/eslint-config-cozy-app/package.json
  164. +2 −1 packages/eslint-config-cozy-app/react.js
  165. +43 −0 packages/playgrounds/CHANGELOG.md
  166. +6 −6 packages/playgrounds/package.json
  167. +396 −251 yarn.lock
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ jobs:
include:
- name: 'Repo Doctor'
script: '[ $TRAVIS_EVENT_TYPE = "cron" ] && pushd ./packages/repo-doctor && yarn start:mattermost && popd || true'
- name: 'Tests'
- name: 'Build'
script:
- ./scripts/travis.sh

24 changes: 12 additions & 12 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# General code owners
* @trollepierre @acezard
* @acezard

# Based on the Paper of the Technical maintainers of 2022
packages/cozy-harvest-lib @doubleface @trollepierre
packages/cozy-doctypes/ @doubleface @trollepierre
packages/cozy-flags/ @acezard @trollepierre @Ldoppea
packages/cozy-app-publish/ @acezard @doubleface @trollepierre
packages/cozy-interapp/ @Ldoppea @acezard @trollepierre
packages/cozy-harvest-lib @doubleface
packages/cozy-doctypes/ @doubleface
packages/cozy-flags/ @acezard @Ldoppea
packages/cozy-app-publish/ @acezard @doubleface
packages/cozy-interapp/ @Ldoppea @acezard
packages/cozy-intent/ @Ldoppea @acezard
packages/cozy-realtime/ @Ldoppea @trollepierre
packages/eslint-config-cozy-app/ @acezard @trollepierre
packages/renovate-config-cozy/ @doubleface @trollepierre
packages/renovate-config-cozy-libs/ @doubleface @trollepierre
packages/cozy-sharing/ @Ldoppea @acezard @trollepierre
packages/cozy-mespapiers-lib/ @Merkur39 @JF-Cozy
packages/cozy-realtime/ @Ldoppea
packages/eslint-config-cozy-app/ @acezard
packages/renovate-config-cozy/ @doubleface
packages/renovate-config-cozy-libs/ @doubleface
packages/cozy-sharing/ @Ldoppea @acezard
packages/cozy-mespapiers-lib/ @Merkur39 @JF-Cozy @PolariTOON
8 changes: 8 additions & 0 deletions packages/babel-preset-cozy-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2.0.4 (2022-10-03)

**Note:** Version bump only for package babel-preset-cozy-app





## 2.0.3 (2022-08-01)


4 changes: 2 additions & 2 deletions packages/babel-preset-cozy-app/README.md
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ See the options on the official docs :

You can reach the Cozy Community by:

- Chatting with us on IRC [#cozycloud on Freenode][freenode]
- Chatting with us on IRC [#cozycloud on Libera.Chat][libera]
- Posting on our [Forum][forum]
- Posting issues on the [Github repos][github]
- Say Hi! on [Twitter][twitter]
@@ -149,7 +149,7 @@ You can reach the Cozy Community by:

[cozy]: https://cozy.io "Cozy Cloud"

[freenode]: http://webchat.freenode.net/?randomnick=1&channels=%23cozycloud&uio=d4
[libera]: https://web.libera.chat/#cozycloud

[forum]: https://forum.cozy.io/

4 changes: 2 additions & 2 deletions packages/babel-preset-cozy-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-cozy-app",
"version": "2.0.3",
"version": "2.0.4",
"description": "Babel preset for Cozy Application (Cozy Cloud)",
"author": "CPatchane <code@patchane.com>",
"repository": {
@@ -27,7 +27,7 @@
"@babel/preset-react": "^7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@babel/runtime": "^7.16.3",
"browserslist-config-cozy": "^0.4.0",
"browserslist-config-cozy": "^0.4.1",
"lodash": "^4.17.21",
"typescript": "^4.5.2"
}
8 changes: 8 additions & 0 deletions packages/browserslist-config-cozy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 0.4.1 (2022-10-03)

**Note:** Version bump only for package browserslist-config-cozy





# 0.4.0 (2021-02-12)


4 changes: 2 additions & 2 deletions packages/browserslist-config-cozy/README.md
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@

You can reach the Cozy Community by:

- Chatting with us on IRC [#cozycloud on Freenode][freenode]
- Chatting with us on IRC [#cozycloud on Libera.Chat][libera]
- Posting on our [Forum][forum]
- Posting issues on the [Github repos][github]
- Say Hi! on [Twitter][twitter]
@@ -38,7 +38,7 @@ The maintainers for Browserslist Config Cozy are [CPatchane](https://github.com/

[cozy]: https://cozy.io "Cozy Cloud"

[freenode]: http://webchat.freenode.net/?randomnick=1&channels=%23cozycloud&uio=d4
[libera]: https://web.libera.chat/#cozycloud

[forum]: https://forum.cozy.io/

2 changes: 1 addition & 1 deletion packages/browserslist-config-cozy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browserslist-config-cozy",
"version": "0.4.0",
"version": "0.4.1",
"description": "Shareable browserslist config enforcing the Cozy official supported browsers list",
"main": "index.js",
"author": "Cozy",
8 changes: 8 additions & 0 deletions packages/commitlint-config-cozy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 0.7.9 (2022-10-03)

**Note:** Version bump only for package commitlint-config-cozy





## 0.7.8 (2022-08-01)

**Note:** Version bump only for package commitlint-config-cozy
4 changes: 2 additions & 2 deletions packages/commitlint-config-cozy/README.md
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@

You can reach the Cozy Community by:

- Chatting with us on IRC [#cozycloud on Freenode][freenode]
- Chatting with us on IRC [#cozycloud on Libera.Chat][libera]
- Posting on our [Forum][forum]
- Posting issues on the [Github repos][github]
- Say Hi! on [Twitter][twitter]
@@ -62,7 +62,7 @@ The maintainer for Commitlint Config Cozy is [kosssi](https://github.com/kosssi)

[cozy]: https://cozy.io "Cozy Cloud"

[freenode]: http://webchat.freenode.net/?randomnick=1&channels=%23cozycloud&uio=d4
[libera]: https://web.libera.chat/#cozycloud

[forum]: https://forum.cozy.io/

4 changes: 2 additions & 2 deletions packages/commitlint-config-cozy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "commitlint-config-cozy",
"version": "0.7.8",
"version": "0.7.9",
"description": "Shareable commitlint config enforcing the cozy commit convention",
"main": "index.js",
"author": "Cozy",
@@ -20,7 +20,7 @@
"@babel/core": "7.16.12",
"@commitlint/lint": "16.2.4",
"babel-jest": "26.6.3",
"babel-preset-cozy-app": "^2.0.3",
"babel-preset-cozy-app": "^2.0.4",
"jest": "26.6.3"
},
"dependencies": {
35 changes: 35 additions & 0 deletions packages/cozy-authentication/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,41 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2.10.8 (2022-10-03)

**Note:** Version bump only for package cozy-authentication





## [2.10.7](https://github.com/cozy/cozy-libs/compare/cozy-authentication@2.10.6...cozy-authentication@2.10.7) (2022-09-12)

**Note:** Version bump only for package cozy-authentication





## [2.10.6](https://github.com/cozy/cozy-libs/compare/cozy-authentication@2.10.5...cozy-authentication@2.10.6) (2022-09-06)

**Note:** Version bump only for package cozy-authentication





## 2.10.5 (2022-08-29)


### Bug Fixes

* Add prepublish script ([30a26e5](https://github.com/cozy/cozy-libs/commit/30a26e5109dcdfc636c76e6cdd20fdec313359ee))





## 2.10.4 (2022-08-01)

**Note:** Version bump only for package cozy-authentication
4 changes: 2 additions & 2 deletions packages/cozy-authentication/README.md
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ If you want to work on cozy-authentication itself and submit code modifications,

You can reach the Cozy Community by:

- Chatting with us on IRC [#cozycloud on Freenode][freenode]
- Chatting with us on IRC [#cozycloud on Libera.Chat][libera]
- Posting on our [Forum][forum]
- Posting issues on the [Github repos][github]
- Say Hi! on [Twitter][twitter]
@@ -35,7 +35,7 @@ cozy-authentication is developed by Cozy Cloud and distributed under the [MIT][]

[contribute]: CONTRIBUTING.md

[freenode]: http://webchat.freenode.net/?randomnick=1&channels=%23cozycloud&uio=d4
[libera]: https://web.libera.chat/#cozycloud

[forum]: https://forum.cozy.io/

7 changes: 4 additions & 3 deletions packages/cozy-authentication/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cozy-authentication",
"version": "2.10.4",
"version": "2.10.8",
"description": "Component providing login to a Cozy",
"main": "dist/index.js",
"files": [
@@ -11,6 +11,7 @@
"scripts": {
"prepare": "yarn build; yarn copy-files",
"build": "env BABEL_ENV=transpilation yarn babel src/ --out-dir dist",
"prepublishOnly": "yarn build",
"watch": "yarn build -w",
"test": "yarn jest src",
"copy-files": "cp -r src/locales/ dist/locales/",
@@ -21,7 +22,7 @@
"devDependencies": {
"@babel/cli": "7.16.8",
"@babel/polyfill": "7.12.1",
"babel-preset-cozy-app": "^2.0.3",
"babel-preset-cozy-app": "^2.0.4",
"cozy-client": "13.21.0",
"cozy-ui": "40.9.1",
"cssnano-preset-advanced": "4.0.8",
@@ -38,7 +39,7 @@
"react-router": "6.3.0"
},
"dependencies": {
"cozy-device-helper": "^2.2.2",
"cozy-device-helper": "^2.4.1",
"localforage": "1.7.3",
"prop-types": "15.7.2",
"snarkdown": "1.2.2",
46 changes: 46 additions & 0 deletions packages/cozy-codemods/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,52 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.18.4 (2022-10-03)

**Note:** Version bump only for package @cozy/codemods





## [1.18.3](https://github.com/cozy/cozy-libs/compare/@cozy/codemods@1.18.2...@cozy/codemods@1.18.3) (2022-09-12)

**Note:** Version bump only for package @cozy/codemods





## [1.18.2](https://github.com/cozy/cozy-libs/compare/@cozy/codemods@1.18.1...@cozy/codemods@1.18.2) (2022-08-31)

**Note:** Version bump only for package @cozy/codemods





## [1.18.1](https://github.com/cozy/cozy-libs/compare/@cozy/codemods@1.18.0...@cozy/codemods@1.18.1) (2022-08-29)


### Bug Fixes

* Add prepublish script ([30a26e5](https://github.com/cozy/cozy-libs/commit/30a26e5109dcdfc636c76e6cdd20fdec313359ee))





# 1.18.0 (2022-08-24)


### Features

* Add codemods for mui styles imports ([4522034](https://github.com/cozy/cozy-libs/commit/4522034de4bf09ec448d62c3d84e2a1571f9005a)), closes [cozy/cozy-ui#2204](https://github.com/cozy/cozy-ui/issues/2204)





## 1.17.1 (2022-08-01)

**Note:** Version bump only for package @cozy/codemods
5 changes: 3 additions & 2 deletions packages/cozy-codemods/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cozy/codemods",
"version": "1.17.1",
"version": "1.18.4",
"description": "Codeshifts used inside Cozies",
"main": "index.js",
"repository": "https://github.com/cozy/cozy-libs",
@@ -12,6 +12,7 @@
"scripts": {
"docs": "jsdoc2md -f 'src/**/*.js' -t .README.md.template > README.md",
"build": "babel src -d dist --verbose",
"prepublishOnly": "yarn build",
"test": "jest",
"cli": "node src/cli.js"
},
@@ -25,7 +26,7 @@
"jscodeshift": "^0.11.0"
},
"devDependencies": {
"eslint-config-cozy-app": "^4.2.1",
"eslint-config-cozy-app": "^5.1.1",
"jest": "26.6.3",
"jsdoc-to-markdown": "5.0.3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import makeStyles from "cozy-ui/transpiled/react/helpers/makeStyles";
import useTheme from "cozy-ui/transpiled/react/helpers/useTheme";
import withStyles from "cozy-ui/transpiled/react/helpers/withStyles";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { makeStyles, useTheme, withStyles } from "cozy-ui/transpiled/react/styles";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const defineTest = require('jscodeshift/dist/testUtils').defineTest
defineTest(__dirname, 'transform-mui-styles-imports')
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { imports } from '..'

export default function transformMuiStylesImports(file, api) {
var j = api.jscodeshift
const root = j(file.source)

imports.simplify(root, {
imports: {
makeStyles: {
importPath: 'cozy-ui/transpiled/react/styles',
defaultImport: false
},
useTheme: {
importPath: 'cozy-ui/transpiled/react/styles',
defaultImport: false
},
withStyles: {
importPath: 'cozy-ui/transpiled/react/styles',
defaultImport: false
}
}
})

return root.toSource()
}
35 changes: 35 additions & 0 deletions packages/cozy-device-helper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,41 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2.4.1 (2022-10-03)

**Note:** Version bump only for package cozy-device-helper





# [2.4.0](https://github.com/cozy/cozy-libs/compare/cozy-device-helper@2.3.0...cozy-device-helper@2.4.0) (2022-09-12)


### Features

* Update FlagshipMetadata interface ([b82cf89](https://github.com/cozy/cozy-libs/commit/b82cf899534edade60f5e1157d614becebe6c5e7))





# 2.3.0 (2022-09-06)


### Bug Fixes

* Use correct image size ([d290c39](https://github.com/cozy/cozy-libs/commit/d290c39a26edfdd7e35fbe3f6822ac7e3dc5f769))


### Features

* Update FlagshipMetadata interface ([d8da519](https://github.com/cozy/cozy-libs/commit/d8da519be2a54602d856ba3eecb4b2a6e18b74e5))





## 2.2.2 (2022-08-01)

**Note:** Version bump only for package cozy-device-helper
4 changes: 2 additions & 2 deletions packages/cozy-device-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cozy-device-helper",
"description": "To know more information about the device platform",
"version": "2.2.2",
"version": "2.4.1",
"author": "Cozy",
"bugs": {
"url": "https://github.com/cozy/cozy-libs/issues"
@@ -14,7 +14,7 @@
"@babel/core": "7.16.12",
"@types/react-native": "0.67.7",
"babel-jest": "26.6.3",
"babel-preset-cozy-app": "^2.0.3",
"babel-preset-cozy-app": "^2.0.4",
"jest": "26.6.3"
},
"files": [
18 changes: 18 additions & 0 deletions packages/cozy-device-helper/src/flagship.ts
Original file line number Diff line number Diff line change
@@ -8,11 +8,29 @@ export enum FlagshipRoutes {
Stack = 'stack'
}

export enum BiometryType {
Face = 'Face',
FaceID = 'FaceID',
Fingerprint = 'Fingerprint',
Iris = 'Iris',
TouchID = 'TouchID'
}

export interface FlagshipMetadata {
capabilities?: {
biometryType?: BiometryType
}
hasBiometry?: boolean
immersive?: boolean
navbarHeight?: number
platform?: Record<string, unknown>
route?: FlagshipRoutes
settings?: {
PINEnabled?: boolean
autoLockDelay?: number
autoLockEnabled?: boolean
biometryEnabled?: boolean
}
statusBarHeight?: number
version?: string
}
31 changes: 31 additions & 0 deletions packages/cozy-doctypes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,37 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.85.4 (2022-10-03)

**Note:** Version bump only for package cozy-doctypes





## [1.85.3](https://github.com/cozy/cozy-libs/compare/cozy-doctypes@1.85.2...cozy-doctypes@1.85.3) (2022-08-29)


### Bug Fixes

* Add prepublish script ([30a26e5](https://github.com/cozy/cozy-libs/commit/30a26e5109dcdfc636c76e6cdd20fdec313359ee))





## 1.85.2 (2022-08-29)


### Bug Fixes

* Remove a reconnection step ([05d2cb6](https://github.com/cozy/cozy-libs/commit/05d2cb674d9ce69164cf0a099059520cbf4f1722))
* Use bookmark if present ([ea12d1d](https://github.com/cozy/cozy-libs/commit/ea12d1dbe3437794734a4b3505670a5434201a19))





## [1.85.1](https://github.com/cozy/cozy-libs/compare/cozy-doctypes@1.85.0...cozy-doctypes@1.85.1) (2022-08-01)

**Note:** Version bump only for package cozy-doctypes
11 changes: 6 additions & 5 deletions packages/cozy-doctypes/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "cozy-doctypes",
"version": "1.85.1",
"version": "1.85.4",
"description": "Definitions for Cozy models",
"main": "src/index.js",
"browser": "dist/index.js",
"repository": "git@github.com:cozy/cozy-libs.git",
"author": "Cozy",
"license": "MIT",
"dependencies": {
"cozy-logger": "^1.9.0",
"cozy-logger": "^1.9.1",
"date-fns": "^1.30.1",
"es6-promise-pool": "^2.5.0",
"lodash": "^4.17.19",
@@ -17,11 +17,11 @@
"devDependencies": {
"@babel/cli": "7.16.8",
"@babel/core": "7.16.12",
"babel-preset-cozy-app": "^2.0.3",
"babel-preset-cozy-app": "^2.0.4",
"btoa": "1.2.1",
"cozy-client": "13.21.0",
"cozy-client-js": "0.19.0",
"cozy-flags": "^2.10.1",
"cozy-flags": "^2.10.2",
"cozy-stack-client": "13.20.2",
"eslint-plugin-node": "10.0.0",
"fs-extra": "8.1.0",
@@ -37,7 +37,8 @@
},
"scripts": {
"lint": "cd ../../; yarn eslint --ext js,jsx packages/cozy-doctypes",
"build": "babel src -d dist",
"build": "babel src -d dist --verbose",
"prepublishOnly": "yarn build",
"watch": "yarn build --watch",
"test": "jest src/",
"encrypt-banking-tests": "cd src/banking/; make encrypted.tar.gz.gpg",
21 changes: 17 additions & 4 deletions packages/cozy-doctypes/src/Document.js
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ const sortBy = require('lodash/sortBy')
const get = require('lodash/get')
const { parallelMap } = require('./utils')
const CozyClient = require('cozy-client/dist/CozyClient').default
const Q = require('cozy-client/dist/queries/dsl').Q
const log = require('cozy-logger').namespace('Document')
const querystring = require('querystring')

@@ -579,12 +580,24 @@ class Document {
return this.fetchAll()
}

const result = []
let query
// let's deal with very old cozy-client where Q doesn't exist.
if (Q !== undefined) {
query = Q(this.doctype).where(selector)
} else {
query = this.cozyClient.find(this.doctype).where(selector)
}

let resp = await this.cozyClient.query(query)
let result = resp.data

const query = this.cozyClient.find(this.doctype).where(selector)
let resp = { next: true }
while (resp && resp.next) {
resp = await this.cozyClient.query(query.offset(result.length))
if (resp.bookmark && query.offsetBookmark) {
resp = await this.cozyClient.query(query.offsetBookmark(resp.bookmark))
} else {
resp = await this.cozyClient.query(query.offset(result.length))
}

result.push(...resp.data)
}

8 changes: 8 additions & 0 deletions packages/cozy-flags/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2.10.2 (2022-10-03)

**Note:** Version bump only for package cozy-flags





## 2.10.1 (2022-08-01)

**Note:** Version bump only for package cozy-flags
4 changes: 2 additions & 2 deletions packages/cozy-flags/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cozy-flags",
"version": "2.10.1",
"version": "2.10.2",
"description": "Flag library used in Cozy",
"main": "dist/index.js",
"browser": "dist/index.browser.js",
@@ -25,7 +25,7 @@
"devDependencies": {
"@babel/cli": "7.16.8",
"@testing-library/react-hooks": "3.2.1",
"babel-preset-cozy-app": "^2.0.3",
"babel-preset-cozy-app": "^2.0.4",
"cozy-client": "^32.2.0",
"jest-localstorage-mock": "2.4.21",
"react": "16.12.0"
183 changes: 183 additions & 0 deletions packages/cozy-harvest-lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,189 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [9.26.15](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.14...cozy-harvest-lib@9.26.15) (2022-10-03)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.14](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.13...cozy-harvest-lib@9.26.14) (2022-09-19)


### Bug Fixes

* Deal with empty and malformed encrypted values ([b4a6406](https://github.com/cozy/cozy-libs/commit/b4a6406be80cec7d3b7246dc42c19a419e442224))





## [9.26.13](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.12...cozy-harvest-lib@9.26.13) (2022-09-15)


### Bug Fixes

* Add missing intentsApi prop in DumbEditAccountModal ([bc4ac01](https://github.com/cozy/cozy-libs/commit/bc4ac01b734f51091c24091e543d55315a4a24f1))





## [9.26.12](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.11...cozy-harvest-lib@9.26.12) (2022-09-12)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.11](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.10...cozy-harvest-lib@9.26.11) (2022-09-12)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.10](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.9...cozy-harvest-lib@9.26.10) (2022-09-07)


### Bug Fixes

* Hide BIContractActivationWindow begin the bi webview flag ([3f7e374](https://github.com/cozy/cozy-libs/commit/3f7e374d7ee7e60f1d25f965e75f50e994b4dc68))





## [9.26.9](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.8...cozy-harvest-lib@9.26.9) (2022-09-07)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.8](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.7...cozy-harvest-lib@9.26.8) (2022-09-06)


### Bug Fixes

* Open oauth window for oauth connectors ([e8293f6](https://github.com/cozy/cozy-libs/commit/e8293f659d3d9bb643fb528b4328885ba451e79e))





## [9.26.7](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.6...cozy-harvest-lib@9.26.7) (2022-09-06)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.6](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.5...cozy-harvest-lib@9.26.6) (2022-08-31)


### Bug Fixes

* Add realtime on bank accounts ([3a03448](https://github.com/cozy/cozy-libs/commit/3a03448e0a371377023f9ec1c856dbdb53fd3e68))
* Better msg on ACCOUNT_WITH_SAME_IDENTIFIER_ALREADY_DEFINED error ([afc1f1c](https://github.com/cozy/cozy-libs/commit/afc1f1c84cb7a8c16a0d84942c6a6bbd68bd50ba))





## [9.26.5](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.4...cozy-harvest-lib@9.26.5) (2022-08-29)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.4](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.3...cozy-harvest-lib@9.26.4) (2022-08-29)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.2...cozy-harvest-lib@9.26.3) (2022-08-26)


### Bug Fixes

* **harvest:** Handle not existing applications ([2e6c7f6](https://github.com/cozy/cozy-libs/commit/2e6c7f6f3558019f3d6ce915a91afd2c4870773e))





## [9.26.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.1...cozy-harvest-lib@9.26.2) (2022-08-26)

**Note:** Version bump only for package cozy-harvest-lib





## [9.26.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.26.0...cozy-harvest-lib@9.26.1) (2022-08-22)


### Bug Fixes

* RefreshContracts now updates contracts in realtime ([463e716](https://github.com/cozy/cozy-libs/commit/463e7169d78ce633308229257bd262d01842fdc1))





# [9.26.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.25.0...cozy-harvest-lib@9.26.0) (2022-08-22)


### Features

* Detect reconnect explicitely ([b092392](https://github.com/cozy/cozy-libs/commit/b0923923727bdb08123bd78073a0dda238361f02))
* Handle cas with multiple bank ids ([9729626](https://github.com/cozy/cozy-libs/commit/97296267e941265a08ad052f1e5a62c3830566f2))
* Use BI account creation webview to handle accounts synchonization ([1b5e5ff](https://github.com/cozy/cozy-libs/commit/1b5e5ff06b6c98b14d0d8c388d31970ae36bfac0))





# [9.25.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.24.4...cozy-harvest-lib@9.25.0) (2022-08-05)


### Bug Fixes

* Let OAuthForm component decide when to remove the OAuth window ([59a132f](https://github.com/cozy/cozy-libs/commit/59a132f71d528cb311d436041951aaae811aed6e))


### Features

* Close OAuthWindow only on login success ([a8cf6a3](https://github.com/cozy/cozy-libs/commit/a8cf6a37a9c76bf2702c1d73d292a4d337f7dc5a))





## [9.24.4](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.24.3...cozy-harvest-lib@9.24.4) (2022-08-05)


### Bug Fixes

* Remove a reconnection step ([05d2cb6](https://github.com/cozy/cozy-libs/commit/05d2cb674d9ce69164cf0a099059520cbf4f1722))
* Remove unused request to BI connection ([be09798](https://github.com/cozy/cozy-libs/commit/be09798e3c551fd9628d15e6f79b9de77b3d1aa5))





## [9.24.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.24.2...cozy-harvest-lib@9.24.3) (2022-08-01)


2 changes: 1 addition & 1 deletion packages/cozy-harvest-lib/README.md
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ const client = new CozyClient({

ReactDOM.render(
<CozyProvider client={client}>
<Query query={()=> Q('io.cozy.apps').getById('my-konnector-id')}>
<Query query={()=> Q('io.cozy.konnectors').getById('my-konnector-id')}>
{({ data: konnector }) => (
<TriggerManager
konnector={konnector}
16 changes: 8 additions & 8 deletions packages/cozy-harvest-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cozy-harvest-lib",
"version": "9.24.3",
"version": "9.26.15",
"description": "Provides logic, modules and components for Cozy's harvest applications.",
"main": "dist/index.js",
"author": "Cozy",
@@ -29,8 +29,8 @@
"@cozy/minilog": "^1.0.0",
"@sentry/browser": "^6.0.1",
"cozy-bi-auth": "0.0.25",
"cozy-doctypes": "^1.85.1",
"cozy-logger": "^1.9.0",
"cozy-doctypes": "^1.85.4",
"cozy-logger": "^1.9.1",
"date-fns": "^1.30.1",
"final-form": "^4.18.5",
"lodash": "^4.17.19",
@@ -51,13 +51,13 @@
"@testing-library/react": "10.4.9",
"babel-jest": "26.6.3",
"babel-plugin-inline-react-svg": "1.1.2",
"babel-preset-cozy-app": "^2.0.3",
"babel-preset-cozy-app": "^2.0.4",
"cozy-client": "27.17.0",
"cozy-device-helper": "^2.2.2",
"cozy-flags": "^2.10.1",
"cozy-intent": "^2.3.1",
"cozy-device-helper": "^2.4.1",
"cozy-flags": "^2.10.2",
"cozy-intent": "^2.5.1",
"cozy-keys-lib": "^4.1.9",
"cozy-realtime": "^4.2.3",
"cozy-realtime": "^4.2.6",
"cozy-ui": "60.6.0",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.6",
Original file line number Diff line number Diff line change
@@ -8,6 +8,13 @@ import bankAccounts from './KonnectorConfiguration/ConfigurationTab/bank-account
describe('DisconnectedAccountModal', () => {
const setup = () => {
const mockClient = {}
mockClient.plugins = {
realtime: {
subscribe: jest.fn(),
unsubscribe: jest.fn()
}
}
mockClient.dispatch = jest.fn()
const root = render(
<AppLike client={mockClient}>
<DisconnectedAccountModal
Original file line number Diff line number Diff line change
@@ -184,11 +184,12 @@ export class EditAccountModal extends Component {
* When we are on mobile, we display a back button
* On desktop we display a cross
*/
const { konnector, reconnect } = this.props
const { konnector, reconnect, intentsApi } = this.props
const { trigger, account, fetching } = this.state
return (
<DumbEditAccountModal
konnector={konnector}
intentsApi={intentsApi}
account={account}
trigger={trigger}
fetching={fetching}
Original file line number Diff line number Diff line change
@@ -4,13 +4,12 @@ import { render, fireEvent, act, waitFor } from '@testing-library/react'

import AppLike from '../../../../test/AppLike'

import BIContractActivationWindow from './BiContractActivationWindow'
const fetchContractSynchronizationUrl = jest.fn()
const fetchExtraOAuthUrlParams = jest.fn()
const refreshContracts = jest.fn()
jest.mock('../../../konnector-policies', () => ({
findKonnectorPolicy: jest.fn()
}))
jest.mock('cozy-ui/transpiled/react/Popup', () => {
jest.mock('../../Popup', () => {
return jest.fn().mockImplementation(({ onClose }) => {
setTimeout(onClose, 1)
return null
@@ -22,14 +21,17 @@ jest.mock('../../InAppBrowser', () => {
return null
})
})

jest.mock('../../../helpers/oauth')
jest.mock('cozy-realtime')
jest.mock('cozy-device-helper')
import BIContractActivationWindow from './BiContractActivationWindow'
import { findKonnectorPolicy } from '../../../konnector-policies'
import Popup from 'cozy-ui/transpiled/react/Popup'
import Popup from '../../Popup'
import InAppBrowser from '../../InAppBrowser'
import { isFlagshipApp } from 'cozy-device-helper'
import { prepareOAuth } from '../../../helpers/oauth'
findKonnectorPolicy.mockImplementation(() => ({
fetchContractSynchronizationUrl,
fetchExtraOAuthUrlParams,
refreshContracts
}))

@@ -58,8 +60,9 @@ describe('BIContractActivationWindow', () => {
})

it('should display popup with url from policy and update contract after popup is closed', async () => {
prepareOAuth.mockImplementation(() => ({ oAuthUrl: 'https://test.url' }))
isFlagshipApp.mockImplementation(() => false)
fetchContractSynchronizationUrl.mockResolvedValue('bi url')
fetchExtraOAuthUrlParams.mockResolvedValue({})
const { getByRole } = setup()
await act(async () => {
await waitFor(() => {
@@ -76,18 +79,19 @@ describe('BIContractActivationWindow', () => {
})
})

expect(fetchContractSynchronizationUrl).toHaveBeenCalled()
expect(fetchExtraOAuthUrlParams).toHaveBeenCalled()
expect(refreshContracts).toHaveBeenCalledTimes(1)
expect(Popup).toHaveBeenCalledWith(
expect.objectContaining({
initialUrl: 'bi url'
url: 'https://test.url'
}),
expect.anything()
{}
)
})
it('should call InAppBrowser display if in flagship app context', async () => {
isFlagshipApp.mockImplementation(() => true)
fetchContractSynchronizationUrl.mockResolvedValue('bi url')
prepareOAuth.mockImplementation(() => ({ oAuthUrl: 'https://testiab.url' }))
fetchExtraOAuthUrlParams.mockResolvedValue({})
const { getByRole } = setup()
await act(async () => {
await waitFor(() => {
@@ -104,11 +108,11 @@ describe('BIContractActivationWindow', () => {
})
})

expect(fetchContractSynchronizationUrl).toHaveBeenCalled()
expect(fetchExtraOAuthUrlParams).toHaveBeenCalled()
expect(refreshContracts).toHaveBeenCalledTimes(1)
expect(InAppBrowser).toHaveBeenCalledWith(
expect.objectContaining({
url: 'bi url'
url: 'https://testiab.url'
}),
expect.anything()
)
Original file line number Diff line number Diff line change
@@ -2,11 +2,9 @@ import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import { useClient } from 'cozy-client'
import Button from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons'
import Popup from 'cozy-ui/transpiled/react/Popup'
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem'
import { findKonnectorPolicy } from '../../../konnector-policies'
import { isFlagshipApp } from 'cozy-device-helper'
import InAppBrowser from '../../InAppBrowser'
import OAuthWindow from '../../OAuthWindow'
import withLocales from '../../hoc/withLocales'
import {
intentsApiProptype,
@@ -20,7 +18,7 @@ const BIContractActivationWindow = ({
intentsApi,
innerAccountModalOverrides
}) => {
const [initialUrl, setInitialUrl] = useState(null)
const [extraParams, setExtraParams] = useState(null)
const [isWindowVisible, setWindowVisible] = useState(false)
const [shouldRefreshContracts, setShouldRefreshContracts] = useState(false)

@@ -33,30 +31,27 @@ const BIContractActivationWindow = ({
}

useEffect(() => {
async function refreshContracts() {
await konnectorPolicy.refreshContracts({ client, account, konnector })
setShouldRefreshContracts(false)
}
if (shouldRefreshContracts) {
refreshContracts()
setShouldRefreshContracts(false)
konnectorPolicy.refreshContracts({ client, account, konnector })
}
}, [account, client, konnectorPolicy, shouldRefreshContracts, konnector])

useEffect(() => {
async function handleLinkFetch() {
const result = await konnectorPolicy.fetchContractSynchronizationUrl({
const result = await konnectorPolicy.fetchExtraOAuthUrlParams({
client,
account,
konnector
})
setInitialUrl(result)
setExtraParams(result)
}
if (konnectorPolicy.fetchContractSynchronizationUrl) {
if (konnectorPolicy.fetchExtraOAuthUrlParams) {
handleLinkFetch()
}
}, [konnector.slug, account, client, konnectorPolicy])

if (!konnectorPolicy.fetchContractSynchronizationUrl) return null
if (!konnectorPolicy.fetchExtraOAuthUrlParams) return null

const ButtonWrapper = innerAccountModalOverrides?.SyncButtonWrapperComp
? innerAccountModalOverrides.SyncButtonWrapperComp
@@ -68,27 +63,22 @@ const BIContractActivationWindow = ({
<Button
variant="text"
color="primary"
disabled={!initialUrl}
disabled={!extraParams}
onClick={() => setWindowVisible(true)}
>
{t('contracts.handle-synchronization')}
</Button>
</ButtonWrapper>
{isWindowVisible &&
(isFlagshipApp() || intentsApi ? (
<InAppBrowser
url={initialUrl}
onClose={onPopupClosed}
intentsApi={intentsApi}
/>
) : (
<Popup
initialUrl={initialUrl}
width="800"
height="800"
onClose={onPopupClosed}
/>
))}
{isWindowVisible && (
<OAuthWindow
extraParams={extraParams}
konnector={konnector}
account={account}
intentsApi={intentsApi}
onSuccess={onPopupClosed}
onCancel={onPopupClosed}
/>
)}
</ListItem>
)
}
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@ import React from 'react'
import PropTypes from 'prop-types'
import compose from 'lodash/flowRight'

import CozyClient, { Q, queryConnect } from 'cozy-client'
import CozyClient, { Q, queryConnect, RealTimeQueries } from 'cozy-client'
import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import NavigationList, {
NavigationListSection,
NavigationListHeader
} from 'cozy-ui/transpiled/react/NavigationList'
import flag from 'cozy-flags'

import withLocales from '../../hoc/withLocales'
import BIContractActivationWindow from './BiContractActivationWindow'
@@ -52,6 +53,7 @@ const DumbContracts = ({

return (
<MuiCozyTheme>
<RealTimeQueries doctype="io.cozy.bank.accounts" />
<NavigationList>
<NavigationListHeader>
{t(`contracts.headers.${headerKey}`)}
@@ -69,12 +71,14 @@ const DumbContracts = ({
/>
)
})}
<BIContractActivationWindow
konnector={konnector}
account={account}
intentsApi={intentsApi}
innerAccountModalOverrides={innerAccountModalOverrides}
/>
{flag('harvest.bi.webview') && (
<BIContractActivationWindow
konnector={konnector}
account={account}
intentsApi={intentsApi}
innerAccountModalOverrides={innerAccountModalOverrides}
/>
)}
</NavigationListSection>
</NavigationList>
</MuiCozyTheme>
47 changes: 30 additions & 17 deletions packages/cozy-harvest-lib/src/components/OAuthForm.jsx
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import withLocales from './hoc/withLocales'
import { findKonnectorPolicy } from '../konnector-policies'
import { intentsApiProptype } from '../helpers/proptypes'
import TriggerErrorInfo from './infos/TriggerErrorInfo'
import { ERROR_EVENT } from '../models/flowEvents'
import { ERROR_EVENT, LOGIN_SUCCESS_EVENT } from '../models/flowEvents'
import { KonnectorJobError } from '../helpers/konnectors'

/**
@@ -23,28 +23,35 @@ export class OAuthForm extends PureComponent {
this.handleConnect = this.handleConnect.bind(this)
this.handleOAuthCancel = this.handleOAuthCancel.bind(this)
this.handleExtraParams = this.handleExtraParams.bind(this)
this.state = {
showingOAuthModal: false
}
this.handleLoginSuccess = this.handleLoginSuccess.bind(this)
this.state = {}
}

componentDidMount() {
const { account, konnector, flow, client } = this.props
const { account, konnector, flow, client, reconnect } = this.props

const konnectorPolicy = findKonnectorPolicy(konnector)

if (konnectorPolicy.fetchExtraOAuthUrlParams) {
this.setState({ needExtraParams: true })
if (reconnect) {
this.showOAuthWindow()
}
// eslint-disable-next-line promise/catch-or-return
konnectorPolicy
.fetchExtraOAuthUrlParams({
flow,
account,
konnector,
client
client,
reconnect
})
.then(this.handleExtraParams)
}
flow.on(LOGIN_SUCCESS_EVENT, this.handleLoginSuccess)
}

handleLoginSuccess() {
this.hideOAuthWindow()
}

handleExtraParams(extraParams) {
@@ -53,14 +60,18 @@ export class OAuthForm extends PureComponent {

handleAccountId(accountId) {
const { onSuccess } = this.props
this.hideOAuthWindow()
if (typeof onSuccess === 'function') onSuccess(accountId)
}

handleConnect() {
this.showOAuthWindow()
}

componentWillUnmount() {
const { flow } = this.props
flow.removeListener(LOGIN_SUCCESS_EVENT, this.handleLoginSuccess)
}

/**
* Translates errors from oauth redirection url to harvest know error messages
*
@@ -117,15 +128,17 @@ export class OAuthForm extends PureComponent {
konnector={konnector}
/>
)}
<Button
className="u-mt-1"
busy={isBusy}
disabled={isBusy}
extension="full"
label={t(buttonLabel)}
onClick={this.handleConnect}
/>
{showOAuthWindow && (
{!reconnect && (
<Button
className="u-mt-1"
busy={isBusy}
disabled={isBusy}
extension="full"
label={t(buttonLabel)}
onClick={this.handleConnect}
/>
)}
{showOAuthWindow && (!needExtraParams || extraParams) && (
<OAuthWindow
extraParams={extraParams}
konnector={konnector}
17 changes: 14 additions & 3 deletions packages/cozy-harvest-lib/src/components/OAuthForm.spec.js
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@ import { shallow } from 'enzyme'
import { OAuthForm } from 'components/OAuthForm'
import { findKonnectorPolicy } from '../konnector-policies'
import { KonnectorJobError } from '../helpers/konnectors'
import ConnectionFlow from '../models/ConnectionFlow'
jest.mock('../konnector-policies', () => ({
findKonnectorPolicy: jest.fn()
}))
jest.mock('../models/ConnectionFlow')
const fetchExtraOAuthUrlParams = jest.fn()
fetchExtraOAuthUrlParams.mockResolvedValue({})
findKonnectorPolicy.mockReturnValue({
@@ -22,17 +24,25 @@ const fixtures = {
}
}

const flow = new ConnectionFlow()

describe('OAuthForm', () => {
it('should render', () => {
const component = shallow(
<OAuthForm flowState={{}} konnector={fixtures.konnector} t={t} />
<OAuthForm
flow={flow}
flowState={{}}
konnector={fixtures.konnector}
t={t}
/>
).getElement()
expect(component).toMatchSnapshot()
})

it('should render reconnect button when updating an account', () => {
it('should bypass reconnect button when updating an account', () => {
const component = shallow(
<OAuthForm
flow={flow}
flowState={{}}
account={{ oauth: { access_token: '1234abcd' } }}
konnector={fixtures.konnector}
@@ -45,6 +55,7 @@ describe('OAuthForm', () => {
it('should call policy fetchExtraOAuthUrlParams with proper params', () => {
shallow(
<OAuthForm
flow={flow}
flowState={{}}
account={{ oauth: { access_token: '1234abcd' } }}
konnector={fixtures.konnector}
@@ -56,13 +67,13 @@ describe('OAuthForm', () => {
oauth: { access_token: '1234abcd' }
},
client: undefined,
flow: undefined,
konnector: { slug: 'test-konnector' }
})
})
it('should handle oauth cancelation', () => {
const component = shallow(
<OAuthForm
flow={flow}
flowState={{ error: new KonnectorJobError('OAUTH_CANCELED') }}
konnector={fixtures.konnector}
t={t}
4 changes: 1 addition & 3 deletions packages/cozy-harvest-lib/src/components/OAuthWindow.jsx
Original file line number Diff line number Diff line change
@@ -104,7 +104,6 @@ export class OAuthWindow extends PureComponent {
this.setState({ succeed: true })

if (typeof onSuccess !== 'function') return
this.setState({ succeed: true })
onSuccess(data.key)
}

@@ -159,10 +158,9 @@ export class OAuthWindow extends PureComponent {

render() {
const { t, intentsApi } = this.props
const { oAuthUrl, succeed } = this.state
const { oAuthUrl } = this.state
return (
oAuthUrl &&
!succeed &&
(!isFlagshipApp() && !intentsApi ? (
<Popup
url={oAuthUrl}
18 changes: 13 additions & 5 deletions packages/cozy-harvest-lib/src/components/Routes.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react'
import React, { useEffect } from 'react'
import { Switch, Route, Redirect } from 'react-router'
import { withStyles } from '@material-ui/core/styles'

import Alerter from 'cozy-ui/transpiled/react/Alerter'
import Dialog from 'cozy-ui/transpiled/react/Dialog'
import {
DialogCloseButton,
useCozyDialog
} from 'cozy-ui/transpiled/react/CozyDialogs'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import Spinner from 'cozy-ui/transpiled/react/Spinner'
import {
useVaultUnlockContext,
@@ -57,16 +59,22 @@ const Routes = ({
onDismiss,
datacardOptions
}) => {
const { t } = useI18n()
const dialogContext = useCozyDialog({
size: 'l',
open: true,
onClose: onDismiss
})

const { konnectorWithTriggers, fetching } = useKonnectorWithTriggers(
konnectorSlug,
konnector
)
const { konnectorWithTriggers, fetching, notFoundError } =
useKonnectorWithTriggers(konnectorSlug, konnector)

useEffect(() => {
if (notFoundError) {
onDismiss()
Alerter.error(t('error.application-not-found'))
}
}, [notFoundError, onDismiss, t])

return (
<DatacardOptions options={datacardOptions}>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`OAuthForm should bypass reconnect button when updating an account 1`] = `<React.Fragment />`;

exports[`OAuthForm should handle oauth cancelation 1`] = `
<React.Fragment>
<withI18n(withClient(withKonnectorLocales(TriggerErrorInfo))
@@ -34,16 +36,3 @@ exports[`OAuthForm should render 1`] = `
/>
</React.Fragment>
`;

exports[`OAuthForm should render reconnect button when updating an account 1`] = `
<React.Fragment>
<DefaultButton
busy={true}
className="u-mt-1"
disabled={true}
extension="full"
label="oauth.reconnect.label"
onClick={[Function]}
/>
</React.Fragment>
`;
Original file line number Diff line number Diff line change
@@ -50,7 +50,11 @@ export const useKonnectorWithTriggers = (slug, injectedKonnector) => {
...konnector,
triggers
}
return { konnectorWithTriggers, fetching: isFetching }
return {
konnectorWithTriggers,
fetching: isFetching,
notFoundError: !isFetching && !konnector
}
}

function isKonnectorTrigger(doc) {
5 changes: 3 additions & 2 deletions packages/cozy-harvest-lib/src/locales/en.json
Original file line number Diff line number Diff line change
@@ -124,6 +124,7 @@
"baseDir": "/Administrative"
},
"error": {
"application-not-found": "This app doesn't exist",
"reconnect-via-form": "Reconnect",
"job": {
"DISK_QUOTA_EXCEEDED": {
@@ -216,7 +217,7 @@
},
"ACCOUNT_WITH_SAME_IDENTIFIER_ALREADY_DEFINED": {
"title": "This account already exists",
"description": "You already have configured an account with these identifiers."
"description": "Your possible modification of the list of synchronized accounts will be taken into account within a few minutes."
}
}
},
@@ -540,4 +541,4 @@
"caption": "This service retrieves your latest documents and keeps a complete back-up for you."
}
}
}
}
5 changes: 3 additions & 2 deletions packages/cozy-harvest-lib/src/locales/fr.json
Original file line number Diff line number Diff line change
@@ -124,6 +124,7 @@
"baseDir": "/Administratif"
},
"error": {
"application-not-found": "Cette application n'existe pas",
"reconnect-via-form": "Se reconnecter",
"job": {
"DISK_QUOTA_EXCEEDED": {
@@ -216,7 +217,7 @@
},
"ACCOUNT_WITH_SAME_IDENTIFIER_ALREADY_DEFINED": {
"title": "Ce compte est déjà configuré",
"description": "Vous avez déjà configuré un compte avec ces identifiants."
"description": "Votre éventuelle modification de la liste des comptes synchronisés sera prise en compte sous quelques minutes."
}
}
},
@@ -540,4 +541,4 @@
"caption": "Ce service récupère vos derniers documents et garde une sauvegarde complète pour vous."
}
}
}
}
122 changes: 51 additions & 71 deletions packages/cozy-harvest-lib/src/services/biWebView.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
* - Deals with the konnector to get temporary tokens
*/

import { getBIConnection, getBIConnectionAccountsList } from './bi-http'
import { getBIConnectionAccountsList, getBIConnection } from './bi-http'
import assert from '../assert'
import logger from '../logger'
import { Q } from 'cozy-client'
@@ -14,7 +14,6 @@ import flag from 'cozy-flags'

import {
setBIConnectionId,
saveBIConfig,
findAccountWithBiConnection,
convertBIErrortoKonnectorJobError,
isBudgetInsightConnector,
@@ -40,71 +39,34 @@ export const isBiWebViewConnector = konnector =>
/**
* Runs multiple checks on the bi connection referenced in the given account
* @param {object} options
* @param {IoCozyAccount} options.account The account content
* @param {number} options.connId The BI connection identifier
* @param {KonnectorManifest} options.konnector konnector manifest content
* @param {ConnectionFlow} options.flow The flow
* @param {CozyClient} options.client CozyClient object
*
* @return {Promise<biConnection>} Connection Id
* @return {Promise}
* @throws KonnectorJobError
*/
export const checkBIConnection = async ({
account,
client,
konnector,
flow
}) => {
export const checkBIConnection = async ({ connId, client, konnector }) => {
try {
let connId = getWebviewBIConnectionId(account)

logger.info('Creating temporary token...')

const biConfig = await createTemporaryToken({
client,
konnector,
account
})
saveBIConfig(flow, biConfig)

const { code: tempToken, ...config } = biConfig

logger.info('Created temporary token')
assert(tempToken, 'No temporary token')

logger.info(`fetch connection ${connId}...`)

const connection = await getBIConnection(config, connId, tempToken)

const sameAccount = await findAccountWithBiConnection({
client,
konnector,
connectionId: connection.id
connectionId: connId
})
if (sameAccount) {
const err = new KonnectorJobError(
'ACCOUNT_WITH_SAME_IDENTIFIER_ALREADY_DEFINED'
)
throw err
}
return connection
return
} catch (err) {
return convertBIErrortoKonnectorJobError(err)
}
}

export const fetchContractSynchronizationUrl = async ({
account,
client,
konnector
}) => {
const { code, url, clientId } = await createTemporaryToken({
client,
konnector,
account
})
const connId = getBIConnectionIdFromAccount(account)
return `${url}/auth/webview/manage?client_id=${clientId}&code=${code}&connection_id=${connId}`
}

/**
* Handles webview connection
*
@@ -113,9 +75,9 @@ export const fetchContractSynchronizationUrl = async ({
* @param {KonnectorManifest} options.konnector konnector manifest content
* @param {ConnectionFlow} options.flow The flow
* @param {CozyClient} options.client CozyClient object
* @param {Boolean} options.reconnect If this is a reconnexion
* @param {Boolean} options.reconnect If this is a reconnection
* @param {Function} options.t Translation fonction
* @return {Promise<Number>} Connection Id
* @return {Promise<Number|null>} Connection Id
*/
export const handleOAuthAccount = async ({
account,
@@ -211,23 +173,22 @@ export const onBIAccountCreation = async ({
konnector
}) => {
const account = await flow.saveAccount(fullAccount)
const connId = getWebviewBIConnectionId(account)

const biConnection = await checkBIConnection({
account: {
...fullAccount,
_id: account._id
},
client,
konnector,
flow
})
if (connId === null) {
throw new Error(
'onBIAccountCreation: bi connection id should not be null on creation'
)
}

flow.setData({
biConnection
await checkBIConnection({
connId,
client,
konnector
})

const updatedAccount = await flow.saveAccount(
setBIConnectionId(account, biConnection.id)
setBIConnectionId(account, connId)
)

flow.triggerEvent(LOGIN_SUCCESS_EVENT)
@@ -257,32 +218,43 @@ const getReconnectExtraOAuthUrlParams = ({ biBankIds, token, connId }) => {
* @param {CozyClient} options.client - CozyClient instance
* @param {KonnectorManifest} options.konnector konnector manifest content
* @param {IoCozyAccount} options.account The account content
* @param {Boolean} options.reconnect If this is a reconnection
* @return {Promise<Object>}
*/
export const fetchExtraOAuthUrlParams = async ({
client,
konnector,
account
account,
reconnect = false
}) => {
const { code: token, biBankIds } = await createTemporaryToken({
const {
code: token,
biBankIds,
...config
} = await createTemporaryToken({
client,
konnector,
account
})

const connId = getBIConnectionIdFromAccount(account)

const isReconnect = Boolean(connId)

if (isReconnect) {
if (reconnect) {
return getReconnectExtraOAuthUrlParams({
biBankIds,
token,
connId
})
} else {
let bankId
if (connId && biBankIds.length > 1) {
// we want to get the bi bank id of the connection. This way, the user does not need
// to choose his bank each time he want to update his synchronizations
const connection = await getBIConnection(config, connId, token)
bankId = connection.id_bank
}
return {
id_connector: biBankIds,
id_connector: bankId ? bankId : biBankIds,
token
}
}
@@ -334,15 +306,24 @@ export const refreshContracts = async ({ client, konnector, account }) => {
(memo, contract) => ({ ...memo, [contract.id + '']: contract.disabled }),
{}
)
const currentContractsList = account?.relationships?.contracts?.data || []
const { data: currentContractsList } = await client.query(
Q('io.cozy.bank.accounts')
.where({ 'relationships.connection.data._id': account._id })
.include(['owners'])
.indexFields(['relationships.connection.data._id'])
)
for (const currentContract of currentContractsList) {
const disabledValue = convertBIDateToStandardDate(
contractsById[currentContract.metadata.vendorId]
contractsById[currentContract.vendorId]
)
currentContract.metadata.imported = !disabledValue
currentContract.metadata.disabledAt = disabledValue
const hasChanged = currentContract.metadata.disabledAt !== disabledValue
if (hasChanged) {
currentContract.metadata.disabledAt = disabledValue
currentContract.metadata.imported = !disabledValue
// FIXME bulk save via client.collection().updateAll does not show update of accounts in realtime
await client.save(currentContract)
}
}
await client.save(account)
}

function convertBIDateToStandardDate(biDate) {
@@ -477,6 +458,5 @@ export const konnectorPolicy = {
onAccountCreation: onBIAccountCreation,
fetchExtraOAuthUrlParams: fetchExtraOAuthUrlParams,
handleOAuthAccount,
fetchContractSynchronizationUrl,
refreshContracts
}
223 changes: 93 additions & 130 deletions packages/cozy-harvest-lib/src/services/biWebView.spec.js
Original file line number Diff line number Diff line change
@@ -3,26 +3,23 @@ import {
handleOAuthAccount,
checkBIConnection,
isBiWebViewConnector,
fetchContractSynchronizationUrl,
refreshContracts,
fetchExtraOAuthUrlParams,
isCacheExpired
} from './biWebView'
import ConnectionFlow from '../models/ConnectionFlow'
import { waitForRealtimeEvent } from './jobUtils'
import biPublicKeyProd from './bi-public-key-prod.json'
import flag from 'cozy-flags'

jest.mock('./bi-http', () => ({
createBIConnection: jest
.fn()
.mockResolvedValue({ text: Promise.resolve('{}') }),
updateBIConnection: jest.fn(),
getBIConnection: jest.fn(),
getBIConnectionAccountsList: jest.fn()
getBIConnectionAccountsList: jest.fn(),
getBIConnection: jest.fn()
}))

import { getBIConnection, getBIConnectionAccountsList } from './bi-http'
import { getBIConnectionAccountsList, getBIConnection } from './bi-http'

jest.mock('cozy-logger', () => ({
namespace: () => () => {}
@@ -32,8 +29,6 @@ jest.mock('./jobUtils', () => ({
waitForRealtimeEvent: jest.fn()
}))

const sleep = duration => new Promise(resolve => setTimeout(resolve, duration))

const TEST_BANK_COZY_ID = '100000'

const konnector = {
@@ -46,6 +41,26 @@ const konnector = {
}
}

const konnectorWithMultipleBankIds = {
slug: 'cic45',
fields: {
bankId: {
type: 'dropdown',
label: 'branchName',
options: [
{
name: 'Autre',
value: '45'
},
{
name: 'Bretagne (Particuliers)',
value: '46'
}
]
}
}
}

const account = {
_id: '1337'
}
@@ -109,48 +124,14 @@ describe('checkBIConnection', () => {
uri: 'http://testcozy.mycozy.cloud'
})
const flow = new ConnectionFlow(client, { konnector, account })
waitForRealtimeEvent.mockImplementation(async () => {
sleep(2)
return {
data: {
result: {
mode: 'prod',
url: 'https://cozy.biapi.pro/2.0',
publicKey: biPublicKeyProd,
code: 'bi-temporary-access-token-145613'
}
}
}
})
jest.spyOn(client, 'query').mockImplementation(async () => ({ data: [] }))
client.save = jest.fn().mockResolvedValue({
data: {
mode: 'prod',
url: 'https://cozy.biapi.pro/2.0',
publicKey: biPublicKeyProd,
code: 'bi-temporary-access-token-145613',
biMapping: {}
}
})
client.query = jest.fn()
client.stackClient.jobs.create = jest.fn().mockReturnValue({
data: {
attributes: {
_id: 'job-id-1337'
}
}
})

return { client, flow }
}

it('should refuse to create an account with a bi connection id which already exists', async () => {
const { client, flow } = setup()

getBIConnection.mockReset().mockResolvedValue({
id: 12
})

const account = {}

const konnector = {
@@ -225,74 +206,38 @@ describe('isBiWebViewConnector', () => {
})
})

describe('fetchContractSynchronizationUrl', () => {
it('should provide a proper bi manage webview url', async () => {
const client = new CozyClient({
uri: 'http://testcozy.mycozy.cloud'
})
client.query = jest.fn().mockResolvedValue({
data: {
mode: 'prod',
timestamp: Date.now(),
biMapping: {},
url: 'https://cozy.biapi.pro/2.0',
clientId: 'test-client-id',
code: 'bi-temporary-access-token-145613'
}
})

const url = await fetchContractSynchronizationUrl({
account: { ...account, data: { auth: { bi: { connId: 1337 } } } },
client,
konnector
})
expect(url).toEqual(
'https://cozy.biapi.pro/2.0/auth/webview/manage?client_id=test-client-id&code=bi-temporary-access-token-145613&connection_id=1337'
)
})
})

describe('refreshContracts', () => {
it('update current contracts with values from BI', async () => {
const client = new CozyClient({
uri: 'http://testcozy.mycozy.cloud'
})
client.save = jest.fn()
client.query = jest.fn().mockResolvedValue({
data: {
mode: 'prod',
timestamp: Date.now(),
biMapping: {},
url: 'https://cozy.biapi.pro/2.0',
clientId: 'test-client-id',
code: 'bi-temporary-access-token-145613'
}
})
const accountWithContracts = {
_id: 'testaccount',
relationships: {
contracts: {
data: [
{ metadata: { vendorId: '1', imported: true } },
{
metadata: {
vendorId: '2',
imported: false,
disabledAt: '2022-05-24T12:00:00'
}
},
{ metadata: { vendorId: '3', imported: true } },
{
metadata: {
vendorId: '4',
imported: false,
disabledAt: '2022-05-23T13:00:00'
}
}
]
client.query = jest
.fn()
.mockResolvedValueOnce({
data: {
mode: 'prod',
timestamp: Date.now(),
biMapping: {},
url: 'https://cozy.biapi.pro/2.0',
clientId: 'test-client-id',
code: 'bi-temporary-access-token-145613'
}
}
}
})
.mockResolvedValue({
data: [
{ vendorId: '1', metadata: { imported: true } },
{
vendorId: '2',
metadata: { imported: false, disabledAt: '2022-08-05 12:00:00' }
},
{ vendorId: '3', metadata: { imported: true } },
{
vendorId: '4',
metadata: { imported: false, disabledAt: '2022-08-05 12:01:00' }
}
]
})
getBIConnectionAccountsList.mockResolvedValue({
accounts: [
{ id: 1, disabled: '2022-05-25 12:00:00' },
@@ -302,31 +247,23 @@ describe('refreshContracts', () => {
]
})

await refreshContracts({ client, konnector, account: accountWithContracts })
expect(client.save).toHaveBeenCalledWith({
_id: 'testaccount',
relationships: {
contracts: {
data: [
{
metadata: {
vendorId: '1',
imported: false,
disabledAt: '2022-05-25T12:00:00'
}
},
{ metadata: { vendorId: '2', imported: true } },
{
metadata: {
vendorId: '3',
imported: false,
disabledAt: '2022-05-25T12:01:00'
}
},
{ metadata: { vendorId: '4', imported: true } }
]
}
}
await refreshContracts({ client, konnector, account: {} })
expect(client.save).toHaveBeenCalledTimes(4)
expect(client.save).toHaveBeenNthCalledWith(1, {
metadata: { disabledAt: '2022-05-25T12:00:00', imported: false },
vendorId: '1'
})
expect(client.save).toHaveBeenNthCalledWith(2, {
metadata: { disabledAt: undefined, imported: true },
vendorId: '2'
})
expect(client.save).toHaveBeenNthCalledWith(3, {
metadata: { disabledAt: '2022-05-25T12:01:00', imported: false },
vendorId: '3'
})
expect(client.save).toHaveBeenNthCalledWith(4, {
metadata: { disabledAt: undefined, imported: true },
vendorId: '4'
})
})
})
@@ -432,15 +369,16 @@ describe('fetchExtraOAuthUrlParams', () => {
const result = await fetchExtraOAuthUrlParams({
client,
konnector,
account: { ...account, data: { auth: { bi: { connId: 15 } } } }
account: { ...account, data: { auth: { bi: { connId: 15 } } } },
reconnect: true
})
expect(result).toMatchObject({
connection_id: 15,
code: 'bi-temporary-access-token-12'
})
})

it('should not add connection_id param if not connection_id', async () => {
it('should not add connection_id param if no connection_id', async () => {
const client = new CozyClient({
uri: 'http://testcozy.mycozy.cloud'
})
@@ -458,4 +396,29 @@ describe('fetchExtraOAuthUrlParams', () => {
})
expect(result).not.toHaveProperty('connection_id')
})

it('should get bi connection bank id if multiple biBankIds are in the mapping', async () => {
const client = new CozyClient({
uri: 'http://testcozy.mycozy.cloud'
})
client.query = jest.fn().mockResolvedValue({
data: {
timestamp: Date.now(),
code: 'bi-temporary-access-token-12',
biMapping: { [TEST_BANK_COZY_ID]: 2, 12: 2, 45: 3, 46: 4 }
}
})
getBIConnection.mockResolvedValueOnce({
id_bank: 4
})
const result = await fetchExtraOAuthUrlParams({
client,
konnector: konnectorWithMultipleBankIds,
account: { ...account, data: { auth: { bi: { connId: 15 } } } }
})
expect(result).toEqual({
id_connector: 4,
token: 'bi-temporary-access-token-12'
})
})
})
20 changes: 18 additions & 2 deletions packages/cozy-harvest-lib/src/services/utils.js
Original file line number Diff line number Diff line change
@@ -5,9 +5,25 @@ import Polyglot from 'node-polyglot'
import { Q } from 'cozy-client'
import SymmetricCryptoKey from 'cozy-keys-lib/transpiled/SymmetricCryptoKey'
import EncryptionType from 'cozy-keys-lib/transpiled/EncryptionType'

export const decryptString = (encryptedString, vaultClient, orgKey) => {
import logger from './logger'

/**
* Decrypt the given string with the organization key
*
* @param {string} encryptedString - The encrypted string
* @param {object} vaultClient - The vault client
* @param {ArrayBuffer} orgKey - The organization key
* @returns {Promise<string>} The decrypted string
*/
export const decryptString = async (encryptedString, vaultClient, orgKey) => {
if (!encryptedString) {
return ''
}
const [encTypeAndIv, data, mac] = encryptedString.split('|')
if (!encTypeAndIv) {
logger.error('Encrypted string is malformed')
throw new Error('DECRYPT_FAILED')
}
const [encTypeString, iv] = encTypeAndIv.split('.')
const encType = parseInt(encTypeString, 10)

15 changes: 15 additions & 0 deletions packages/cozy-harvest-lib/src/services/utils.spec.js
Original file line number Diff line number Diff line change
@@ -63,6 +63,21 @@ describe('decryptString', () => {
orgKey
)
})

it('should return empty if the encrypted string is empty', async () => {
const res = await decryptString(
'',
mockVaultClient,
new SymmetricCryptoKey('123', 2)
)
expect(res).toEqual('')
})

it('should throw if the encrypted string is empty', async () => {
await expect(
decryptString('|', mockVaultClient, new SymmetricCryptoKey('123', 2))
).rejects.toThrowError()
})
})

describe('getOrganizationKey', () => {
38 changes: 38 additions & 0 deletions packages/cozy-intent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2.5.1 (2022-10-03)

**Note:** Version bump only for package cozy-intent





# [2.5.0](https://github.com/cozy/cozy-libs/compare/cozy-intent@2.4.0...cozy-intent@2.5.0) (2022-09-12)


### Features

* **cozy-intent:** Update cozy-settings switch API ([5b0337c](https://github.com/cozy/cozy-libs/commit/5b0337c3c89e806e307d1429c1a02a434426c41c))





# [2.4.0](https://github.com/cozy/cozy-libs/compare/cozy-intent@2.3.2...cozy-intent@2.4.0) (2022-09-07)


### Features

* Update methods interface for biometry ([a8a3062](https://github.com/cozy/cozy-libs/commit/a8a30624b33250c4b306c51f428bbec2c0325be9))





## 2.3.2 (2022-08-29)

**Note:** Version bump only for package cozy-intent





## 2.3.1 (2022-08-01)

**Note:** Version bump only for package cozy-intent
6 changes: 3 additions & 3 deletions packages/cozy-intent/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cozy-intent",
"description": "Event-based library allowing interactions between React-Native and React applications",
"version": "2.3.1",
"version": "2.5.1",
"author": {
"name": "Cozy Cloud",
"url": "https://github.com/cozy"
@@ -16,8 +16,8 @@
"@babel/core": "7.16.12",
"@testing-library/react": "10.4.9",
"@testing-library/react-hooks": "7.0.2",
"babel-preset-cozy-app": "^2.0.3",
"cozy-logger": "^1.9.0",
"babel-preset-cozy-app": "^2.0.4",
"cozy-logger": "^1.9.1",
"jest": "26.6.3",
"mutationobserver-shim": "0.3.7",
"react": "16.12.0",
26 changes: 19 additions & 7 deletions packages/cozy-intent/src/api/models/methods.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { AppManifest, FlagshipUI } from '../../api'

export type NativeMethodsRegister = {
backToHome: () => void
hideSplashScreen: () => void
logout: () => void
openApp: (href: string, app: AppManifest, iconParams?: DOMRect) => void
setFlagshipUI: (flagshipUI: FlagshipUI, caller?: string) => void
showSplashScreen: () => void
type PostMeDefault = Record<string, (...args: unknown[]) => Promise<null>>

interface _NativeMethodsRegister {
backToHome: () => Promise<null>
hideSplashScreen: () => Promise<null>
logout: () => Promise<null>
openApp: (
href: string,
app: AppManifest,
iconParams?: DOMRect
) => Promise<null>
openSettingBiometry: () => Promise<boolean>
setFlagshipUI: (flagshipUI: FlagshipUI, caller?: string) => Promise<null>
showSplashScreen: () => Promise<null>
toggleSetting: (
settingName: 'biometryLock' | 'PINLock' | 'autoLock'
) => Promise<boolean | null>
}

export type NativeMethodsRegister = _NativeMethodsRegister & PostMeDefault

export type WebviewMethods = Record<string, () => unknown>
2 changes: 1 addition & 1 deletion packages/cozy-intent/src/api/services/NativeService.ts
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ export class NativeService {
uri: string,
methodName: keyof WebviewMethods,
...args: Parameters<NativeMethodsRegister[keyof NativeMethodsRegister]>
): Promise<void> | void =>
): ReturnType<NativeMethodsRegister[keyof NativeMethodsRegister]> | void =>
this.messengerRegister[this.getHostname(uri)]?.connection
?.remoteHandle()
.call(methodName, ...args)
2 changes: 1 addition & 1 deletion packages/cozy-intent/src/api/services/WebviewService.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ export class WebviewService {
public call = (
methodName: keyof NativeMethodsRegister,
...args: Parameters<NativeMethodsRegister[keyof NativeMethodsRegister]>
): Promise<void> => this.remoteHandle.call(methodName, ...args)
): Promise<boolean | null> => this.remoteHandle.call(methodName, ...args)

public closeMessenger = (): void => this.close()
}
19 changes: 19 additions & 0 deletions packages/cozy-interapp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 0.7.7 (2022-10-03)

**Note:** Version bump only for package cozy-interapp





## 0.7.6 (2022-08-29)


### Bug Fixes

* Add prepublish script ([30a26e5](https://github.com/cozy/cozy-libs/commit/30a26e5109dcdfc636c76e6cdd20fdec313359ee))





## 0.7.5 (2022-08-01)

**Note:** Version bump only for package cozy-interapp
7 changes: 4 additions & 3 deletions packages/cozy-interapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cozy-interapp",
"version": "0.7.5",
"version": "0.7.7",
"description": "Cozy Interapp allows applications to interact with each other and not have access to all data",
"main": "dist/index.js",
"author": "Cozy",
@@ -15,13 +15,14 @@
},
"scripts": {
"test": "jest",
"build": "babel src -d dist --ignore *.spec.js"
"build": "babel src -d dist --ignore *.spec.js",
"prepublishOnly": "yarn build"
},
"devDependencies": {
"@babel/cli": "7.16.8",
"@babel/core": "7.16.12",
"babel-jest": "26.6.3",
"babel-preset-cozy-app": "^2.0.3",
"babel-preset-cozy-app": "^2.0.4",
"jest": "26.6.3"
},
"peerDependencies": {
11 changes: 11 additions & 0 deletions packages/cozy-logger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.9.1 (2022-08-29)


### Bug Fixes

* Add prepublish script ([30a26e5](https://github.com/cozy/cozy-libs/commit/30a26e5109dcdfc636c76e6cdd20fdec313359ee))





# [1.9.0](https://github.com/cozy/cozy-libs/compare/cozy-logger@1.8.1...cozy-logger@1.9.0) (2022-03-10)


5 changes: 3 additions & 2 deletions packages/cozy-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cozy-logger",
"version": "1.9.0",
"version": "1.9.1",
"description": "Logger for Cozy konnector and services",
"main": "src/index.js",
"browser": "dist/index.js",
@@ -11,7 +11,8 @@
},
"scripts": {
"test": "yarn jest",
"build": "babel src/ --out-dir dist"
"build": "babel src/ --out-dir dist",
"prepublishOnly": "yarn build"
},
"prettier": {
"semi": false,
506 changes: 506 additions & 0 deletions packages/cozy-mespapiers-lib/CHANGELOG.md

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion packages/cozy-mespapiers-lib/README.md
Original file line number Diff line number Diff line change
@@ -104,6 +104,16 @@ const AppRouter = () => {
Then inside your route component, you have to import exposed component from `cozy-mespapiers-lib`.
:warning: You must pass it the `lang` prop of the application so that it uses the right locales files.
## Styles
You need to add the following import to the base of your application:
```
import 'cozy-mespapiers-lib/dist/stylesheet.css'
```
***
# Components Overload
You can also overload some components (currently only the `PapersFab` & `Onboarding` components) or not use them (with `null` value).
@@ -157,7 +167,13 @@ const handleClick = () => {
***
## Development
# Development
For development purpose, you can link the lib in your application, but you don't need to run `yarn install` in the lib before. The packages of the application will be used.
However you need to run `yarn install` to run the tests in the lib with `yarn test`.
## Papers definitions
The definitions of the papers is in the file [`papersDefinitions.json`](https://github.com/cozy/cozy-libs/blob/master/packages/cozy-mespapiers-lib/src/constants/papersDefinitions.json)
- [Documentation](https://github.com/cozy/cozy-libs/blob/master/packages/cozy-mespapiers-lib/docs/papersDefinitions.md)
16 changes: 15 additions & 1 deletion packages/cozy-mespapiers-lib/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
module.exports = {
presets: ['cozy-app']
presets: ['cozy-app'],
plugins: [
[
'css-modules-transform',
{
extensions: ['.styl'],
preprocessCss: './preprocess',
extractCss: './dist/stylesheet.css',
generateScopedName:
process.env['NODE_ENV'] == 'test'
? '[local]'
: '[name]__[local]___[hash:base64:5]'
}
]
]
}
8 changes: 6 additions & 2 deletions packages/cozy-mespapiers-lib/docs/papersDefinitions.md
Original file line number Diff line number Diff line change
@@ -66,8 +66,12 @@ Let's see how it is built:
- `[required]`: {boolean} Make the field mandatory
- `[minLength]`: {number} Requires a minimum number of characters
- `[maxLength]`: {number} Requires a maximum number of characters
- `[mask]`: {string} Formats and forces a type
- `[placeholderMask]`: {string} Choice of placeholder for the mask (default `_`)
- `[mask]`: {string} Formats and forces a type (see [here](https://github.com/sanniassin/react-input-mask#properties) for more details)
- Varation with the `mask` attribute:
- `[required]`: {boolean} Make all Mask mandatory (**high priority**)
- `[minLength]`: {number} Requires a minimum number of characters
- `[maxLength]`: {number} Ignored, always the length of the Mask
- `[placeholderMask]`: {string} Choice of placeholder for the mask (default `ˍ`)

<br>

26 changes: 13 additions & 13 deletions packages/cozy-mespapiers-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cozy-mespapiers-lib",
"version": "1.1.14",
"version": "8.0.1",
"description": "Cozy Mes papiers lib",
"license": "AGPL-3.0",
"main": "dist/index.js",
@@ -16,16 +16,16 @@
"@testing-library/react": "11.2.7",
"babel-preset-cozy-app": "2.0.1",
"cozy-bar": "7.16.0",
"cozy-client": "^32.2.0",
"cozy-device-helper": "^2.2.2",
"cozy-doctypes": "^1.85.1",
"cozy-harvest-lib": "^9.24.3",
"cozy-intent": "^2.3.1",
"cozy-realtime": "^4.2.3",
"cozy-sharing": "^4.5.3",
"cozy-ui": "^68.9.1",
"cozy-client": "^33.1.0",
"cozy-device-helper": "^2.4.1",
"cozy-doctypes": "^1.85.4",
"cozy-harvest-lib": "^9.26.15",
"cozy-intent": "^2.5.1",
"cozy-realtime": "^4.2.6",
"cozy-sharing": "^4.5.8",
"cozy-ui": "^75.6.1",
"jest-environment-jsdom-sixteen": "2.0.0",
"react-router-dom": "5.2.0"
"react-router-dom": "6.3.0"
},
"dependencies": {
"@date-io/date-fns": "1",
@@ -37,14 +37,14 @@
"react-input-mask": "3.0.0-alpha.2"
},
"peerDependencies": {
"cozy-client": ">=32.2.0",
"cozy-client": ">=33.1.0",
"cozy-device-helper": ">=2.2.0",
"cozy-doctypes": ">=1.83.8",
"cozy-harvest-lib": ">=9.10.1",
"cozy-intent": ">=2.2.0",
"cozy-realtime": ">=4.2.0",
"cozy-sharing": ">=4.3.0",
"cozy-ui": ">=68.9.1",
"react-router-dom": ">=5.2.0"
"cozy-ui": ">=75.6.1",
"react-router-dom": ">=6.3.0"
}
}
15 changes: 15 additions & 0 deletions packages/cozy-mespapiers-lib/preprocess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const stylus = require('stylus')
const cozyStylusPlugin = require('cozy-ui/stylus')

const renderStylus = function (css, filename) {
try {
return stylus(css)
.use(cozyStylusPlugin())
.set('filename', filename)
.render()
} catch (e) {
console.log(e) // eslint-disable-line no-console
}
}

module.exports = renderStylus
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import cx from 'classnames'

import makeStyles from 'cozy-ui/transpiled/react/helpers/makeStyles'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
import Typography from 'cozy-ui/transpiled/react/Typography'
import Icon from 'cozy-ui/transpiled/react/Icon'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { useHistory, useLocation } from 'react-router-dom'
import { useNavigate, useLocation } from 'react-router-dom'

import { useI18n } from 'cozy-ui/transpiled/react/I18n'

@@ -10,15 +10,15 @@ export const createPaper = ({ hideActionsMenu }) => {
name: 'createPaper',
Component: function CreatePaper({ className }) {
const { t } = useI18n()
const history = useHistory()
const navigate = useNavigate()
const { pathname } = useLocation()

return (
<ActionMenuItemWrapper
className={className}
icon="paper"
onClick={() => {
history.push({
navigate({
pathname: `/paper/create`,
search: `backgroundPath=${pathname}`
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { useHistory } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'

import { useI18n } from 'cozy-ui/transpiled/react/I18n'

@@ -10,15 +10,17 @@ export const open = () => {
name: 'open',
Component: function Open({ className, files }) {
const { t } = useI18n()
const history = useHistory()
const navigate = useNavigate()
const fileId = files[0]?._id
const fileTheme = files[0]?.metadata?.qualification?.label

return (
<ActionMenuItemWrapper
className={className}
icon="openwith"
onClick={() =>
history.push({
pathname: `/paper/file/${files[0]._id}`
navigate({
pathname: `/paper/file/${fileTheme}/${fileId}`
})
}
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'

import { useI18n } from 'cozy-ui/transpiled/react/I18n'

import ActionMenuItemWrapper from '../ActionMenuItemWrapper'

export const rename = ({ setPaperBeingRenamedId }) => {
return {
name: 'rename',
action: files => setPaperBeingRenamedId(files[0].id),
Component: function Open({ onClick, className }) {
const { t } = useI18n()

return (
<ActionMenuItemWrapper
className={className}
icon="rename"
onClick={onClick}
>
{t('action.rename')}
</ActionMenuItemWrapper>
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { useHistory, useLocation } from 'react-router-dom'
import { useNavigate, useLocation } from 'react-router-dom'

import { useI18n } from 'cozy-ui/transpiled/react/I18n'

@@ -10,15 +10,16 @@ export const select = ({ hideActionsMenu, addMultiSelectionFile }) => {
name: 'select',
Component: function Select({ className, files }) {
const { t } = useI18n()
const history = useHistory()
const navigate = useNavigate()
const { pathname } = useLocation()
const selectFromFile = files.length === 1

return (
<ActionMenuItemWrapper
className={className}
icon="paperplane"
icon={selectFromFile ? 'select-all' : 'paperplane'}
onClick={() => {
history.push({
navigate({
pathname: `/paper/multiselect`,
search: `backgroundPath=${pathname}`
})
@@ -28,7 +29,7 @@ export const select = ({ hideActionsMenu, addMultiSelectionFile }) => {
addMultiSelectionFile(files[0])
}}
>
{files.length === 0 ? t('action.forwardPapers') : t('action.select')}
{selectFromFile ? t('action.select') : t('action.forwardPapers')}
</ActionMenuItemWrapper>
)
}
94 changes: 28 additions & 66 deletions packages/cozy-mespapiers-lib/src/components/AppRouter.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import React from 'react'
import {
Switch,
Route,
Redirect,
HashRouter,
useLocation
} from 'react-router-dom'
import { Routes, Route, Navigate, useLocation } from 'react-router-dom'

import Home from './Home/Home'
import MultiselectView from './Multiselect/MultiselectView'
@@ -14,29 +8,12 @@ import FilesViewerWithQuery from './Viewer/FileViewerWithQuery'
import OnboardedGuardedRoute from './OnboardedGuardedRoute'
import PlaceholderListModal from './Placeholders/PlaceholderListModal/PlaceholderListModal'
import CreatePaperModal from './StepperDialog/CreatePaperModal'
import { StepperDialogProvider } from './Contexts/StepperDialogProvider'
import OnboardingWrapper from './Onboarding/OnboardingWrapper'
import InformationEditWrapper from './ModelSteps/Edit/InformationEditWrapper'
import PageEdit from './ModelSteps/Edit/PageEdit'
import ContactEditWrapper from './ModelSteps/Edit/ContactEditWrapper'

const routes = [
{
path: '/paper',
component: Home
},
{
path: '/paper/files/:fileTheme',
component: PapersListWrapper
},
{
path: '/paper/file/:fileTheme/:fileId',
component: FilesViewerWithQuery
},
{
path: '/paper/onboarding',
component: OnboardingWrapper
}
]

const Routes = () => {
export const AppRouter = () => {
const location = useLocation()
const backgroundPath = new URLSearchParams(location.search).get(
'backgroundPath'
@@ -45,49 +22,34 @@ const Routes = () => {

return (
<>
<Switch location={background || location}>
{routes.map((route, idx) => (
<OnboardedGuardedRoute
key={idx}
exact
path={route.path}
component={route.component}
<Routes location={background || location}>
<Route element={<OnboardedGuardedRoute />}>
<Route index element={<Home />} />
<Route path="files/:fileTheme" element={<PapersListWrapper />} />
<Route
path="file/:fileTheme/:fileId"
element={<FilesViewerWithQuery />}
/>
))}
<Redirect from="*" to="/paper" />
</Switch>
<Route path="onboarding" element={<OnboardingWrapper />} />
</Route>
<Route path="*" element={<Navigate to="/" />} />
</Routes>
{background && (
<>
<Route exact path="/paper/multiselect" component={MultiselectView} />
<Route exact path="/paper/create" component={PlaceholderListModal} />
<Routes>
<Route path="multiselect" element={<MultiselectView />} />
<Route path="create" element={<PlaceholderListModal />} />
<Route
exact
path="/paper/create/:qualificationLabel"
render={props => {
const {
location: { search },
history
} = props
const isDeepBack = search.includes('deepBack')
const onClose = () => history.go(isDeepBack ? -2 : -1)

return (
<StepperDialogProvider>
<CreatePaperModal {...props} onClose={onClose} />
</StepperDialogProvider>
)
}}
path="create/:qualificationLabel"
element={<CreatePaperModal />}
/>
<Route
path="edit/information/:fileId"
element={<InformationEditWrapper />}
/>
</>
<Route path="edit/page/:fileId" element={<PageEdit />} />
<Route path="edit/contact/:fileId" element={<ContactEditWrapper />} />
</Routes>
)}
</>
)
}

export const AppRouter = () => {
return (
<HashRouter>
<Routes />
</HashRouter>
)
}
58 changes: 0 additions & 58 deletions packages/cozy-mespapiers-lib/src/components/AppRouter.spec.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import cx from 'classnames'
import isArray from 'lodash/isArray'

import makeStyles from 'cozy-ui/transpiled/react/helpers/makeStyles'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
import useBreakpoints from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
import Typography from 'cozy-ui/transpiled/react/Typography'
import { iconPropType } from 'cozy-ui/transpiled/react/Icon'
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'

import makeStyles from 'cozy-ui/transpiled/react/helpers/makeStyles'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
import Icon, { iconPropType } from 'cozy-ui/transpiled/react/Icon'

import IlluCovidVaccineCertificate from '../../assets/images/IlluCovidVaccineCertificate.png'
@@ -77,7 +77,14 @@ const CompositeHeaderImage = ({ icon, fallbackIcon, iconSize = 'large' }) => {
const isBitmap = typeof src === 'string' && src.endsWith('.png')

if (isBitmap) {
return <img data-testid={src} src={src} alt="illustration" />
return (
<img
data-testid={src}
src={src}
alt="illustration"
style={{ maxWidth: '16.25rem' }}
/>
)
}

return (
Original file line number Diff line number Diff line change
@@ -13,10 +13,7 @@ const ScannerI18nProvider = ({ children }) => {
const { lang } = useI18n()
const scannerI18n = getBoundT(lang || 'fr')

const scannerT = React.useCallback(
key => scannerI18n(`${prefix}.${key}`),
[scannerI18n]
)
const scannerT = (key, country) => scannerI18n(`${prefix}.${key}`, country)

return (
<ScannerI18nContext.Provider value={scannerT}>
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import React, { createContext, useEffect, useState } from 'react'
import { filterWithRemaining } from '../../helpers/filterWithRemaining'

const isOwner = item => item === 'owner'

const StepperDialogContext = createContext()

@@ -26,26 +23,7 @@ const StepperDialogProvider = ({ children }) => {
const allCurrentStepsDefinitionsSorted =
allCurrentStepsDefinitions.sort((a, b) => a.stepIndex - b.stepIndex)

// Despite its presence in the PapersDefinitions.json, it is not yet expected that the Contact step will be anywhere but in the last position
const {
itemsFound: contactStep,
remainingItems: allStepsWithoutContact
} = filterWithRemaining(allCurrentStepsDefinitionsSorted, isOwner)

const { stepIndex: lastStepIndex } = allStepsWithoutContact
.slice(-1)
.pop()

setAllCurrentSteps([
...allStepsWithoutContact,
{
stepIndex: lastStepIndex + 1,
multiple: contactStep[0]?.multiple || false,
illustration: 'Account.svg',
text: 'PaperJSON.generic.owner.text',
model: 'contact'
}
])
setAllCurrentSteps(allCurrentStepsDefinitionsSorted)
}
}
}, [currentDefinition])
69 changes: 69 additions & 0 deletions packages/cozy-mespapiers-lib/src/components/Home/FilterButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react'
import PropTypes from 'prop-types'

import IconButton from 'cozy-ui/transpiled/react/IconButton'
import Icon from 'cozy-ui/transpiled/react/Icon'
import Badge from 'cozy-ui/transpiled/react/Badge'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'

const useStyles = makeStyles(theme => ({
iconButton: {
color: theme.palette.text.icon,
boxShadow: theme.shadows[2],
backgroundColor: theme.palette.background.paper,
marginLeft: '0.5rem'
}
}))

const FilterButton = ({ badge, onClick }) => {
const styles = useStyles()

const { active, content, showZero } = badge

return active ? (
<Badge
badgeContent={content}
showZero={showZero}
color="primary"
variant="standard"
size="medium"
>
<IconButton
data-testid="SwitchButton"
className={styles.iconButton}
size="medium"
onClick={onClick}
>
<Icon icon="setting" />
</IconButton>
</Badge>
) : (
<IconButton
data-testid="SwitchButton"
className={styles.iconButton}
size="medium"
onClick={onClick}
>
<Icon icon="setting" />
</IconButton>
)
}

FilterButton.defaultProps = {
badge: {
active: false,
content: 0,
showZero: undefined
}
}

FilterButton.propTypes = {
onClick: PropTypes.func,
badge: PropTypes.shape({
active: PropTypes.bool,
content: PropTypes.number,
showZero: PropTypes.bool
})
}

export default FilterButton
80 changes: 44 additions & 36 deletions packages/cozy-mespapiers-lib/src/components/Home/Home.jsx
Original file line number Diff line number Diff line change
@@ -7,13 +7,15 @@ import Empty from 'cozy-ui/transpiled/react/Empty'
import Spinner from 'cozy-ui/transpiled/react/Spinner'
import Box from 'cozy-ui/transpiled/react/Box'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import IconButton from 'cozy-ui/transpiled/react/IconButton'
import Icon from 'cozy-ui/transpiled/react/Icon'
import Badge from 'cozy-ui/transpiled/react/Badge'
import makeStyles from 'cozy-ui/transpiled/react/helpers/makeStyles'
import useBreakpoints from 'cozy-ui/transpiled/react/hooks/useBreakpoints'

import ThemesFilter from '../ThemesFilter'
import SearchInput from '../SearchInput'
import { buildContactsQueryByIds } from '../../helpers/queries'
import {
buildFilesWithContacts,
getContactsRefIdsByFiles
} from '../Papers/helpers'
import PaperGroup from '../Papers/PaperGroup'
import FeaturedPlaceholdersList from '../Placeholders/FeaturedPlaceholdersList'
import { usePapersDefinitions } from '../Hooks/usePapersDefinitions'
@@ -25,28 +27,20 @@ import HomeCloud from '../../assets/icons/HomeCloud.svg'
import { filterPapersByThemeAndSearchValue } from './helpers'
import HomeToolbar from './HomeToolbar'
import SearchResult from '../SearchResult/SearchResult'

const useStyles = makeStyles(theme => ({
iconButton: {
color: theme.palette.text.icon,
boxShadow: theme.shadows[2],
backgroundColor: theme.palette.background.paper,
marginLeft: '0.5rem'
}
}))
import FilterButton from './FilterButton'

const {
themes: { themesList }
} = models.document

const Home = ({ setSelectedThemeLabel }) => {
const { isMultiSelectionActive } = useMultiSelection()
const { isMobile } = useBreakpoints()
const [searchValue, setSearchValue] = useState('')
const [isThemesFilterDisplayed, setIsThemesFilterDisplayed] = useState(
!isMultiSelectionActive
)
const [selectedTheme, setSelectedTheme] = useState('')
const styles = useStyles()
const { t } = useI18n()
const scannerT = useScannerI18n()
const { papersDefinitions } = usePapersDefinitions()
@@ -70,7 +64,7 @@ const Home = ({ setSelectedThemeLabel }) => {
[filesWithQualificationLabel, papersDefinitionsLabels]
)

const isLoading = isQueryLoading(queryResult) || queryResult.hasMore
const isLoadingFiles = isQueryLoading(queryResult) || queryResult.hasMore
const isSearching = searchValue.length > 0 || selectedTheme

const allPapersByCategories = useMemo(
@@ -79,14 +73,37 @@ const Home = ({ setSelectedThemeLabel }) => {
[filesWithPapersDefinitionsLabels]
)

const contactIds = getContactsRefIdsByFiles(filesWithPapersDefinitionsLabels)

const contactsQueryByIds = buildContactsQueryByIds(contactIds)
const { data: contacts, ...contactQueryResult } = useQueryAll(
contactsQueryByIds.definition,
{
...contactsQueryByIds.options,
enabled: isSearching && !isLoadingFiles
}
)

const isLoadingContacts =
isQueryLoading(contactQueryResult) || contactQueryResult.hasMore

const filesWithContacts =
isSearching && !isLoadingFiles && !isLoadingContacts
? buildFilesWithContacts({
files: filesWithPapersDefinitionsLabels,
contacts,
t
})
: []

const filteredPapers = filterPapersByThemeAndSearchValue({
files: isSearching
? filesWithPapersDefinitionsLabels
: allPapersByCategories,
? filesWithContacts
: allPapersByCategories.map(file => ({ file })),
theme: selectedTheme,
search: searchValue,
scannerT
})
}).map(({ file }) => file)

const featuredPlaceholders = useMemo(
() =>
@@ -106,7 +123,7 @@ const Home = ({ setSelectedThemeLabel }) => {
setIsThemesFilterDisplayed(isDisplayed)
}

if (isLoading) {
if (isLoadingFiles || isLoadingContacts) {
return (
<Spinner
size="xxlarge"
@@ -126,23 +143,14 @@ const Home = ({ setSelectedThemeLabel }) => {
onChange={ev => setSearchValue(ev.target.value)}
onFocus={() => handleThemesFilterDisplayed(false)}
/>
{!isThemesFilterDisplayed && (
<Badge
badgeContent={selectedTheme ? 1 : 0}
showZero={false}
color="primary"
variant="standard"
size="medium"
>
<IconButton
data-testid="SwitchButton"
className={styles.iconButton}
size="medium"
onClick={() => handleThemesFilterDisplayed(true)}
>
<Icon icon="setting" />
</IconButton>
</Badge>
{(!isThemesFilterDisplayed || isMobile) && (
<FilterButton
badge={{
active: !isThemesFilterDisplayed,
content: selectedTheme ? 1 : 0
}}
onClick={() => handleThemesFilterDisplayed(prev => !prev)}
/>
)}
</Box>
<Box className="u-flex u-flex-justify-center" flexWrap="wrap">
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global cozy */
import React from 'react'
import { useHistory } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'

import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import UIBarTitle from 'cozy-ui/transpiled/react/BarTitle'
import IconButton from 'cozy-ui/transpiled/react/IconButton'
@@ -13,14 +14,14 @@ import { useMultiSelection } from '../Hooks/useMultiSelection'
const HomeToolbar = () => {
const { t } = useI18n()
const { isDesktop } = useBreakpoints()
const history = useHistory()
const navigate = useNavigate()
const { setIsMultiSelectionActive } = useMultiSelection()
const { BarRight, BarLeft, BarCenter } = cozy.bar

return (
<>
<BarLeft>
<IconButton onClick={() => history.goBack()}>
<IconButton onClick={() => navigate(-1)}>
<Icon icon="previous" />
</IconButton>
</BarLeft>
11 changes: 6 additions & 5 deletions packages/cozy-mespapiers-lib/src/components/Home/helpers.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ const fuse = new Fuse([], {
threshold: 0.3,
ignoreLocation: true,
ignoreFieldNorm: true,
keys: ['name', 'tranlatedQualificationLabel']
keys: ['name', 'tranlatedQualificationLabel', 'contact']
})

// TODO: hasItemByLabel should be in cozy-client : https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/document/documentTypeDataHelpers.js
@@ -23,13 +23,14 @@ export const filterPapersByThemeAndSearchValue = ({
let filteredFiles = files

if (search || theme) {
const simpleFiles = files.map(file => ({
const simpleFiles = files.map(({ file, contact }) => ({
_id: file._id,
name: file.name,
qualifiationLabel: file.metadata.qualification.label,
tranlatedQualificationLabel: scannerT(
`items.${file.metadata.qualification.label}`
)
),
contact
}))

let filteredSimplesFiles = simpleFiles
@@ -46,10 +47,10 @@ export const filterPapersByThemeAndSearchValue = ({
}

filteredFiles = files
.filter(file =>
.filter(({ file }) =>
filteredSimplesFiles.some(simpleFile => simpleFile._id === file._id)
)
.sort((a, b) => b.updated_at.localeCompare(a.updated_at))
.sort((a, b) => b.file.updated_at.localeCompare(a.file.updated_at))
}

return filteredFiles
53 changes: 41 additions & 12 deletions packages/cozy-mespapiers-lib/src/components/Home/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -14,22 +14,38 @@ const scannerT = x => get(locales, x)

const files = [
{
_id: 'file01',
name: 'Facture internet',
metadata: { qualification: { label: 'isp_invoice' } },
updated_at: '2021-01-01:09:00.000000+01:00'
file: {
_id: 'file01',
name: 'Facture internet',
metadata: { qualification: { label: 'isp_invoice' } },
updated_at: '2021-01-01:09:00.000000+01:00'
}
},
{
_id: 'file02',
name: 'Permis de conduire',
metadata: { qualification: { label: 'driver_license' } },
updated_at: '2021-05-01:09:00.000000+01:00'
file: {
_id: 'file02',
name: 'Permis de conduire',
metadata: { qualification: { label: 'driver_license' } },
updated_at: '2021-05-01:09:00.000000+01:00'
},
contact: 'Alice Durand'
},
{
_id: 'file03',
name: 'Facture minitel',
metadata: { qualification: { label: 'phone_invoice' } },
updated_at: '2021-11-01:09:00.000000+01:00'
file: {
_id: 'file03',
name: 'Facture minitel',
metadata: { qualification: { label: 'phone_invoice' } },
updated_at: '2021-11-01:09:00.000000+01:00'
}
},
{
file: {
_id: 'file04',
name: "Dernier avis d'imposition",
metadata: { qualification: { label: 'tax_notice' } },
updated_at: '2022-07-01:09:00.000000+01:00'
},
contact: 'Alice et Bob Durand'
}
]

@@ -90,6 +106,19 @@ describe('filterPapersByThemeAndSearchValue', () => {
expect(res).toHaveLength(1)
expect(res).toContain(files[2])
})

test('when contact matches', () => {
const res = filterPapersByThemeAndSearchValue({
files,
theme: '',
search: 'alice d',
scannerT
})

expect(res).toHaveLength(2)
expect(res).toContain(files[1])
expect(res).toContain(files[3])
})
})

describe('with theme selected and search value', () => {
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { getReferencedBy, useQuery, isQueryLoading } from 'cozy-client'
import { CONTACTS_DOCTYPE } from '../../doctypes'
import { buildContactsQueryByIds } from '../../helpers/queries'

/**
* Get all contacts document from file
*/
const useReferencedContact = file => {
const contactsReferenced = getReferencedBy(file, CONTACTS_DOCTYPE)
const contactIds = contactsReferenced.map(ref => ref.id)
const isContactByIdsQueryEnabled = contactIds.length > 0

const contactsQueryByIds = buildContactsQueryByIds(contactIds)
const { data: contacts, ...contactsQueryResult } = useQuery(
contactsQueryByIds.definition,
{
...contactsQueryByIds.options,
enabled: isContactByIdsQueryEnabled
}
)

const isLoadingContacts =
isContactByIdsQueryEnabled &&
(isQueryLoading(contactsQueryResult) || contactsQueryResult.hasMore)

return { contacts, isLoadingContacts }
}
export default useReferencedContact
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import cx from 'classnames'

import { useClient } from 'cozy-client'
import makeStyles from 'cozy-ui/transpiled/react/helpers/makeStyles'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import Typography from 'cozy-ui/transpiled/react/Typography'
import Icon, { iconPropType } from 'cozy-ui/transpiled/react/Icon'
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ import { PapersDefinitionsProvider } from './Contexts/PapersDefinitionsProvider'
import { MultiSelectionProvider } from './Contexts/MultiSelectionProvider'
import { AppRouter } from './AppRouter'
import { usePapersDefinitions } from './Hooks/usePapersDefinitions'
import MoreOptions from './MoreOptions/MoreOptions'
import { getComponents } from '../helpers/defaultComponent'
import PapersFabWrapper from './PapersFab/PapersFabWrapper'
import { OnboardingProvider } from './Contexts/OnboardingProvider'
@@ -41,10 +40,7 @@ const App = () => {
className="u-flex u-flex-justify-center u-mt-2 u-h-5"
/>
) : (
<>
<MoreOptions />
<AppRouter />
</>
<AppRouter />
)}
<RealTimeQueries doctype="io.cozy.files" />
<RealTimeQueries doctype="io.cozy.mespapiers.settings" />
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React, { memo, useCallback, useEffect } from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'

import makeStyles from 'cozy-ui/transpiled/react/helpers/makeStyles'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
import Card from 'cozy-ui/transpiled/react/Card'
import DialogActions from 'cozy-ui/transpiled/react/DialogActions'
import Typography from 'cozy-ui/transpiled/react/Typography'
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import Avatar from 'cozy-ui/transpiled/react/Avatar'
import Radio from 'cozy-ui/transpiled/react/Radios'
import Checkbox from 'cozy-ui/transpiled/react/Checkbox'

const { getFullname } = models.contact
const { getDisplayName } = models.contact

const styleAvatar = {
color: 'var(--primaryColor)',
@@ -51,7 +51,7 @@ const Contact = ({
<Avatar size="small" style={styleAvatar} />
</ListItemIcon>
<ListItemText
primary={`${getFullname(contact)} ${
primary={`${getDisplayName(contact)} ${
contact.me ? `(${t('ContactStep.me')})` : ''
}`}
/>
Original file line number Diff line number Diff line change
@@ -24,11 +24,12 @@ const ContactList = ({
multiple,
currentUser,
contactIdsSelected,
setContactIdsSelected
setContactIdsSelected,
contactModalOpened,
setContactModalOpened
}) => {
const { t } = useI18n()
const { setFormData } = useFormData()
const [contactModalOpened, setContactModalOpened] = useState(false)
const [contactsLocalSession, setContactLocalSession] = useSessionstorage(
'contactList',
[]
Original file line number Diff line number Diff line change
@@ -26,9 +26,12 @@ const ContactWrapper = ({ currentStep, onClose }) => {
const [confirmReplaceFileModal, setConfirmReplaceFileModal] = useState(false)
const [currentUser, setCurrentUser] = useState(null)
const [contactIdsSelected, setContactIdsSelected] = useState([])
const [contactModalOpened, setContactModalOpened] = useState(false)
const { isMobile } = useBreakpoints()

const cozyFiles = formData.data.filter(d => d.file.constructor === Blob)
const saveButtonDisabled =
onLoad || contactIdsSelected.length === 0 || contactModalOpened

const closeConfirmReplaceFileModal = () => setConfirmReplaceFileModal(false)
const openConfirmReplaceFileModal = () => setConfirmReplaceFileModal(true)
@@ -58,7 +61,12 @@ const ContactWrapper = ({ currentStep, onClose }) => {
}

const handleKeyDown = ({ key }) => {
if (key === KEYS.ENTER) handleClick()
if (saveButtonDisabled) {
return
}
if (key === KEYS.ENTER) {
handleClick()
}
}

useEventListener(window, 'keydown', handleKeyDown)
@@ -84,6 +92,8 @@ const ContactWrapper = ({ currentStep, onClose }) => {
currentUser={currentUser}
contactIdsSelected={contactIdsSelected}
setContactIdsSelected={setContactIdsSelected}
contactModalOpened={contactModalOpened}
setContactModalOpened={setContactModalOpened}
/>
)
}
@@ -99,7 +109,7 @@ const ContactWrapper = ({ currentStep, onClose }) => {
fullWidth
label={t(!onLoad ? 'ContactStep.save' : 'ContactStep.onLoad')}
onClick={handleClick}
disabled={onLoad || contactIdsSelected.length === 0}
disabled={saveButtonDisabled}
busy={onLoad}
data-testid="ButtonSave"
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { useState } from 'react'

import Button from 'cozy-ui/transpiled/react/Buttons'
import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'

import { useScannerI18n } from '../../Hooks/useScannerI18n'
import CompositeHeaderImage from '../../CompositeHeader/CompositeHeaderImage'
import IlluGenericInputText from '../../../assets/icons/IlluGenericInputText.svg'
import ContactEditList from './ContactEditList'

const ContactEditDialog = ({
isBusy,
currentEditInformation,
contacts,
onConfirm,
onClose
}) => {
const { t } = useI18n()
const scannerT = useScannerI18n()

const [contactsList, setContactsList] = useState(contacts)
const [contactIdsSelected, setContactIdsSelected] = useState(
contacts.map(contact => contact._id)
)

const dialogTitle = currentEditInformation?.paperDef?.label
? scannerT(`items.${currentEditInformation.paperDef.label}`)
: ''

const isMultipleContactAllowed =
currentEditInformation.currentStep?.multiple ?? false

return (
<Dialog
open
onClose={onClose}
title={dialogTitle}
content={
<>
<CompositeHeaderImage
icon={currentEditInformation.currentStep?.illustration}
fallbackIcon={IlluGenericInputText}
iconSize="medium"
/>
<ContactEditList
contactsList={contactsList}
setContactsList={setContactsList}
contactIdsSelected={contactIdsSelected}
setContactIdsSelected={setContactIdsSelected}
isMultiple={isMultipleContactAllowed}
/>
</>
}
actions={
<Button
label={t('common.apply')}
onClick={() => onConfirm(contactIdsSelected)}
fullWidth
disabled={contactIdsSelected.length === 0}
busy={isBusy}
/>
}
/>
)
}

export default ContactEditDialog
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react'

import { models } from 'cozy-client'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem'
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon'
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemSecondaryAction'
import Avatar from 'cozy-ui/transpiled/react/Avatar'
import Checkbox from 'cozy-ui/transpiled/react/Checkbox'
import Radio from 'cozy-ui/transpiled/react/Radios'

const { getDisplayName } = models.contact

const AvatarStyle = {
color: 'var(--primaryColor)',
backgroundColor: 'var(--primaryColorLightest)'
}

const ContactEditItem = ({
contactIdsSelected,
setContactIdsSelected,
isMultiple,
contact
}) => {
const { t } = useI18n()

const onClickContactLine = val => {
const newValue = val?.target?.value || val

if (isMultiple) {
const newContactIdSelected = [...contactIdsSelected]
const find = newContactIdSelected.indexOf(newValue)

if (find > -1) newContactIdSelected.splice(find, 1)
else newContactIdSelected.push(newValue)

setContactIdsSelected(newContactIdSelected)
} else {
setContactIdsSelected([newValue])
}
}

return (
<ListItem
button
key={contact._id}
onClick={() => onClickContactLine(contact._id)}
>
<ListItemIcon>
<Avatar size="small" style={AvatarStyle} />
</ListItemIcon>
<ListItemText
primary={`${getDisplayName(contact)} ${
contact.me ? `(${t('ContactStep.me')})` : ''
}`}
/>
<ListItemSecondaryAction className="u-mr-half">
{isMultiple ? (
<Checkbox
checked={contactIdsSelected.includes(contact._id)}
onChange={onClickContactLine}
value={contact._id}
name="checkbox-contactEditItem"
/>
) : (
<Radio
checked={contactIdsSelected.includes(contact._id)}
onChange={onClickContactLine}
value={contact._id}
name="radio-contactEditItem"
/>
)}
</ListItemSecondaryAction>
</ListItem>
)
}

export default ContactEditItem
Loading