cozy-sharing 32.1.2 → 32.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.claude/settings.local.json +27 -0
  2. package/AGENTS.md +7 -0
  3. package/CHANGELOG.md +18 -0
  4. package/dist/RefreshableSharings.spec.js +40 -0
  5. package/dist/assets/illustrations/illustration-shared-drives.svg +1 -0
  6. package/dist/components/EditLinkPermissionDialog.js +72 -0
  7. package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
  8. package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +65 -0
  9. package/dist/components/FederatedFolder/DumbFederatedFolderModal.spec.js +107 -0
  10. package/dist/components/FederatedFolder/FederatedFolderModal.js +41 -4
  11. package/dist/components/FederatedFolder/FederatedFolderModal.jsx.tmp.179197.1773939270471 +172 -0
  12. package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +79 -8
  13. package/dist/components/Recipient/actions/revokeGroup.js +42 -0
  14. package/dist/components/Recipient/actions/revokeMember.js +42 -0
  15. package/dist/components/Recipient/actions/revokeSharedDriveMember.js +41 -0
  16. package/dist/components/ShareAutosuggest.js +1 -0
  17. package/dist/components/ShareAutosuggest.spec.js +12 -4
  18. package/dist/components/ShareDialogCozyToCozy.spec.js +55 -8
  19. package/dist/components/ShareDiscardChangesModal.js +35 -0
  20. package/dist/components/ShareModal/ShareModal copy.js +43 -0
  21. package/dist/components/ShareModal/ShareModal.spec.js +197 -0
  22. package/dist/components/ShareModal/ShareModalBatchContainer.js +276 -0
  23. package/dist/components/ShareModal/ShareModalBatchContainer.spec.js +131 -0
  24. package/dist/components/ShareModal/SharedDriveEditModal.js +59 -0
  25. package/dist/components/ShareRecipientsInput.js +13 -3
  26. package/dist/components/ShareRecipientsInput.spec.js +63 -4
  27. package/dist/components/SharedDrive/DumbSharedDriveModal.js +78 -0
  28. package/dist/components/SharedDrive/DumbSharedDriveModal.spec.js +126 -0
  29. package/dist/components/SharedDrive/SharedDriveEditModal.js +110 -0
  30. package/dist/components/SharedDrive/SharedDriveModal copy.js +356 -0
  31. package/dist/components/SharedDrive/helpers.js +102 -0
  32. package/dist/components/SharedDrive/helpers.spec.js +208 -0
  33. package/dist/components/SharedDriveEditModal.js +43 -0
  34. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.spec.js +321 -0
  35. package/dist/components/SharedStatus.js +61 -0
  36. package/dist/components/SharedStatus.spec.js +44 -0
  37. package/dist/components/Sharesubmit.js +28 -0
  38. package/dist/components/__snapshots__/SharedStatus.spec.js.snap +94 -0
  39. package/dist/helpers/owner.js +14 -0
  40. package/dist/helpers/owner.spec.js +34 -0
  41. package/dist/hooks/useConfirmDiscardChanges.js +33 -0
  42. package/dist/hooks/useContactsAndGroups.js +65 -0
  43. package/dist/hooks/useSharedDrive.js +130 -0
  44. package/dist/hooks/useSharedDriveContactsAndGroups.js +65 -0
  45. package/dist/propTypes.js +26 -0
  46. package/dist/styles/shareddrive.styl +8 -0
  47. package/locales/en.json +10 -5
  48. package/locales/fr.json +10 -5
  49. package/locales/ru.json +10 -5
  50. package/locales/vi.json +10 -5
  51. package/package.json +2 -2
  52. package/src/components/FederatedFolder/FederatedFolderModal.jsx +184 -138
  53. package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +47 -0
  54. package/src/components/ShareAutosuggest.jsx +1 -0
  55. package/src/components/ShareAutosuggest.spec.jsx +10 -5
  56. package/src/components/ShareDialogCozyToCozy.spec.jsx +50 -4
  57. package/src/components/ShareDiscardChangesModal.jsx +40 -0
  58. package/src/components/ShareRecipientsInput.jsx +11 -6
  59. package/src/components/ShareRecipientsInput.spec.jsx +59 -0
