cozy-sharing 28.5.0 → 28.7.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 (36) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/SharingProvider.js +186 -87
  3. package/dist/SharingProvider.spec.js +152 -0
  4. package/dist/components/Recipient/LinkRecipient.js +27 -8
  5. package/dist/components/Recipient/LinkRecipient.stories.js +0 -1
  6. package/dist/components/Recipient/LinkRecipientPermissions.js +62 -15
  7. package/dist/components/Recipient/MemberRecipient.spec.js +13 -0
  8. package/dist/components/Recipient/MemberRecipientPermissions.js +80 -20
  9. package/dist/components/Recipient/MemberRecipientPermissions.spec.js +214 -0
  10. package/dist/components/Recipient/actions/revokeLink.js +34 -0
  11. package/dist/components/Recipient/actions/setReadOnlySharedPermission.js +0 -1
  12. package/dist/components/Recipient/actions/setReadOnlySharedPermission.spec.js +72 -0
  13. package/dist/components/Recipient/actions/setReadWriteSharedPermission.js +0 -1
  14. package/dist/components/Recipient/actions/setReadWriteSharedPermission.spec.js +72 -0
  15. package/dist/components/ShareDialogCozyToCozy.spec.js +9 -0
  16. package/dist/components/WhoHasAccess.js +0 -1
  17. package/locales/en.json +4 -1
  18. package/locales/fr.json +4 -1
  19. package/locales/ru.json +4 -1
  20. package/locales/vi.json +4 -1
  21. package/package.json +2 -2
  22. package/src/SharingProvider.jsx +52 -1
  23. package/src/SharingProvider.spec.jsx +94 -0
  24. package/src/components/Recipient/LinkRecipient.jsx +30 -7
  25. package/src/components/Recipient/LinkRecipient.stories.jsx +0 -1
  26. package/src/components/Recipient/LinkRecipientPermissions.jsx +54 -16
  27. package/src/components/Recipient/MemberRecipient.spec.jsx +11 -0
  28. package/src/components/Recipient/MemberRecipientPermissions.jsx +69 -16
  29. package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +165 -0
  30. package/src/components/Recipient/actions/revokeLink.js +33 -0
  31. package/src/components/Recipient/actions/setReadOnlySharedPermission.js +1 -1
  32. package/src/components/Recipient/actions/setReadOnlySharedPermission.spec.jsx +95 -0
  33. package/src/components/Recipient/actions/setReadWriteSharedPermission.js +1 -1
  34. package/src/components/Recipient/actions/setReadWriteSharedPermission.spec.jsx +95 -0
  35. package/src/components/ShareDialogCozyToCozy.spec.jsx +6 -0
  36. package/src/components/WhoHasAccess.jsx +0 -1
@@ -1,4 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
2
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
9
  import { act, render, screen } from '@testing-library/react';
4
10
  import React from 'react';
@@ -308,6 +314,152 @@ describe('updateDocumentPermissions', function () {
308
314
  }
309
315
  }, _callee5);
310
316
  })));
