cozy-sharing 6.0.6 → 7.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 +24 -0
- package/dist/ConfirmTrustedRecipientsDialog.js +1 -1
- package/dist/RefreshableSharings.spec.js +2 -2
- package/dist/ShareButton.js +1 -1
- package/dist/ShareButton.spec.js +1 -1
- package/dist/ShareButtonWithRecipients.js +3 -3
- package/dist/ShareModal.js +2 -2
- package/dist/SharedBadge.js +1 -1
- package/dist/SharedRecipients.js +1 -1
- package/dist/SharedRecipientsList.js +1 -1
- package/dist/SharedStatus.js +1 -1
- package/dist/SharingBanner/components/PublicBanner.js +1 -1
- package/dist/SharingBanner/components/PublicBanner.spec.js +3 -3
- package/dist/SharingBanner/components/SharingBanner.js +1 -1
- package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
- package/dist/SharingBanner/hooks/useSharingInfos.spec.js +1 -1
- package/dist/SharingBanner/index.js +3 -3
- package/dist/SharingBanner/test/AppLike.js +6 -6
- package/dist/SharingDetailsModal.js +8 -8
- package/dist/SharingOwnerAvatar.js +1 -1
- package/dist/SharingProvider.js +2 -2
- package/dist/SharingProvider.spec.js +4 -4
- package/dist/components/ContactSuggestion.js +4 -4
- package/dist/components/ContactSuggestion.spec.js +2 -2
- package/dist/components/CozyPassFingerprintDialogContent.js +4 -4
- package/dist/components/CozyPassFingerprintDialogContent.spec.js +2 -2
- package/dist/components/EditLinkPermissionDialog.js +5 -5
- package/dist/components/EditLinkPermissionDialog.spec.js +2 -2
- package/dist/components/EditableSharingModal.js +3 -3
- package/dist/components/EditableSharingModal.spec.js +4 -4
- package/dist/components/Recipient/AvatarPlusX.js +2 -2
- package/dist/components/Recipient/Identity.js +2 -2
- package/dist/components/Recipient/LinkRecipient.js +8 -8
- package/dist/components/Recipient/LinkRecipientPermissions.js +5 -5
- package/dist/components/Recipient/OwnerIdentity.js +1 -1
- package/dist/components/Recipient/OwnerRecipient.js +2 -2
- package/dist/components/Recipient/Recipient.js +6 -6
- package/dist/components/Recipient/Recipient.spec.js +2 -2
- package/dist/components/Recipient/RecipientConfirm.js +2 -2
- package/dist/components/Recipient/RecipientPermissions.js +5 -5
- package/dist/components/Recipient/RecipientPlusX.js +2 -2
- package/dist/components/Recipient/RecipientStatus.js +3 -3
- package/dist/components/Recipient/RecipientWithoutStatus.js +1 -1
- package/dist/components/Recipient/RecipientsAvatars.js +2 -2
- package/dist/components/Recipient/RecipientsAvatars.spec.js +1 -1
- package/dist/components/ShareAutosuggest.js +5 -5
- package/dist/components/ShareAutosuggest.spec.js +1 -1
- package/dist/components/ShareButton.js +3 -3
- package/dist/components/ShareByEmail.js +6 -6
- package/dist/components/ShareByEmail.spec.js +2 -2
- package/dist/components/ShareByLink.js +7 -7
- package/dist/components/ShareDialogCozyToCozy.js +3 -3
- package/dist/components/ShareDialogCozyToCozy.spec.js +3 -3
- package/dist/components/ShareDialogOnlyByLink.js +1 -1
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +1 -1
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.spec.js +3 -3
- package/dist/components/ShareModal.js +2 -2
- package/dist/components/ShareModal.spec.js +2 -2
- package/dist/components/ShareRecipientsInput.js +2 -2
- package/dist/components/ShareRecipientsInput.spec.js +1 -1
- package/dist/components/SharedBadge.js +3 -3
- package/dist/components/SharedDocuments.js +2 -2
- package/dist/components/SharedStatus.js +2 -2
- package/dist/components/SharedStatus.spec.js +1 -1
- package/dist/components/Sharesubmit.js +1 -1
- package/dist/components/Sharetypeselect.js +5 -5
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/WhoHasAccess.js +5 -5
- package/dist/components/WhoHasAccessLight.js +2 -2
- package/dist/getSharedDocument.js +14 -5
- package/dist/getSharedDocument.spec.js +81 -10
- package/dist/helpers/sharings.js +1 -1
- package/dist/helpers/successMessage.js +1 -1
- package/dist/index.js +1 -1
- package/dist/state.js +2 -6
- package/package.json +2 -2
- package/preprocess.js +1 -0
- package/src/ConfirmTrustedRecipientsDialog.jsx +1 -1
- package/src/RefreshableSharings.spec.jsx +2 -2
- package/src/ShareButton.jsx +2 -2
- package/src/ShareButton.spec.jsx +2 -1
- package/src/ShareButtonWithRecipients.jsx +5 -3
- package/src/ShareModal.jsx +2 -2
- package/src/SharedBadge.jsx +1 -1
- package/src/SharedRecipients.jsx +1 -1
- package/src/SharedRecipientsList.jsx +1 -1
- package/src/SharedStatus.jsx +1 -1
- package/src/SharingBanner/components/PublicBanner.jsx +1 -2
- package/src/SharingBanner/components/PublicBanner.spec.jsx +5 -3
- package/src/SharingBanner/components/SharingBanner.jsx +1 -1
- package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
- package/src/SharingBanner/hooks/useSharingInfos.spec.js +1 -1
- package/src/SharingBanner/index.jsx +3 -3
- package/src/SharingBanner/test/AppLike.jsx +7 -7
- package/src/SharingDetailsModal.jsx +3 -3
- package/src/SharingOwnerAvatar.jsx +1 -1
- package/src/SharingProvider.jsx +9 -9
- package/src/SharingProvider.spec.jsx +5 -5
- package/src/components/ConfirmTrustedRecipientsDialog.jsx +1 -1
- package/src/components/ContactSuggestion.jsx +4 -4
- package/src/components/ContactSuggestion.spec.jsx +2 -2
- package/src/components/CozyPassFingerprintDialogContent.jsx +4 -5
- package/src/components/CozyPassFingerprintDialogContent.spec.jsx +2 -2
- package/src/components/EditLinkPermissionDialog.jsx +5 -5
- package/src/components/EditLinkPermissionDialog.spec.jsx +3 -2
- package/src/components/EditableSharingModal.jsx +4 -3
- package/src/components/EditableSharingModal.spec.jsx +4 -4
- package/src/components/Recipient/AvatarPlusX.jsx +2 -2
- package/src/components/Recipient/Identity.jsx +2 -2
- package/src/components/Recipient/LinkRecipient.jsx +8 -8
- package/src/components/Recipient/LinkRecipientPermissions.jsx +5 -6
- package/src/components/Recipient/OwnerIdentity.jsx +1 -1
- package/src/components/Recipient/OwnerRecipient.jsx +2 -2
- package/src/components/Recipient/Recipient.jsx +6 -6
- package/src/components/Recipient/Recipient.spec.jsx +4 -2
- package/src/components/Recipient/RecipientAvatar.jsx +1 -1
- package/src/components/Recipient/RecipientConfirm.jsx +2 -2
- package/src/components/Recipient/RecipientPermissions.jsx +6 -6
- package/src/components/Recipient/RecipientPlusX.jsx +2 -2
- package/src/components/Recipient/RecipientStatus.jsx +3 -3
- package/src/components/Recipient/RecipientWithoutStatus.jsx +1 -1
- package/src/components/Recipient/RecipientsAvatars.jsx +3 -3
- package/src/components/Recipient/RecipientsAvatars.spec.jsx +2 -1
- package/src/components/ShareAutosuggest.jsx +5 -6
- package/src/components/ShareAutosuggest.spec.jsx +1 -1
- package/src/components/ShareButton.jsx +4 -4
- package/src/components/ShareByEmail.jsx +6 -7
- package/src/components/ShareByEmail.spec.jsx +3 -2
- package/src/components/ShareByLink.jsx +8 -7
- package/src/components/ShareDialogCozyToCozy.jsx +4 -5
- package/src/components/ShareDialogCozyToCozy.spec.jsx +5 -3
- package/src/components/ShareDialogOnlyByLink.jsx +2 -1
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +2 -1
- package/src/components/ShareDialogTwoStepsConfirmationContainer.spec.jsx +5 -3
- package/src/components/ShareModal.jsx +3 -3
- package/src/components/ShareModal.spec.js +4 -2
- package/src/components/ShareRecipientsInput.jsx +2 -2
- package/src/components/ShareRecipientsInput.spec.jsx +1 -1
- package/src/components/SharedBadge.jsx +4 -3
- package/src/components/SharedDocuments.jsx +3 -2
- package/src/components/SharedStatus.jsx +4 -3
- package/src/components/SharedStatus.spec.js +2 -1
- package/src/components/Sharesubmit.jsx +2 -1
- package/src/components/Sharetypeselect.jsx +5 -7
- package/src/components/Tooltip.jsx +2 -1
- package/src/components/WhoHasAccess.jsx +6 -5
- package/src/components/WhoHasAccessLight.jsx +3 -3
- package/src/components/useFetchDocumentPath.jsx +1 -0
- package/src/getSharedDocument.js +13 -5
- package/src/getSharedDocument.spec.js +26 -5
- package/src/helpers/permissions.js +1 -0
- package/src/helpers/sharings.js +1 -2
- package/src/helpers/successMessage.js +2 -1
- package/src/index.jsx +1 -1
- package/src/state.js +2 -6
- package/src/state.spec.js +0 -1
- package/src/withLocales.jsx +1 -0
- package/test/AppLike.jsx +2 -2
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import PropTypes from 'prop-types'
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
5
4
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
6
5
|
import List from 'cozy-ui/transpiled/react/MuiCozyTheme/List'
|
|
7
6
|
|
|
8
|
-
import
|
|
9
|
-
import { usePrevious } from '../helpers/hooks'
|
|
7
|
+
import LinkRecipient from './Recipient/LinkRecipient'
|
|
10
8
|
import OwnerRecipient from './Recipient/OwnerRecipient'
|
|
9
|
+
import Recipient from './Recipient/Recipient'
|
|
10
|
+
import { usePrevious } from '../helpers/hooks'
|
|
11
|
+
import { filterAndReworkRecipients } from '../helpers/recipients'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Displays a warning if some contacts are waiting for confirmation of their sharing
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import cx from 'classnames'
|
|
3
|
-
import
|
|
4
|
-
import RecipientPlusX from './Recipient/RecipientPlusX'
|
|
2
|
+
import React from 'react'
|
|
5
3
|
|
|
4
|
+
import RecipientPlusX from './Recipient/RecipientPlusX'
|
|
5
|
+
import RecipientWithoutStatus from './Recipient/RecipientWithoutStatus'
|
|
6
6
|
import styles from './recipient.styl'
|
|
7
7
|
|
|
8
8
|
const MAX_DISPLAYED_RECIPIENTS = 2
|
package/src/getSharedDocument.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isReadOnly } from 'cozy-client/dist/models/permission'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Get the first shared document for the current shared token
|
|
5
|
+
*
|
|
6
|
+
* @param {CozyClient} client
|
|
7
|
+
* @returns {{id, isReadOnly}} id of the document and the readOnly status
|
|
8
|
+
*/
|
|
3
9
|
const getSharedDocument = async client => {
|
|
4
10
|
const { data: permissionsData } = await client
|
|
5
11
|
.collection('io.cozy.permissions')
|
|
6
12
|
.getOwnPermissions()
|
|
7
13
|
|
|
8
|
-
const permissions = permissionsData.attributes.permissions
|
|
14
|
+
const permissions = Object.values(permissionsData.attributes.permissions)
|
|
9
15
|
// permissions contains several named keys, but the one to use depends on the situation. Using the first one is what we want in all known cases.
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
const perm = permissions[0]
|
|
17
|
+
return {
|
|
18
|
+
id: perm.values[0],
|
|
19
|
+
isReadOnly: isReadOnly(perm)
|
|
20
|
+
}
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
export default getSharedDocument
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import getSharedDocument from './getSharedDocument'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
function setupClient(verbs = []) {
|
|
4
|
+
return {
|
|
5
5
|
collection: () => ({
|
|
6
6
|
getOwnPermissions: jest.fn().mockReturnValue({
|
|
7
7
|
data: {
|
|
@@ -9,14 +9,14 @@ describe('Getting the shared document id', () => {
|
|
|
9
9
|
permissions: {
|
|
10
10
|
collection: {
|
|
11
11
|
type: 'io.cozy.photos.albums',
|
|
12
|
-
verbs
|
|
12
|
+
verbs,
|
|
13
13
|
values: ['myshareid']
|
|
14
14
|
},
|
|
15
15
|
files: {
|
|
16
16
|
selector: 'referenced_by',
|
|
17
17
|
type: 'io.cozy.files',
|
|
18
18
|
values: ['io.cozy.photos.albums/myshareid'],
|
|
19
|
-
verbs
|
|
19
|
+
verbs
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -24,9 +24,30 @@ describe('Getting the shared document id', () => {
|
|
|
24
24
|
})
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
|
+
}
|
|
27
28
|
|
|
29
|
+
describe('Getting the shared document', () => {
|
|
28
30
|
it('should get the id', async () => {
|
|
29
|
-
const
|
|
31
|
+
const client = setupClient(['GET'])
|
|
32
|
+
const { id } = await getSharedDocument(client)
|
|
30
33
|
expect(id).toEqual('myshareid')
|
|
31
34
|
})
|
|
35
|
+
|
|
36
|
+
it('should return isReadOnly is true when we have only a GET permission', async () => {
|
|
37
|
+
const client = setupClient(['GET'])
|
|
38
|
+
const { isReadOnly } = await getSharedDocument(client)
|
|
39
|
+
expect(isReadOnly).toBeTruthy()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should return isReadOnly is false when we have an ALL permission', async () => {
|
|
43
|
+
const client = setupClient(['ALL'])
|
|
44
|
+
const { isReadOnly } = await getSharedDocument(client)
|
|
45
|
+
expect(isReadOnly).toBeFalsy()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should return isReadOnly is false when we have a PATCH permission', async () => {
|
|
49
|
+
const client = setupClient(['GET', 'PATCH', 'PUT'])
|
|
50
|
+
const { isReadOnly } = await getSharedDocument(client)
|
|
51
|
+
expect(isReadOnly).toBeFalsy()
|
|
52
|
+
})
|
|
32
53
|
})
|
package/src/helpers/sharings.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Q } from 'cozy-client'
|
|
2
2
|
|
|
3
|
+
import { fetchFilesPaths } from './files'
|
|
3
4
|
import {
|
|
4
5
|
updateInternalObjectFromRealtime,
|
|
5
6
|
normalizeDocFromRealtime
|
|
6
7
|
} from './realtime'
|
|
7
|
-
|
|
8
8
|
import { addSharing, updateSharing } from '../state'
|
|
9
|
-
import { fetchFilesPaths } from './files'
|
|
10
9
|
|
|
11
10
|
export const getSharingObject = (internalSharing, sharing) => {
|
|
12
11
|
if (internalSharing) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Contact } from '../models'
|
|
2
1
|
import { models } from 'cozy-client'
|
|
2
|
+
|
|
3
|
+
import { Contact } from '../models'
|
|
3
4
|
export const countNewRecipients = (currentRecipients, newRecipients) => {
|
|
4
5
|
return newRecipients.filter(contact => {
|
|
5
6
|
const email = models.contact.getPrimaryEmail(contact)
|
package/src/index.jsx
CHANGED
package/src/state.js
CHANGED
|
@@ -349,18 +349,14 @@ const getApps = state => state.apps
|
|
|
349
349
|
|
|
350
350
|
export const hasSharedParent = (state, documentPath) => {
|
|
351
351
|
if (!state.sharedPaths) {
|
|
352
|
-
//
|
|
353
|
-
console.log('hasSharedParent should not occur', state, documentPath)
|
|
354
|
-
return false
|
|
352
|
+
return false // hasSharedParent should not occur
|
|
355
353
|
}
|
|
356
354
|
return state.sharedPaths.some(path => documentPath.indexOf(`${path}/`) === 0)
|
|
357
355
|
}
|
|
358
356
|
|
|
359
357
|
export const hasSharedChild = (state, documentPath) => {
|
|
360
358
|
if (!state.sharedPaths) {
|
|
361
|
-
//
|
|
362
|
-
console.log('hasSharedChild should not occur', state, documentPath)
|
|
363
|
-
return false
|
|
359
|
+
return false // hasSharedChild should not occur
|
|
364
360
|
}
|
|
365
361
|
const ret = state.sharedPaths.some(
|
|
366
362
|
path => path.indexOf(`${documentPath}/`) === 0
|
package/src/state.spec.js
CHANGED
package/src/withLocales.jsx
CHANGED
package/test/AppLike.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
|
|
4
|
-
import { I18n } from 'cozy-ui/transpiled/react/I18n'
|
|
5
3
|
import { CozyProvider, createMockClient } from 'cozy-client'
|
|
4
|
+
import { I18n } from 'cozy-ui/transpiled/react/I18n'
|
|
5
|
+
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
|
|
6
6
|
|
|
7
7
|
import langEn from '../locales/en.json'
|
|
8
8
|
|