cozy-sharing 17.0.0 → 19.0.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 (55) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/SharingProvider.spec.js +84 -80
  3. package/dist/components/Recipient/LinkRecipientPermissions.js +18 -129
  4. package/dist/components/Recipient/actions/editPermissionLink.js +71 -0
  5. package/dist/components/Recipient/actions/readOnlyPermissionLink.js +63 -0
  6. package/dist/components/ShareByLink.js +45 -185
  7. package/dist/components/ShareDialogCozyToCozy.js +2 -6
  8. package/dist/components/ShareDialogOnlyByLink.js +2 -8
  9. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +1 -3
  10. package/dist/components/ShareModal/EditableSharingModal.js +1 -7
  11. package/dist/components/ShareModal/EditableSharingModal.spec.js +49 -52
  12. package/dist/components/ShareModal/SharingDetailsModal.js +1 -1
  13. package/dist/components/ShareModal.js +0 -12
  14. package/dist/components/ShareRestrictionModal/BoxDate.js +77 -0
  15. package/dist/components/ShareRestrictionModal/BoxEditingRights.js +83 -0
  16. package/dist/components/ShareRestrictionModal/BoxPassword.js +138 -0
  17. package/dist/components/ShareRestrictionModal/ShareRestrictionContentModal.js +94 -0
  18. package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +260 -0
  19. package/dist/components/ShareRestrictionModal/helpers.js +275 -0
  20. package/dist/components/ShareRestrictionModal/helpers.spec.js +110 -0
  21. package/dist/components/SharedStatus.spec.js +20 -21
  22. package/dist/components/WhoHasAccess.js +1 -5
  23. package/jest.config.js +8 -3
  24. package/jestHelpers/setup.js +1 -8
  25. package/locales/en.json +28 -0
  26. package/locales/fr.json +29 -0
  27. package/package.json +13 -11
  28. package/src/SharingProvider.spec.jsx +88 -88
  29. package/src/components/Recipient/LinkRecipientPermissions.jsx +28 -137
  30. package/src/components/Recipient/actions/editPermissionLink.js +63 -0
  31. package/src/components/Recipient/actions/readOnlyPermissionLink.js +59 -0
  32. package/src/components/ShareByLink.jsx +20 -96
  33. package/src/components/ShareDialogCozyToCozy.jsx +1 -5
  34. package/src/components/ShareDialogOnlyByLink.jsx +0 -6
  35. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +0 -2
  36. package/src/components/ShareModal/EditableSharingModal.jsx +1 -7
  37. package/src/components/ShareModal/EditableSharingModal.spec.jsx +50 -44
  38. package/src/components/ShareModal/SharingDetailsModal.jsx +1 -1
  39. package/src/components/ShareModal.jsx +0 -12
  40. package/src/components/ShareRestrictionModal/BoxDate.jsx +76 -0
  41. package/src/components/ShareRestrictionModal/BoxEditingRights.jsx +91 -0
  42. package/src/components/ShareRestrictionModal/BoxPassword.jsx +112 -0
  43. package/src/components/ShareRestrictionModal/ShareRestrictionContentModal.jsx +102 -0
  44. package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +177 -0
  45. package/src/components/ShareRestrictionModal/helpers.js +193 -0
  46. package/src/components/ShareRestrictionModal/helpers.spec.js +78 -0
  47. package/src/components/SharedStatus.spec.js +32 -31
  48. package/src/components/WhoHasAccess.jsx +1 -5
  49. package/src/components/__snapshots__/SharedStatus.spec.js.snap +59 -129
  50. package/dist/RefreshableSharings.spec.js +0 -40
  51. package/dist/components/EditLinkPermissionDialog.js +0 -72
  52. package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
  53. package/src/RefreshableSharings.spec.jsx +0 -43
  54. package/src/components/EditLinkPermissionDialog.jsx +0 -89
  55. package/src/components/EditLinkPermissionDialog.spec.jsx +0 -53