317
+ });
318
+ describe('updateSharingMemberType', function () {
319
+ var mockContact = {
320
+ _id: 'contact-1',
321
+ email: [{
322
+ address: 'bob@bob.cozy'
323
+ }]
324
+ };
325
+ var mockSharing = {
326
+ id: 'sharing-123',
327
+ type: 'io.cozy.sharings',
328
+ attributes: {
329
+ members: [{
330
+ status: 'owner',
331
+ email: 'owner@cozy.local'
332
+ }, {
333
+ status: 'ready',
334
+ email: 'bob@bob.cozy'
335
+ }]
336
+ }
337
+ };
338
+ var instance;
339
+ var mockContactsCollection;
340
+ beforeEach(function () {
341
+ mockContactsCollection = {
342
+ find: jest.fn().mockResolvedValue({
343
+ data: [mockContact]
344
+ })
345
+ };
346
+ var mockClient = {
347
+ getStackClient: function getStackClient() {
348
+ return {
349
+ uri: 'http://cozy.local'
350
+ };
351
+ },
352
+ collection: jest.fn().mockReturnValue(mockContactsCollection)
353
+ };
354
+ instance = new SharingProvider({
355
+ client: mockClient
356
+ });
357
+ instance.state = _objectSpread(_objectSpread({}, instance.state), {}, {
358
+ sharings: [mockSharing]
359
+ });
360
+ instance.sharingCol = {
361
+ revokeRecipient: jest.fn().mockResolvedValue({})
362
+ };
363
+ jest.spyOn(instance, 'addRecipients').mockResolvedValue({});
364
+ });
365
+ it('should throw when sharing is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
366
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
367
+ while (1) switch (_context6.prev = _context6.next) {
368
+ case 0:
369
+ _context6.next = 2;
370
+ return expect(instance.updateSharingMemberType('unknown-id', 1, 'one-way')).rejects.toThrow('Sharing not found');
371
+
372
+ case 2:
373
+ case "end":
374
+ return _context6.stop();
375
+ }
376
+ }, _callee6);
377
+ })));
378
+ it('should throw when member is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
379
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
380
+ while (1) switch (_context7.prev = _context7.next) {
381
+ case 0:
382
+ _context7.next = 2;
383
+ return expect(instance.updateSharingMemberType('sharing-123', 99, 'one-way')).rejects.toThrow('Member not found');
384
+
385
+ case 2:
386
+ case "end":
387
+ return _context7.stop();
388
+ }
389
+ }, _callee7);
390
+ })));
391
+ it('should throw when contact is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
392
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
393
+ while (1) switch (_context8.prev = _context8.next) {
394
+ case 0:
395
+ mockContactsCollection.find.mockResolvedValue({
396
+ data: []
397
+ });
398
+ _context8.next = 3;
399
+ return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Contact not found');
400
+
401
+ case 3:
402
+ case "end":
403
+ return _context8.stop();
404
+ }
405
+ }, _callee8);
406
+ })));
407
+ it('should revoke and re-add with readOnly when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
408
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
409
+ while (1) switch (_context9.prev = _context9.next) {
410
+ case 0:
411
+ _context9.next = 2;
412
+ return instance.updateSharingMemberType('sharing-123', 1, 'one-way');
413
+
414
+ case 2:
415
+ expect(instance.sharingCol.revokeRecipient).toHaveBeenCalledWith(mockSharing, 1);
416
+ expect(instance.addRecipients).toHaveBeenCalledWith({
417
+ document: mockSharing,
418
+ recipients: [],
419
+ readOnlyRecipients: [mockContact]
420
+ });
421
+
422
+ case 4:
423
+ case "end":
424
+ return _context9.stop();
425
+ }
426
+ }, _callee9);
427
+ })));
428
+ it('should revoke and re-add as read-write when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
429
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
430
+ while (1) switch (_context10.prev = _context10.next) {
431
+ case 0:
432
+ _context10.next = 2;
433
+ return instance.updateSharingMemberType('sharing-123', 1, 'two-way');
434
+
435
+ case 2:
436
+ expect(instance.sharingCol.revokeRecipient).toHaveBeenCalledWith(mockSharing, 1);
437
+ expect(instance.addRecipients).toHaveBeenCalledWith({
438
+ document: mockSharing,
439
+ recipients: [mockContact],
440
+ readOnlyRecipients: []
441
+ });
442
+
443
+ case 4:
444
+ case "end":
445
+ return _context10.stop();
446
+ }
447
+ }, _callee10);
448
+ })));
449
+ it('should rethrow error if addRecipients fails after revocation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
450
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
451
+ while (1) switch (_context11.prev = _context11.next) {
452
+ case 0:
453
+ instance.addRecipients.mockRejectedValue(new Error('Network error'));
454
+ _context11.next = 3;
455
+ return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Network error');
456
+
457
+ case 3:
458
+ case "end":
459
+ return _context11.stop();
460
+ }
461
+ }, _callee11);
462
+ })));
311
463
  }); // TODO Convert with react-testing-library
