cozy-sharing 21.0.0 → 21.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.
- package/CHANGELOG.md +27 -0
- package/dist/actions/createCozySharingLink.js +2 -2
- package/dist/components/ShareRestrictionModal/helpers.js +39 -103
- package/dist/components/SharingBanner/components/PublicBanner.js +1 -1
- package/package.json +2 -2
- package/src/actions/createCozySharingLink.js +2 -2
- package/src/components/ShareRestrictionModal/helpers.js +0 -44
- package/src/components/SharingBanner/components/PublicBanner.jsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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
|
+
# [21.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@21.1.0...cozy-sharing@21.2.0) (2025-01-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Remove unused forwardFile ([dbc6aa8](https://github.com/cozy/cozy-libs/commit/dbc6aa8b5e642cdc0b7b626ff9ec91713ffdc7c1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [21.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@21.0.0...cozy-sharing@21.1.0) (2025-01-23)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **sharing:** Fix SharingBannerCozyToCozy propTypes ([1c28e60](https://github.com/cozy/cozy-libs/commit/1c28e60acc2352f75433b67d23ddb2d25b276183))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **sharing:** Rename prop of createCozySharingLink action ([cbfb7c9](https://github.com/cozy/cozy-libs/commit/cbfb7c9f179f7396841257f5ad09be7f61ad725d))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# [21.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@20.0.0...cozy-sharing@21.0.0) (2025-01-23)
|
|
7
34
|
|
|
8
35
|
|
|
@@ -27,7 +27,7 @@ export var createCozySharingLink = function createCozySharingLink(_ref) {
|
|
|
27
27
|
openSharingLinkDisplayed = _ref$openSharingLinkD === void 0 ? true : _ref$openSharingLinkD,
|
|
28
28
|
_ref$isShortLabel = _ref.isShortLabel,
|
|
29
29
|
isShortLabel = _ref$isShortLabel === void 0 ? false : _ref$isShortLabel,
|
|
30
|
-
|
|
30
|
+
createCozyLink = _ref.createCozyLink;
|
|
31
31
|
|
|
32
32
|
var _getActionsI18n = getActionsI18n(),
|
|
33
33
|
t = _getActionsI18n.t;
|
|
@@ -44,7 +44,7 @@ export var createCozySharingLink = function createCozySharingLink(_ref) {
|
|
|
44
44
|
return openSharingLinkDisplayed;
|
|
45
45
|
},
|
|
46
46
|
action: function action() {
|
|
47
|
-
openExternalLink(
|
|
47
|
+
openExternalLink(createCozyLink);
|
|
48
48
|
},
|
|
49
49
|
Component: makeComponent(label, icon)
|
|
50
50
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { getSharingLink } from 'cozy-client/dist/models/sharing';
|
|
4
3
|
import minilog from 'cozy-minilog';
|
|
5
4
|
var log = minilog('ShareRestrictionModal/helpers');
|
|
6
5
|
export var WRITE_PERMS = ['GET', 'POST', 'PUT', 'PATCH'];
|
|
@@ -102,69 +101,6 @@ export var makeTTL = function makeTTL(selectedDate) {
|
|
|
102
101
|
return;
|
|
103
102
|
}
|
|
104
103
|
};
|
|
105
|
-
/**
|
|
106
|
-
* forwardFile - Triggers the download of one or multiple files by the browser
|
|
107
|
-
* @param {object} options
|
|
108
|
-
* @param {import('cozy-client/types/CozyClient').default} options.client
|
|
109
|
-
* @param {import('cozy-client/types/types').IOCozyFile} options.file File to download
|
|
110
|
-
* @param {Function} options.t i18n function
|
|
111
|
-
* @param {string} options.ttl Time to live of the sharing link
|
|
112
|
-
* @param {string} options.password Password of the sharing link
|
|
113
|
-
* @param {Function} options.showAlert - Function to display an alert
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
export var forwardFile = /*#__PURE__*/function () {
|
|
117
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
118
|
-
var client, file, t, ttl, password, showAlert, url, isZipFile, shareData;
|
|
119
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
120
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
121
|
-
case 0:
|
|
122
|
-
client = _ref3.client, file = _ref3.file, t = _ref3.t, ttl = _ref3.ttl, password = _ref3.password, showAlert = _ref3.showAlert;
|
|
123
|
-
_context2.prev = 1;
|
|
124
|
-
_context2.next = 4;
|
|
125
|
-
return getSharingLink(client, [file._id], {
|
|
126
|
-
ttl: ttl,
|
|
127
|
-
password: password
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
case 4:
|
|
131
|
-
url = _context2.sent;
|
|
132
|
-
isZipFile = file.class === 'zip';
|
|
133
|
-
shareData = {
|
|
134
|
-
title: t('shareFile.title', {
|
|
135
|
-
name: file.name,
|
|
136
|
-
smart_count: isZipFile ? 2 : 1
|
|
137
|
-
}),
|
|
138
|
-
text: t('shareFile.text', {
|
|
139
|
-
name: file.name,
|
|
140
|
-
smart_count: isZipFile ? 2 : 1
|
|
141
|
-
}),
|
|
142
|
-
url: url
|
|
143
|
-
};
|
|
144
|
-
navigator.share(shareData);
|
|
145
|
-
_context2.next = 13;
|
|
146
|
-
break;
|
|
147
|
-
|
|
148
|
-
case 10:
|
|
149
|
-
_context2.prev = 10;
|
|
150
|
-
_context2.t0 = _context2["catch"](1);
|
|
151
|
-
showAlert({
|
|
152
|
-
message: t('shareFile.error'),
|
|
153
|
-
severity: 'error',
|
|
154
|
-
variant: 'filled'
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
case 13:
|
|
158
|
-
case "end":
|
|
159
|
-
return _context2.stop();
|
|
160
|
-
}
|
|
161
|
-
}, _callee2, null, [[1, 10]]);
|
|
162
|
-
}));
|
|
163
|
-
|
|
164
|
-
return function forwardFile(_x2) {
|
|
165
|
-
return _ref4.apply(this, arguments);
|
|
166
|
-
};
|
|
167
|
-
}();
|
|
168
104
|
/**
|
|
169
105
|
* createPermissions - Create the permissions of a file
|
|
170
106
|
* @param {object} options
|
|
@@ -179,39 +115,39 @@ export var forwardFile = /*#__PURE__*/function () {
|
|
|
179
115
|
*/
|
|
180
116
|
|
|
181
117
|
export var createPermissions = /*#__PURE__*/function () {
|
|
182
|
-
var
|
|
118
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
183
119
|
var file, t, ttl, password, editingRights, documentType, shareByLink, showAlert, verbs;
|
|
184
|
-
return _regeneratorRuntime.wrap(function
|
|
185
|
-
while (1) switch (
|
|
120
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
121
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
186
122
|
case 0:
|
|
187
|
-
file =
|
|
188
|
-
|
|
123
|
+
file = _ref3.file, t = _ref3.t, ttl = _ref3.ttl, password = _ref3.password, editingRights = _ref3.editingRights, documentType = _ref3.documentType, shareByLink = _ref3.shareByLink, showAlert = _ref3.showAlert;
|
|
124
|
+
_context2.prev = 1;
|
|
189
125
|
verbs = editingRights === 'readOnly' ? READ_ONLY_PERMS : WRITE_PERMS;
|
|
190
|
-
return
|
|
126
|
+
return _context2.abrupt("return", shareByLink(file, {
|
|
191
127
|
verbs: verbs,
|
|
192
128
|
ttl: ttl,
|
|
193
129
|
password: password
|
|
194
130
|
}));
|
|
195
131
|
|
|
196
132
|
case 6:
|
|
197
|
-
|
|
198
|
-
|
|
133
|
+
_context2.prev = 6;
|
|
134
|
+
_context2.t0 = _context2["catch"](1);
|
|
199
135
|
showAlert({
|
|
200
136
|
message: t("".concat(documentType, ".share.shareByLink.permserror")),
|
|
201
137
|
severity: 'error',
|
|
202
138
|
variant: 'filled'
|
|
203
139
|
});
|
|
204
|
-
log.error("Error in 'readOnlyPermissionLink' function when trying to change permission",
|
|
140
|
+
log.error("Error in 'readOnlyPermissionLink' function when trying to change permission", _context2.t0);
|
|
205
141
|
|
|
206
142
|
case 10:
|
|
207
143
|
case "end":
|
|
208
|
-
return
|
|
144
|
+
return _context2.stop();
|
|
209
145
|
}
|
|
210
|
-
},
|
|
146
|
+
}, _callee2, null, [[1, 6]]);
|
|
211
147
|
}));
|
|
212
148
|
|
|
213
|
-
return function createPermissions(
|
|
214
|
-
return
|
|
149
|
+
return function createPermissions(_x2) {
|
|
150
|
+
return _ref4.apply(this, arguments);
|
|
215
151
|
};
|
|
216
152
|
}();
|
|
217
153
|
/**
|
|
@@ -230,41 +166,41 @@ export var createPermissions = /*#__PURE__*/function () {
|
|
|
230
166
|
*/
|
|
231
167
|
|
|
232
168
|
export var updatePermissions = /*#__PURE__*/function () {
|
|
233
|
-
var
|
|
169
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
|
|
234
170
|
var file, t, dateToggle, selectedDate, passwordToggle, password, editingRights, documentType, updateDocumentPermissions, showAlert, expiresAt, ensurePassword, verbs;
|
|
235
|
-
return _regeneratorRuntime.wrap(function
|
|
236
|
-
while (1) switch (
|
|
171
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
172
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
237
173
|
case 0:
|
|
238
|
-
file =
|
|
239
|
-
|
|
174
|
+
file = _ref5.file, t = _ref5.t, dateToggle = _ref5.dateToggle, selectedDate = _ref5.selectedDate, passwordToggle = _ref5.passwordToggle, password = _ref5.password, editingRights = _ref5.editingRights, documentType = _ref5.documentType, updateDocumentPermissions = _ref5.updateDocumentPermissions, showAlert = _ref5.showAlert;
|
|
175
|
+
_context3.prev = 1;
|
|
240
176
|
expiresAt = dateToggle ? (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.toISOString()) || undefined : '';
|
|
241
177
|
ensurePassword = passwordToggle ? password || undefined : '';
|
|
242
178
|
verbs = editingRights === 'readOnly' ? READ_ONLY_PERMS : WRITE_PERMS;
|
|
243
|
-
return
|
|
179
|
+
return _context3.abrupt("return", updateDocumentPermissions(file, {
|
|
244
180
|
verbs: verbs,
|
|
245
181
|
expiresAt: expiresAt,
|
|
246
182
|
password: ensurePassword
|
|
247
183
|
}));
|
|
248
184
|
|
|
249
185
|
case 8:
|
|
250
|
-
|
|
251
|
-
|
|
186
|
+
_context3.prev = 8;
|
|
187
|
+
_context3.t0 = _context3["catch"](1);
|
|
252
188
|
showAlert({
|
|
253
189
|
message: t("".concat(documentType, ".share.shareByLink.permserror")),
|
|
254
190
|
severity: 'error',
|
|
255
191
|
variant: 'filled'
|
|
256
192
|
});
|
|
257
|
-
log.error("Error in 'updateDocumentPermissions' function when trying to change permission",
|
|
193
|
+
log.error("Error in 'updateDocumentPermissions' function when trying to change permission", _context3.t0);
|
|
258
194
|
|
|
259
195
|
case 12:
|
|
260
196
|
case "end":
|
|
261
|
-
return
|
|
197
|
+
return _context3.stop();
|
|
262
198
|
}
|
|
263
|
-
},
|
|
199
|
+
}, _callee3, null, [[1, 8]]);
|
|
264
200
|
}));
|
|
265
201
|
|
|
266
|
-
return function updatePermissions(
|
|
267
|
-
return
|
|
202
|
+
return function updatePermissions(_x3) {
|
|
203
|
+
return _ref6.apply(this, arguments);
|
|
268
204
|
};
|
|
269
205
|
}();
|
|
270
206
|
/**
|
|
@@ -278,33 +214,33 @@ export var updatePermissions = /*#__PURE__*/function () {
|
|
|
278
214
|
*/
|
|
279
215
|
|
|
280
216
|
export var revokePermissions = /*#__PURE__*/function () {
|
|
281
|
-
var
|
|
217
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
|
|
282
218
|
var file, t, documentType, revokeSharingLink, showAlert;
|
|
283
|
-
return _regeneratorRuntime.wrap(function
|
|
284
|
-
while (1) switch (
|
|
219
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
220
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
285
221
|
case 0:
|
|
286
|
-
file =
|
|
287
|
-
|
|
288
|
-
return
|
|
222
|
+
file = _ref7.file, t = _ref7.t, documentType = _ref7.documentType, revokeSharingLink = _ref7.revokeSharingLink, showAlert = _ref7.showAlert;
|
|
223
|
+
_context4.prev = 1;
|
|
224
|
+
return _context4.abrupt("return", revokeSharingLink(file));
|
|
289
225
|
|
|
290
226
|
case 5:
|
|
291
|
-
|
|
292
|
-
|
|
227
|
+
_context4.prev = 5;
|
|
228
|
+
_context4.t0 = _context4["catch"](1);
|
|
293
229
|
showAlert({
|
|
294
230
|
message: t("".concat(documentType, ".share.error.revoke")),
|
|
295
231
|
severity: 'error',
|
|
296
232
|
variant: 'filled'
|
|
297
233
|
});
|
|
298
|
-
log.error("Error in 'revokePermissions' function when trying to revoke sharing link",
|
|
234
|
+
log.error("Error in 'revokePermissions' function when trying to revoke sharing link", _context4.t0);
|
|
299
235
|
|
|
300
236
|
case 9:
|
|
301
237
|
case "end":
|
|
302
|
-
return
|
|
238
|
+
return _context4.stop();
|
|
303
239
|
}
|
|
304
|
-
},
|
|
240
|
+
}, _callee4, null, [[1, 5]]);
|
|
305
241
|
}));
|
|
306
242
|
|
|
307
|
-
return function revokePermissions(
|
|
308
|
-
return
|
|
243
|
+
return function revokePermissions(_x4) {
|
|
244
|
+
return _ref8.apply(this, arguments);
|
|
309
245
|
};
|
|
310
246
|
}();
|
|
@@ -146,7 +146,7 @@ var SharingBannerByLink = function SharingBannerByLink(_ref3) {
|
|
|
146
146
|
SharingBannerCozyToCozy.propTypes = {
|
|
147
147
|
sharing: PropTypes.object.isRequired,
|
|
148
148
|
isSharingShortcutCreated: PropTypes.bool.isRequired,
|
|
149
|
-
|
|
149
|
+
addSharingLink: PropTypes.string.isRequired,
|
|
150
150
|
onClose: PropTypes.func.isRequired
|
|
151
151
|
};
|
|
152
152
|
export { SharingBannerCozyToCozy, SharingBannerByLink };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.2.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"sideEffects": [
|
|
79
79
|
"*.css"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "bae4fe2c256d56d032667537c27caedf110fa582"
|
|
82
82
|
}
|
|
@@ -28,7 +28,7 @@ const makeComponent = (label, icon) => {
|
|
|
28
28
|
export const createCozySharingLink = ({
|
|
29
29
|
openSharingLinkDisplayed = true,
|
|
30
30
|
isShortLabel = false,
|
|
31
|
-
|
|
31
|
+
createCozyLink
|
|
32
32
|
}) => {
|
|
33
33
|
const { t } = getActionsI18n()
|
|
34
34
|
const label = t('Share.create-cozy', { smart_count: isShortLabel ? 1 : 2 })
|
|
@@ -40,7 +40,7 @@ export const createCozySharingLink = ({
|
|
|
40
40
|
icon,
|
|
41
41
|
displayCondition: () => openSharingLinkDisplayed,
|
|
42
42
|
action: () => {
|
|
43
|
-
openExternalLink(
|
|
43
|
+
openExternalLink(createCozyLink)
|
|
44
44
|
},
|
|
45
45
|
Component: makeComponent(label, icon)
|
|
46
46
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getSharingLink } from 'cozy-client/dist/models/sharing'
|
|
2
1
|
import minilog from 'cozy-minilog'
|
|
3
2
|
|
|
4
3
|
const log = minilog('ShareRestrictionModal/helpers')
|
|
@@ -66,49 +65,6 @@ export const makeTTL = selectedDate => {
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
/**
|
|
70
|
-
* forwardFile - Triggers the download of one or multiple files by the browser
|
|
71
|
-
* @param {object} options
|
|
72
|
-
* @param {import('cozy-client/types/CozyClient').default} options.client
|
|
73
|
-
* @param {import('cozy-client/types/types').IOCozyFile} options.file File to download
|
|
74
|
-
* @param {Function} options.t i18n function
|
|
75
|
-
* @param {string} options.ttl Time to live of the sharing link
|
|
76
|
-
* @param {string} options.password Password of the sharing link
|
|
77
|
-
* @param {Function} options.showAlert - Function to display an alert
|
|
78
|
-
*/
|
|
79
|
-
export const forwardFile = async ({
|
|
80
|
-
client,
|
|
81
|
-
file,
|
|
82
|
-
t,
|
|
83
|
-
ttl,
|
|
84
|
-
password,
|
|
85
|
-
showAlert
|
|
86
|
-
}) => {
|
|
87
|
-
try {
|
|
88
|
-
// We currently support only one file at a time
|
|
89
|
-
const url = await getSharingLink(client, [file._id], { ttl, password })
|
|
90
|
-
const isZipFile = file.class === 'zip'
|
|
91
|
-
const shareData = {
|
|
92
|
-
title: t('shareFile.title', {
|
|
93
|
-
name: file.name,
|
|
94
|
-
smart_count: isZipFile ? 2 : 1
|
|
95
|
-
}),
|
|
96
|
-
text: t('shareFile.text', {
|
|
97
|
-
name: file.name,
|
|
98
|
-
smart_count: isZipFile ? 2 : 1
|
|
99
|
-
}),
|
|
100
|
-
url
|
|
101
|
-
}
|
|
102
|
-
navigator.share(shareData)
|
|
103
|
-
} catch (error) {
|
|
104
|
-
showAlert({
|
|
105
|
-
message: t('shareFile.error'),
|
|
106
|
-
severity: 'error',
|
|
107
|
-
variant: 'filled'
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
68
|
/**
|
|
113
69
|
* createPermissions - Create the permissions of a file
|
|
114
70
|
* @param {object} options
|
|
@@ -139,7 +139,7 @@ const SharingBannerByLink = ({ onClose }) => {
|
|
|
139
139
|
SharingBannerCozyToCozy.propTypes = {
|
|
140
140
|
sharing: PropTypes.object.isRequired,
|
|
141
141
|
isSharingShortcutCreated: PropTypes.bool.isRequired,
|
|
142
|
-
|
|
142
|
+
addSharingLink: PropTypes.string.isRequired,
|
|
143
143
|
onClose: PropTypes.func.isRequired
|
|
144
144
|
}
|
|
145
145
|
export { SharingBannerCozyToCozy, SharingBannerByLink }
|