@@ -0,0 +1,27 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(yarn test:*)",
5
+ "Bash(git stash)",
6
+ "Bash(git stash pop)",
7
+ "Bash(find /home/doubleface/Workspace/cozy-libs -path \"*/node_modules/cozy-client*\" -name \"*.js\" 2>/dev/null | head -3)",
8
+ "Bash(find /home/doubleface/Workspace/cozy-libs/packages -path \"*/cozy-client/src*\" -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\\\\b\" 2>/dev/null | head -3)",
9
+ "Bash(find /home/doubleface/Workspace/cozy-libs/packages/cozy-client -name \"PermissionsCollection*\" 2>/dev/null | head -5)",
10
+ "Bash(find /home/doubleface/Workspace/cozy-libs/packages/cozy-sharing/node_modules -path \"*/cozy-client/dist*\" -name \"collections.js\" 2>/dev/null | head -3)",
11
+ "Bash(find /home/doubleface/Workspace/cozy-libs/packages/cozy-sharing/node_modules -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\" 2>/dev/null | head -5)",
12
+ "Bash(find /home/doubleface/Workspace/cozy-libs/node_modules -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\" 2>/dev/null | head -5)",
13
+ "Bash(find /home/doubleface/.cache/yarn -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\" 2>/dev/null | head -3)",
14
+ "Bash(find /home/doubleface/.cache/yarn -name \"*.js\" 2>/dev/null | xargs grep -l \"class PermissionsCollection\" 2>/dev/null | head -3)",
15
+ "Bash(find /home/doubleface/.cache/yarn -path \"*cozy-client-60*\" -name \"*.js\" 2>/dev/null | head -5; find /home/doubleface/.cache/yarn -name \"package.json\" 2>/dev/null | xargs grep -l '\"name\": \"cozy-client\"' 2>/dev/null | head -3)",
16
+ "Bash(npx jest:*)",
17
+ "Bash(git:*)",
18
+ "Bash(grep -v \"^$\")",
19
+ "Bash(grep -v \"^\\\\-\\\\-$\")",
20
+ "Bash(grep -v \"console\\\\.\\\\|^--$\\\\|JSS\\\\|CozyThemeContext\")"
21
+ ]
22
+ },
23
+ "sandbox": {
24
+ "enabled": true,
25
+ "autoAllowBashIfSandboxed": true
26
+ }
27
+ }
package/AGENTS.md ADDED
@@ -0,0 +1,7 @@
1
+ - Package manager: `yarn`.
2
+ - Run all tests: `corepack yarn test`
3
+ - Run a single test file: `corepack yarn test path/to/file.spec.js`
4
+ - Run eslint (with fix): `corepack yarn lint --fix`
5
+ - Run eslint (with fix) on one file: `corepack yarn lint --fix path/to/file.js`
6
+
7
+ No need to build the package. The user will handle this
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [32.3.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.3.0...cozy-sharing@32.3.1) (2026-05-22)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **cozy-sharing:** Filter out owner from the list of suggested users ([cb312ee](https://github.com/cozy/cozy-libs/commit/cb312ee6e412d021aff4a44830229404478ba316))
11
+
12
+ # [32.3.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.2.0...cozy-sharing@32.3.0) (2026-05-21)
13
+
14
+ ### Features
15
+
16
+ - **sharing:** Update sharing dialog close actions ([0624f97](https://github.com/cozy/cozy-libs/commit/0624f972fa681f199724a0bc10cfffe1f31c9657))
17
+
18
+ # [32.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.1.2...cozy-sharing@32.2.0) (2026-05-21)
19
+
20
+ ### Features
21
+
22
+ - **cozy-sharing:** Add autoFocus to the share recipient input ([0919284](https://github.com/cozy/cozy-libs/commit/09192847eb6659692b5950094095eb07e5be30ad))
23
+
6
24
  ## [32.1.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.1.1...cozy-sharing@32.1.2) (2026-05-19)
7
25
 
8
26
  **Note:** Version bump only for package cozy-sharing
@@ -0,0 +1,40 @@
1
+ import { mount } from 'enzyme';
2
+ import React from 'react';
3
+ import { createMockClient } from 'cozy-client';
4
+ import { RefreshableSharings } from './RefreshableSharings';
5
+ import { SharingProvider } from './SharingProvider';
6
+ import AppLike from '../test/AppLike';
7
+
8
+ var DumbComponent = function DumbComponent() {
9
+ return /*#__PURE__*/React.createElement("div", null, "test ");
10
+ };
11
+
12
+ var AppWrapper = function AppWrapper(_ref) {
13
+ var children = _ref.children,
14
+ client = _ref.client;
15
+ return /*#__PURE__*/React.createElement(AppLike, {
16
+ client: client
17
+ }, /*#__PURE__*/React.createElement(SharingProvider, {
18
+ client: client
19
+ }, children));
20
+ };
21
+
22
+ describe('RefreshableSharings', function () {
23
+ it('should test', function () {
24
+ var client = createMockClient({});
25
+ var component = mount( /*#__PURE__*/React.createElement(AppWrapper, {
26
+ client: client
27
+ }, /*#__PURE__*/React.createElement(RefreshableSharings, null, function (_ref2) {
28
+ var refresh = _ref2.refresh;
29
+ return /*#__PURE__*/React.createElement(DumbComponent, {
30
+ client: client,
31
+ t: function t(x) {
32
+ return x;
33
+ },
34
+ refreshSharings: refresh
35
+ });
36
+ })));
37
+ var refreshMethod = component.find(DumbComponent).prop('refreshSharings');
38
+ expect(typeof refreshMethod).toBe('function');
39
+ });
40
+ });
@@ -0,0 +1 @@
1
+ <svg width="200" height="136" viewBox="0 0 200 136" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M161 14.592c-1.888.222-7.568-.664-15.182-5.982-9.518-6.647-13.847-8.724-22.434-4.183C115 8.86 115.227 23.012 115 27" stroke="#CEBEF7" stroke-width="4" stroke-linecap="round"/><path d="M165.844 92c5.431-3.51 16.097-12.335 15.315-19.555-.977-9.025-12.708-11.281-22.81-10.78-10.101.502-17.596 4.513-28.349 1.504" stroke="#B9F6F7" stroke-width="4" stroke-linecap="round"/><path d="M23.495 72c-.329 4.729-2.425 21.765 5.479 27.308 9.88 6.928 23.668-1.244 30.831-5.203C66.97 90.146 79.072 83.217 85 85.527" stroke="#FFD799" stroke-width="4" stroke-linecap="round"/><circle cx="100" cy="64" fill="#297EF2" r="48"/><circle cx="148" cy="104" r="24" fill="#B9F6F7"/><path fill-rule="evenodd" clip-rule="evenodd" d="M148 106c-4.418 0-8-4.029-8-9 0-4.97 3.582-9 8-9s8 4.03 8 9c0 4.971-3.582 9-8 9Zm-16 10c0-2 4-8 8-8s2 2 8 2 4-2 8-2 8 6 8 8 0 4-2 4h-28c-2 0-2-2-2-4Z" fill="#38D1D3"/><circle cx="148" cy="104" r="20" stroke="#B9F6F7" stroke-width="8"/><circle cx="24" cy="65" r="24" fill="#FFD799"/><path fill-rule="evenodd" clip-rule="evenodd" d="M24 67c-4.418 0-8-4.03-8-9s3.582-9 8-9 8 4.03 8 9-3.582 9-8 9ZM8 77c0-2 4-8 8-8s2 2 8 2 4-2 8-2 8 6 8 8 0 4-2 4H10c-2 0-2-2-2-4Z" fill="#FF9300"/><circle cx="24" cy="65" r="20" stroke="#FFD799" stroke-width="8"/><circle cx="172" cy="28" r="24" fill="#CEBEF7"/><path fill-rule="evenodd" clip-rule="evenodd" d="M172 30c-4.418 0-8-4.03-8-9s3.582-9 8-9 8 4.03 8 9-3.582 9-8 9Zm-16 10c0-2 4-8 8-8s2 2 8 2 4-2 8-2 8 6 8 8 0 4-2 4h-28c-2 0-2-2-2-4Z" fill="#855CEA"/><circle cx="172" cy="28" r="20" stroke="#CEBEF7" stroke-width="8"/><path d="M66.418 133.29a81.818 81.818 0 0 0 16.142 2.244c16.166.948 38.758.424 48.325-1.346 9.567-1.771 10.083-4.465-14.448-5.812-20.925-1.147-45.26.474-50.362 2.894-1.52.648-1.447 1.371.343 2.02Z" fill="#BBD9FD"/><path d="M80.198 64.752a6 6 0 0 1 4.686-2.252h30.232c1.823 0 3.547.828 4.685 2.252l3.213 4.015c.638.798.986 1.79.986 2.812V76H76v-4.421a4.5 4.5 0 0 1 .986-2.812l3.212-4.015ZM80.198 43.752a6 6 0 0 1 4.686-2.252h30.232c1.823 0 3.547.828 4.685 2.252l3.213 4.015c.638.798.986 1.79.986 2.811V55H76v-4.422a4.5 4.5 0 0 1 .986-2.81l3.212-4.016Z" fill="#fff"/><path d="M76 71.5a3 3 0 0 1 3-3h42a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H79a3 3 0 0 1-3-3v-12ZM76 50.5a3 3 0 0 1 3-3h42a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H79a3 3 0 0 1-3-3v-12Z" fill="#B2D3FF"/><path d="M88 77.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM88 56.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" fill="#fff"/><path d="M194.751 99.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.607.061 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.061-.546.303-.121.666-.121.969-.242ZM48.112 111.445c1.212-.045 1.17-1.968-.043-1.968-.216 0-.433 0-.65.134v-.627c-.043-.537-.389-.984-.952-.984-.476 0-.995.447-.952.984v.537H45.3c-.13-.044-.217 0-.347 0-.649 0-.952.671-.952 1.164 0 .492.26.715.65.85.259.134.562.044.865.044 0 .135.043.269.043.448.044 1.297 1.992 1.297 1.905 0 0-.134 0-.269-.043-.403.216-.089.476-.089.692-.179ZM176.04 97.024c.121.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.301 1.03-.121.242-.121.485-.06.788Z" fill="#BBD9FD"/><path d="M185.045 86.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.545 0 .788ZM28.09 29.576c1.695-.06 1.634-2.667-.061-2.667-.303 0-.605 0-.908.182V26.243c-.06-.788-.545-1.394-1.332-1.394-.666 0-1.392.606-1.332 1.333v.727h-.303c-.181-.06-.302 0-.484 0-.908 0-1.332.91-1.332 1.576 0 .667.364.97.908 1.152.364.181.787.06 1.211.06 0 .182.06.364.06.606.061 1.758 2.785 1.758 2.664 0 0-.182 0-.364-.06-.545.303 0 .666-.06.968-.182ZM78.751 8.667C80.446 8.607 80.386 6 78.691 6c-.303 0-.606 0-.909.182v-.849C77.722 4.606 77.239 4 76.451 4c-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.21.06 0 .182.061.364.061.607.06 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.06-.546.302-.121.665-.121.968-.242Z" fill="#3281EE"/><path d="M107.751 10.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.606.061 1.758 2.785 1.758 2.664 0 0-.181 0-.363-.061-.545.303-.06.666-.121.969-.242ZM21.612 7.879h-1.634v-1.03c0-2.304-3.633-2.304-3.572 0 0 .424 0 .848.06 1.272-.181 0-.847-.06-.968-.121-2.18-.727-3.148 2.727-.969 3.454.545.182 1.574.182 2.119.182v.788c0 2.303 3.632 2.303 3.572 0v-.97c.484 0 .968-.06 1.513-.06 2.18.06 2.18-3.515-.12-3.515ZM8.9 32.485c.12.424.423.788.665.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.485-2.363-.908-.546-1.998.06-2.3 1.03-.121.242-.121.546-.06.788ZM44.04 41.024c.12.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.3 1.03-.122.242-.122.546-.061.788ZM58.066 16.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.485-2.363-.908-.546-1.998.06-2.3 1.03a.87.87 0 0 0-.061.788Z" fill="#BBD9FD"/><path d="M43.89 7.576c.12.424.423.788.666.97.666.424 1.695.302 2.179-.425.484-.667.545-1.757-.545-2.363-.908-.546-1.998.06-2.3 1.03-.06.242-.06.545 0 .788ZM84.026 28.97c.12.424.424.787.666.969.666.424 1.695.303 2.18-.424.483-.667.544-1.758-.546-2.364-.908-.545-1.997.06-2.3 1.03a1.73 1.73 0 0 0 0 .788Z" fill="#3281EE"/><path d="M20.04 107.024c.12.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.3 1.03-.122.242-.122.546-.061.788ZM5.04 88.024c.12.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.3 1.03-.122.242-.122.545-.061.788Z" fill="#BBD9FD"/><path d="M191.311 54.758h-1.634v-1.03c0-2.304-3.632-2.304-3.572 0 0 .423 0 .848.061 1.272-.182 0-.848-.06-.969-.121-2.179-.727-3.148 2.727-.969 3.454.545.182 1.574.182 2.119.182v.788c0 2.303 3.633 2.303 3.572 0v-.97c.484 0 .969-.06 1.513-.06 2.24.06 2.24-3.515-.121-3.515Z" fill="#3281EE"/><path d="M136.045 21.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.485 0 .788Z" fill="#BBD9FD"/><path d="M129.045 10.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.545-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.546 0 .788ZM46.07 26.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.546-2.363-.908-.546-1.997.06-2.3 1.03-.06.242-.121.546 0 .788ZM11.751 99.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.21.06 0 .182.061.364.061.607.06 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.06-.546.363-.06.665-.121.968-.242ZM164.751 74.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.606.061 1.758 2.785 1.758 2.664 0 0-.181 0-.363-.061-.545.364-.06.666-.121.969-.242ZM153.045 56.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.545-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.546 0 .788Z" fill="#3281EE"/><path d="M193.07 73.024c.121.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.545-2.363-.908-.546-1.997.06-2.3 1.03-.061.242-.121.545 0 .788ZM194.751 7.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.607.061 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.061-.546.303-.121.666-.182.969-.242Z" fill="#BBD9FD"/><path d="M49.751 89.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.21.06 0 .182.061.364.061.606.06 1.758 2.785 1.758 2.664 0 0-.181 0-.363-.06-.545.302-.121.665-.182.968-.242ZM59.045 105.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.545-2.363-.908-.546-1.998.06-2.3 1.03-.061.243-.061.546 0 .788Z" fill="#3281EE"/></svg>
@@ -0,0 +1,72 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import PropTypes from 'prop-types';
3
+ import React, { useState } from 'react';
4
+ import Button from 'cozy-ui/transpiled/react/Buttons';
5
+ import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
6
+ import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel';
7
+ import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup';
8
+ import Radio from 'cozy-ui/transpiled/react/Radios';
9
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
10
+
11
+ var EditLinkPermissionDialog = function EditLinkPermissionDialog(_ref) {
12
+ var open = _ref.open,
13
+ onClose = _ref.onClose,
14
+ document = _ref.document,
15
+ onPermissionsSelected = _ref.onPermissionsSelected;
16
+
17
+ var _useI18n = useI18n(),
18
+ t = _useI18n.t;
19
+
20
+ var _useState = useState(true),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ isReadOnlyPermissions = _useState2[0],
23
+ setIsReadOnlyPermissions = _useState2[1];
24
+
25
+ var onChange = function onChange(event) {
26
+ setIsReadOnlyPermissions(event.target.value === 'true');
27
+ };
28
+
29
+ var onConfirm = function onConfirm() {
30
+ var verbs = isReadOnlyPermissions ? ['GET'] : ['GET', 'POST', 'PUT', 'PATCH'];
31
+ onPermissionsSelected({
32
+ verbs: verbs
33
+ });
34
+ onClose();
35
+ };
36
+
37
+ return /*#__PURE__*/React.createElement(ConfirmDialog, {
38
+ open: open,
39
+ onClose: onClose,
40
+ title: t('Share.permissionLink.title'),
41
+ content: /*#__PURE__*/React.createElement(RadioGroup, {
42
+ "aria-label": "radio",
43
+ value: isReadOnlyPermissions.toString(),
44
+ onChange: onChange
45
+ }, /*#__PURE__*/React.createElement(FormControlLabel, {
46
+ value: "true",
47
+ label: (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.seeFolder") : t("Share.permissionLink.seeFile"),
48
+ control: /*#__PURE__*/React.createElement(Radio, null)
49
+ }), /*#__PURE__*/React.createElement(FormControlLabel, {
50
+ value: "false",
51
+ label: (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.modifyFolder") : t("Share.permissionLink.modifyFile"),
52
+ control: /*#__PURE__*/React.createElement(Radio, null)
53
+ })),
54
+ actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
55
+ variant: "secondary",
56
+ label: t('Share.permissionLink.cancel'),
57
+ onClick: onClose
58
+ }), /*#__PURE__*/React.createElement(Button, {
59
+ variant: "primary",
60
+ label: t('Share.permissionLink.confirm'),
61
+ onClick: onConfirm
62
+ }))
63
+ });
64
+ };
65
+
66
+ EditLinkPermissionDialog.propTypes = {
67
+ open: PropTypes.bool.isRequired,
68
+ onClose: PropTypes.func.isRequired,
69
+ document: PropTypes.object.isRequired,
70
+ onPermissionsSelected: PropTypes.func.isRequired
71
+ };
72
+ export default EditLinkPermissionDialog;
@@ -0,0 +1,48 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import React from 'react';
4
+ import { createMockClient } from 'cozy-client';
5
+ import EditLinkPermissionDialog from './EditLinkPermissionDialog';
6
+ import AppLike from '../../test/AppLike';
7
+ describe('EditLinkPermissionDialog', function () {
8
+ var client = createMockClient({});
9
+
10
+ var setup = function setup(props) {
11
+ return render( /*#__PURE__*/React.createElement(AppLike, {
12
+ client: client
13
+ }, /*#__PURE__*/React.createElement(EditLinkPermissionDialog, _extends({
14
+ open: true,
15
+ onClose: function onClose() {}
16
+ }, props))));
17
+ };
18
+
19
+ it('should select read permissions', function () {
20
+ var onPermissionsSelected = jest.fn();
21
+ var props = {
22
+ onPermissionsSelected: onPermissionsSelected
23
+ };
24
+
25
+ var _setup = setup(props),
26
+ getByText = _setup.getByText;
27
+
28
+ fireEvent.click(getByText('OK'));
29
+ expect(onPermissionsSelected).toHaveBeenCalledWith({
30
+ verbs: ['GET']
31
+ });
32
+ });
33
+ it('should select write permissions', function () {
34
+ var onPermissionsSelected = jest.fn();
35
+ var props = {
36
+ onPermissionsSelected: onPermissionsSelected
37
+ };
38
+
39
+ var _setup2 = setup(props),
40
+ getByText = _setup2.getByText;
41
+
42
+ fireEvent.click(getByText('Modify file'));
43
+ fireEvent.click(getByText('OK'));
44
+ expect(onPermissionsSelected).toHaveBeenCalledWith({
45
+ verbs: ['GET', 'POST', 'PUT', 'PATCH']
46
+ });
47
+ });
48
+ });
@@ -0,0 +1,65 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import { useI18n } from 'twake-i18n';
4
+ import withLocales from '../../hoc/withLocales';
5
+ import { DumbBatchSharedFolderModal } from '../SharedFolder/DumbBatchSharedFolderModal';
6
+ export var DumbFederatedFolderModal = withLocales(function (_ref) {
7
+ var title = _ref.title,
8
+ document = _ref.document,
9
+ createContact = _ref.createContact,
10
+ recipients = _ref.recipients,
11
+ readOnlyRecipients = _ref.readOnlyRecipients,
12
+ currentRecipients = _ref.currentRecipients,
13
+ onRevoke = _ref.onRevoke,
14
+ onSetType = _ref.onSetType,
15
+ onSend = _ref.onSend,
16
+ onClose = _ref.onClose,
17
+ onShare = _ref.onShare,
18
+ sharingLink = _ref.sharingLink,
19
+ showShareByEmail = _ref.showShareByEmail,
20
+ autoOpenShareRestriction = _ref.autoOpenShareRestriction,
21
+ showGenerateLinkButton = _ref.showGenerateLinkButton;
22
+
23
+ var _useI18n = useI18n(),
24
+ t = _useI18n.t;
25
+
26
+ return /*#__PURE__*/React.createElement(DumbBatchSharedFolderModal, {
27
+ title: title,
28
+ document: document,
29
+ createContact: createContact,
30
+ recipients: recipients,
31
+ readOnlyRecipients: readOnlyRecipients,
32
+ currentRecipients: currentRecipients,
33
+ onRevoke: onRevoke,
34
+ onSetType: onSetType,
35
+ onSend: onSend,
36
+ onClose: onClose,
37
+ onShare: onShare,
38
+ sharingLink: sharingLink,
39
+ showNameField: false,
40
+ addPeopleLabel: t('FederatedFolder.addPeople'),
41
+ addButtonLabel: t('FederatedFolder.add'),
42
+ shareLabel: t('FederatedFolder.share'),
43
+ showShareByEmail: showShareByEmail,
44
+ autoOpenShareRestriction: autoOpenShareRestriction,
45
+ showGenerateLinkButton: showGenerateLinkButton
46
+ });
47
+ });
48
+ DumbFederatedFolderModal.propTypes = {
49
+ title: PropTypes.string,
50
+ document: PropTypes.object,
51
+ createContact: PropTypes.func.isRequired,
52
+ recipients: PropTypes.array,
53
+ readOnlyRecipients: PropTypes.array,
54
+ currentRecipients: PropTypes.array,
55
+ onRevoke: PropTypes.func.isRequired,
56
+ onSetType: PropTypes.func.isRequired,
57
+ onSend: PropTypes.func.isRequired,
58
+ onClose: PropTypes.func.isRequired,
59
+ onShare: PropTypes.func.isRequired,
60
+ sharingLink: PropTypes.string,
61
+ showShareByEmail: PropTypes.bool,
62
+ autoOpenShareRestriction: PropTypes.bool,
63
+ showGenerateLinkButton: PropTypes.bool
64
+ };
65
+ export default DumbFederatedFolderModal;
@@ -0,0 +1,107 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { render } from '@testing-library/react';
3
+ import React from 'react';
4
+ import { DumbFederatedFolderModal } from './DumbFederatedFolderModal';
5
+ var mockDumbBatchSharedFolderModal = jest.fn();
6
+ jest.mock('../SharedFolder/DumbBatchSharedFolderModal', function () {
7
+ return {
8
+ __esModule: true,
9
+ default: function _default(props) {
10
+ mockDumbBatchSharedFolderModal(props);
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ "data-testid": "dumb-batch-shared-folder-modal"
13
+ }, "DumbBatchSharedFolderModal");
14
+ }
15
+ };
16
+ });
17
+ jest.mock('../../hoc/withLocales', function () {
18
+ return {
19
+ __esModule: true,
20
+ default: function _default(Component) {
21
+ return Component;
22
+ }
23
+ };
24
+ });
25
+ jest.mock('twake-i18n', function () {
26
+ return {
27
+ useI18n: jest.fn().mockReturnValue({
28
+ t: jest.fn(function (key) {
29
+ return key;
30
+ })
31
+ })
32
+ };
33
+ });
34
+ describe('DumbFederatedFolderModal', function () {
35
+ var defaultProps = {
36
+ title: 'Test Folder',
37
+ document: {
38
+ _id: 'doc-123',
39
+ name: 'Test'
40
+ },
41
+ createContact: jest.fn(),
42
+ recipients: [{
43
+ _id: 'r1',
44
+ email: 'test@test.com'
45
+ }],
46
+ currentRecipients: [],
47
+ onRevoke: jest.fn(),
48
+ onSetType: jest.fn(),
49
+ onSend: jest.fn(),
50
+ onClose: jest.fn(),
51
+ onShare: jest.fn(),
52
+ sharingLink: 'https://share.link/123',
53
+ hasRecipientsInitially: false
54
+ };
55
+
56
+ var setup = function setup() {
57
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
58
+ mockDumbBatchSharedFolderModal.mockClear();
59
+ return render( /*#__PURE__*/React.createElement(DumbFederatedFolderModal, _extends({}, defaultProps, props)));
60
+ };
61
+
62
+ it('should render DumbBatchSharedFolderModal with correct props', function () {
63
+ setup();
64
+ expect(mockDumbBatchSharedFolderModal).toHaveBeenCalledWith(expect.objectContaining({
65
+ title: 'Test Folder',
66
+ document: defaultProps.document,
67
+ createContact: defaultProps.createContact,
68
+ recipients: defaultProps.recipients,
69
+ currentRecipients: defaultProps.currentRecipients,
70
+ onRevoke: defaultProps.onRevoke,
71
+ onSetType: defaultProps.onSetType,
72
+ onSend: defaultProps.onSend,
73
+ onClose: defaultProps.onClose,
74
+ onShare: defaultProps.onShare,
75
+ sharingLink: 'https://share.link/123',
76
+ hasRecipientsInitially: false,
77
+ showNameField: false
78
+ }));
79
+ });
80
+ it('should pass correct i18n labels to DumbBatchSharedFolderModal', function () {
81
+ setup();
82
+ var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
83
+ expect(passedProps.addPeopleLabel).toBe('SharedDrive.sharedDriveModal.addPeople');
84
+ expect(passedProps.addButtonLabel).toBe('SharedDrive.sharedDriveModal.add');
85
+ expect(passedProps.shareLabel).toBe('SharedDrive.sharedDriveModal.share');
86
+ });
87
+ it('should always set showNameField to false', function () {
88
+ setup({
89
+ showNameField: true
90
+ });
91
+ var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
92
+ expect(passedProps.showNameField).toBe(false);
93
+ });
94
+ it('should handle hasRecipientsInitially prop correctly', function () {
95
+ setup({
96
+ hasRecipientsInitially: true
97
+ });
98
+ var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
99
+ expect(passedProps.hasRecipientsInitially).toBe(true);
100
+ });
101
+ it('should render the mocked component', function () {
102
+ var _setup = setup(),
103
+ getByTestId = _setup.getByTestId;
104
+
105
+ expect(getByTestId('dumb-batch-shared-folder-modal')).toBeInTheDocument();
106
+ });
107
+ });
@@ -2,16 +2,19 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import PropTypes from 'prop-types';
5
- import React, { useEffect, useState } from 'react';
5
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
6
6
  import { useClient } from 'cozy-client';
7
+ import Button from 'cozy-ui/transpiled/react/Buttons';
7
8
  import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
9
+ import ConfirmDialogProvider, { useConfirmDialog } from 'cozy-ui/transpiled/react/providers/ConfirmDialog';
8
10
  import { useI18n } from 'twake-i18n';
9
11
  import { getOrCreateFromArray } from '../../helpers/contacts';
10
12
  import withLocales from '../../hoc/withLocales';
11
13
  import { usePendingRecipients } from '../../hooks/usePendingRecipients';
12
14
  import { useSharingContext } from '../../hooks/useSharingContext';
13
15
  import { DumbBatchSharedFolderModal } from '../SharedFolder/DumbBatchSharedFolderModal';
14
- export var FederatedFolderModal = withLocales(function (_ref) {
16
+
17
+ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
15
18
  var onClose = _ref.onClose,
16
19
  existingDocument = _ref.document,
17
20
  autoOpenShareRestriction = _ref.autoOpenShareRestriction,
@@ -34,6 +37,10 @@ export var FederatedFolderModal = withLocales(function (_ref) {
34
37
  var _useAlert = useAlert(),
35
38
  showAlert = _useAlert.showAlert;
36
39
 
40
+ var _useConfirmDialog = useConfirmDialog(),
41
+ showConfirmDialog = _useConfirmDialog.showConfirmDialog,
42
+ closeConfirmDialog = _useConfirmDialog.closeConfirmDialog;
43
+
37
44
  var _useState = useState(null),
38
45
  _useState2 = _slicedToArray(_useState, 2),
39
46
  sharingLink = _useState2[0],
@@ -66,7 +73,33 @@ export var FederatedFolderModal = withLocales(function (_ref) {
66
73
  frozenRecipients = _useState8[0],
67
74
  setFrozenRecipients = _useState8[1];
68
75
 
69
- var documentPermissions = existingDocument ? getDocumentPermissions(existingDocument._id) : [];
76
+ var handleCloseRequest = useCallback(function () {
77
+ if (pendingRecipients.length === 0) {
78
+ onClose();
79
+ return;
80
+ }
81
+
82
+ showConfirmDialog({
83
+ title: t('ShareDiscardChangesModal.title'),
84
+ actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
85
+ variant: "secondary",
86
+ label: t('ShareDiscardChangesModal.cancel'),
87
+ className: "u-fz-small",
88
+ onClick: closeConfirmDialog
89
+ }), /*#__PURE__*/React.createElement(Button, {
90
+ variant: "primary",
91
+ label: t('ShareDiscardChangesModal.discard'),
92
+ className: "u-fz-small",
93
+ onClick: function onClick() {
94
+ closeConfirmDialog();
95
+ onClose();
96
+ }
97
+ }))
98
+ });
99
+ }, [closeConfirmDialog, onClose, pendingRecipients.length, showConfirmDialog, t]);
100
+ var documentPermissions = useMemo(function () {
101
+ return existingDocument ? getDocumentPermissions(existingDocument._id) : [];
102
+ }, [existingDocument, getDocumentPermissions]);
70
103
  useEffect(function () {
71
104
  var fetchSharingLink = /*#__PURE__*/function () {
72
105
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
@@ -201,7 +234,7 @@ export var FederatedFolderModal = withLocales(function (_ref) {
201
234
  currentRecipients: isSending ? frozenRecipients : existingRecipients,
202
235
  onRevoke: revoke,
203
236
  onSend: onSend,
204
- onClose: onClose,
237
+ onClose: handleCloseRequest,
205
238
  sharingLink: sharingLink,
206
239
  shareLabel: t('FederatedFolder.share'),
207
240
  showShareByEmail: !isSharedDrive,
@@ -212,6 +245,10 @@ export var FederatedFolderModal = withLocales(function (_ref) {
212
245
  selectedOption: selectedOption,
213
246
  onSelectedOptionChange: setSelectedOption
214
247
  });
248
+ };
249
+
250
+ export var FederatedFolderModal = withLocales(function (props) {
251
+ return /*#__PURE__*/React.createElement(ConfirmDialogProvider, null, /*#__PURE__*/React.createElement(FederatedFolderModalContent, props));
215
252
  });
216
253
  FederatedFolderModal.propTypes = {
217
254
  onClose: PropTypes.func.isRequired,