cozy-sharing 31.1.0 → 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.
- package/CHANGELOG.md +16 -0
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +15 -16
- package/dist/components/FederatedFolder/FederatedFolderModal.js +78 -103
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +102 -292
- package/dist/components/Recipient/RecipientConfirm.js +0 -5
- package/dist/components/ShareAutosuggest.js +9 -4
- package/dist/components/ShareByEmail.js +29 -274
- package/dist/components/ShareByEmail.spec.js +52 -230
- package/dist/components/ShareByLink.js +1 -3
- package/dist/components/ShareDialogCozyToCozy.js +169 -35
- package/dist/components/ShareDialogCozyToCozy.spec.js +122 -35
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +13 -3
- package/dist/components/ShareModal/SharingDetailsModal.js +0 -5
- package/dist/components/ShareRecipientsInput.js +6 -3
- package/dist/components/SharedDrive/SharedDriveForm.js +11 -23
- package/dist/components/SharedDrive/SharedDriveModal.js +1 -1
- package/dist/components/SharedDrive/useSharedDrive.js +33 -57
- package/dist/components/SharedDrive/useSharedDrive.spec.js +29 -93
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +15 -26
- package/dist/components/Sharetypeselect.js +85 -90
- package/dist/hooks/usePendingRecipients.js +20 -0
- package/dist/hooks/usePendingRecipients.spec.js +30 -0
- package/dist/styles/autosuggest.styl +8 -2
- package/dist/styles/share.styl +0 -39
- package/dist/stylesheet.css +8 -36
- package/locales/en.json +5 -9
- package/locales/fr.json +5 -9
- package/locales/ru.json +5 -9
- package/locales/vi.json +5 -9
- package/package.json +2 -2
- package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +14 -15
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +50 -67
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +63 -186
- package/src/components/ShareAutosuggest.jsx +7 -2
- package/src/components/ShareByEmail.jsx +35 -186
- package/src/components/ShareByEmail.spec.jsx +22 -173
- package/src/components/ShareByLink.jsx +1 -7
- package/src/components/ShareDialogCozyToCozy.jsx +171 -38
- package/src/components/ShareDialogCozyToCozy.spec.jsx +66 -0
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +11 -1
- package/src/components/ShareRecipientsInput.jsx +5 -2
- package/src/components/SharedDrive/SharedDriveForm.jsx +10 -23
- package/src/components/SharedDrive/SharedDriveModal.jsx +1 -1
- package/src/components/SharedDrive/useSharedDrive.js +24 -50
- package/src/components/SharedDrive/useSharedDrive.spec.js +19 -67
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +15 -29
- package/src/components/Sharetypeselect.jsx +75 -58
- package/src/hooks/usePendingRecipients.js +13 -0
- package/src/hooks/usePendingRecipients.spec.js +21 -0
- package/src/styles/autosuggest.styl +8 -2
- package/src/styles/share.styl +0 -39
- package/dist/components/SharedDrive/helpers.js +0 -102
- package/dist/components/SharedDrive/helpers.spec.js +0 -227
- package/dist/components/Sharesubmit.js +0 -28
- package/src/components/SharedDrive/helpers.js +0 -108
- package/src/components/SharedDrive/helpers.spec.js +0 -177
- package/src/components/Sharesubmit.jsx +0 -31
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { renderHook, act } from '@testing-library/react-hooks';
|
|
2
|
+
import { usePendingRecipients } from './usePendingRecipients';
|
|
3
|
+
describe('usePendingRecipients', function () {
|
|
4
|
+
it('starts with empty recipients and readWrite option', function () {
|
|
5
|
+
var _renderHook = renderHook(function () {
|
|
6
|
+
return usePendingRecipients();
|
|
7
|
+
}),
|
|
8
|
+
result = _renderHook.result;
|
|
9
|
+
|
|
10
|
+
expect(result.current.pendingRecipients).toEqual([]);
|
|
11
|
+
expect(result.current.selectedOption).toBe('readWrite');
|
|
12
|
+
});
|
|
13
|
+
it('exposes setters that update state', function () {
|
|
14
|
+
var _renderHook2 = renderHook(function () {
|
|
15
|
+
return usePendingRecipients();
|
|
16
|
+
}),
|
|
17
|
+
result = _renderHook2.result;
|
|
18
|
+
|
|
19
|
+
act(function () {
|
|
20
|
+
result.current.setPendingRecipients([{
|
|
21
|
+
email: 'a@b.c'
|
|
22
|
+
}]);
|
|
23
|
+
result.current.setSelectedOption('readOnly');
|
|
24
|
+
});
|
|
25
|
+
expect(result.current.pendingRecipients).toEqual([{
|
|
26
|
+
email: 'a@b.c'
|
|
27
|
+
}]);
|
|
28
|
+
expect(result.current.selectedOption).toBe('readOnly');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
box-sizing border-box
|
|
6
6
|
position absolute
|
|
7
7
|
top 100%
|
|
8
|
-
margin-top .
|
|
8
|
+
margin-top .5rem
|
|
9
9
|
z-index var(--zIndex-alertMobile)
|
|
10
10
|
width 100%
|
|
11
11
|
overflow hidden
|
|
@@ -37,12 +37,13 @@
|
|
|
37
37
|
display flex
|
|
38
38
|
flex-wrap wrap
|
|
39
39
|
align-items center
|
|
40
|
-
padding .25rem .5rem
|
|
40
|
+
padding .25rem 3.5rem .25rem .5rem
|
|
41
41
|
border-radius .25rem
|
|
42
42
|
border 1px solid var(--borderMainColor)
|
|
43
43
|
min-height 2.5rem
|
|
44
44
|
max-height 6.75rem
|
|
45
45
|
overflow auto
|
|
46
|
+
position relative
|
|
46
47
|
|
|
47
48
|
&:hover
|
|
48
49
|
border 1px solid var(--borderMainColor)
|
|
@@ -69,3 +70,8 @@
|
|
|
69
70
|
font-size 1rem
|
|
70
71
|
.recipientChip
|
|
71
72
|
margin .25rem .5rem .25rem 0
|
|
73
|
+
|
|
74
|
+
.endAdornment
|
|
75
|
+
position absolute
|
|
76
|
+
top .75rem
|
|
77
|
+
right 1rem
|
package/dist/styles/share.styl
CHANGED
|
@@ -38,45 +38,6 @@
|
|
|
38
38
|
.coz-form-desc
|
|
39
39
|
color var(--secondaryTextColor)
|
|
40
40
|
|
|
41
|
-
.share-type-control
|
|
42
|
-
display flex
|
|
43
|
-
flex-direction row
|
|
44
|
-
justify-content space-between
|
|
45
|
-
padding .5rem 0 0
|
|
46
|
-
|
|
47
|
-
.select-wrapper
|
|
48
|
-
flex 0 0 49%
|
|
49
|
-
position relative
|
|
50
|
-
|
|
51
|
-
.select-option
|
|
52
|
-
padding .5rem 1.5rem .5rem 3rem
|
|
53
|
-
position relative
|
|
54
|
-
|
|
55
|
-
svg
|
|
56
|
-
position absolute
|
|
57
|
-
left 1rem
|
|
58
|
-
top 1rem
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.select-option-label
|
|
62
|
-
line-height 2
|
|
63
|
-
|
|
64
|
-
.select-option-desc
|
|
65
|
-
line-height 1.5
|
|
66
|
-
font-size .8125rem
|
|
67
|
-
color var(--secondaryTextColor)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
button
|
|
72
|
-
flex 0 0 49%
|
|
73
|
-
margin 0
|
|
74
|
-
|
|
75
|
-
:global
|
|
76
|
-
// dirty hack for react-select: its API doesn't allow to make change to active styles
|
|
77
|
-
.react-select__option:active
|
|
78
|
-
background-color var(--defaultBackgroundColor) !important
|
|
79
|
-
|
|
80
41
|
input[type=text]
|
|
81
42
|
width 100%
|
|
82
43
|
|
package/dist/stylesheet.css
CHANGED
|
@@ -312,40 +312,6 @@
|
|
|
312
312
|
.share__coz-form-group___VsQp7 .share__coz-form-desc___2mYN4 {
|
|
313
313
|
color: var(--secondaryTextColor);
|
|
314
314
|
}
|
|
315
|
-
.share__share-type-control___1YoRr {
|
|
316
|
-
display: flex;
|
|
317
|
-
flex-direction: row;
|
|
318
|
-
justify-content: space-between;
|
|
319
|
-
padding: 0.5rem 0 0;
|
|
320
|
-
}
|
|
321
|
-
.share__share-type-control___1YoRr .share__select-wrapper___3XBKC {
|
|
322
|
-
flex: 0 0 49%;
|
|
323
|
-
position: relative;
|
|
324
|
-
}
|
|
325
|
-
.share__share-type-control___1YoRr .share__select-wrapper___3XBKC .share__select-option___3Jp8_ {
|
|
326
|
-
padding: 0.5rem 1.5rem 0.5rem 3rem;
|
|
327
|
-
position: relative;
|
|
328
|
-
}
|
|
329
|
-
.share__share-type-control___1YoRr .share__select-wrapper___3XBKC .share__select-option___3Jp8_ svg {
|
|
330
|
-
position: absolute;
|
|
331
|
-
left: 1rem;
|
|
332
|
-
top: 1rem;
|
|
333
|
-
}
|
|
334
|
-
.share__share-type-control___1YoRr .share__select-wrapper___3XBKC .share__select-option-label___1BWz_ {
|
|
335
|
-
line-height: 2;
|
|
336
|
-
}
|
|
337
|
-
.share__share-type-control___1YoRr .share__select-wrapper___3XBKC .share__select-option-desc___3jOnr {
|
|
338
|
-
line-height: 1.5;
|
|
339
|
-
font-size: 0.8125rem;
|
|
340
|
-
color: var(--secondaryTextColor);
|
|
341
|
-
}
|
|
342
|
-
.share__share-type-control___1YoRr button {
|
|
343
|
-
flex: 0 0 49%;
|
|
344
|
-
margin: 0;
|
|
345
|
-
}
|
|
346
|
-
.react-select__option:active {
|
|
347
|
-
background-color: var(--defaultBackgroundColor) !important;
|
|
348
|
-
}
|
|
349
315
|
input[type=text] {
|
|
350
316
|
width: 100%;
|
|
351
317
|
}
|
|
@@ -380,7 +346,7 @@ input[type=text] {
|
|
|
380
346
|
box-sizing: border-box;
|
|
381
347
|
position: absolute;
|
|
382
348
|
top: 100%;
|
|
383
|
-
margin-top: 0.
|
|
349
|
+
margin-top: 0.5rem;
|
|
384
350
|
z-index: var(--zIndex-alertMobile);
|
|
385
351
|
width: 100%;
|
|
386
352
|
overflow: hidden;
|
|
@@ -412,12 +378,13 @@ input[type=text] {
|
|
|
412
378
|
display: flex;
|
|
413
379
|
flex-wrap: wrap;
|
|
414
380
|
align-items: center;
|
|
415
|
-
padding: 0.25rem 0.5rem;
|
|
381
|
+
padding: 0.25rem 3.5rem 0.25rem 0.5rem;
|
|
416
382
|
border-radius: 0.25rem;
|
|
417
383
|
border: 1px solid var(--borderMainColor);
|
|
418
384
|
min-height: 2.5rem;
|
|
419
385
|
max-height: 6.75rem;
|
|
420
386
|
overflow: auto;
|
|
387
|
+
position: relative;
|
|
421
388
|
}
|
|
422
389
|
.autosuggest__recipientsContainer___1JYxA:hover {
|
|
423
390
|
border: 1px solid var(--borderMainColor);
|
|
@@ -449,6 +416,11 @@ input[type=text] {
|
|
|
449
416
|
.autosuggest__recipientChip___d5I3R {
|
|
450
417
|
margin: 0.25rem 0.5rem 0.25rem 0;
|
|
451
418
|
}
|
|
419
|
+
.autosuggest__endAdornment___2EwTN {
|
|
420
|
+
position: absolute;
|
|
421
|
+
top: 0.75rem;
|
|
422
|
+
right: 1rem;
|
|
423
|
+
}
|
|
452
424
|
/* imported from button.styl */
|
|
453
425
|
|
|
454
426
|
.button__coz-btn-shared___9MFbY {
|
package/locales/en.json
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": {
|
|
17
17
|
"one-way": "Viewer",
|
|
18
|
-
"two-way": "Editor"
|
|
19
|
-
"desc": {
|
|
20
|
-
"one-way": "Contacts can view, download, and add the content to their Twake. If they add the content to their Twake, they will get updates you make to the content, but they won't be able to update it.",
|
|
21
|
-
"two-way": "Contacts can update, delete and add the content to their Twake. Updates on the content will be seen on other Cozies."
|
|
22
|
-
}
|
|
18
|
+
"two-way": "Editor"
|
|
23
19
|
},
|
|
24
20
|
"locked-type-file": "Coming soon: you will be able to change permissions you grant on the file.",
|
|
25
21
|
"locked-type-folder": "Coming soon: you will be able to change permissions you grant on the folder.",
|
|
@@ -131,7 +127,7 @@
|
|
|
131
127
|
"shareByEmail": {
|
|
132
128
|
"subtitle": "By email",
|
|
133
129
|
"emailPlaceholder": "Add contacts",
|
|
134
|
-
"send": "
|
|
130
|
+
"send": "Share",
|
|
135
131
|
"singleContactSuccess": "You sent an invite to %{email}.",
|
|
136
132
|
"contactSuccess": "You sent an invite to %{smart_count} contact. |||| You sent an invite to %{smart_count} contacts.",
|
|
137
133
|
"singleGroupSuccess": "You sent an invite to the members of the %{groupName} group.",
|
|
@@ -199,7 +195,7 @@
|
|
|
199
195
|
"subtitle": "By email",
|
|
200
196
|
"email": "To:",
|
|
201
197
|
"emailPlaceholder": "Enter the email address or name of the recipient",
|
|
202
|
-
"send": "
|
|
198
|
+
"send": "Share",
|
|
203
199
|
"singleContactSuccess": "You sent an invite to %{email}.",
|
|
204
200
|
"contactSuccess": "You sent an invite to %{smart_count} contact. |||| You sent an invite to %{smart_count} contacts.",
|
|
205
201
|
"singleGroupSuccess": "You sent an invite to the members of the %{groupName} group.",
|
|
@@ -268,7 +264,7 @@
|
|
|
268
264
|
"subtitle": "By email",
|
|
269
265
|
"email": "email",
|
|
270
266
|
"emailPlaceholder": "Enter the email address or name of the recipient",
|
|
271
|
-
"send": "
|
|
267
|
+
"send": "Share",
|
|
272
268
|
"singleContactSuccess": "You sent an invite to %{email}.",
|
|
273
269
|
"contactSuccess": "You sent an invite to %{smart_count} contact. |||| You sent an invite to %{smart_count} contacts.",
|
|
274
270
|
"singleGroupSuccess": "You sent an invite to the members of the %{groupName} group.",
|
|
@@ -332,7 +328,7 @@
|
|
|
332
328
|
"subtitle": "By email",
|
|
333
329
|
"email": "Send to:",
|
|
334
330
|
"emailPlaceholder": "Enter the email address or name of the recipient",
|
|
335
|
-
"send": "
|
|
331
|
+
"send": "Share",
|
|
336
332
|
"error": {
|
|
337
333
|
"addingRecipient": "An error occurred while adding the recipient. Please try again."
|
|
338
334
|
},
|
package/locales/fr.json
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": {
|
|
17
17
|
"one-way": "Lecteur",
|
|
18
|
-
"two-way": "Éditeur"
|
|
19
|
-
"desc": {
|
|
20
|
-
"one-way": "Les contacts peuvent consulter, télécharger, et ajouter le contenu à leur Twake. En cas d’ajout à leur Twake, ils recevront vos modifications sur le contenu mais ils ne pourront pas le modifier.",
|
|
21
|
-
"two-way": "Les contacts peuvent modifier, supprimer et ajouter le contenu à leur Twake. Les modifications sur le contenu seront répercutées automatiquement entre vos Twake."
|
|
22
|
-
}
|
|
18
|
+
"two-way": "Éditeur"
|
|
23
19
|
},
|
|
24
20
|
"locked-type-file": "Bientôt : vous pourrez changer la permission donnée sur le fichier.",
|
|
25
21
|
"locked-type-folder": "Bientôt : vous pourrez changer la permission donnée sur le dossier.",
|
|
@@ -128,7 +124,7 @@
|
|
|
128
124
|
"shareByEmail": {
|
|
129
125
|
"subtitle": "Par email",
|
|
130
126
|
"emailPlaceholder": "Ajouter des contacts",
|
|
131
|
-
"send": "
|
|
127
|
+
"send": "Partager",
|
|
132
128
|
"singleContactSuccess": "Vous avez envoyé une invitation à %{email}.",
|
|
133
129
|
"contactSuccess": "Vous avez invité %{smart_count} contact. |||| Vous avez invité %{smart_count} contacts.",
|
|
134
130
|
"singleGroupSuccess": "Vous avez invité les membres du groupe %{groupName}.",
|
|
@@ -196,7 +192,7 @@
|
|
|
196
192
|
"subtitle": "Par email",
|
|
197
193
|
"email": "À :",
|
|
198
194
|
"emailPlaceholder": "Saisissez le courriel ou le nom du destinataire.",
|
|
199
|
-
"send": "
|
|
195
|
+
"send": "Partager",
|
|
200
196
|
"singleContactSuccess": "Vous avez envoyé une invitation à %{email}.",
|
|
201
197
|
"contactSuccess": "Vous avez invité %{smart_count} contact. |||| Vous avez invité %{smart_count} contacts.",
|
|
202
198
|
"singleGroupSuccess": "Vous avez invité les membres du groupe %{groupName}.",
|
|
@@ -266,7 +262,7 @@
|
|
|
266
262
|
"subtitle": "Par email",
|
|
267
263
|
"email": "e-mail",
|
|
268
264
|
"emailPlaceholder": "Saisissez l'email ou le nom du destinataire.",
|
|
269
|
-
"send": "
|
|
265
|
+
"send": "Partager",
|
|
270
266
|
"singleContactSuccess": "Vous avez envoyé une invitation à %{email}.",
|
|
271
267
|
"contactSuccess": "Vous avez invité %{smart_count} contact. |||| Vous avez invité %{smart_count} contacts.",
|
|
272
268
|
"singleGroupSuccess": "Vous avez invité les membres du groupe %{groupName}.",
|
|
@@ -330,7 +326,7 @@
|
|
|
330
326
|
"subtitle": "Par email",
|
|
331
327
|
"email": "Envoyer à :",
|
|
332
328
|
"emailPlaceholder": "Saisissez le courriel ou le nom du destinataire.",
|
|
333
|
-
"send": "
|
|
329
|
+
"send": "Partager",
|
|
334
330
|
"error": {
|
|
335
331
|
"addingRecipient": "Une erreur s'est produite lors de l'ajout du destinataire. Veuillez réessayer."
|
|
336
332
|
},
|
package/locales/ru.json
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": {
|
|
17
17
|
"one-way": "Читатель",
|
|
18
|
-
"two-way": "Редактор"
|
|
19
|
-
"desc": {
|
|
20
|
-
"one-way": "Контакты могут просматривать, скачивать и добавлять этот элемент в свой Twake. В таком случае они будут получать ваши обновления, но не смогут обновлять содержимое сами.",
|
|
21
|
-
"two-way": "Контакты могут обновлять, удалять и добавлять этот элемент в свой Twake. Обновления содержимого будут видны на других аккаунтах."
|
|
22
|
-
}
|
|
18
|
+
"two-way": "Редактор"
|
|
23
19
|
},
|
|
24
20
|
"locked-type-file": "Скоро: вы сможете изменять разрешения для файла.",
|
|
25
21
|
"locked-type-folder": "Скоро: вы сможете изменять разрешения для папки.",
|
|
@@ -131,7 +127,7 @@
|
|
|
131
127
|
"shareByEmail": {
|
|
132
128
|
"subtitle": "По электронной почте",
|
|
133
129
|
"emailPlaceholder": "Добавить контакты",
|
|
134
|
-
"send": "
|
|
130
|
+
"send": "Поделиться",
|
|
135
131
|
"singleContactSuccess": "Вы отправили приглашение на %{email}.",
|
|
136
132
|
"contactSuccess": "Вы отправили приглашение %{smart_count} контакту. |||| Вы отправили приглашение %{smart_count} контактам.",
|
|
137
133
|
"singleGroupSuccess": "Вы отправили приглашение участникам группы %{groupName}.",
|
|
@@ -199,7 +195,7 @@
|
|
|
199
195
|
"subtitle": "По электронной почте",
|
|
200
196
|
"email": "Кому:",
|
|
201
197
|
"emailPlaceholder": "Введите адрес электронной почты или имя получателя",
|
|
202
|
-
"send": "
|
|
198
|
+
"send": "Поделиться",
|
|
203
199
|
"singleContactSuccess": "Вы отправили приглашение на %{email}.",
|
|
204
200
|
"contactSuccess": "Вы отправили приглашение %{smart_count} контакту. |||| Вы отправили приглашение %{smart_count} контактам.",
|
|
205
201
|
"singleGroupSuccess": "Вы отправили приглашение участникам группы %{groupName}.",
|
|
@@ -268,7 +264,7 @@
|
|
|
268
264
|
"subtitle": "По электронной почте",
|
|
269
265
|
"email": "эл. почта",
|
|
270
266
|
"emailPlaceholder": "Введите адрес электронной почты или имя получателя",
|
|
271
|
-
"send": "
|
|
267
|
+
"send": "Поделиться",
|
|
272
268
|
"singleContactSuccess": "Вы отправили приглашение на %{email}.",
|
|
273
269
|
"contactSuccess": "Вы отправили приглашение %{smart_count} контакту. |||| Вы отправили приглашение %{smart_count} контактам.",
|
|
274
270
|
"singleGroupSuccess": "Вы отправили приглашение участникам группы %{groupName}.",
|
|
@@ -332,7 +328,7 @@
|
|
|
332
328
|
"subtitle": "По электронной почте",
|
|
333
329
|
"email": "Отправить:",
|
|
334
330
|
"emailPlaceholder": "Введите адрес электронной почты или имя получателя",
|
|
335
|
-
"send": "
|
|
331
|
+
"send": "Поделиться",
|
|
336
332
|
"error": {
|
|
337
333
|
"addingRecipient": "Произошла ошибка при добавлении получателя. Пожалуйста, попробуйте еще раз."
|
|
338
334
|
},
|
package/locales/vi.json
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": {
|
|
17
17
|
"one-way": "Người xem",
|
|
18
|
-
"two-way": "Người chỉnh sửa"
|
|
19
|
-
"desc": {
|
|
20
|
-
"one-way": "Người liên hệ có thể xem, tải xuống và thêm nội dung vào Twake của họ. Nếu họ thêm nội dung vào Twake, họ sẽ nhận được các bản cập nhật mà bạn thực hiện đối với nội dung, nhưng họ sẽ không thể cập nhật nó.",
|
|
21
|
-
"two-way": "Người liên hệ có thể cập nhật, xóa và thêm nội dung vào Twake của họ. Các bản cập nhật trên nội dung sẽ được thấy trên các Cozy khác."
|
|
22
|
-
}
|
|
18
|
+
"two-way": "Người chỉnh sửa"
|
|
23
19
|
},
|
|
24
20
|
"locked-type-file": "Sắp ra mắt: bạn sẽ có thể thay đổi quyền mà bạn cấp trên tệp.",
|
|
25
21
|
"locked-type-folder": "Sắp ra mắt: bạn sẽ có thể thay đổi quyền mà bạn cấp trên thư mục.",
|
|
@@ -131,7 +127,7 @@
|
|
|
131
127
|
"shareByEmail": {
|
|
132
128
|
"subtitle": "Bằng email",
|
|
133
129
|
"emailPlaceholder": "Thêm liên hệ",
|
|
134
|
-
"send": "
|
|
130
|
+
"send": "Chia sẻ",
|
|
135
131
|
"singleContactSuccess": "Bạn đã gửi lời mời đến %{email}.",
|
|
136
132
|
"contactSuccess": "Bạn đã gửi lời mời đến %{smart_count} liên hệ. |||| Bạn đã gửi lời mời đến %{smart_count} liên hệ.",
|
|
137
133
|
"singleGroupSuccess": "Bạn đã gửi lời mời đến các thành viên của nhóm %{groupName}.",
|
|
@@ -199,7 +195,7 @@
|
|
|
199
195
|
"subtitle": "Bằng email",
|
|
200
196
|
"email": "Đến:",
|
|
201
197
|
"emailPlaceholder": "Nhập địa chỉ email hoặc tên người nhận",
|
|
202
|
-
"send": "
|
|
198
|
+
"send": "Chia sẻ",
|
|
203
199
|
"singleContactSuccess": "Bạn đã gửi lời mời đến %{email}.",
|
|
204
200
|
"contactSuccess": "Bạn đã gửi lời mời đến %{smart_count} liên hệ. |||| Bạn đã gửi lời mời đến %{smart_count} liên hệ.",
|
|
205
201
|
"singleGroupSuccess": "Bạn đã gửi lời mời đến các thành viên của nhóm %{groupName}.",
|
|
@@ -268,7 +264,7 @@
|
|
|
268
264
|
"subtitle": "Bằng email",
|
|
269
265
|
"email": "email",
|
|
270
266
|
"emailPlaceholder": "Nhập địa chỉ email hoặc tên người nhận",
|
|
271
|
-
"send": "
|
|
267
|
+
"send": "Chia sẻ",
|
|
272
268
|
"singleContactSuccess": "Bạn đã gửi lời mời đến %{email}.",
|
|
273
269
|
"contactSuccess": "Bạn đã gửi lời mời đến %{smart_count} liên hệ. |||| Bạn đã gửi lời mời đến %{smart_count} liên hệ.",
|
|
274
270
|
"singleGroupSuccess": "Bạn đã gửi lời mời đến các thành viên của nhóm %{groupName}.",
|
|
@@ -332,7 +328,7 @@
|
|
|
332
328
|
"subtitle": "Bằng email",
|
|
333
329
|
"email": "Gửi đến:",
|
|
334
330
|
"emailPlaceholder": "Nhập địa chỉ email hoặc tên người nhận",
|
|
335
|
-
"send": "
|
|
331
|
+
"send": "Chia sẻ",
|
|
336
332
|
"error": {
|
|
337
333
|
"addingRecipient": "Đã xảy ra lỗi khi thêm người nhận. Vui lòng thử lại."
|
|
338
334
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.2.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sideEffects": [
|
|
85
85
|
"*.css"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "a014359670929b248620d8bbd95621de7b5aa7bb"
|
|
88
88
|
}
|
|
@@ -10,42 +10,41 @@ export const DumbFederatedFolderModal = withLocales(
|
|
|
10
10
|
({
|
|
11
11
|
title,
|
|
12
12
|
document,
|
|
13
|
-
createContact,
|
|
14
13
|
recipients,
|
|
15
|
-
readOnlyRecipients,
|
|
16
14
|
currentRecipients,
|
|
17
15
|
onRevoke,
|
|
18
|
-
onSetType,
|
|
19
16
|
onSend,
|
|
20
17
|
onClose,
|
|
21
|
-
onShare,
|
|
22
18
|
sharingLink,
|
|
23
19
|
showShareByEmail,
|
|
24
20
|
autoOpenShareRestriction,
|
|
25
|
-
showGenerateLinkButton
|
|
21
|
+
showGenerateLinkButton,
|
|
22
|
+
pendingRecipients,
|
|
23
|
+
onPendingRecipientsChange,
|
|
24
|
+
selectedOption,
|
|
25
|
+
onSelectedOptionChange
|
|
26
26
|
}) => {
|
|
27
27
|
const { t } = useI18n()
|
|
28
28
|
return (
|
|
29
29
|
<DumbBatchSharedFolderModal
|
|
30
30
|
title={title}
|
|
31
31
|
document={document}
|
|
32
|
-
createContact={createContact}
|
|
33
32
|
recipients={recipients}
|
|
34
|
-
readOnlyRecipients={readOnlyRecipients}
|
|
35
33
|
currentRecipients={currentRecipients}
|
|
36
34
|
onRevoke={onRevoke}
|
|
37
|
-
onSetType={onSetType}
|
|
38
35
|
onSend={onSend}
|
|
39
36
|
onClose={onClose}
|
|
40
|
-
onShare={onShare}
|
|
41
37
|
sharingLink={sharingLink}
|
|
42
38
|
showNameField={false}
|
|
43
39
|
addPeopleLabel={t('FederatedFolder.addPeople')}
|
|
44
|
-
addButtonLabel={t('FederatedFolder.add')}
|
|
45
40
|
shareLabel={t('FederatedFolder.share')}
|
|
46
41
|
showShareByEmail={showShareByEmail}
|
|
47
42
|
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
48
43
|
showGenerateLinkButton={showGenerateLinkButton}
|
|
44
|
+
pendingRecipients={pendingRecipients}
|
|
45
|
+
onPendingRecipientsChange={onPendingRecipientsChange}
|
|
46
|
+
selectedOption={selectedOption}
|
|
47
|
+
onSelectedOptionChange={onSelectedOptionChange}
|
|
49
48
|
/>
|
|
50
49
|
)
|
|
51
50
|
}
|
|
@@ -54,19 +53,19 @@ export const DumbFederatedFolderModal = withLocales(
|
|
|
54
53
|
DumbFederatedFolderModal.propTypes = {
|
|
55
54
|
title: PropTypes.string,
|
|
56
55
|
document: PropTypes.object,
|
|
57
|
-
createContact: PropTypes.func.isRequired,
|
|
58
56
|
recipients: PropTypes.array,
|
|
59
|
-
readOnlyRecipients: PropTypes.array,
|
|
60
57
|
currentRecipients: PropTypes.array,
|
|
61
58
|
onRevoke: PropTypes.func.isRequired,
|
|
62
|
-
onSetType: PropTypes.func.isRequired,
|
|
63
59
|
onSend: PropTypes.func.isRequired,
|
|
64
60
|
onClose: PropTypes.func.isRequired,
|
|
65
|
-
onShare: PropTypes.func.isRequired,
|
|
66
61
|
sharingLink: PropTypes.string,
|
|
67
62
|
showShareByEmail: PropTypes.bool,
|
|
68
63
|
autoOpenShareRestriction: PropTypes.bool,
|
|
69
|
-
showGenerateLinkButton: PropTypes.bool
|
|
64
|
+
showGenerateLinkButton: PropTypes.bool,
|
|
65
|
+
pendingRecipients: PropTypes.array.isRequired,
|
|
66
|
+
onPendingRecipientsChange: PropTypes.func.isRequired,
|
|
67
|
+
selectedOption: PropTypes.oneOf(['readWrite', 'readOnly']).isRequired,
|
|
68
|
+
onSelectedOptionChange: PropTypes.func.isRequired
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
export default DumbFederatedFolderModal
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useEffect, useState } from 'react'
|
|
3
3
|
|
|
4
4
|
import { useClient } from 'cozy-client'
|
|
5
5
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
|
|
6
6
|
import { useI18n } from 'twake-i18n'
|
|
7
7
|
|
|
8
8
|
import { DumbFederatedFolderModal } from './DumbFederatedFolderModal'
|
|
9
|
+
import { getOrCreateFromArray } from '../../helpers/contacts'
|
|
9
10
|
import withLocales from '../../hoc/withLocales'
|
|
11
|
+
import { usePendingRecipients } from '../../hooks/usePendingRecipients'
|
|
10
12
|
import { useSharingContext } from '../../hooks/useSharingContext'
|
|
11
|
-
import {
|
|
12
|
-
formatRecipients,
|
|
13
|
-
mergeAndDeduplicateRecipients,
|
|
14
|
-
moveRecipientToReadWrite,
|
|
15
|
-
moveRecipientToReadOnly,
|
|
16
|
-
RECIPIENT_INDEX_PREFIX
|
|
17
|
-
} from '../SharedDrive/helpers'
|
|
18
13
|
|
|
19
14
|
export const FederatedFolderModal = withLocales(
|
|
20
15
|
({
|
|
@@ -38,6 +33,22 @@ export const FederatedFolderModal = withLocales(
|
|
|
38
33
|
const { showAlert } = useAlert()
|
|
39
34
|
|
|
40
35
|
const [sharingLink, setSharingLink] = useState(null)
|
|
36
|
+
const {
|
|
37
|
+
pendingRecipients,
|
|
38
|
+
setPendingRecipients,
|
|
39
|
+
selectedOption,
|
|
40
|
+
setSelectedOption
|
|
41
|
+
} = usePendingRecipients()
|
|
42
|
+
|
|
43
|
+
// share from CozyProvider is wired to callbacks and realtime that
|
|
44
|
+
// makes existingDocument and existingRecipients reactive to changes.
|
|
45
|
+
// But we want it to be reactive only when we revoke a member. When we add member
|
|
46
|
+
// we close the popup and we do not want to see briefly the new contacts added
|
|
47
|
+
// in members before the modal closes. That's why when clicking on "Share"
|
|
48
|
+
// we do not use the reactive existingDocument and existingRecipients.
|
|
49
|
+
const [isSending, setIsSending] = useState(false)
|
|
50
|
+
const [frozenDoc, setFrozenDoc] = useState(null)
|
|
51
|
+
const [frozenRecipients, setFrozenRecipients] = useState(null)
|
|
41
52
|
|
|
42
53
|
const documentPermissions = existingDocument
|
|
43
54
|
? getDocumentPermissions(existingDocument._id)
|
|
@@ -65,32 +76,33 @@ export const FederatedFolderModal = withLocales(
|
|
|
65
76
|
getSharingById
|
|
66
77
|
])
|
|
67
78
|
|
|
68
|
-
const
|
|
69
|
-
recipients: [],
|
|
70
|
-
readOnlyRecipients: []
|
|
71
|
-
})
|
|
72
|
-
const [folderName] = useState(existingDocument?.name || '')
|
|
73
|
-
|
|
74
|
-
const onShare = params => {
|
|
75
|
-
setFederatedRecipients(prev => ({
|
|
76
|
-
recipients: mergeAndDeduplicateRecipients([
|
|
77
|
-
prev.recipients,
|
|
78
|
-
params.recipients || []
|
|
79
|
-
]),
|
|
80
|
-
readOnlyRecipients: mergeAndDeduplicateRecipients([
|
|
81
|
-
prev.readOnlyRecipients,
|
|
82
|
-
params.readOnlyRecipients || []
|
|
83
|
-
])
|
|
84
|
-
}))
|
|
85
|
-
}
|
|
79
|
+
const folderName = existingDocument?.name || ''
|
|
86
80
|
|
|
87
81
|
const onSend = async () => {
|
|
82
|
+
if (pendingRecipients.length === 0) {
|
|
83
|
+
onClose()
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setIsSending(true)
|
|
88
|
+
setFrozenDoc(existingDocument)
|
|
89
|
+
setFrozenRecipients(existingRecipients)
|
|
90
|
+
|
|
88
91
|
try {
|
|
92
|
+
const contacts = await getOrCreateFromArray(
|
|
93
|
+
client,
|
|
94
|
+
pendingRecipients,
|
|
95
|
+
contact => client.create('io.cozy.contacts', contact)
|
|
96
|
+
)
|
|
97
|
+
const readWriteRecipients =
|
|
98
|
+
selectedOption === 'readOnly' ? [] : contacts
|
|
99
|
+
const readOnlyRecipients = selectedOption === 'readOnly' ? contacts : []
|
|
100
|
+
|
|
89
101
|
await share({
|
|
90
102
|
description: folderName,
|
|
91
103
|
document: existingDocument,
|
|
92
|
-
recipients:
|
|
93
|
-
readOnlyRecipients
|
|
104
|
+
recipients: readWriteRecipients,
|
|
105
|
+
readOnlyRecipients,
|
|
94
106
|
sharedDrive: true,
|
|
95
107
|
openSharing: false
|
|
96
108
|
})
|
|
@@ -108,31 +120,8 @@ export const FederatedFolderModal = withLocales(
|
|
|
108
120
|
severity: 'error',
|
|
109
121
|
variant: 'filled'
|
|
110
122
|
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const onSetType = (index, newType) => {
|
|
115
|
-
const _id = index.split(RECIPIENT_INDEX_PREFIX)[1]
|
|
116
|
-
|
|
117
|
-
if (newType === 'two-way') {
|
|
118
|
-
setFederatedRecipients(prev => moveRecipientToReadWrite(prev, _id))
|
|
119
|
-
} else {
|
|
120
|
-
setFederatedRecipients(prev => moveRecipientToReadOnly(prev, _id))
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const onRevoke = async (documentOrIndex, sharingId, memberIndex) => {
|
|
125
|
-
if (
|
|
126
|
-
typeof documentOrIndex === 'string' &&
|
|
127
|
-
documentOrIndex.startsWith(RECIPIENT_INDEX_PREFIX)
|
|
128
|
-
) {
|
|
129
|
-
const _id = documentOrIndex.split(RECIPIENT_INDEX_PREFIX)[1]
|
|
130
|
-
setFederatedRecipients(prev => ({
|
|
131
|
-
recipients: prev.recipients.filter(r => r._id !== _id),
|
|
132
|
-
readOnlyRecipients: prev.readOnlyRecipients.filter(r => r._id !== _id)
|
|
133
|
-
}))
|
|
134
|
-
} else {
|
|
135
|
-
await revoke(documentOrIndex, sharingId, memberIndex)
|
|
123
|
+
} finally {
|
|
124
|
+
setIsSending(false)
|
|
136
125
|
}
|
|
137
126
|
}
|
|
138
127
|
|
|
@@ -140,32 +129,26 @@ export const FederatedFolderModal = withLocales(
|
|
|
140
129
|
? getRecipients(existingDocument._id)
|
|
141
130
|
: []
|
|
142
131
|
|
|
143
|
-
const recipients = [
|
|
144
|
-
...existingRecipients,
|
|
145
|
-
...formatRecipients(federatedRecipients)
|
|
146
|
-
]
|
|
147
|
-
|
|
148
132
|
const modalTitle = t('FederatedFolder.shareTitle', { name: folderName })
|
|
149
|
-
|
|
150
133
|
const isSharedDrive = Boolean(existingDocument?.driveId)
|
|
151
134
|
|
|
152
135
|
return (
|
|
153
136
|
<DumbFederatedFolderModal
|
|
154
137
|
title={modalTitle}
|
|
155
|
-
document={existingDocument}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
currentRecipients={existingRecipients}
|
|
160
|
-
onRevoke={onRevoke}
|
|
161
|
-
onSetType={onSetType}
|
|
138
|
+
document={isSending ? frozenDoc : existingDocument}
|
|
139
|
+
recipients={isSending ? frozenRecipients : existingRecipients}
|
|
140
|
+
currentRecipients={isSending ? frozenRecipients : existingRecipients}
|
|
141
|
+
onRevoke={revoke}
|
|
162
142
|
onSend={onSend}
|
|
163
143
|
onClose={onClose}
|
|
164
|
-
onShare={onShare}
|
|
165
144
|
sharingLink={sharingLink}
|
|
166
145
|
showShareByEmail={!isSharedDrive}
|
|
167
146
|
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
168
147
|
showGenerateLinkButton={showGenerateLinkButton}
|
|
148
|
+
pendingRecipients={pendingRecipients}
|
|
149
|
+
onPendingRecipientsChange={setPendingRecipients}
|
|
150
|
+
selectedOption={selectedOption}
|
|
151
|
+
onSelectedOptionChange={setSelectedOption}
|
|
169
152
|
/>
|
|
170
153
|
)
|
|
171
154
|
}
|