package/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
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
+ # [19.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@18.0.0...cozy-sharing@19.0.0) (2025-01-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **sharing:** Update propTypes ([0474d9c](https://github.com/cozy/cozy-libs/commit/0474d9c46344b1f7abf65fc6e419a25aef33d2ed))
12
+
13
+
14
+ ### Features
15
+
16
+ * **sharing:** Add 3 actions to use the new action menu ([1af8fa7](https://github.com/cozy/cozy-libs/commit/1af8fa7dbffad63d117149d14e09399e9d71a8a6))
17
+ * **sharing:** Add missing devDeps ([5221b40](https://github.com/cozy/cozy-libs/commit/5221b40397935538e95dcec82c939fb22196c991))
18
+ * **sharing:** Add needed packages ([36a2b67](https://github.com/cozy/cozy-libs/commit/36a2b6771275a35b3ab484b22a18b6d9c7b61496))
19
+ * **sharing:** Add ShareRestrictionModal component ([df5ed28](https://github.com/cozy/cozy-libs/commit/df5ed28c7c7f5dbb339bf26d563e8ffd825a686f))
20
+ * **sharing:** Add the 3 boxes of the new link-sharing modal ([a297d20](https://github.com/cozy/cozy-libs/commit/a297d20c46966c82447491a6fefe2d96509c45a9))
21
+ * **sharing:** Move revoke action to a secondary button ([83d3738](https://github.com/cozy/cozy-libs/commit/83d3738220e2c02ed749a08a47f92ca08ce9feb7))
22
+ * **sharing:** Remove EditLinkPermissionDialog ([1b8bd56](https://github.com/cozy/cozy-libs/commit/1b8bd560f4e72b885817f1f17a83156b6c1a7d58))
23
+ * **sharing:** Remove useless props ([cc3f816](https://github.com/cozy/cozy-libs/commit/cc3f816b6d35deb619488495bb767e1d76b557de))
24
+ * **sharing:** Replace old sharing link menu with the new modal ([de1a1c2](https://github.com/cozy/cozy-libs/commit/de1a1c27a5747c0b8bf091ed1856994f65cdcdb2))
25
+ * **sharing:** Upgrade packages ([9a1312d](https://github.com/cozy/cozy-libs/commit/9a1312d43cba1dcd521e8d6502865ac2071535cf))
26
+ * **sharing:** Use ShareRestrictionModal when creating share link ([248c3b4](https://github.com/cozy/cozy-libs/commit/248c3b4904649e17e935afdef1bd2a0b87082dc7))
27
+
28
+
29
+ ### BREAKING CHANGES
30
+
31
+ * **sharing:** You muse have `cozy-client >= 52.1.0` and `cozy-ui >= 116.0.0`
32
+
33
+
34
+
35
+
36
+
37
+ # [18.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@17.0.0...cozy-sharing@18.0.0) (2024-12-23)
38
+
39
+
40
+ ### Features
41
+
42
+ * **cozy-sharing:** Remove Enzyme tests ([0c678a1](https://github.com/cozy/cozy-libs/commit/0c678a1a096966db9baf5311b99964fc458ce8dc))
43
+ * **cozy-sharing:** Replace jsdom-sixteen package ([b75bc51](https://github.com/cozy/cozy-libs/commit/b75bc51a8d2cbfa0300e5c9fc5f0d839dea24ef2))
44
+ * **cozy-sharing:** Upgrade cozy-ui to 115.0.2 ([f25a351](https://github.com/cozy/cozy-libs/commit/f25a351df58ed0517f35ec4fef7c9044ceac6d56))
45
+
46
+
47
+ ### BREAKING CHANGES
48
+
49
+ * **cozy-sharing:** You must have `cozy-ui >= 115.0.2` & `cozy-client >= 51.6.1`
50
+
51
+
52
+
53
+
54
+
6
55
  # [17.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.17.0...cozy-sharing@17.0.0) (2024-12-18)
7
56
 
8
57
 
@@ -1,12 +1,11 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { act, render, screen } from '@testing-library/react';
4
- import { mount } from 'enzyme';
5
4
  import React from 'react';
6
5
  import { createMockClient } from 'cozy-client';
7
6
  import { SharingProvider } from './SharingProvider';
8
- import SharingContext from './context';
9
- import { receiveSharings } from './state';
7
+ import SharingContext from './context'; // import { receiveSharings } from './state'
8
+
10
9
  import AppLike from '../test/AppLike';
11
10
 
12
11
  var AppWrapper = function AppWrapper(_ref) {
@@ -102,7 +101,7 @@ describe('SharingProvider', function () {
102
101
  return jest.resetAllMocks();
103
102
  });
104
103
  it('loads data on mount', function () {
105
- mount( /*#__PURE__*/React.createElement(AppWrapper, {
104
+ render( /*#__PURE__*/React.createElement(AppWrapper, {
106
105
  client: client
107
106
  }));
108
107
  expect(client.plugins.realtime.subscribe).toHaveBeenCalled();
@@ -110,7 +109,7 @@ describe('SharingProvider', function () {
110
109
  });
111
110
  it('loads nothing when the client is not logged in', function () {
112
111
  client.isLogged = false;
113
- mount( /*#__PURE__*/React.createElement(AppWrapper, {
112
+ render( /*#__PURE__*/React.createElement(AppWrapper, {
114
113
  client: client
115
114
  }));
116
115
  expect(client.plugins.realtime.subscribe).not.toHaveBeenCalled();
@@ -131,78 +130,83 @@ describe('SharingProvider', function () {
131
130
  expect(client.collection().findLinksByDoctype).not.toHaveBeenCalled();
132
131
  expect(client.collection().findApps).not.toHaveBeenCalled();
133
132
  });
134
- });
135
- describe('hasWriteAccess', function () {
136
- it('tells if a doc is writtable', function () {
137
- var client = createMockClient({});
138
- client.stackClient.uri = 'http://cozy.tools:8080';
139
- var component = mount( /*#__PURE__*/React.createElement(AppWrapper, {
140
- client: client
141
- }, /*#__PURE__*/React.createElement(SharingContext.Consumer, null, function (_ref5) {
142
- var hasWriteAccess = _ref5.hasWriteAccess;
143
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
144
- "data-id": "no-sharing"
145
- }, hasWriteAccess('no-sharing') ? 'yes' : 'no'), /*#__PURE__*/React.createElement("div", {
146
- "data-id": "owner-doc"
147
- }, hasWriteAccess('owner-doc') ? 'yes' : 'no'), /*#__PURE__*/React.createElement("div", {
148
- "data-id": "synced-doc"
149
- }, hasWriteAccess('synced-doc') ? 'yes' : 'no'), /*#__PURE__*/React.createElement("div", {
150
- "data-id": "read-only-doc"
151
- }, hasWriteAccess('read-only-doc') ? 'yes' : 'no'));
152
- })));
153
- expect(component.find('div[data-id="no-sharing"]').text()).toBe('yes');
154
- expect(component.find('div[data-id="owner-doc"]').text()).toBe('yes');
155
- expect(component.find('div[data-id="synced-doc"]').text()).toBe('yes');
156
- expect(component.find('div[data-id="read-only-doc"]').text()).toBe('yes');
157
- var provider = component.find(SharingProvider);
158
- provider.instance().dispatch(receiveSharings({
159
- sharings: [{
160
- id: '123',
161
- type: 'io.cozy.sharings',
162
- attributes: {
163
- owner: true,
164
- members: [{
165
- read_only: false,
166
- instance: 'http://cozy.tools:8080'
167
- }],
168
- rules: [{
169
- values: ['owner-doc']
170
- }]
171
- }
172
- }, {
173
- id: '456',
174
- type: 'io.cozy.sharings',
175
- attributes: {
176
- owner: false,
177
- members: [{
178
- read_only: false,
179
- instance: 'http://cozy.tools:8080'
180
- }],
181
- rules: [{
182
- values: ['synced-doc'],
183
- update: 'sync',
184
- remove: 'sync'
185
- }]
186
- }
187
- }, {
188
- id: '789',
189
- type: 'io.cozy.sharings',
190
- attributes: {
191
- owner: false,
192
- members: [{
193
- read_only: true,
194
- instance: 'http://cozy.tools:8080'
195
- }],
196
- rules: [{
197
- values: ['read-only-doc']
198
- }]
199
- }
200
- }]
201
- }));
202
- component.update();
203
- expect(component.find('div[data-id="no-sharing"]').text()).toBe('yes');
204
- expect(component.find('div[data-id="owner-doc"]').text()).toBe('yes');
205
- expect(component.find('div[data-id="synced-doc"]').text()).toBe('yes');
206
- expect(component.find('div[data-id="read-only-doc"]').text()).toBe('no');
207
- });
208
- });
133
+ }); // TODO Convert with react-testing-library
134
+ // describe('hasWriteAccess', () => {
135
+ // it('tells if a doc is writtable', () => {
136
+ // const client = createMockClient({})
137
+ // client.stackClient.uri = 'http://cozy.tools:8080'
138
+ // const component = mount(
139
+ // <AppWrapper client={client}>
140
+ // <SharingContext.Consumer>
141
+ // {({ hasWriteAccess }) => (
142
+ // <>
143
+ // <div data-id="no-sharing">
144
+ // {hasWriteAccess('no-sharing') ? 'yes' : 'no'}
145
+ // </div>
146
+ // <div data-id="owner-doc">
147
+ // {hasWriteAccess('owner-doc') ? 'yes' : 'no'}
148
+ // </div>
149
+ // <div data-id="synced-doc">
150
+ // {hasWriteAccess('synced-doc') ? 'yes' : 'no'}
151
+ // </div>
152
+ // <div data-id="read-only-doc">
153
+ // {hasWriteAccess('read-only-doc') ? 'yes' : 'no'}
154
+ // </div>
155
+ // </>
156
+ // )}
157
+ // </SharingContext.Consumer>
158
+ // </AppWrapper>
159
+ // )
160
+ // expect(component.find('div[data-id="no-sharing"]').text()).toBe('yes')
161
+ // expect(component.find('div[data-id="owner-doc"]').text()).toBe('yes')
162
+ // expect(component.find('div[data-id="synced-doc"]').text()).toBe('yes')
163
+ // expect(component.find('div[data-id="read-only-doc"]').text()).toBe('yes')
164
+ // const provider = component.find(SharingProvider)
165
+ // provider.instance().dispatch(
166
+ // receiveSharings({
167
+ // sharings: [
168
+ // {
169
+ // id: '123',
170
+ // type: 'io.cozy.sharings',
171
+ // attributes: {
172
+ // owner: true,
173
+ // members: [
174
+ // { read_only: false, instance: 'http://cozy.tools:8080' }
175
+ // ],
176
+ // rules: [{ values: ['owner-doc'] }]
177
+ // }
178
+ // },
179
+ // {
180
+ // id: '456',
181
+ // type: 'io.cozy.sharings',
182
+ // attributes: {
183
+ // owner: false,
184
+ // members: [
185
+ // { read_only: false, instance: 'http://cozy.tools:8080' }
186
+ // ],
187
+ // rules: [
188
+ // { values: ['synced-doc'], update: 'sync', remove: 'sync' }
189
+ // ]
190
+ // }
191
+ // },
192
+ // {
193
+ // id: '789',
194
+ // type: 'io.cozy.sharings',
195
+ // attributes: {
196
+ // owner: false,
197
+ // members: [
198
+ // { read_only: true, instance: 'http://cozy.tools:8080' }
199
+ // ],
200
+ // rules: [{ values: ['read-only-doc'] }]
201
+ // }
202
+ // }
203
+ // ]
204
+ // })
205
+ // )
206
+ // component.update()
207
+ // expect(component.find('div[data-id="no-sharing"]').text()).toBe('yes')
208
+ // expect(component.find('div[data-id="owner-doc"]').text()).toBe('yes')
209
+ // expect(component.find('div[data-id="synced-doc"]').text()).toBe('yes')
210
+ // expect(component.find('div[data-id="read-only-doc"]').text()).toBe('no')
211
+ // })
212
+ // })
@@ -1,26 +1,15 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import PropTypes from 'prop-types';
4
3
  import React, { useState, useRef } from 'react';
5
4
  import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
6
- import Icon from 'cozy-ui/transpiled/react/Icon';
7
- import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
8
- import Spinner from 'cozy-ui/transpiled/react/Spinner';
9
- import Typography from 'cozy-ui/transpiled/react/Typography';
10
- import ActionMenu, { ActionMenuItem, ActionMenuRadio } from 'cozy-ui/transpiled/react/deprecated/ActionMenu';
11
- import Alerter from 'cozy-ui/transpiled/react/deprecated/Alerter';
12
5
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
13
- import { isOnlyReadOnlyLinkAllowed } from '../../helpers/link';
14
6
  import { checkIsReadOnlyPermissions } from '../../helpers/permissions';
15
- import logger from '../../logger';
7
+ import { ShareRestrictionModal } from '../ShareRestrictionModal/ShareRestrictionModal';
16
8
 
17
9
  var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
18
10
  var className = _ref.className,
19
11
  document = _ref.document,
20
- documentType = _ref.documentType,
21
- permissions = _ref.permissions,
22
- onChangePermissions = _ref.onChangePermissions,
23
- onDisable = _ref.onDisable;
12
+ permissions = _ref.permissions;
24
13
 
25
14
  var _useI18n = useI18n(),
26
15
  t = _useI18n.t;
@@ -29,129 +18,29 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
29
18
 
30
19
  var _useState = useState(false),
31
20
  _useState2 = _slicedToArray(_useState, 2),
32
- menuIsOpen = _useState2[0],
33
- setMenuIsOpen = _useState2[1];
34
-
35
- var _useState3 = useState(false),
36
- _useState4 = _slicedToArray(_useState3, 2),
37
- loading = _useState4[0],
38
- setLoading = _useState4[1];
21
+ openShareRestrictionModal = _useState2[0],
22
+ setOpenShareRestrictionModal = _useState2[1];
39
23
 
40
24
  var isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions);
41
-
42
- var toggleMenu = function toggleMenu() {
43
- setMenuIsOpen(!menuIsOpen);
44
- };
45
-
46
- var deleteShareLink = /*#__PURE__*/function () {
47
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
48
- return _regeneratorRuntime.wrap(function _callee$(_context) {
49
- while (1) switch (_context.prev = _context.next) {
50
- case 0:
51
- _context.prev = 0;
52
- setLoading(true);
53
- _context.next = 4;
54
- return onDisable(document);
55
-
56
- case 4:
57
- _context.next = 10;
58
- break;
59
-
60
- case 6:
61
- _context.prev = 6;
62
- _context.t0 = _context["catch"](0);
63
- Alerter.error(t("".concat(documentType, ".share.error.revoke")));
64
- logger.log(_context.t0);
65
-
66
- case 10:
67
- _context.prev = 10;
68
- setLoading(false);
69
- return _context.finish(10);
70
-
71
- case 13:
72
- case "end":
73
- return _context.stop();
74
- }
75
- }, _callee, null, [[0, 6, 10, 13]]);
76
- }));
77
-
78
- return function deleteShareLink() {
79
- return _ref2.apply(this, arguments);
80
- };
81
- }();
82
-
83
- var updateLinkPermissions = function updateLinkPermissions(_ref3) {
84
- var isReadOnly = _ref3.isReadOnly;
85
- var verbs = isReadOnly ? ['GET'] : ['GET', 'POST', 'PUT', 'PATCH'];
86
-
87
- try {
88
- onChangePermissions(document, verbs);
89
- } catch (err) {
90
- Alerter.error(t("".concat(documentType, ".share.shareByLink.permserror")));
91
- logger.log(err);
92
- }
93
- };
94
-
95
25
  return /*#__PURE__*/React.createElement("div", {
96
26
  className: className
97
- }, loading && /*#__PURE__*/React.createElement(Spinner, null), !loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
98
- onClick: toggleMenu,
27
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
99
28
  ref: buttonRef,
100
- textVariant: "body2"
101
- }, t("Share.type.".concat(isReadOnlyPermissions ? 'one-way' : 'two-way')).toLowerCase()), menuIsOpen && /*#__PURE__*/React.createElement(ActionMenu, {
102
- onClose: toggleMenu,
103
- popperOptions: {
104
- placement: 'bottom-end',
105
- strategy: 'fixed'
106
- },
107
- anchorElRef: buttonRef
108
- }, /*#__PURE__*/React.createElement(ActionMenuItem, {
109
- left: /*#__PURE__*/React.createElement(ActionMenuRadio, {
110
- name: "permissionLinkMenu",
111
- value: "true",
112
- checked: isReadOnlyPermissions
113
- }),
29
+ textVariant: "body2",
114
30
  onClick: function onClick() {
115
- toggleMenu();
116
- updateLinkPermissions({
117
- isReadOnly: true
118
- });
31
+ return setOpenShareRestrictionModal(true);
119
32
  }
120
- }, /*#__PURE__*/React.createElement(React.Fragment, null, (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.seeFolder") : t("Share.permissionLink.seeFile"), /*#__PURE__*/React.createElement(Typography, {
121
- className: "u-mt-half",
122
- variant: "caption",
123
- color: "textSecondary"
124
- }, t('Share.permissionLink.readDescription')))), !isOnlyReadOnlyLinkAllowed({
125
- documentType: documentType
126
- }) && /*#__PURE__*/React.createElement(ActionMenuItem, {
127
- left: /*#__PURE__*/React.createElement(ActionMenuRadio, {
128
- name: "permissionLinkMenu",
129
- value: "false",
130
- checked: !isReadOnlyPermissions
131
- }),
132
- onClick: function onClick() {
133
- toggleMenu();
134
- updateLinkPermissions({
135
- isReadOnly: false
136
- });
137
- }
138
- }, /*#__PURE__*/React.createElement(React.Fragment, null, (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.modifyFolder") : t("Share.permissionLink.modifyFile"), /*#__PURE__*/React.createElement(Typography, {
139
- className: "u-mt-half",
140
- variant: "caption",
141
- color: "textSecondary"
142
- }, t('Share.permissionLink.writeDescription')))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
143
- left: /*#__PURE__*/React.createElement(Icon, {
144
- icon: TrashIcon,
145
- color: "var(--errorColor)"
146
- }),
147
- onClick: function onClick() {
148
- toggleMenu();
149
- deleteShareLink();
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);
150
37
  }
151
- }, /*#__PURE__*/React.createElement(Typography, {
152
- className: "u-error",
153
- variant: "body1"
154
- }, t('Share.permissionLink.deactivate'))))));
38
+ })));
155
39
  };
156
40
 
41
+ LinkRecipientPermissions.propTypes = {
42
+ className: PropTypes.string,
43
+ document: PropTypes.object.isRequired,
44
+ permissions: PropTypes.arrayOf(PropTypes.object).isRequired
45
+ };
157
46
  export default LinkRecipientPermissions;
@@ -0,0 +1,71 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
4
+ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
5
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
6
+ import Radios from 'cozy-ui/transpiled/react/Radios';
7
+ import { isOnlyReadOnlyLinkAllowed } from '../../../helpers/link';
8
+ import { useSharingContext } from '../../../hooks/useSharingContext';
9
+
10
+ var makeComponent = function makeComponent(_ref) {
11
+ var label = _ref.label,
12
+ desc = _ref.desc,
13
+ editingRights = _ref.editingRights;
14
+ var Component = /*#__PURE__*/forwardRef(function (props, ref) {
15
+ var _useSharingContext = useSharingContext(),
16
+ updateDocumentPermissions = _useSharingContext.updateDocumentPermissions;
17
+
18
+ return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
19
+ ref: ref,
20
+ button: false,
21
+ onClick: function onClick() {
22
+ return props.onClick({
23
+ updateDocumentPermissions: updateDocumentPermissions
24
+ });
25
+ }
26
+ }), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Radios, {
27
+ checked: editingRights === 'write'
28
+ })), /*#__PURE__*/React.createElement(ListItemText, {
29
+ primary: label,
30
+ secondary: desc
31
+ }));
32
+ });
33
+ Component.displayName = 'EditPermissionLink';
34
+ return Component;
35
+ };
36
+ /**
37
+ * @param {boolean} isDirectory - true if the document is a directory
38
+ * @param {function} t - translation function
39
+ * @param {string} editingRights - current editing rights
40
+ * @param {function} setEditingRights - function to set editing rights
41
+ * @param {string} documentType - type of the document
42
+ */
43
+
44
+
45
+ export var editPermissionLink = function editPermissionLink(_ref2) {
46
+ var isDirectory = _ref2.isDirectory,
47
+ t = _ref2.t,
48
+ editingRights = _ref2.editingRights,
49
+ setEditingRights = _ref2.setEditingRights,
50
+ documentType = _ref2.documentType;
51
+ var label = isDirectory ? t('Share.permissionLink.modifyFolder') : t('Share.permissionLink.modifyFile');
52
+ var desc = t('Share.permissionLink.writeDescription');
53
+ return {
54
+ name: 'editPermissionLink',
55
+ label: label,
56
+ icon: null,
57
+ displayCondition: function displayCondition() {
58
+ return !isOnlyReadOnlyLinkAllowed({
59
+ documentType: documentType
60
+ });
61
+ },
62
+ action: function action() {
63
+ setEditingRights('write');
64
+ },
65
+ Component: makeComponent({
66
+ label: label,
67
+ desc: desc,
68
+ editingRights: editingRights
69
+ })
70
+ };
71
+ };
@@ -0,0 +1,63 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
4
+ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
5
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
6
+ import Radios from 'cozy-ui/transpiled/react/Radios';
7
+ import { useSharingContext } from '../../../hooks/useSharingContext';
8
+
9
+ var makeComponent = function makeComponent(_ref) {
10
+ var label = _ref.label,
11
+ desc = _ref.desc,
12
+ editingRights = _ref.editingRights;
13
+ var Component = /*#__PURE__*/forwardRef(function (props, ref) {
14
+ var _useSharingContext = useSharingContext(),
15
+ updateDocumentPermissions = _useSharingContext.updateDocumentPermissions;
16
+
17
+ return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
18
+ ref: ref,
19
+ button: false,
20
+ onClick: function onClick() {
21
+ return props.onClick({
22
+ updateDocumentPermissions: updateDocumentPermissions
23
+ });
24
+ }
25
+ }), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Radios, {
26
+ checked: editingRights === 'readOnly'
27
+ })), /*#__PURE__*/React.createElement(ListItemText, {
28
+ primary: label,
29
+ secondary: desc
30
+ }));
31
+ });
32
+ Component.displayName = 'ReadOnlyPermissionLink';
33
+ return Component;
34
+ };
35
+ /**
36
+ * @param {boolean} isDirectory - true if the document is a directory
37
+ * @param {function} t - translation function
38
+ * @param {string} editingRights - current editing rights
39
+ * @param {function} setEditingRights - function to set editing rights
40
+ */
41
+
42
+
43
+ export var readOnlyPermissionLink = function readOnlyPermissionLink(_ref2) {
44
+ var isDirectory = _ref2.isDirectory,
45
+ t = _ref2.t,
46
+ editingRights = _ref2.editingRights,
47
+ setEditingRights = _ref2.setEditingRights;
48
+ var label = isDirectory ? t('Share.permissionLink.seeFolder') : t('Share.permissionLink.seeFile');
49
+ var desc = t('Share.permissionLink.readDescription');
50
+ return {
51
+ name: 'readOnlyPermissionLink',
52
+ label: label,
53
+ icon: null,
54
+ action: function action() {
55
+ setEditingRights('readOnly');
56
+ },
57
+ Component: makeComponent({
58
+ label: label,
59
+ desc: desc,
60
+ editingRights: editingRights
61
+ })
62
+ };
63
+ };