cozy-sharing 21.2.1 → 21.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/SharingProvider.js +4 -3
  3. package/dist/assets/illustrations/illustration-shared-drives.svg +1 -0
  4. package/dist/components/Avatar/AvatarList.js +0 -1
  5. package/dist/components/Identity/ExtraIdentity.js +0 -1
  6. package/dist/components/Identity/Identity.js +0 -1
  7. package/dist/components/Identity/MemberIdentity.js +0 -1
  8. package/dist/components/Identity/OwnerIdentity.js +0 -1
  9. package/dist/components/Recipient/GroupRecipient.js +0 -1
  10. package/dist/components/Recipient/GroupRecipientPermissions.js +0 -4
  11. package/dist/components/Recipient/LinkRecipient.js +0 -2
  12. package/dist/components/Recipient/LinkRecipientLite.js +0 -1
  13. package/dist/components/Recipient/MemberRecipient.js +0 -1
  14. package/dist/components/Recipient/MemberRecipientLite.js +3 -2
  15. package/dist/components/Recipient/MemberRecipientPermissions.js +0 -4
  16. package/dist/components/Recipient/MemberRecipientStatus.js +4 -22
  17. package/dist/components/Recipient/RecipientList.js +15 -0
  18. package/dist/components/Recipient/actions/revokeSharedDriveMember.js +41 -0
  19. package/dist/components/Recipient/actions/setReadOnlySharedPermission.js +54 -0
  20. package/dist/components/Recipient/actions/setReadWriteSharedPermission.js +54 -0
  21. package/dist/components/ShareByEmail.js +32 -19
  22. package/dist/components/ShareDialogCozyToCozy.js +0 -2
  23. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +0 -2
  24. package/dist/components/ShareModal/EditableSharingModal.js +13 -5
  25. package/dist/components/ShareModal.js +0 -3
  26. package/dist/components/ShareRestrictionModal/BoxEditingRights.js +0 -4
  27. package/dist/components/SharedDrive/SharedDriveModal.js +350 -0
  28. package/dist/components/SharedDrive/SharedDriveRecipient.js +61 -0
  29. package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +101 -0
  30. package/dist/components/SharedDrive/SharedDriveRecipientStatus.js +22 -0
  31. package/dist/components/SharedDrive/helpers.js +53 -0
  32. package/dist/components/WhoHasAccess.js +3 -1
  33. package/dist/components/WhoHasAccessLight.js +0 -1
  34. package/dist/index.js +1 -0
  35. package/dist/styles/autosuggest.styl +6 -2
  36. package/dist/styles/recipient.styl +0 -3
  37. package/dist/styles/shareddrive.styl +8 -0
  38. package/dist/stylesheet.css +20 -4
  39. package/locales/en.json +16 -0
  40. package/locales/fr.json +16 -0
  41. package/package.json +2 -2
  42. package/src/SharingProvider.jsx +4 -2
  43. package/src/assets/illustrations/illustration-shared-drives.svg +1 -0
  44. package/src/components/Recipient/GroupRecipient.jsx +1 -5
  45. package/src/components/Recipient/GroupRecipientPermissions.jsx +0 -4
  46. package/src/components/Recipient/LinkRecipient.jsx +1 -5
  47. package/src/components/Recipient/MemberRecipient.jsx +1 -1
  48. package/src/components/Recipient/MemberRecipientLite.jsx +3 -3
  49. package/src/components/Recipient/MemberRecipientPermissions.jsx +0 -4
  50. package/src/components/Recipient/MemberRecipientStatus.jsx +7 -17
  51. package/src/components/Recipient/RecipientList.jsx +18 -0
  52. package/src/components/Recipient/actions/revokeSharedDriveMember.js +41 -0
  53. package/src/components/Recipient/actions/setReadOnlySharedPermission.js +43 -0
  54. package/src/components/Recipient/actions/setReadWriteSharedPermission.js +43 -0
  55. package/src/components/ShareByEmail.jsx +33 -23
  56. package/src/components/ShareDialogCozyToCozy.jsx +0 -2
  57. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +0 -2
  58. package/src/components/ShareModal/EditableSharingModal.jsx +14 -5
  59. package/src/components/ShareModal.jsx +0 -3
  60. package/src/components/ShareRestrictionModal/BoxEditingRights.jsx +0 -4
  61. package/src/components/SharedDrive/SharedDriveModal.jsx +196 -0
  62. package/src/components/SharedDrive/SharedDriveRecipient.jsx +62 -0
  63. package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +77 -0
  64. package/src/components/SharedDrive/SharedDriveRecipientStatus.jsx +23 -0
  65. package/src/components/SharedDrive/helpers.js +60 -0
  66. package/src/components/WhoHasAccess.jsx +3 -1
  67. package/src/index.jsx +1 -0
  68. package/src/styles/autosuggest.styl +6 -2
  69. package/src/styles/recipient.styl +0 -3
  70. package/src/styles/shareddrive.styl +8 -0
