cozy-sharing 31.0.2 → 31.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +15 -16
  3. package/dist/components/FederatedFolder/FederatedFolderModal.js +78 -103
  4. package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +102 -292
  5. package/dist/components/Recipient/GroupRecipientPermissions.js +15 -11
  6. package/dist/components/Recipient/LinkRecipient.js +15 -11
  7. package/dist/components/Recipient/LinkRecipientLite.js +1 -1
  8. package/dist/components/Recipient/LinkRecipientPermissions.js +2 -1
  9. package/dist/components/Recipient/MemberRecipient.spec.js +8 -10
  10. package/dist/components/Recipient/MemberRecipientLite.js +1 -1
  11. package/dist/components/Recipient/MemberRecipientPermissions.js +16 -12
  12. package/dist/components/Recipient/MemberRecipientPermissions.spec.js +62 -50
  13. package/dist/components/Recipient/RecipientConfirm.js +0 -5
  14. package/dist/components/ShareAutosuggest.js +9 -4
  15. package/dist/components/ShareByEmail.js +29 -274
  16. package/dist/components/ShareByEmail.spec.js +52 -230
  17. package/dist/components/ShareByLink.js +1 -3
  18. package/dist/components/ShareDialogCozyToCozy.js +169 -35
  19. package/dist/components/ShareDialogCozyToCozy.spec.js +123 -36
  20. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +13 -3
  21. package/dist/components/ShareModal/SharingDetailsModal.js +0 -5
  22. package/dist/components/ShareRecipientsInput.js +6 -3
  23. package/dist/components/SharedDrive/SharedDriveForm.js +17 -25
  24. package/dist/components/SharedDrive/SharedDriveModal.js +1 -1
  25. package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +15 -10
  26. package/dist/components/SharedDrive/useSharedDrive.js +33 -57
  27. package/dist/components/SharedDrive/useSharedDrive.spec.js +29 -93
  28. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +15 -26
  29. package/dist/components/Sharetypeselect.js +85 -90
  30. package/dist/hooks/usePendingRecipients.js +20 -0
  31. package/dist/hooks/usePendingRecipients.spec.js +30 -0
  32. package/dist/styles/autosuggest.styl +8 -2
  33. package/dist/styles/share.styl +0 -39
  34. package/dist/stylesheet.css +8 -36
  35. package/locales/en.json +14 -44
  36. package/locales/fr.json +14 -44
  37. package/locales/ru.json +14 -44
  38. package/locales/vi.json +14 -42
  39. package/package.json +2 -2
  40. package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +14 -15
  41. package/src/components/FederatedFolder/FederatedFolderModal.jsx +50 -67
  42. package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +63 -186
  43. package/src/components/Recipient/GroupRecipientPermissions.jsx +15 -13
  44. package/src/components/Recipient/LinkRecipient.jsx +9 -9
  45. package/src/components/Recipient/LinkRecipientLite.jsx +1 -3
  46. package/src/components/Recipient/LinkRecipientPermissions.jsx +2 -1
  47. package/src/components/Recipient/MemberRecipient.spec.jsx +4 -6
  48. package/src/components/Recipient/MemberRecipientLite.jsx +2 -2
  49. package/src/components/Recipient/MemberRecipientPermissions.jsx +16 -21
  50. package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +21 -23
  51. package/src/components/ShareAutosuggest.jsx +7 -2
  52. package/src/components/ShareByEmail.jsx +35 -186
  53. package/src/components/ShareByEmail.spec.jsx +22 -173
  54. package/src/components/ShareByLink.jsx +1 -7
  55. package/src/components/ShareDialogCozyToCozy.jsx +171 -38
  56. package/src/components/ShareDialogCozyToCozy.spec.jsx +67 -1
  57. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +11 -1
  58. package/src/components/ShareRecipientsInput.jsx +5 -2
  59. package/src/components/SharedDrive/SharedDriveForm.jsx +16 -25
  60. package/src/components/SharedDrive/SharedDriveModal.jsx +1 -1
  61. package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +15 -17
  62. package/src/components/SharedDrive/useSharedDrive.js +24 -50
  63. package/src/components/SharedDrive/useSharedDrive.spec.js +19 -67
  64. package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +15 -29
  65. package/src/components/Sharetypeselect.jsx +75 -58
  66. package/src/hooks/usePendingRecipients.js +13 -0
  67. package/src/hooks/usePendingRecipients.spec.js +21 -0
  68. package/src/styles/autosuggest.styl +8 -2
  69. package/src/styles/share.styl +0 -39
  70. package/dist/components/Recipient/actions/revokeGroup.js +0 -42
  71. package/dist/components/Recipient/actions/revokeMember.js +0 -42
  72. package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
  73. package/dist/components/SharedDrive/helpers.js +0 -102
  74. package/dist/components/SharedDrive/helpers.spec.js +0 -227
  75. package/dist/components/Sharesubmit.js +0 -28
  76. package/src/components/Recipient/actions/revokeGroup.js +0 -42
  77. package/src/components/Recipient/actions/revokeMember.js +0 -42
  78. package/src/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
  79. package/src/components/SharedDrive/helpers.js +0 -108
  80. package/src/components/SharedDrive/helpers.spec.js +0 -177
  81. package/src/components/Sharesubmit.jsx +0 -31