312
464
  // describe('hasWriteAccess', () => {
313
465
  // it('tells if a doc is writtable', () => {
@@ -1,21 +1,23 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import PropTypes from 'prop-types';
3
- import React from 'react';
4
+ import React, { useState } from 'react';
4
5
  import { useI18n } from 'twake-i18n';
5
6
  import Avatar from 'cozy-ui/transpiled/react/Avatar';
7
+ import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
6
8
  import Fade from 'cozy-ui/transpiled/react/Fade';
7
9
  import Icon from 'cozy-ui/transpiled/react/Icon';
8
10
  import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
9
11
  import ListItem from 'cozy-ui/transpiled/react/ListItem';
10
12
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
11
13
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
12
- import Typography from 'cozy-ui/transpiled/react/Typography';
13
14
  import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
14
15
  import LinkRecipientPermissions from './LinkRecipientPermissions';
15
16
  import RecipientConfirm from './RecipientConfirm';
16
17
  import { checkIsPermissionHasPassword, getPermissionExpiresDate } from '../../helpers/permissions';
17
18
  import { FADE_IN_DURATION } from '../../helpers/recipients';
18
19
  import { useSharingContext } from '../../hooks/useSharingContext';
20
+ import { ShareRestrictionModal } from '../ShareRestrictionModal/ShareRestrictionModal';
19
21
 
20
22
  var LinkRecipient = function LinkRecipient(props) {
21
23
  var _useI18n = useI18n(),
@@ -31,9 +33,14 @@ var LinkRecipient = function LinkRecipient(props) {
31
33
 
32
34
  var recipientConfirmationData = props.recipientConfirmationData,
33
35
  verifyRecipient = props.verifyRecipient,
34
- link = props.link,
35
36
  fadeIn = props.fadeIn,
36
37
  document = props.document;
38
+
39
+ var _useState = useState(false),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ openShareRestrictionModal = _useState2[0],
42
+ setOpenShareRestrictionModal = _useState2[1];
43
+
37
44
  var permissions = getDocumentPermissions(document === null || document === void 0 ? void 0 : document._id);
38
45
  var hasPassword = checkIsPermissionHasPassword(permissions);
39
46
  var expiresDate = getPermissionExpiresDate(permissions);
@@ -41,7 +48,7 @@ var LinkRecipient = function LinkRecipient(props) {
41
48
  var textPrimary = hasPassword ? t('Share.recipients.linkWithPassword') : t('Share.recipients.anyoneWithTheLink');
42
49
  var textSecondary = expiresDate ? t('Share.recipients.expires', {
43
50
  date: dateFormatted
44
- }) : link;
51
+ }) : '';
45
52
  var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
46
53
  recipientConfirmationData: recipientConfirmationData,
47
54
  verifyRecipient: verifyRecipient
@@ -62,14 +69,26 @@ var LinkRecipient = function LinkRecipient(props) {
62
69
  }, /*#__PURE__*/React.createElement(Icon, {
63
70
  icon: LinkIcon
64
71
  }))), /*#__PURE__*/React.createElement(ListItemText, {
65
- primary: /*#__PURE__*/React.createElement(Typography, {
66
- variant: "body1"
72
+ primary: /*#__PURE__*/React.createElement(DropdownButton, {
73
+ textVariant: "body1",
74
+ onClick: function onClick() {
75
+ return setOpenShareRestrictionModal(true);
76
+ }
67
77
  }, textPrimary),
68
78
  secondary: textSecondary
69
- }), RightPart));
79
+ }), RightPart, openShareRestrictionModal && /*#__PURE__*/React.createElement(ShareRestrictionModal, {
80
+ file: document,
81
+ onClose: function onClose() {
82
+ return setOpenShareRestrictionModal(false);
83
+ }
84
+ })));
70
85
  };
71
86
 