@@ -0,0 +1,350 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import cx from 'classnames';
6
+ import PropTypes from 'prop-types';
7
+ import React, { useState } from 'react';
8
+ import { useClient } from 'cozy-client';
9
+ import Button from 'cozy-ui/transpiled/react/Buttons';
10
+ import { FixedActionsDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
11
+ import TextField from 'cozy-ui/transpiled/react/TextField';
12
+ import Typography from 'cozy-ui/transpiled/react/Typography';
13
+ import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
14
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
15
+ import { mergeAndDeduplicateRecipients, formatRecipients } from './helpers';
16
+
17
+ var IllustrationSharedDrives = function IllustrationSharedDrives(props) {
18
+ return /*#__PURE__*/React.createElement("svg", props, /*#__PURE__*/React.createElement("path", {
19
+ 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",
20
+ stroke: "#CEBEF7",
21
+ strokeWidth: "4",
22
+ strokeLinecap: "round"
23
+ }), /*#__PURE__*/React.createElement("path", {
24
+ 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",
25
+ stroke: "#B9F6F7",
26
+ strokeWidth: "4",
27
+ strokeLinecap: "round"
28
+ }), /*#__PURE__*/React.createElement("path", {
29
+ 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",
30
+ stroke: "#FFD799",
31
+ strokeWidth: "4",
32
+ strokeLinecap: "round"
33
+ }), /*#__PURE__*/React.createElement("circle", {
34
+ cx: "100",
35
+ cy: "64",
36
+ fill: "#297EF2",
37
+ r: "48"
38
+ }), /*#__PURE__*/React.createElement("circle", {
39
+ cx: "148",
40
+ cy: "104",
41
+ r: "24",
42
+ fill: "#B9F6F7"
43
+ }), /*#__PURE__*/React.createElement("path", {
44
+ fillRule: "evenodd",
45
+ clipRule: "evenodd",
46
+ 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",
47
+ fill: "#38D1D3"
48
+ }), /*#__PURE__*/React.createElement("circle", {
49
+ cx: "148",
50
+ cy: "104",
51
+ r: "20",
52
+ stroke: "#B9F6F7",
53
+ strokeWidth: "8"
54
+ }), /*#__PURE__*/React.createElement("circle", {
55
+ cx: "24",
56
+ cy: "65",
57
+ r: "24",
58
+ fill: "#FFD799"
59
+ }), /*#__PURE__*/React.createElement("path", {
60
+ fillRule: "evenodd",
61
+ clipRule: "evenodd",
62
+ 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",
63
+ fill: "#FF9300"
64
+ }), /*#__PURE__*/React.createElement("circle", {
65
+ cx: "24",
66
+ cy: "65",
67
+ r: "20",
68
+ stroke: "#FFD799",
69
+ strokeWidth: "8"
70
+ }), /*#__PURE__*/React.createElement("circle", {
71
+ cx: "172",
72
+ cy: "28",
73
+ r: "24",
74
+ fill: "#CEBEF7"
75
+ }), /*#__PURE__*/React.createElement("path", {
76
+ fillRule: "evenodd",
77
+ clipRule: "evenodd",
78
+ 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",
79
+ fill: "#855CEA"
80
+ }), /*#__PURE__*/React.createElement("circle", {
81
+ cx: "172",
82
+ cy: "28",
83
+ r: "20",
84
+ stroke: "#CEBEF7",
85
+ strokeWidth: "8"
86
+ }), /*#__PURE__*/React.createElement("path", {
87
+ 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",
88
+ fill: "#BBD9FD"
89
+ }), /*#__PURE__*/React.createElement("path", {
90
+ 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.015zm0-21a6 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",
91
+ fill: "#fff"
92
+ }), /*#__PURE__*/React.createElement("path", {
93
+ 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-12zm0-21a3 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",
94
+ fill: "#B2D3FF"
95
+ }), /*#__PURE__*/React.createElement("path", {
96
+ d: "M88 77.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0zm0-21a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",
97
+ fill: "#fff"
98
+ }), /*#__PURE__*/React.createElement("path", {
99
+ 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",
100
+ fill: "#BBD9FD"
101
+ }), /*#__PURE__*/React.createElement("path", {
102
+ 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.182v-.848c-.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",
103
+ fill: "#3281EE"
104
+ }), /*#__PURE__*/React.createElement("path", {
105
+ 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.788zm35.14 8.539c.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.788zm14.026-25c.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",
106
+ fill: "#BBD9FD"
107
+ }), /*#__PURE__*/React.createElement("path", {
108
+ 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",
109
+ fill: "#3281EE"
110
+ }), /*#__PURE__*/React.createElement("path", {
111
+ 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.788zm-15-19c.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",
112
+ fill: "#BBD9FD"
113
+ }), /*#__PURE__*/React.createElement("path", {
114
+ 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",
115
+ fill: "#3281EE"
116
+ }), /*#__PURE__*/React.createElement("path", {
117
+ 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",
118
+ fill: "#BBD9FD"
119
+ }), /*#__PURE__*/React.createElement("path", {
120
+ 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 .788zm-82.975 16c.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-.242zm153-25c1.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-.242zm-11.706-18.643c.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",
121
+ fill: "#3281EE"
122
+ }), /*#__PURE__*/React.createElement("path", {
123
+ 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 .788zm1.681-65.357c1.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",
124
+ fill: "#BBD9FD"
125
+ }), /*#__PURE__*/React.createElement("path", {
126
+ 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-.242zm9.294 15.357c.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.03a1.72 1.72 0 0 0 0 .788z",
127
+ fill: "#3281EE"
128
+ }));
129
+ };
130
+
131
+ IllustrationSharedDrives.defaultProps = {
132
+ width: "200",
133
+ height: "136",
134
+ viewBox: "0 0 200 136",
135
+ fill: "none",
136
+ xmlns: "http://www.w3.org/2000/svg"
137
+ };
138
+ import withLocales from '../../hoc/withLocales';
139
+ import { useSharingContext } from '../../hooks/useSharingContext';
140
+ import { Contact } from '../../models';
141
+ var styles = {
142
+ "shared-drive-who-has-access-wrapper": "shareddrive__shared-drive-who-has-access-wrapper___K1kbr"
143
+ };
144
+ import { default as DumbShareByEmail } from '../ShareByEmail';
145
+ import WhoHasAccess from '../WhoHasAccess';
146
+ export var SharedDriveModal = withLocales(function (_ref) {
147
+ var onClose = _ref.onClose;
148
+ var client = useClient();
149
+
150
+ var _useI18n = useI18n(),
151
+ t = _useI18n.t;
152
+
153
+ var _useSharingContext = useSharingContext(),
154
+ share = _useSharingContext.share;
155
+
156
+ var _useAlert = useAlert(),
157
+ showAlert = _useAlert.showAlert;
158
+
159
+ var _useState = useState({
160
+ recipients: [],
161
+ readOnlyRecipients: []
162
+ }),
163
+ _useState2 = _slicedToArray(_useState, 2),
164
+ sharedDriveRecipients = _useState2[0],
165
+ setSharedDriveRecipients = _useState2[1];
166
+
167
+ var _useState3 = useState(''),
168
+ _useState4 = _slicedToArray(_useState3, 2),
169
+ sharedDriveName = _useState4[0],
170
+ setSharedDriveName = _useState4[1];
171
+
172
+ var _useState5 = useState(''),
173
+ _useState6 = _slicedToArray(_useState5, 2),
174
+ sharedDriveDescription = _useState6[0],
175
+ setSharedDriveDescription = _useState6[1];
176
+
177
+ var onShare = function onShare(params) {
178
+ setSharedDriveRecipients({
179
+ recipients: mergeAndDeduplicateRecipients([sharedDriveRecipients.recipients, params.recipients]),
180
+ readOnlyRecipients: mergeAndDeduplicateRecipients([sharedDriveRecipients.readOnlyRecipients, params.readOnlyRecipients])
181
+ });
182
+ };
183
+
184
+ var handleSharedDriveNameChange = function handleSharedDriveNameChange(event) {
185
+ setSharedDriveName(event.target.value);
186
+ };
187
+
188
+ var handleSharedDriveDescriptionChange = function handleSharedDriveDescriptionChange(event) {
189
+ setSharedDriveDescription(event.target.value);
190
+ };
191
+
192
+ var onCreate = /*#__PURE__*/function () {
193
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
194
+ var _yield$client$create2, sharedDriveFolder;
195
+
196
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
197
+ while (1) switch (_context.prev = _context.next) {
198
+ case 0:
199
+ _context.prev = 0;
200
+ _context.next = 3;
201
+ return client.create('io.cozy.files', {
202
+ name: sharedDriveName,
203
+ dirId: 'io.cozy.files.shared-drives-dir',
204
+ type: 'directory'
205
+ });
206
+
207
+ case 3:
208
+ _yield$client$create2 = _context.sent;
209
+ sharedDriveFolder = _yield$client$create2.data;
210
+ _context.next = 7;
211
+ return share({
212
+ document: sharedDriveFolder,
213
+ recipients: sharedDriveRecipients.recipients,
214
+ readOnlyRecipients: sharedDriveRecipients.readOnlyRecipients,
215
+ description: sharedDriveDescription,
216
+ sharedDrive: true
217
+ });
218
+
219
+ case 7:
220
+ showAlert({
221
+ message: t('SharedDrive.sharedDriveModal.successNotification'),
222
+ severity: 'success',
223
+ variant: 'filled'
224
+ });
225
+ onClose();
226
+ _context.next = 14;
227
+ break;
228
+
229
+ case 11:
230
+ _context.prev = 11;
231
+ _context.t0 = _context["catch"](0);
232
+ showAlert({
233
+ message: t('SharedDrive.sharedDriveModal.errorNotification'),
234
+ severity: 'error',
235
+ variant: 'filled'
236
+ });
237
+
238
+ case 14:
239
+ case "end":
240
+ return _context.stop();
241
+ }
242
+ }, _callee, null, [[0, 11]]);
243
+ }));
244
+
245
+ return function onCreate() {
246
+ return _ref2.apply(this, arguments);
247
+ };
248
+ }();
249
+
250
+ var onSetType = function onSetType(index, newType) {
251
+ var _id = index.split('virtual-shared-drive-sharing-')[1];
252
+
253
+ if (newType === 'two-way') {
254
+ setSharedDriveRecipients(function (prev) {
255
+ var recipientToMove = prev.readOnlyRecipients.find(function (r) {
256
+ return r._id === _id;
257
+ });
258
+ return {
259
+ recipients: [].concat(_toConsumableArray(prev.recipients), [recipientToMove]),
260
+ readOnlyRecipients: prev.readOnlyRecipients.filter(function (r) {
261
+ return r._id !== _id;
262
+ })
263
+ };
264
+ });
265
+ } else {
266
+ setSharedDriveRecipients(function (prev) {
267
+ var recipientToMove = prev.recipients.find(function (r) {
268
+ return r._id === _id;
269
+ });
270
+ return {
271
+ recipients: prev.recipients.filter(function (r) {
272
+ return r._id !== _id;
273
+ }),
274
+ readOnlyRecipients: [].concat(_toConsumableArray(prev.readOnlyRecipients), [recipientToMove])
275
+ };
276
+ });
277
+ }
278
+ };
279
+
280
+ var onRevoke = function onRevoke(index) {
281
+ var _id = index.split('virtual-shared-drive-sharing-')[1];
282
+ setSharedDriveRecipients(function (prev) {
283
+ return {
284
+ recipients: prev.recipients.filter(function (r) {
285
+ return r._id !== _id;
286
+ }),
287
+ readOnlyRecipients: prev.readOnlyRecipients.filter(function (r) {
288
+ return r._id !== _id;
289
+ })
290
+ };
291
+ });
292
+ };
293
+
294
+ var recipients = formatRecipients(sharedDriveRecipients);
295
+ return /*#__PURE__*/React.createElement(FixedActionsDialog, {
296
+ open: true,
297
+ onClose: onClose,
298
+ title: t('SharedDrive.sharedDriveModal.title'),
299
+ content: /*#__PURE__*/React.createElement("div", {
300
+ className: "u-flex u-flex-column u-flex-items-center"
301
+ }, /*#__PURE__*/React.createElement(IllustrationSharedDrives, null), /*#__PURE__*/React.createElement(TextField, {
302
+ required: true,
303
+ label: t('SharedDrive.sharedDriveModal.nameLabel'),
304
+ variant: "outlined",
305
+ size: "small",
306
+ className: "u-w-100 u-mt-1",
307
+ value: sharedDriveName,
308
+ onChange: handleSharedDriveNameChange
309
+ }), /*#__PURE__*/React.createElement(TextField, {
310
+ required: true,
311
+ label: t('SharedDrive.sharedDriveModal.descriptionLabel'),
312
+ variant: "outlined",
313
+ size: "large",
314
+ className: "u-w-100 u-mt-1",
315
+ value: sharedDriveDescription,
316
+ onChange: handleSharedDriveDescriptionChange
317
+ }), /*#__PURE__*/React.createElement("div", {
318
+ className: cx('u-mt-1', styles['shared-drive-who-has-access-wrapper'])
319
+ }, /*#__PURE__*/React.createElement(Typography, {
320
+ variant: "h6",
321
+ className: "u-mb-1-half"
322
+ }, t('Share.contacts.whoHasAccess')), /*#__PURE__*/React.createElement(DumbShareByEmail, {
323
+ createContact: function createContact(contact) {
324
+ return client.create(Contact.doctype, contact);
325
+ },
326
+ currentRecipients: [],
327
+ document: document,
328
+ documentType: "Files",
329
+ onShare: onShare,
330
+ submitLabel: t('SharedDrive.sharedDriveModal.add'),
331
+ showNotifications: false
332
+ }), /*#__PURE__*/React.createElement(WhoHasAccess, {
333
+ isOwner: true,
334
+ recipients: recipients,
335
+ document: document,
336
+ documentType: "Files",
337
+ className: "u-w-100",
338
+ onRevoke: onRevoke,
339
+ onSetType: onSetType
340
+ }))),
341
+ actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
342
+ variant: "primary",
343
+ label: t('SharedDrive.sharedDriveModal.create'),
344
+ onClick: onCreate
345
+ }))
346
+ });
347
+ });
348
+ SharedDriveModal.propTypes = {
349
+ onClose: PropTypes.func.isRequired
350
+ };
@@ -0,0 +1,61 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["fadeIn", "members"];
4
+ import PropTypes from 'prop-types';
5
+ import React from 'react';
6
+ import Fade from 'cozy-ui/transpiled/react/Fade';
7
+ import ListItem from 'cozy-ui/transpiled/react/ListItem';
8
+ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
9
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
10
+ import Typography from 'cozy-ui/transpiled/react/Typography';
11
+ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
12
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
13
+ import SharedDriveRecipientPermissions from './SharedDriveRecipientPermissions';
14
+ import SharedDriveRecipientStatus from './SharedDriveRecipientStatus';
15
+ import { FADE_IN_DURATION, DEFAULT_DISPLAY_NAME } from '../../helpers/recipients';
16
+ import { getDisplayName } from '../../models';
17
+ import { GroupAvatar } from '../Avatar/GroupAvatar';
18
+ import { MemberAvatar } from '../Avatar/MemberAvatar';
19
+
20
+ var SharedDriveRecipient = function SharedDriveRecipient(props) {
21
+ var _useI18n = useI18n(),
22
+ t = _useI18n.t;
23
+
24
+ var _useBreakpoints = useBreakpoints(),
25
+ isMobile = _useBreakpoints.isMobile;
26
+
27
+ var fadeIn = props.fadeIn,
28
+ members = props.members,
29
+ rest = _objectWithoutProperties(props, _excluded);
30
+
31
+ var defaultDisplayName = t(DEFAULT_DISPLAY_NAME);
32
+ var name = getDisplayName(rest, defaultDisplayName);
33
+ return /*#__PURE__*/React.createElement(Fade, {
34
+ in: true,
35
+ timeout: fadeIn ? FADE_IN_DURATION : 0
36
+ }, /*#__PURE__*/React.createElement(ListItem, {
37
+ gutters: isMobile ? 'default' : 'double',
38
+ size: "small"
39
+ }, /*#__PURE__*/React.createElement(ListItemIcon, null, members ? /*#__PURE__*/React.createElement(GroupAvatar, {
40
+ size: "small"
41
+ }) : /*#__PURE__*/React.createElement(MemberAvatar, {
42
+ size: "small",
43
+ recipient: props
44
+ })), /*#__PURE__*/React.createElement(ListItemText, {
45
+ primary: /*#__PURE__*/React.createElement(Typography, {
46
+ variant: "body1"
47
+ }, name),
48
+ secondary: /*#__PURE__*/React.createElement(SharedDriveRecipientStatus, props)
49
+ }), /*#__PURE__*/React.createElement(SharedDriveRecipientPermissions, _extends({}, props, {
50
+ className: "u-flex-shrink-0"
51
+ }))));
52
+ };
53
+
54
+ SharedDriveRecipient.propTypes = {
55
+ instance: PropTypes.string,
56
+ isOwner: PropTypes.bool,
57
+ status: PropTypes.string,
58
+ recipientConfirmationData: PropTypes.object,
59
+ verifyRecipient: PropTypes.func
60
+ };
61
+ export default SharedDriveRecipient;
@@ -0,0 +1,101 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import React, { useState, useRef } from 'react';
5
+ import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
6
+ import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
7
+ import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
8
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
9
+ import { revokeSharedDriveMember } from '../Recipient/actions/revokeSharedDriveMember';
10
+ import { setReadOnlySharedPermission } from '../Recipient/actions/setReadOnlySharedPermission';
11
+ import { setReadWriteSharedPermission } from '../Recipient/actions/setReadWriteSharedPermission';
12
+
13
+ var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_ref) {
14
+ var index = _ref.index,
15
+ onSetType = _ref.onSetType,
16
+ type = _ref.type,
17
+ onRevoke = _ref.onRevoke;
18
+
19
+ var _useI18n = useI18n(),
20
+ t = _useI18n.t;
21
+
22
+ var buttonRef = useRef();
23
+
24
+ var _useState = useState(false),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ isMenuDisplayed = _useState2[0],
27
+ setMenuDisplayed = _useState2[1];
28
+
29
+ var toggleMenu = function toggleMenu() {
30
+ return setMenuDisplayed(!isMenuDisplayed);
31
+ };
32
+
33
+ var hideMenu = function hideMenu() {
34
+ return setMenuDisplayed(false);
35
+ };
36
+
37
+ var handleRevocation = /*#__PURE__*/function () {
38
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
39
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
40
+ while (1) switch (_context.prev = _context.next) {
41
+ case 0:
42
+ onRevoke(index);
43
+ hideMenu();
44
+
45
+ case 2:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }, _callee);
50
+ }));
51
+
52
+ return function handleRevocation() {
53
+ return _ref2.apply(this, arguments);
54
+ };
55
+ }();
56
+
57
+ var setType = /*#__PURE__*/function () {
58
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(newType) {
59
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
60
+ while (1) switch (_context2.prev = _context2.next) {
61
+ case 0:
62
+ if (newType !== type) {
63
+ onSetType(index, newType);
64
+ }
65
+
66
+ hideMenu();
67
+
68
+ case 2:
69
+ case "end":
70
+ return _context2.stop();
71
+ }
72
+ }, _callee2);
73
+ }));
74
+
75
+ return function setType(_x) {
76
+ return _ref3.apply(this, arguments);
77
+ };
78
+ }();
79
+
80
+ var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission, divider, revokeSharedDriveMember], {
81
+ t: t,
82
+ type: type,
83
+ setType: setType,
84
+ handleRevocation: handleRevocation
85
+ });
86
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DropdownButton, {
87
+ ref: buttonRef,
88
+ "aria-controls": "simple-menu",
89
+ "aria-haspopup": "true",
90
+ onClick: toggleMenu,
91
+ textVariant: "body2"
92
+ }, t("Share.type.".concat(type)).toLowerCase()), /*#__PURE__*/React.createElement(ActionsMenu, {
93
+ ref: buttonRef,
94
+ open: isMenuDisplayed,
95
+ actions: actions,
96
+ autoClose: true,
97
+ onClose: hideMenu
98
+ }));
99
+ };
100
+
101
+ export default ShareDriveRecipientPermissions;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import Typography from 'cozy-ui/transpiled/react/Typography';
3
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
4
+
5
+ var SharedDriveRecipientStatus = function SharedDriveRecipientStatus(_ref) {
6
+ var members = _ref.members,
7
+ email = _ref.email;
8
+
9
+ var _useI18n = useI18n(),
10
+ t = _useI18n.t;
11
+
12
+ var text = members ? t('GroupRecipient.secondary', {
13
+ memberCount: members.length,
14
+ smart_count: members.length
15
+ }) : email;
16
+ return /*#__PURE__*/React.createElement(Typography, {
17
+ variant: "caption",
18
+ color: "textSecondary"
19
+ }, text);
20
+ };
21
+
22
+ export default SharedDriveRecipientStatus;
@@ -0,0 +1,53 @@
1
+ import { models } from 'cozy-client';
2
+ var ContactModel = models.contact;
3
+ export var mergeAndDeduplicateRecipients = function mergeAndDeduplicateRecipients(arrays) {
4
+ var combinedArray = arrays.flat();
5
+ var seenIds = new Set();
6
+ var uniqueArray = combinedArray.filter(function (item) {
7
+ if (!seenIds.has(item.id)) {
8
+ seenIds.add(item.id);
9
+ return true;
10
+ }
11
+
12
+ return false;
13
+ });
14
+ return uniqueArray;
15
+ };
16
+ export var formatRecipients = function formatRecipients(sharedDriveRecipients) {
17
+ var recipients = [];
18
+ sharedDriveRecipients.recipients.forEach(function (r) {
19
+ recipients.push({
20
+ index: "virtual-shared-drive-sharing-".concat(r._id),
21
+ email: ContactModel.getPrimaryEmail(r),
22
+ public_name: r.displayName || r.name,
23
+ memberIndex: r._id,
24
+ type: 'two-way',
25
+ members: r.members
26
+ });
27
+ });
28
+ sharedDriveRecipients.readOnlyRecipients.forEach(function (r) {
29
+ recipients.push({
30
+ index: "virtual-shared-drive-sharing-".concat(r._id),
31
+ email: ContactModel.getPrimaryEmail(r),
32
+ public_name: r.displayName || r.name,
33
+ memberIndex: r._id,
34
+ type: 'one-way',
35
+ members: r.members
36
+ });
37
+ }); // We need to sort recipients by public_name
38
+ // to avoid reording them every time we change
39
+ // them from read only to read write.
40
+
41
+ recipients.sort(function (a, b) {
42
+ if (a.public_name < b.public_name) {
43
+ return -1;
44
+ }
45
+
46
+ if (a.public_name > b.public_name) {
47
+ return 1;
48
+ }
49
+
50
+ return 0;
51
+ });
52
+ return recipients;
53
+ };
@@ -35,9 +35,10 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
35
35
  recipientsToBeConfirmed = _ref2$recipientsToBeC === void 0 ? [] : _ref2$recipientsToBeC,