@@ -6,7 +6,6 @@ import Typography from 'cozy-ui/transpiled/react/Typography';
6
6
  import { useI18n } from 'twake-i18n';
7
7
  import withLocales from '../../hoc/withLocales';
8
8
  import { default as DumbShareByEmail } from '../ShareByEmail';
9
- import WhoHasAccess from '../WhoHasAccess';
10
9
  import { useSharedDrive } from './useSharedDrive';
11
10
  export var SharedDriveForm = withLocales(function (_ref) {
12
11
  var onSuccess = _ref.onSuccess,
@@ -19,13 +18,12 @@ export var SharedDriveForm = withLocales(function (_ref) {
19
18
  onSuccess: onSuccess
20
19
  }),
21
20
  sharedDriveName = _useSharedDrive.sharedDriveName,
22
- recipients = _useSharedDrive.recipients,
23
21
  handleSharedDriveNameChange = _useSharedDrive.handleSharedDriveNameChange,
24
- onShare = _useSharedDrive.onShare,
25
- onCreate = _useSharedDrive.onCreate,
26
- onSetType = _useSharedDrive.onSetType,
27
- onRevoke = _useSharedDrive.onRevoke,
28
- createContact = _useSharedDrive.createContact;
22
+ pendingRecipients = _useSharedDrive.pendingRecipients,
23
+ setPendingRecipients = _useSharedDrive.setPendingRecipients,
24
+ selectedOption = _useSharedDrive.selectedOption,
25
+ setSelectedOption = _useSharedDrive.setSelectedOption,
26
+ onCreate = _useSharedDrive.onCreate;
29
27
 
30
28
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
31
29
  className: "u-ph-2"
@@ -41,31 +39,25 @@ export var SharedDriveForm = withLocales(function (_ref) {
41
39
  variant: "h6",
42
40
  className: "u-mt-1-half u-mb-half"
43
41
  }, t('SharedDrive.sharedDriveModal.addPeople')), /*#__PURE__*/React.createElement(DumbShareByEmail, {
44
- createContact: createContact,
45
- currentRecipients: recipients,
42
+ currentRecipients: [],
46
43
  documentType: "Files",
47
- sharedDrive: true,
48
- onShare: onShare,
49
- submitLabel: t('SharedDrive.sharedDriveModal.add'),
50
- showNotifications: false,
51
- sharingDesc: ""
52
- })), /*#__PURE__*/React.createElement(WhoHasAccess, {
53
- isOwner: true,
54
- isSharedDrive: true,
55
- recipients: recipients,
56
- documentType: "Files",
57
- className: "u-w-100",
58
- onRevoke: onRevoke,
59
- onSetType: onSetType
60
- }), /*#__PURE__*/React.createElement("div", {
61
- className: "u-flex u-flex-justify-end u-ph-2 u-pv-1 u-column-gap-half"
44
+ pendingRecipients: pendingRecipients,
45
+ onPendingRecipientsChange: setPendingRecipients,
46
+ selectedOption: selectedOption,
47
+ onSelectedOptionChange: setSelectedOption
48
+ })), /*#__PURE__*/React.createElement("div", {
49
+ className: "u-flex u-ph-2 u-pv-1"
62
50
  }, /*#__PURE__*/React.createElement(Button, {
63
- variant: "secondary",
51
+ variant: "text",
64
52
  label: t('SharedDrive.sharedDriveModal.cancel'),
53
+ className: "u-w-100 u-m-1",
54
+ size: "large",
65
55
  onClick: onCancel
66
56
  }), /*#__PURE__*/React.createElement(Button, {
67
57
  variant: "primary",
68
58
  label: t('SharedDrive.sharedDriveModal.create'),
59
+ className: "u-w-100 u-m-1",
60
+ size: "large",
69
61
  onClick: onCreate
70
62
  })));