72
87
  LinkRecipient.propTypes = {
73
- link: PropTypes.string.isRequired
88
+ recipientConfirmationData: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
89
+ verifyRecipient: PropTypes.func,
90
+ fadeIn: PropTypes.bool,
91
+ document: PropTypes.object,
92
+ permissions: PropTypes.arrayOf(PropTypes.object)
74
93
  };
75
94
  export default LinkRecipient;
@@ -6,7 +6,6 @@ var meta = {
6
6
  verifyRecipient: function verifyRecipient() {
7
7
  return true;
8
8
  },
9
- link: 'test',
10
9
  fadeIn: false
11
10
  }
12
11
  };
@@ -2,14 +2,20 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import PropTypes from 'prop-types';
3
3
  import React, { useState, useRef } from 'react';
4
4
  import { useI18n } from 'twake-i18n';
5
+ import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
6
+ import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
5
7
  import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
8
+ import { revokeLink } from './actions/revokeLink';
9
+ import { setReadOnlySharedPermission } from './actions/setReadOnlySharedPermission';
10
+ import { setReadWriteSharedPermission } from './actions/setReadWriteSharedPermission';
11
+ import { isOnlyReadOnlyLinkAllowed } from '../../helpers/link';
6
12
  import { checkIsReadOnlyPermissions } from '../../helpers/permissions';
7
- import { ShareRestrictionModal } from '../ShareRestrictionModal/ShareRestrictionModal';
13
+ import { useSharingContext } from '../../hooks/useSharingContext';
14
+ import { WRITE_PERMS, READ_ONLY_PERMS } from '../ShareRestrictionModal/helpers';
8
15
 
9
16
  var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
10
17
  var className = _ref.className,
11
- document = _ref.document,
12
- permissions = _ref.permissions;
18
+ document = _ref.document;
13
19
 
14
20
  var _useI18n = useI18n(),
15
21
  t = _useI18n.t;
@@ -18,29 +24,70 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
18
24
 
19
25
  var _useState = useState(false),
20
26
  _useState2 = _slicedToArray(_useState, 2),
21
- openShareRestrictionModal = _useState2[0],
22
- setOpenShareRestrictionModal = _useState2[1];
27
+ isMenuDisplayed = _useState2[0],
28
+ setMenuDisplayed = _useState2[1];
23
29
 
30
+ var _useSharingContext = useSharingContext(),
31
+ updateDocumentPermissions = _useSharingContext.updateDocumentPermissions,
32
+ revokeSharingLink = _useSharingContext.revokeSharingLink,
33
+ documentType = _useSharingContext.documentType,
34
+ getDocumentPermissions = _useSharingContext.getDocumentPermissions;
35
+
36
+ var permissions = getDocumentPermissions(document._id);
24
37
  var isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions);
38
+ var type = isReadOnlyPermissions ? 'one-way' : 'two-way';
39
+
40
+ var toggleMenu = function toggleMenu() {
41
+ return setMenuDisplayed(!isMenuDisplayed);
42
+ };
43
+
44
+ var hideMenu = function hideMenu() {
45
+ return setMenuDisplayed(false);
46
+ };
47
+
48
+ var handleSetType = function handleSetType(newType) {
49
+ var verbs = newType === 'one-way' ? READ_ONLY_PERMS : WRITE_PERMS;
50
+ updateDocumentPermissions(document, {
51
+ verbs: verbs
52
+ });
53
+ };
54
+
55
+ var handleRevocation = function handleRevocation() {
56
+ return revokeSharingLink(document);
57
+ };
58
+
59
+ var actionsToShow = [setReadOnlySharedPermission];
60
+
61
+ if (!isOnlyReadOnlyLinkAllowed({
62
+ documentType: documentType
63
+ })) {
64
+ actionsToShow.push(setReadWriteSharedPermission);
65
+ }
66
+
67
+ actionsToShow.push(divider, revokeLink);
68
+ var actions = makeActions(actionsToShow, {
69
+ t: t,
70
+ type: type,
71
+ setType: handleSetType,
72
+ handleRevocation: handleRevocation
73
+ });
25
74
  return /*#__PURE__*/React.createElement("div", {
26
75
  className: className
27
76
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
28
77
  ref: buttonRef,
29
78
  textVariant: "body2",
30
- onClick: function onClick() {
31
- return setOpenShareRestrictionModal(true);
32
- }
33
- }, t("Share.type.".concat(isReadOnlyPermissions ? 'one-way' : 'two-way')).toLowerCase()), openShareRestrictionModal && /*#__PURE__*/React.createElement(ShareRestrictionModal, {
34
- file: document,
35
- onClose: function onClose() {
36
- return setOpenShareRestrictionModal(false);
37
- }
79
+ onClick: toggleMenu
80
+ }, t("Share.type.".concat(type)).toLowerCase()), /*#__PURE__*/React.createElement(ActionsMenu, {
81
+ ref: buttonRef,
82
+ open: isMenuDisplayed,
83
+ actions: actions,
84
+ autoClose: true,
85
+ onClose: hideMenu
38
86
  })));