36
36
  document = _ref2.document,
37
37
  documentType = _ref2.documentType,
38
- onRevoke = _ref2.onRevoke,
39
38
  className = _ref2.className,
39
+ onRevoke = _ref2.onRevoke,
40
40
  onRevokeSelf = _ref2.onRevokeSelf,
41
+ onSetType = _ref2.onSetType,
41
42
  verifyRecipient = _ref2.verifyRecipient,
42
43
  link = _ref2.link,
43
44
  permissions = _ref2.permissions;
@@ -65,6 +66,7 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
65
66
  documentType: documentType,
66
67
  onRevoke: onRevoke,
67
68
  onRevokeSelf: onRevokeSelf,
69
+ onSetType: onSetType,
68
70
  verifyRecipient: verifyRecipient
69
71
  })));
70
72
  };
@@ -7,7 +7,6 @@ var styles = {
7
7
  "recipient": "recipient__recipient___2DmZI",
8
8
  "recipients-list-light": "recipient__recipients-list-light___Vq4op",
9
9
  "recipient-idents": "recipient__recipient-idents___3s7rw",
10
- "recipient-status-icon": "recipient__recipient-status-icon___-liGw",
11
10
  "recipient-user": "recipient__recipient-user___1THIU",
12
11
  "recipient-details": "recipient__recipient-details___2fZfc",
13
12
  "avatar": "recipient__avatar___2LnIV",
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ export { default as LinkRecipientLite } from './components/Recipient/LinkRecipie
15
15
  export { default as OwnerRecipientDefaultLite } from './components/Recipient/OwnerRecipientDefaultLite';
16
16
  export { SharedRecipientsList } from './SharedRecipientsList';
17
17
  export { ShareButton } from './ShareButton';
18
+ export { SharedDriveModal } from './components/SharedDrive/SharedDriveModal';
18
19
  export { ShareModal } from './components/ShareModal/ShareModal';
19
20
  export { RefreshableSharings } from './RefreshableSharings';
20
21
  export { CozyPassFingerprintDialogContent } from './components/CozyPassFingerprintDialogContent';
@@ -55,9 +55,13 @@
55
55
  border none
56
56
  &:hover
57
57
  &:focus
58
+ &:focus-visible
58
59
  border none
60
+ outline none
59
61
  &:first-child
60
- padding .25rem .5rem
61
-
62
+ padding .25rem .5rem
63
+ &::placeholder
64
+ color var(--secondaryTextColor)
65
+ font-size 1rem
62
66
  .recipientChip
63
67
  margin .25rem .5rem .25rem 0
@@ -25,9 +25,6 @@
25
25
  overflow hidden
26
26
  text-overflow ellipsis
27
27
 
28
- .recipient-status-icon
29
- margin-right: .25rem
30
-
31
28
  .recipient-user
32
29
  .recipient-details
33
30
  text-overflow ellipsis
@@ -0,0 +1,8 @@
1
+ @require 'components/forms.styl'
2
+
3
+ .shared-drive-who-has-access-wrapper
4
+ border: 1px solid var(--borderMainColor)
5
+ border-radius: 0.5rem
6
+ width: 100%
7
+ padding: 1rem
8
+ box-sizing: border-box