71
63
  });
@@ -2,8 +2,8 @@ import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
4
4
  import { useI18n } from 'twake-i18n';
5
- import withLocales from '../../hoc/withLocales';
6
5
  import { SharedDriveForm } from './SharedDriveForm';
6
+ import withLocales from '../../hoc/withLocales';
7
7
  export var SharedDriveModal = withLocales(function (_ref) {
8
8
  var onClose = _ref.onClose;
9
9
 
@@ -2,12 +2,13 @@ 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 React, { useState, useRef } from 'react';
5
- import { useClient } from 'cozy-client';
6
5
  import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
7
- import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
6
+ import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
8
7
  import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
8
+ import Icon from 'cozy-ui/transpiled/react/Icon';
9
+ import IconButton from 'cozy-ui/transpiled/react/IconButton';
10
+ import CrossCircleOutlineIcon from 'cozy-ui/transpiled/react/Icons/CrossCircleOutline';
9
11
  import { useI18n } from 'twake-i18n';
10
- import { revokeSharedDriveMember } from '../Recipient/actions/revokeSharedDriveMember';
11
12
  import { setReadOnlySharedPermission } from '../Recipient/actions/setReadOnlySharedPermission';
12
13
  import { setReadWriteSharedPermission } from '../Recipient/actions/setReadWriteSharedPermission';
13
14
 
@@ -21,7 +22,6 @@ var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_re
21
22
  t = _useI18n.t;
22
23
 
23
24
  var buttonRef = useRef();
24
- var client = useClient();
25
25
 
26
26
  var _useState = useState(false),
27
27
  _useState2 = _slicedToArray(_useState, 2),
@@ -79,12 +79,10 @@ var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_re
79
79
  };
80
80
  }();
81
81
 
82
- var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission, divider, revokeSharedDriveMember], {
82
+ var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission], {
83
83
  t: t,
84
- client: client,
85
84
  type: type,
86
- setType: setType,
87
- handleRevocation: handleRevocation
85
+ setType: setType
88
86
  });
89
87
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DropdownButton, {
90
88
  ref: buttonRef,
@@ -92,13 +90,20 @@ var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_re
92
90
  "aria-haspopup": "true",
93
91
  onClick: toggleMenu,
94
92
  textVariant: "body2"
95
- }, t("Share.type.".concat(type)).toLowerCase()), /*#__PURE__*/React.createElement(ActionsMenu, {
93
+ }, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
96
94
  ref: buttonRef,
97
95
  open: isMenuDisplayed,
98
96
  actions: actions,
99
97
  autoClose: true,
100
98
  onClose: hideMenu
101
- }));
99
+ }), /*#__PURE__*/React.createElement(IconButton, {
100
+ onClick: handleRevocation,
101
+ size: "small",
102
+ className: "u-ml-half",
103
+ "aria-label": t('Share.members.revoke')
104
+ }, /*#__PURE__*/React.createElement(Icon, {
105
+ icon: CrossCircleOutlineIcon
106
+ })));
102
107
  };