39
87
  };
40
88
 
41
89
  LinkRecipientPermissions.propTypes = {
42
90
  className: PropTypes.string,
43
- document: PropTypes.object.isRequired,
44
- permissions: PropTypes.arrayOf(PropTypes.object).isRequired
91
+ document: PropTypes.object.isRequired
45
92
  };
46
93
  export default LinkRecipientPermissions;
@@ -5,6 +5,19 @@ import React from 'react';
5
5
  import { createMockClient } from 'cozy-client';
6
6
  import MemberRecipient from './MemberRecipient';
7
7
  import AppLike from '../../../test/AppLike';
8
+ var mockUpdateDocumentPermissions = jest.fn();
9
+ var mockUpdateSharingMemberType = jest.fn();
10
+ jest.mock('../../hooks/useSharingContext', function () {
11
+ return {
12
+ // eslint-disable-next-line react/display-name
13
+ useSharingContext: function useSharingContext() {
14
+ return {
15
+ updateDocumentPermissions: mockUpdateDocumentPermissions,
16
+ updateSharingMemberType: mockUpdateSharingMemberType
17
+ };
18
+ }
19
+ };
20
+ });
8
21
  describe('MemberRecipient component', function () {
9
22
  var client = createMockClient({});
10
23
  client.options = {
@@ -4,13 +4,18 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import React, { useState, useRef, useCallback } from 'react';
5
5
  import { useI18n } from 'twake-i18n';
6
6
  import { useClient } from 'cozy-client';
7
+ import minilog from 'cozy-minilog';
7
8
  import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
8
9
  import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
9
10
  import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
10
11
  import Spinner from 'cozy-ui/transpiled/react/Spinner';
11
12
  import Typography from 'cozy-ui/transpiled/react/Typography';
12
- import { permission } from './actions/permission';
13
+ import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
13
14
  import { revokeMember } from './actions/revokeMember';
15
+ import { setReadOnlySharedPermission } from './actions/setReadOnlySharedPermission';
16
+ import { setReadWriteSharedPermission } from './actions/setReadWriteSharedPermission';
17
+ import { useSharingContext } from '../../hooks/useSharingContext';
18
+ var log = minilog('MemberRecipientPermissions');
14
19
 
15
20
  var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
16
21
  var isOwner = _ref.isOwner,
@@ -31,6 +36,12 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
31
36
  var buttonRef = useRef();
32
37
  var client = useClient();
33
38
 
39
+ var _useSharingContext = useSharingContext(),
40
+ updateSharingMemberType = _useSharingContext.updateSharingMemberType;
41
+
42
+ var _useAlert = useAlert(),
43
+ showAlert = _useAlert.showAlert;
44
+
34
45
  var _useState = useState(false),
35
46
  _useState2 = _slicedToArray(_useState, 2),
36
47
  revoking = _useState2[0],
@@ -44,52 +55,101 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
44
55
  var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
45
56
  var contactIsOwner = status === 'owner';
46
57
  var shouldShowMenu = !revoking && !contactIsOwner && (instanceMatchesClient && !isOwner || isOwner);
47
-
48
- var toggleMenu = function toggleMenu() {
49
- return setMenuDisplayed(!isMenuDisplayed);
50
- };
51
-
52
- var hideMenu = function hideMenu() {
53
- return setMenuDisplayed(false);
54
- };
55
-
58
+ var toggleMenu = useCallback(function () {
59
+ setMenuDisplayed(function (displayed) {
60
+ return !displayed;
61
+ });
62
+ }, []);
63
+ var hideMenu = useCallback(function () {
64
+ setMenuDisplayed(false);
65
+ }, []);
56
66
  var handleRevocation = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
57
67
  return _regeneratorRuntime.wrap(function _callee$(_context) {
58
68
  while (1) switch (_context.prev = _context.next) {
59
69
  case 0:
60
70
  setRevoking(true);
71
+ _context.prev = 1;
61
72
 
62
73
  if (!isOwner) {
63
- _context.next = 6;
74
+ _context.next = 7;
64
75
  break;
65
76
  }
66
77
 
67
- _context.next = 4;
78
+ _context.next = 5;
68
79
  return onRevoke(document, sharingId, memberIndex);
69
80
 
70
- case 4:
71
- _context.next = 8;
81
+ case 5:
82
+ _context.next = 9;
72
83
  break;
73
84
 
74
- case 6:
75
- _context.next = 8;
85
+ case 7:
86
+ _context.next = 9;
76
87
  return onRevokeSelf(document);
77
88
 
78
- case 8:
89
+ case 9:
90
+ _context.prev = 9;
79
91
  setRevoking(false);
92
+ return _context.finish(9);
80
93
 
81
- case 9:
94
+ case 12:
82
95
  case "end":
83
96
  return _context.stop();
84
97
  }
85
- }, _callee);
98
+ }, _callee, null, [[1,, 9, 12]]);
86
99
  })), [isOwner, onRevoke, onRevokeSelf, document, sharingId, memberIndex]);
