cozy-sharing 5.0.0 → 6.0.1
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 +80 -0
- package/dist/SharedRecipients.js +1 -1
- package/dist/SharedStatus.js +1 -1
- package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
- package/dist/SharingDetailsModal.js +1 -1
- package/dist/SharingOwnerAvatar.js +1 -1
- package/dist/SharingProvider.js +21 -8
- package/dist/components/ConfirmTrustedRecipientsDialog.js +1 -1
- package/dist/components/ContactSuggestion.js +15 -27
- package/dist/components/EditLinkPermissionDialog.js +72 -0
- package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
- package/dist/components/EditableSharingModal.js +15 -62
- package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
- package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
- package/dist/components/Recipient/LinkRecipient.js +72 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
- package/dist/components/Recipient/OwnerIdentity.js +44 -0
- package/dist/components/Recipient/Recipient.js +72 -0
- package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
- package/dist/components/Recipient/RecipientAvatar.js +33 -0
- package/dist/components/Recipient/RecipientConfirm.js +63 -0
- package/dist/components/Recipient/RecipientPermissions.js +126 -0
- package/dist/components/Recipient/RecipientPlusX.js +45 -0
- package/dist/components/Recipient/RecipientStatus.js +64 -0
- package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
- package/dist/components/Recipient/RecipientsAvatars.js +100 -0
- package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
- package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/dist/components/ShareAutosuggest.js +176 -252
- package/dist/components/ShareAutosuggest.spec.js +3 -2
- package/dist/components/ShareByEmail.js +142 -193
- package/dist/components/ShareByEmail.spec.js +42 -23
- package/dist/components/ShareByLink.js +251 -357
- package/dist/components/ShareDialogCozyToCozy.js +16 -4
- package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
- package/dist/components/ShareDialogOnlyByLink.js +23 -10
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
- package/dist/components/ShareModal.js +5 -1
- package/dist/components/ShareRecipientsInput.js +44 -128
- package/dist/components/WhoHasAccess.js +43 -5
- package/dist/components/WhoHasAccessLight.js +3 -19
- package/dist/components/autosuggest.styl +21 -36
- package/dist/helpers/documentType.js +6 -0
- package/dist/helpers/hooks.js +8 -1
- package/dist/helpers/link.js +5 -0
- package/dist/helpers/permissions.js +8 -0
- package/dist/helpers/recipients.js +24 -0
- package/dist/helpers/sharings.js +72 -53
- package/dist/helpers/synchronousJobQueue.js +67 -0
- package/dist/helpers/synchronousJobQueue.spec.js +97 -0
- package/dist/index.js +2 -1
- package/dist/queries/queries.js +72 -0
- package/dist/share.styl +0 -15
- package/dist/stylesheet.css +67 -92
- package/locales/en.json +29 -41
- package/locales/fr.json +26 -39
- package/package.json +10 -10
- package/src/SharedRecipients.jsx +1 -1
- package/src/SharedStatus.jsx +1 -1
- package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
- package/src/SharingDetailsModal.jsx +1 -1
- package/src/SharingOwnerAvatar.jsx +1 -1
- package/src/SharingProvider.jsx +17 -4
- package/src/components/ConfirmTrustedRecipientsDialog.jsx +1 -1
- package/src/components/ContactSuggestion.jsx +25 -10
- package/src/components/EditLinkPermissionDialog.jsx +89 -0
- package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
- package/src/components/EditableSharingModal.jsx +58 -100
- package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
- package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
- package/src/components/Recipient/LinkRecipient.jsx +59 -0
- package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
- package/src/components/Recipient/OwnerIdentity.jsx +20 -0
- package/src/components/Recipient/Recipient.jsx +79 -0
- package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
- package/src/components/Recipient/RecipientAvatar.jsx +38 -0
- package/src/components/Recipient/RecipientConfirm.jsx +37 -0
- package/src/components/Recipient/RecipientPermissions.jsx +114 -0
- package/src/components/Recipient/RecipientPlusX.jsx +28 -0
- package/src/components/Recipient/RecipientStatus.jsx +48 -0
- package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
- package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
- package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
- package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/src/components/ShareAutosuggest.jsx +136 -127
- package/src/components/ShareAutosuggest.spec.jsx +12 -8
- package/src/components/ShareByEmail.jsx +65 -90
- package/src/components/ShareByEmail.spec.jsx +39 -11
- package/src/components/ShareByLink.jsx +146 -238
- package/src/components/ShareDialogCozyToCozy.jsx +14 -2
- package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
- package/src/components/ShareDialogOnlyByLink.jsx +30 -13
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
- package/src/components/ShareModal.jsx +5 -1
- package/src/components/ShareRecipientsInput.jsx +30 -44
- package/src/components/WhoHasAccess.jsx +85 -27
- package/src/components/WhoHasAccessLight.jsx +2 -1
- package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
- package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
- package/src/components/autosuggest.styl +21 -36
- package/src/helpers/documentType.js +6 -0
- package/src/helpers/hooks.js +11 -1
- package/src/helpers/link.js +4 -0
- package/src/helpers/permissions.js +15 -0
- package/src/helpers/recipients.js +21 -0
- package/src/helpers/sharings.js +15 -12
- package/src/helpers/synchronousJobQueue.js +22 -0
- package/src/helpers/synchronousJobQueue.spec.js +75 -0
- package/src/index.jsx +1 -0
- package/src/queries/queries.js +75 -0
- package/src/share.styl +0 -15
- package/dist/SharingBanner/helpers/queries.js +0 -12
- package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
- package/dist/components/Recipient.js +0 -450
- package/src/SharingBanner/helpers/queries.js +0 -14
- package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
- package/src/components/Recipient.jsx +0 -415
|
@@ -1,115 +1,99 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`ShareRecipientsInput component should include groups only if all contacts are loaded 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object {
|
|
15
|
-
"_id": "df563cc4-6440",
|
|
16
|
-
"_type": "io.cozy.contacts",
|
|
17
|
-
"id": "df563cc4-6440",
|
|
18
|
-
"name": Object {
|
|
19
|
-
"familyName": "Russel",
|
|
20
|
-
"givenName": "Michale",
|
|
21
|
-
},
|
|
4
|
+
<ShareAutocomplete
|
|
5
|
+
contactsAndGroups={
|
|
6
|
+
Array [
|
|
7
|
+
Object {
|
|
8
|
+
"_id": "df563cc4-6440",
|
|
9
|
+
"_type": "io.cozy.contacts",
|
|
10
|
+
"id": "df563cc4-6440",
|
|
11
|
+
"name": Object {
|
|
12
|
+
"familyName": "Russel",
|
|
13
|
+
"givenName": "Michale",
|
|
22
14
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
},
|
|
16
|
+
Object {
|
|
17
|
+
"_id": "5a3b4ccf-c257",
|
|
18
|
+
"_type": "io.cozy.contacts",
|
|
19
|
+
"id": "5a3b4ccf-c257",
|
|
20
|
+
"name": Object {
|
|
21
|
+
"familyName": "Wolf",
|
|
22
|
+
"givenName": "Teagan",
|
|
31
23
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
loading={false}
|
|
28
|
+
onFocus={[Function]}
|
|
29
|
+
onPick={[MockFunction onPick]}
|
|
30
|
+
onRemove={[MockFunction onRemove]}
|
|
31
|
+
placeholder="Enter recipients here"
|
|
32
|
+
recipients={
|
|
33
|
+
Array [
|
|
34
|
+
Object {
|
|
35
|
+
"id": "5a3b4ccf-c257",
|
|
36
|
+
"name": Object {
|
|
37
|
+
"familyName": "Wolf",
|
|
38
|
+
"givenName": "Teagan",
|
|
47
39
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
/>
|
|
52
44
|
`;
|
|
53
45
|
|
|
54
46
|
exports[`ShareRecipientsInput component should match snapshot 1`] = `
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Object {
|
|
66
|
-
"_id": "df563cc4-6440",
|
|
67
|
-
"_type": "io.cozy.contacts",
|
|
68
|
-
"id": "df563cc4-6440",
|
|
69
|
-
"name": Object {
|
|
70
|
-
"familyName": "Russel",
|
|
71
|
-
"givenName": "Michale",
|
|
72
|
-
},
|
|
47
|
+
<ShareAutocomplete
|
|
48
|
+
contactsAndGroups={
|
|
49
|
+
Array [
|
|
50
|
+
Object {
|
|
51
|
+
"_id": "df563cc4-6440",
|
|
52
|
+
"_type": "io.cozy.contacts",
|
|
53
|
+
"id": "df563cc4-6440",
|
|
54
|
+
"name": Object {
|
|
55
|
+
"familyName": "Russel",
|
|
56
|
+
"givenName": "Michale",
|
|
73
57
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
58
|
+
},
|
|
59
|
+
Object {
|
|
60
|
+
"_id": "5a3b4ccf-c257",
|
|
61
|
+
"_type": "io.cozy.contacts",
|
|
62
|
+
"id": "5a3b4ccf-c257",
|
|
63
|
+
"name": Object {
|
|
64
|
+
"familyName": "Wolf",
|
|
65
|
+
"givenName": "Teagan",
|
|
82
66
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
67
|
+
},
|
|
68
|
+
Object {
|
|
69
|
+
"_id": "fe86af20-c6c5",
|
|
70
|
+
"_type": "io.cozy.contacts.groups",
|
|
71
|
+
"id": "fe86af20-c6c5",
|
|
72
|
+
"name": "The Night's Watch",
|
|
73
|
+
},
|
|
74
|
+
Object {
|
|
75
|
+
"_id": "3d8193ab-2ce4",
|
|
76
|
+
"_type": "io.cozy.contacts.groups",
|
|
77
|
+
"id": "3d8193ab-2ce4",
|
|
78
|
+
"name": "The North",
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
loading={false}
|
|
83
|
+
onFocus={[Function]}
|
|
84
|
+
onPick={[MockFunction onPick]}
|
|
85
|
+
onRemove={[MockFunction onRemove]}
|
|
86
|
+
placeholder="Enter recipients here"
|
|
87
|
+
recipients={
|
|
88
|
+
Array [
|
|
89
|
+
Object {
|
|
90
|
+
"id": "5a3b4ccf-c257",
|
|
91
|
+
"name": Object {
|
|
92
|
+
"familyName": "Wolf",
|
|
93
|
+
"givenName": "Teagan",
|
|
88
94
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"name": "The North",
|
|
94
|
-
},
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
loading={false}
|
|
98
|
-
onFocus={[Function]}
|
|
99
|
-
onPick={[MockFunction onPick]}
|
|
100
|
-
onRemove={[MockFunction onRemove]}
|
|
101
|
-
placeholder="Enter recipients here"
|
|
102
|
-
recipients={
|
|
103
|
-
Array [
|
|
104
|
-
Object {
|
|
105
|
-
"id": "5a3b4ccf-c257",
|
|
106
|
-
"name": Object {
|
|
107
|
-
"familyName": "Wolf",
|
|
108
|
-
"givenName": "Teagan",
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
/>
|
|
114
|
-
</div>
|
|
95
|
+
},
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
/>
|
|
115
99
|
`;
|
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
box-sizing border-box
|
|
9
9
|
position absolute
|
|
10
10
|
top 100%
|
|
11
|
-
margin-top .
|
|
11
|
+
margin-top .25rem
|
|
12
12
|
z-index $alert-index-mobile
|
|
13
13
|
width 100%
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
border .
|
|
17
|
-
border-radius .25rem
|
|
14
|
+
overflow hidden
|
|
15
|
+
box-shadow 0px 0px 0px 0.5px rgba(29, 33, 42, 0.12), 0px 2px 4px rgba(29, 33, 42, 0.0793047), 0px 4px 16px rgba(29, 33, 42, 0.06)
|
|
16
|
+
border-radius .5rem
|
|
18
17
|
background var(--white)
|
|
19
18
|
display none
|
|
20
19
|
|
|
@@ -25,56 +24,42 @@
|
|
|
25
24
|
width 100%
|
|
26
25
|
|
|
27
26
|
.suggestionsList
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
max-height 9rem
|
|
28
|
+
overflow auto
|
|
29
|
+
margin 0 -1px 0 0
|
|
30
|
+
padding .5rem 0
|
|
30
31
|
list-style none
|
|
31
32
|
|
|
32
|
-
.suggestion
|
|
33
|
-
padding 0 .625rem .625rem .625rem
|
|
34
|
-
|
|
35
33
|
.suggestionHighlighted
|
|
36
|
-
background var(--
|
|
34
|
+
background var(--actionColorSelected)
|
|
37
35
|
|
|
38
36
|
.recipientsContainer
|
|
39
37
|
display flex
|
|
40
38
|
flex-wrap wrap
|
|
41
|
-
padding .
|
|
42
|
-
border-radius .
|
|
43
|
-
border 1px solid var(--
|
|
39
|
+
padding .25rem .5rem
|
|
40
|
+
border-radius .25rem
|
|
41
|
+
border 1px solid var(--borderMainColor)
|
|
42
|
+
min-height 2.5rem
|
|
44
43
|
max-height 6.75rem
|
|
45
44
|
overflow auto
|
|
46
45
|
|
|
47
46
|
&:hover
|
|
48
|
-
border
|
|
47
|
+
border 1px solid var(--coolGrey)
|
|
48
|
+
|
|
49
|
+
&:focus-within
|
|
50
|
+
border 1px solid var(--primaryColor)
|
|
49
51
|
|
|
50
52
|
input[type=email]
|
|
51
53
|
width auto
|
|
52
54
|
flex-grow 1
|
|
53
55
|
padding .5rem 0
|
|
56
|
+
margin auto
|
|
54
57
|
border none
|
|
55
58
|
&:hover
|
|
56
59
|
&:focus
|
|
57
60
|
border none
|
|
61
|
+
&:only-child
|
|
62
|
+
padding .25rem .5rem
|
|
58
63
|
|
|
59
64
|
.recipientChip
|
|
60
|
-
|
|
61
|
-
align-items center
|
|
62
|
-
flex 0 0 auto
|
|
63
|
-
background-color var(--paleGrey)
|
|
64
|
-
border-radius .125rem
|
|
65
|
-
height 1.75rem
|
|
66
|
-
line-height 1.75rem
|
|
67
|
-
padding 0 .5rem
|
|
68
|
-
margin .25rem .5rem .25rem 0
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.removeRecipient
|
|
72
|
-
border 0
|
|
73
|
-
background-color transparent
|
|
74
|
-
padding .15rem 0 0 0
|
|
75
|
-
margin-left .3rem
|
|
76
|
-
cursor pointer
|
|
77
|
-
color var(--coolGrey)
|
|
78
|
-
|
|
79
|
-
&:hover
|
|
80
|
-
color var(--slateGrey)
|
|
65
|
+
margin .25rem .5rem .25rem 0
|
package/src/helpers/hooks.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import React, { useCallback, useRef } from 'react'
|
|
1
|
+
import React, { useCallback, useRef, useEffect } from 'react'
|
|
2
2
|
|
|
3
3
|
export const isServer = typeof window === 'undefined'
|
|
4
4
|
|
|
5
|
+
export function usePrevious(value) {
|
|
6
|
+
const ref = useRef()
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
ref.current = value
|
|
10
|
+
}, [value])
|
|
11
|
+
|
|
12
|
+
return ref.current
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* based on : https://github.com/tannerlinsley/react-query/blob/79ad5a9ccbce1486c10e7e364d8fc28bef3fa19f/src/devtools/utils.ts#L61
|
|
7
17
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import { models } from 'cozy-client'
|
|
3
|
+
|
|
4
|
+
export const checkIsReadOnlyPermissions = permissions => {
|
|
5
|
+
const permissionCategories = get(
|
|
6
|
+
permissions,
|
|
7
|
+
'[0].attributes.permissions',
|
|
8
|
+
{}
|
|
9
|
+
)
|
|
10
|
+
return (
|
|
11
|
+
Object.values(permissionCategories).filter(permissionCategory =>
|
|
12
|
+
models.permission.isReadOnly(permissionCategory)
|
|
13
|
+
).length > 0
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const filterAndReworkRecipients = (recipients, previousRecipients) => {
|
|
2
|
+
return recipients
|
|
3
|
+
.filter(recipient => recipient.status !== 'owner')
|
|
4
|
+
.map(recipient => {
|
|
5
|
+
const recipientHasChanged =
|
|
6
|
+
previousRecipients &&
|
|
7
|
+
!previousRecipients.find(
|
|
8
|
+
previousRecipient =>
|
|
9
|
+
previousRecipient.name === recipient.name &&
|
|
10
|
+
previousRecipient.email === recipient.email
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if (recipientHasChanged) {
|
|
14
|
+
return { ...recipient, hasBeenJustAdded: true }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return recipient
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const FADE_IN_DURATION = 600
|
package/src/helpers/sharings.js
CHANGED
|
@@ -16,26 +16,29 @@ export const getSharingObject = (internalSharing, sharing) => {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const createSharingInStore = (
|
|
19
|
+
export const createSharingInStore = async ({
|
|
20
20
|
client,
|
|
21
21
|
doctype,
|
|
22
22
|
dispatch,
|
|
23
23
|
docsId,
|
|
24
24
|
sharing
|
|
25
|
-
) => {
|
|
25
|
+
}) => {
|
|
26
26
|
// TODO Check if we can getByIds to avoid query in map
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
await Promise.all(
|
|
28
|
+
docsId.map(async id => {
|
|
29
|
+
const file =
|
|
30
|
+
doctype === 'io.cozy.files'
|
|
31
|
+
? await client.query(Q(doctype).getById(id))
|
|
32
|
+
: undefined
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const path =
|
|
35
|
+
file &&
|
|
36
|
+
(file.data.path ||
|
|
37
|
+
(await fetchFilesPaths(client, doctype, [file.data])))
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
dispatch(addSharing(sharing, path))
|
|
40
|
+
})
|
|
41
|
+
)
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
export const updateSharingInStore = (dispatch, sharing) => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class SynchronousJobQueue {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.isRunning = false
|
|
4
|
+
this.queue = []
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
push(job) {
|
|
8
|
+
this.queue.push(job)
|
|
9
|
+
if (!this.isRunning) {
|
|
10
|
+
this.run()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async run() {
|
|
15
|
+
this.isRunning = true
|
|
16
|
+
while (this.queue.length > 0) {
|
|
17
|
+
const job = this.queue.shift()
|
|
18
|
+
await job.function(job.arguments)
|
|
19
|
+
}
|
|
20
|
+
this.isRunning = false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { SynchronousJobQueue } from './synchronousJobQueue'
|
|
2
|
+
|
|
3
|
+
const flushPromises = () => new Promise(process.nextTick)
|
|
4
|
+
|
|
5
|
+
const callback = jest.fn()
|
|
6
|
+
|
|
7
|
+
const resolveAfter100Ms = jest.fn().mockImplementation(() => {
|
|
8
|
+
callback('100Ms start')
|
|
9
|
+
return new Promise(resolve => {
|
|
10
|
+
setTimeout(function () {
|
|
11
|
+
callback('100Ms end')
|
|
12
|
+
resolve()
|
|
13
|
+
}, 100)
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const resolveAfter500Ms = jest.fn().mockImplementation(() => {
|
|
18
|
+
callback('500Ms start')
|
|
19
|
+
return new Promise(resolve => {
|
|
20
|
+
setTimeout(function () {
|
|
21
|
+
callback('500Ms end')
|
|
22
|
+
resolve()
|
|
23
|
+
}, 500)
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
describe('SynchronousJobQueue', () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
jest.useFakeTimers()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
jest.useRealTimers()
|
|
34
|
+
jest.clearAllMocks()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('should execute job synchronously with SynchronousJobQueue', async () => {
|
|
38
|
+
const synchronousJobQueue = new SynchronousJobQueue()
|
|
39
|
+
synchronousJobQueue.push({ function: resolveAfter500Ms })
|
|
40
|
+
synchronousJobQueue.push({ function: resolveAfter100Ms })
|
|
41
|
+
|
|
42
|
+
jest.runAllTimers()
|
|
43
|
+
await flushPromises()
|
|
44
|
+
jest.runAllTimers()
|
|
45
|
+
await flushPromises()
|
|
46
|
+
|
|
47
|
+
const expectedCallbackOrder = [
|
|
48
|
+
['500Ms start'],
|
|
49
|
+
['500Ms end'],
|
|
50
|
+
['100Ms start'],
|
|
51
|
+
['100Ms end']
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
expect(callback.mock.calls).toEqual(expectedCallbackOrder)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should execute job asynchronously without SynchronousJobQueue', async () => {
|
|
58
|
+
resolveAfter500Ms()
|
|
59
|
+
resolveAfter100Ms()
|
|
60
|
+
|
|
61
|
+
jest.runAllTimers()
|
|
62
|
+
await flushPromises()
|
|
63
|
+
jest.runAllTimers()
|
|
64
|
+
await flushPromises()
|
|
65
|
+
|
|
66
|
+
const expectedCallbackOrder = [
|
|
67
|
+
['500Ms start'],
|
|
68
|
+
['100Ms start'],
|
|
69
|
+
['100Ms end'],
|
|
70
|
+
['500Ms end']
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
expect(callback.mock.calls).toEqual(expectedCallbackOrder)
|
|
74
|
+
})
|
|
75
|
+
})
|
package/src/index.jsx
CHANGED
|
@@ -21,3 +21,4 @@ export { SharingBannerPlugin } from './SharingBanner'
|
|
|
21
21
|
export { useSharingInfos } from './SharingBanner/hooks/useSharingInfos'
|
|
22
22
|
export { ConfirmTrustedRecipientsDialog } from './ConfirmTrustedRecipientsDialog'
|
|
23
23
|
export { ShareButtonWithRecipients } from './ShareButtonWithRecipients'
|
|
24
|
+
export { DOCUMENT_TYPE } from './helpers/documentType'
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Q, fetchPolicies } from 'cozy-client'
|
|
2
|
+
|
|
3
|
+
import { Contact, Group } from '../models'
|
|
4
|
+
|
|
5
|
+
const DEFAULT_CACHE_TIMEOUT_QUERIES = 9 * 60 * 1000
|
|
6
|
+
|
|
7
|
+
const defaultFetchPolicy = fetchPolicies.olderThan(
|
|
8
|
+
DEFAULT_CACHE_TIMEOUT_QUERIES
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
export const fetchApps = () => ({
|
|
12
|
+
definition: Q('io.cozy.apps'),
|
|
13
|
+
options: {
|
|
14
|
+
as: 'io.cozy.apps',
|
|
15
|
+
fetchPolicy: defaultFetchPolicy
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
export const buildSharingsByIdQuery = sharingId => ({
|
|
20
|
+
definition: Q('io.cozy.sharings').getById(sharingId),
|
|
21
|
+
options: {
|
|
22
|
+
as: `io.cozy.sharings/${sharingId}`,
|
|
23
|
+
fetchPolicy: defaultFetchPolicy
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const buildContactsQuery = () => ({
|
|
28
|
+
definition: Q(Contact.doctype)
|
|
29
|
+
.where({
|
|
30
|
+
_id: {
|
|
31
|
+
$gt: null
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
.partialIndex({
|
|
35
|
+
trashed: {
|
|
36
|
+
$or: [{ $eq: false }, { $exists: false }]
|
|
37
|
+
},
|
|
38
|
+
$or: [
|
|
39
|
+
{
|
|
40
|
+
cozy: {
|
|
41
|
+
$not: {
|
|
42
|
+
$size: 0
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
email: {
|
|
48
|
+
$not: {
|
|
49
|
+
$size: 0
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
.indexFields(['_id'])
|
|
56
|
+
.limitBy(1000),
|
|
57
|
+
options: {
|
|
58
|
+
as: 'io.cozy.contacts'
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export const buildGroupsQuery = () => ({
|
|
63
|
+
definition: Q(Group.doctype),
|
|
64
|
+
options: {
|
|
65
|
+
as: 'io.cozy.contacts.groups'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
export const buildInstanceSettingsQuery = () => ({
|
|
70
|
+
definition: Q('io.cozy.settings').getById('instance'),
|
|
71
|
+
options: {
|
|
72
|
+
as: 'io.cozy.settings/instance',
|
|
73
|
+
singleDocData: true
|
|
74
|
+
}
|
|
75
|
+
})
|
package/src/share.styl
CHANGED
|
@@ -21,10 +21,6 @@
|
|
|
21
21
|
.coz-form-group
|
|
22
22
|
flex-shrink 0
|
|
23
23
|
|
|
24
|
-
.coz-form-label
|
|
25
|
-
padding-top 0
|
|
26
|
-
margin-top 0
|
|
27
|
-
|
|
28
24
|
.aligned-dropdown-button
|
|
29
25
|
margin-right: -1rem
|
|
30
26
|
|
|
@@ -82,17 +78,6 @@
|
|
|
82
78
|
.react-select__option:active
|
|
83
79
|
background-color var(--paleGrey) !important
|
|
84
80
|
|
|
85
|
-
@media (max-width 32em)
|
|
86
|
-
.react-select__menu
|
|
87
|
-
width 100% !important
|
|
88
|
-
|
|
89
|
-
@media (max-width 32em)
|
|
90
|
-
.share-type-control
|
|
91
|
-
flex-direction column
|
|
92
|
-
|
|
93
|
-
.select-wrapper
|
|
94
|
-
margin-bottom .5rem
|
|
95
|
-
|
|
96
81
|
input[type=text]
|
|
97
82
|
width 100%
|
|
98
83
|
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import CozyClient, { Q } from 'cozy-client';
|
|
2
|
-
var DEFAULT_CACHE_TIMEOUT_QUERIES = 9 * 60 * 1000;
|
|
3
|
-
var defaultFetchPolicy = CozyClient.fetchPolicies.olderThan(DEFAULT_CACHE_TIMEOUT_QUERIES);
|
|
4
|
-
export var buildSharingsByIdQuery = function buildSharingsByIdQuery(sharingId) {
|
|
5
|
-
return {
|
|
6
|
-
definition: Q('io.cozy.sharings').getById(sharingId),
|
|
7
|
-
options: {
|
|
8
|
-
as: "io.cozy.sharings/".concat(sharingId),
|
|
9
|
-
fetchPolicy: defaultFetchPolicy
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
|
-
import { Component } from 'react';
|
|
12
|
-
|
|
13
|
-
var ContactsAndGroupsDataLoader = /*#__PURE__*/function (_Component) {
|
|
14
|
-
_inherits(ContactsAndGroupsDataLoader, _Component);
|
|
15
|
-
|
|
16
|
-
var _super = _createSuper(ContactsAndGroupsDataLoader);
|
|
17
|
-
|
|
18
|
-
function ContactsAndGroupsDataLoader() {
|
|
19
|
-
_classCallCheck(this, ContactsAndGroupsDataLoader);
|
|
20
|
-
|
|
21
|
-
return _super.apply(this, arguments);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_createClass(ContactsAndGroupsDataLoader, [{
|
|
25
|
-
key: "shouldComponentUpdate",
|
|
26
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
27
|
-
return nextProps.contacts.hasMore !== this.props.contacts.hasMore || nextProps.contacts.fetchStatus !== this.props.contacts.fetchStatus || nextProps.contacts.data.length !== this.props.contacts.data.length || nextProps.groups.hasMore !== this.props.groups.hasMore || nextProps.groups.fetchStatus !== this.props.groups.fetchStatus || nextProps.groups.data.length !== this.props.groups.data.length;
|
|
28
|
-
}
|
|
29
|
-
}, {
|
|
30
|
-
key: "componentDidUpdate",
|
|
31
|
-
value: function componentDidUpdate() {
|
|
32
|
-
if (this.props.contacts.hasMore) {
|
|
33
|
-
this.props.contacts.fetchMore();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (this.props.groups.hasMore) {
|
|
37
|
-
this.props.groups.fetchMore();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}, {
|
|
41
|
-
key: "render",
|
|
42
|
-
value: function render() {
|
|
43
|
-
return this.props.children;
|
|
44
|
-
}
|
|
45
|
-
}]);
|
|
46
|
-
|
|
47
|
-
return ContactsAndGroupsDataLoader;
|
|
48
|
-
}(Component);
|
|
49
|
-
|
|
50
|
-
export default ContactsAndGroupsDataLoader;
|