103
108
 
104
109
  export default ShareDriveRecipientPermissions;
@@ -5,7 +5,8 @@ import { useState } from 'react';
5
5
  import { useClient } from 'cozy-client';
6
6
  import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
7
7
  import { useI18n } from 'twake-i18n';
8
- import { RECIPIENT_INDEX_PREFIX, formatRecipients, mergeAndDeduplicateRecipients, moveRecipientToReadOnly, moveRecipientToReadWrite } from './helpers';
8
+ import { getOrCreateFromArray } from '../../helpers/contacts';
9
+ import { usePendingRecipients } from '../../hooks/usePendingRecipients';
9
10
  import { Contact } from '../../models';
10
11
  export var useSharedDrive = function useSharedDrive(_ref) {
11
12
  var onSuccess = _ref.onSuccess;
@@ -17,58 +18,59 @@ export var useSharedDrive = function useSharedDrive(_ref) {
17
18
  var _useAlert = useAlert(),
18
19
  showAlert = _useAlert.showAlert;
19
20
 
20
- var _useState = useState({
21
- recipients: [],
22
- readOnlyRecipients: []
23
- }),
21
+ var _useState = useState(''),
24
22
  _useState2 = _slicedToArray(_useState, 2),
25
- sharedDriveRecipients = _useState2[0],
26
- setSharedDriveRecipients = _useState2[1];
23
+ sharedDriveName = _useState2[0],
24
+ setSharedDriveName = _useState2[1];
27
25
 
28
- var _useState3 = useState(''),
29
- _useState4 = _slicedToArray(_useState3, 2),
30
- sharedDriveName = _useState4[0],
31
- setSharedDriveName = _useState4[1];
26
+ var _usePendingRecipients = usePendingRecipients(),
27
+ pendingRecipients = _usePendingRecipients.pendingRecipients,
28
+ setPendingRecipients = _usePendingRecipients.setPendingRecipients,
29
+ selectedOption = _usePendingRecipients.selectedOption,
30
+ setSelectedOption = _usePendingRecipients.setSelectedOption;
32
31
 
33
32
  var handleSharedDriveNameChange = function handleSharedDriveNameChange(event) {
34
33
  setSharedDriveName(event.target.value);
35
34
  };
36
35
 
37
- var onShare = function onShare(params) {
38
- setSharedDriveRecipients(function (prev) {
39
- return {
40
- recipients: mergeAndDeduplicateRecipients([prev.recipients, params.recipients]),
41
- readOnlyRecipients: mergeAndDeduplicateRecipients([prev.readOnlyRecipients, params.readOnlyRecipients])
42
- };
43
- });
36
+ var createContact = function createContact(contact) {
37
+ return client.create(Contact.doctype, contact);
44
38
  };
45
39
 
46
40
  var onCreate = /*#__PURE__*/function () {
47
41
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
42
+ var contacts, readWriteRecipients, readOnlyRecipients;
48
43
  return _regeneratorRuntime.wrap(function _callee$(_context) {
49
44
  while (1) switch (_context.prev = _context.next) {
50
45
  case 0:
51
46
  _context.prev = 0;
52
47
  _context.next = 3;
48
+ return getOrCreateFromArray(client, pendingRecipients, createContact);
49
+
50
+ case 3:
51
+ contacts = _context.sent;
52
+ readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts;
53
+ readOnlyRecipients = selectedOption === 'readOnly' ? contacts : [];
54
+ _context.next = 8;
53
55
  return client.collection('io.cozy.sharings').createSharedDrive({
54
56
  name: sharedDriveName,
55
57
  description: sharedDriveName,
56
- recipients: sharedDriveRecipients.recipients,
57
- readOnlyRecipients: sharedDriveRecipients.readOnlyRecipients
58
+ recipients: readWriteRecipients,
59
+ readOnlyRecipients: readOnlyRecipients
58
60
  });
59
61
 
60
- case 3:
62
+ case 8:
61
63
  showAlert({
62
64
  message: t('SharedDrive.sharedDriveModal.successNotification'),
63
65
  severity: 'success',
64
66
  variant: 'filled'
65
67
  });
66
68
  onSuccess();
67
- _context.next = 10;
69
+ _context.next = 15;
68
70
  break;
69
71
 
70
- case 7:
71
- _context.prev = 7;
72
+ case 12:
73
+ _context.prev = 12;
72
74
  _context.t0 = _context["catch"](0);
73
75
  showAlert({
74
76
  message: t('SharedDrive.sharedDriveModal.errorNotification'),
@@ -76,11 +78,11 @@ export var useSharedDrive = function useSharedDrive(_ref) {
76
78
  variant: 'filled'
77
79
  });
78
80
 
79
- case 10:
81
+ case 15:
80
82
  case "end":
81
83
  return _context.stop();
82
84
  }
83
- }, _callee, null, [[0, 7]]);
85
+ }, _callee, null, [[0, 12]]);
84
86
  }));