87
- var actions = makeActions([permission, divider, revokeMember], {
100
+ var setType = useCallback( /*#__PURE__*/function () {
101
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(newType) {
102
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
103
+ while (1) switch (_context2.prev = _context2.next) {
104
+ case 0:
105
+ if (!(newType === type)) {
106
+ _context2.next = 3;
107
+ break;
108
+ }
109
+
110
+ hideMenu();
111
+ return _context2.abrupt("return");
112
+
113
+ case 3:
114
+ _context2.prev = 3;
115
+ _context2.next = 6;
116
+ return updateSharingMemberType(sharingId, memberIndex, newType);
117
+
118
+ case 6:
119
+ _context2.next = 12;
120
+ break;
121
+
122
+ case 8:
123
+ _context2.prev = 8;
124
+ _context2.t0 = _context2["catch"](3);
125
+ log.error('Failed to change member permission type', _context2.t0);
126
+ showAlert({
127
+ message: t('Share.members.error.changePermission'),
128
+ severity: 'error',
129
+ variant: 'filled'
130
+ });
131
+
132
+ case 12:
133
+ hideMenu();
134
+
135
+ case 13:
136
+ case "end":
137
+ return _context2.stop();
138
+ }
139
+ }, _callee2, null, [[3, 8]]);
140
+ }));
141
+
142
+ return function (_x) {
143
+ return _ref3.apply(this, arguments);
144
+ };
145
+ }(), [hideMenu, memberIndex, sharingId, showAlert, t, type, updateSharingMemberType]);
146
+ var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission, divider, revokeMember], {
88
147
  client: client,
89
148
  t: t,
90
149
  type: type !== null && type !== void 0 ? type : 'one-way',
91
150
  isOwner: isOwner,
92
151
  isSharedDrive: isSharedDrive,
152
+ setType: setType,
93
153
  handleRevocation: handleRevocation
94
154
  });
95
155
  return /*#__PURE__*/React.createElement("div", {