85
87
 
86
88
  return function onCreate() {
@@ -88,39 +90,13 @@ export var useSharedDrive = function useSharedDrive(_ref) {
88
90
  };
89
91
  }();
90
92
 
91
- var onSetType = function onSetType(index, newType) {
92
- var _id = index.split(RECIPIENT_INDEX_PREFIX)[1];
93
- setSharedDriveRecipients(function (prev) {
94
- return newType === 'two-way' ? moveRecipientToReadWrite(prev, _id) : moveRecipientToReadOnly(prev, _id);
95
- });
96
- };
97
-
98
- var onRevoke = function onRevoke(index) {
99
- var _id = index.split(RECIPIENT_INDEX_PREFIX)[1];
100
- setSharedDriveRecipients(function (prev) {
101
- return {
102
- recipients: prev.recipients.filter(function (r) {
103
- return r._id !== _id;
104
- }),
105
- readOnlyRecipients: prev.readOnlyRecipients.filter(function (r) {
106
- return r._id !== _id;
107
- })
108
- };
109
- });
110
- };
111
-
112
- var createContact = function createContact(contact) {
113
- return client.create(Contact.doctype, contact);
114
- };
115
-
116
93
  return {
117
94
  sharedDriveName: sharedDriveName,
118
- recipients: formatRecipients(sharedDriveRecipients),
119
95
  handleSharedDriveNameChange: handleSharedDriveNameChange,
120
- onShare: onShare,
121
- onCreate: onCreate,
122
- onSetType: onSetType,
123
- onRevoke: onRevoke,
124
- createContact: createContact
96
+ pendingRecipients: pendingRecipients,
97
+ setPendingRecipients: setPendingRecipients,
98
+ selectedOption: selectedOption,
99
+ setSelectedOption: setSelectedOption,
100
+ onCreate: onCreate
125
101
  };
126
102
  };
@@ -16,19 +16,10 @@ jest.mock('cozy-client', function () {
16
16
  return {
17
17
  useClient: jest.fn(function () {
18
18
  return {
19
- collection: mockCollection
19
+ collection: mockCollection,
20
+ create: jest.fn()
20
21
  };
21
- }),
22
- models: {
23
- contact: {
24
- getPrimaryEmail: jest.fn(function (r) {
25
- return Array.isArray(r.email) && r.email[0] ? r.email[0].address : '';
26
- }),
27
- getDisplayName: jest.fn(function (r) {
28
- return r.displayName || r.name || '';
29
- })
30
- }
31
- }
22
+ })
32
23
  };
33
24
  });
34
25
  jest.mock('cozy-ui/transpiled/react/providers/Alert', function () {
@@ -56,6 +47,13 @@ jest.mock('../../models', function () {
56
47
  }
57
48
  };
58
49
  });
50
+ jest.mock('../../helpers/contacts', function () {
51
+ return {
52
+ getOrCreateFromArray: jest.fn(function (client, recipients) {
53
+ return Promise.resolve(recipients);
54
+ })
55
+ };
56
+ });
59
57
  describe('useSharedDrive', function () {
60
58
  beforeEach(function () {
61
59
  jest.clearAllMocks();
@@ -69,7 +67,8 @@ describe('useSharedDrive', function () {
69
67
  result = _renderHook.result;
70
68
 
71
69
  expect(result.current.sharedDriveName).toBe('');
72
- expect(result.current.recipients).toEqual([]);
70
+ expect(result.current.pendingRecipients).toEqual([]);
71
+ expect(result.current.selectedOption).toBe('readWrite');
73
72
  });
74
73
  it('handleSharedDriveNameChange updates the name', function () {
75
74
  var _renderHook2 = renderHook(function () {
@@ -88,95 +87,28 @@ describe('useSharedDrive', function () {
88
87
  });
89
88
  expect(result.current.sharedDriveName).toBe('My Drive');
90
89
  });
91
- it('onRevoke removes a recipient from both lists', function () {
92
- var _renderHook3 = renderHook(function () {
93
- return useSharedDrive({
94
- onSuccess: jest.fn()
95
- });
96
- }),
97
- result = _renderHook3.result;
98
-
99
- act(function () {
100
- result.current.onShare({
101
- recipients: [{
102
- _id: 'abc',
103
- displayName: 'Alice',
104
- email: []
105
- }],
106
- readOnlyRecipients: []
107
- });
108
- });
109
- act(function () {
110
- result.current.onRevoke("virtual-shared-drive-sharing-abc");
111
- });
112
- expect(result.current.recipients).toHaveLength(0);
113
- });
114
- it('onSetType moves a recipient to read-only', function () {
115
- var _renderHook4 = renderHook(function () {
116
- return useSharedDrive({
117
- onSuccess: jest.fn()
118
- });
119
- }),
120
- result = _renderHook4.result;
121
-
122
- act(function () {
123
- result.current.onShare({
124
- recipients: [{
125
- _id: 'abc',
126
- displayName: 'Alice',
127
- email: []
128
- }],
129
- readOnlyRecipients: []
130
- });
131
- });
132
- act(function () {
133
- result.current.onSetType("virtual-shared-drive-sharing-abc", 'one-way');
134
- });
135
- expect(result.current.recipients[0].type).toBe('one-way');
136
- });
137
- it('onSetType moves a recipient to read-write', function () {
138
- var _renderHook5 = renderHook(function () {
139
- return useSharedDrive({
140
- onSuccess: jest.fn()
141
- });
142
- }),
143
- result = _renderHook5.result;
144
-
145
- act(function () {
146
- result.current.onShare({
147
- recipients: [],
148
- readOnlyRecipients: [{
149
- _id: 'xyz',
150
- displayName: 'Bob',
151
- email: []
152
- }]
153
- });
154
- });
155
- act(function () {
156
- result.current.onSetType("virtual-shared-drive-sharing-xyz", 'two-way');
157
- });
158
- expect(result.current.recipients).toHaveLength(1);
159
- expect(result.current.recipients[0].type).toBe('two-way');
160
- });
161
- it('onCreate calls createSharedDrive, showAlert with success, and onSuccess', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
162
- var onSuccess, _renderHook6, result;
90
+ it('onCreate calls createSharedDrive and onSuccess', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
91
+ var onSuccess, _renderHook3, result;
163
92
 
164
93
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
165
94
  while (1) switch (_context2.prev = _context2.next) {
166
95
  case 0:
167
96
  onSuccess = jest.fn();
168
97
  mockCreateSharedDrive.mockResolvedValue({});
169
- _renderHook6 = renderHook(function () {
98
+ _renderHook3 = renderHook(function () {
170
99
  return useSharedDrive({
171
100
  onSuccess: onSuccess
172
101
  });
173
- }), result = _renderHook6.result;
102
+ }), result = _renderHook3.result;
174
103
  act(function () {
175
104
  result.current.handleSharedDriveNameChange({
176
105
  target: {
177
106
  value: 'My Drive'
178
107
  }
179
108
  });
109
+ result.current.setPendingRecipients([{
110
+ email: 'a@b.c'
111
+ }]);
180
112
  });
181
113
  _context2.next = 6;
182
114
  return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
@@ -194,10 +126,14 @@ describe('useSharedDrive', function () {
194
126
  })));
195
127
 
196
128
  case 6:
197
- expect(mockCreateSharedDrive).toHaveBeenCalledWith(expect.objectContaining({
129
+ expect(mockCreateSharedDrive).toHaveBeenCalledWith({
198
130
  name: 'My Drive',
199
- description: 'My Drive'
200
- }));
131
+ description: 'My Drive',
132
+ recipients: [{
133
+ email: 'a@b.c'
134
+ }],
135
+ readOnlyRecipients: []
136
+ });
201
137
  expect(mockShowAlert).toHaveBeenCalledWith(expect.objectContaining({
202
138
  severity: 'success'
203
139
  }));
@@ -210,18 +146,18 @@ describe('useSharedDrive', function () {
210
146
  }, _callee2);
211
147
  })));
212
148
  it('onCreate shows error alert and does not call onSuccess on failure', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
213
- var onSuccess, _renderHook7, result;
149
+ var onSuccess, _renderHook4, result;
214
150
 
215
151
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
216
152
  while (1) switch (_context4.prev = _context4.next) {
217
153
  case 0:
218
154
  onSuccess = jest.fn();
219
155
  mockCreateSharedDrive.mockRejectedValue(new Error('network error'));
220
- _renderHook7 = renderHook(function () {
156
+ _renderHook4 = renderHook(function () {
221
157
  return useSharedDrive({
222
158
  onSuccess: onSuccess
223
159
  });
224
- }), result = _renderHook7.result;
160
+ }), result = _renderHook4.result;
225
161
  _context4.next = 5;
226
162
  return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
227
163
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
@@ -14,32 +14,30 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
14
14
  document = _ref.document,
15
15
  folderName = _ref.folderName,
16
16
  handleFolderNameChange = _ref.handleFolderNameChange,
17
- createContact = _ref.createContact,
18
17
  recipients = _ref.recipients,
19
18
  currentRecipients = _ref.currentRecipients,
20
19
  onRevoke = _ref.onRevoke,
21
- onSetType = _ref.onSetType,
22
20
  onCreate = _ref.onCreate,
23
21
  onSend = _ref.onSend,
24
22
  onClose = _ref.onClose,
25
- _onShare = _ref.onShare,
26
23
  onRename = _ref.onRename,
27
24
  _ref$showNameField = _ref.showNameField,
28
25
  showNameField = _ref$showNameField === void 0 ? false : _ref$showNameField,
29
26
  sharingLink = _ref.sharingLink,
30
27
  nameLabel = _ref.nameLabel,
31
28
  addPeopleLabel = _ref.addPeopleLabel,
32
- addButtonLabel = _ref.addButtonLabel,
33
29
  cancelLabel = _ref.cancelLabel,
34
30
  createLabel = _ref.createLabel,
35
31
  shareLabel = _ref.shareLabel,
36
32
  saveLabel = _ref.saveLabel,
37
- sharingDesc = _ref.sharingDesc,
38
33
  _ref$showShareByEmail = _ref.showShareByEmail,
39
34
  showShareByEmail = _ref$showShareByEmail === void 0 ? true : _ref$showShareByEmail,
40
35
  autoOpenShareRestriction = _ref.autoOpenShareRestriction,
41
- showGenerateLinkButton = _ref.showGenerateLinkButton;
42
- var hasRecipients = Boolean(recipients === null || recipients === void 0 ? void 0 : recipients.length); // Determine action buttons based on modal mode
36
+ showGenerateLinkButton = _ref.showGenerateLinkButton,
37
+ pendingRecipients = _ref.pendingRecipients,
38
+ onPendingRecipientsChange = _ref.onPendingRecipientsChange,
39
+ selectedOption = _ref.selectedOption,
40
+ onSelectedOptionChange = _ref.onSelectedOptionChange;
43
41
 
44
42
  var actionButtons = function () {
45
43
  if (showNameField && onCreate) {
@@ -74,7 +72,7 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
74
72
  }), /*#__PURE__*/React.createElement(Button, {
75
73
  variant: "primary",
76
74
  label: shareLabel,
77
- disabled: !hasRecipients || !onSend,
75
+ disabled: !onSend,
78
76
  onClick: onSend
79
77
  }));
80
78
  }
@@ -121,17 +119,13 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
121
119
  variant: "h6",
122
120
  className: "u-mt-1-half u-mb-half"
123
121
  }, addPeopleLabel), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
124
- createContact: createContact,
125
122
  currentRecipients: currentRecipients,
126
123
  document: document,
127
124
  documentType: "Files",
128
- sharedDrive: true,
129
- sharingDesc: sharingDesc,
130
- onShare: function onShare(params) {
131
- _onShare(params);
132
- },
133
- submitLabel: addButtonLabel,
134
- showNotifications: false
125
+ pendingRecipients: pendingRecipients,
126
+ onPendingRecipientsChange: onPendingRecipientsChange,
127
+ selectedOption: selectedOption,
128
+ onSelectedOptionChange: onSelectedOptionChange
135
129
  })), /*#__PURE__*/React.createElement(WhoHasAccess, {
136
130
  isOwner: true,
137
131
  isSharedDrive: true,
@@ -140,7 +134,6 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
140
134
  documentType: "Files",
141
135
  className: "u-w-100",
142
136
  onRevoke: onRevoke,
143
- onSetType: onSetType,
144
137
  link: sharingLink
145
138
  })),
146
139
  actions: actionButtons
@@ -151,30 +144,26 @@ DumbBatchSharedFolderModal.propTypes = {
151
144
  document: PropTypes.object,
152
145
  folderName: PropTypes.string,
153
146
  handleFolderNameChange: PropTypes.func,
154
- createContact: PropTypes.func.isRequired,
155
147
  recipients: PropTypes.array,
156
148
  currentRecipients: PropTypes.array,
157
149
  onRevoke: PropTypes.func.isRequired,
158
- onSetType: PropTypes.func.isRequired,
159
150
  onCreate: PropTypes.func,
160
151
  onSend: PropTypes.func,
161
152
  onClose: PropTypes.func.isRequired,
162
- onShare: PropTypes.func.isRequired,
163
153
  onRename: PropTypes.func,
164
154
  showNameField: PropTypes.bool,
165
155
  sharingLink: PropTypes.string,
166
156
  nameLabel: PropTypes.string,
167
157
  addPeopleLabel: PropTypes.string,
168
- addButtonLabel: PropTypes.string,
169
158
  cancelLabel: PropTypes.string,
170
159
  createLabel: PropTypes.string,
171
160
  shareLabel: PropTypes.string,
172
161
  saveLabel: PropTypes.string,
173
- sharingDesc: PropTypes.string,
174
162
  showShareByEmail: PropTypes.bool,
175
163
  autoOpenShareRestriction: PropTypes.bool,
176
- showGenerateLinkButton: PropTypes.bool
177
- };
178
- DumbBatchSharedFolderModal.defaultProps = {
179
- sharingDesc: ''
164
+ showGenerateLinkButton: PropTypes.bool,
165
+ pendingRecipients: PropTypes.array,
166
+ onPendingRecipientsChange: PropTypes.func,
167
+ selectedOption: PropTypes.oneOf(['readWrite', 'readOnly']),
168
+ onSelectedOptionChange: PropTypes.func
180
169
  };