cozy-sharing 6.0.3 → 6.0.5

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 (43) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/SharingBanner/hooks/useSharingInfos.js +35 -37
  3. package/dist/SharingBanner/hooks/useSharingInfos.spec.js +40 -44
  4. package/dist/SharingProvider.js +351 -375
  5. package/dist/SharingProvider.spec.js +29 -33
  6. package/dist/components/CozyPassFingerprintDialogContent.spec.js +14 -16
  7. package/dist/components/Recipient/LinkRecipientPermissions.js +25 -27
  8. package/dist/components/Recipient/OwnerRecipient.js +22 -0
  9. package/dist/components/Recipient/OwnerRecipientDefault.js +20 -0
  10. package/dist/components/Recipient/Recipient.spec.js +39 -43
  11. package/dist/components/Recipient/RecipientPermissions.js +20 -22
  12. package/dist/components/Recipient/RecipientStatus.js +1 -1
  13. package/dist/components/ShareButton.js +0 -2
  14. package/dist/components/ShareByEmail.js +53 -55
  15. package/dist/components/ShareByEmail.spec.js +50 -52
  16. package/dist/components/ShareByLink.js +73 -79
  17. package/dist/components/ShareDialogCozyToCozy.spec.js +250 -269
  18. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +33 -35
  19. package/dist/components/ShareDialogTwoStepsConfirmationContainer.spec.js +240 -266
  20. package/dist/components/SharedBadge.js +0 -2
  21. package/dist/components/WhoHasAccess.js +3 -13
  22. package/dist/components/badge.styl +7 -5
  23. package/dist/components/button.styl +11 -12
  24. package/dist/components/useFetchDocumentPath.js +16 -18
  25. package/dist/fetchNextPermissions.js +15 -17
  26. package/dist/getSharedDocument.js +13 -15
  27. package/dist/getSharedDocument.spec.js +10 -12
  28. package/dist/helpers/contacts.js +65 -69
  29. package/dist/helpers/contacts.spec.js +30 -32
  30. package/dist/helpers/files.js +26 -28
  31. package/dist/helpers/files.spec.js +54 -58
  32. package/dist/helpers/sharings.js +56 -60
  33. package/dist/helpers/synchronousJobQueue.js +19 -21
  34. package/dist/helpers/synchronousJobQueue.spec.js +39 -43
  35. package/dist/stylesheet.css +28 -820
  36. package/package.json +2 -2
  37. package/src/components/Recipient/OwnerRecipient.jsx +23 -0
  38. package/src/components/Recipient/OwnerRecipientDefault.jsx +29 -0
  39. package/src/components/Recipient/RecipientStatus.jsx +1 -1
  40. package/src/components/ShareDialogCozyToCozy.spec.jsx +19 -18
  41. package/src/components/WhoHasAccess.jsx +2 -20
  42. package/src/components/badge.styl +7 -5
  43. package/src/components/button.styl +11 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "6.0.3",
3
+ "version": "6.0.5",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -61,5 +61,5 @@
61
61
  "sideEffects": [
62
62
  "*.css"
63
63
  ],
64
- "gitHead": "d999a80061d173dcf25e6715cad4db1cb032f38f"
64
+ "gitHead": "5198837dbb9f5ee395cbb67746b749ecd1121e45"
65
65
  }
@@ -0,0 +1,23 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import Recipient from './Recipient'
5
+ import OwnerRecipientDefault from './OwnerRecipientDefault'
6
+
7
+ const OwnerRecipient = ({ recipients }) => {
8
+ const ownerRecipient = recipients.find(
9
+ recipient => recipient.status === 'owner'
10
+ )
11
+
12
+ if (ownerRecipient) {
13
+ return <Recipient {...ownerRecipient} />
14
+ }
15
+
16
+ return <OwnerRecipientDefault />
17
+ }
18
+
19
+ OwnerRecipient.propTypes = {
20
+ recipients: PropTypes.array.isRequired
21
+ }
22
+
23
+ export default OwnerRecipient
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+
3
+ import { useClient, useQuery, hasQueryBeenLoaded } from 'cozy-client'
4
+
5
+ import Recipient from './Recipient'
6
+ import { buildInstanceSettingsQuery } from '../../queries/queries'
7
+
8
+ const OwnerRecipientDefault = () => {
9
+ const client = useClient()
10
+
11
+ const instanceSettingsQuery = buildInstanceSettingsQuery()
12
+ const instanceSettingsResult = useQuery(
13
+ instanceSettingsQuery.definition,
14
+ instanceSettingsQuery.options
15
+ )
16
+
17
+ return (
18
+ hasQueryBeenLoaded(instanceSettingsResult) && (
19
+ <Recipient
20
+ isOwner={true}
21
+ status="owner"
22
+ instance={client.options.uri}
23
+ public_name={instanceSettingsResult?.data?.attributes?.public_name}
24
+ />
25
+ )
26
+ )
27
+ }
28
+
29
+ export default OwnerRecipientDefault
@@ -14,7 +14,7 @@ const RecipientStatus = ({ status, isMe, instance }) => {
14
14
  const { t } = useI18n()
15
15
 
16
16
  const isSendingEmail = !isMe && status === 'mail-not-sent'
17
- const isReady = isMe || status === 'ready'
17
+ const isReady = isMe || status === 'ready' || status === 'owner'
18
18
  let text, icon
19
19
  if (isReady) {
20
20
  text = instance
@@ -8,7 +8,8 @@ import { act, render, fireEvent } from '@testing-library/react'
8
8
  jest.mock('cozy-client', () => ({
9
9
  ...jest.requireActual('cozy-client'),
10
10
  useQuery: jest.fn().mockReturnValue({ data: { public_name: 'Alice' } }),
11
- hasQueryBeenLoaded: jest.fn().mockReturnValue(true)
11
+ hasQueryBeenLoaded: jest.fn().mockReturnValue(true),
12
+ useClient: () => ({ options: { uri: mockRecipientAlice.instance } })
12
13
  }))
13
14
 
14
15
  describe('ShareDialogCozyToCozy', () => {
@@ -54,9 +55,9 @@ describe('ShareDialogCozyToCozy', () => {
54
55
  await act(async () => {
55
56
  resolve([
56
57
  {
57
- name: recipientBob.public_name,
58
+ name: mockRecipientBob.public_name,
58
59
  id: 'SOME_ID',
59
- email: recipientBob.email
60
+ email: mockRecipientBob.email
60
61
  }
61
62
  ])
62
63
  await promise
@@ -81,9 +82,9 @@ describe('ShareDialogCozyToCozy', () => {
81
82
  await act(async () => {
82
83
  resolve([
83
84
  {
84
- name: recipientBob.public_name,
85
+ name: mockRecipientBob.public_name,
85
86
  id: 'SOME_ID',
86
- email: recipientBob.email
87
+ email: mockRecipientBob.email
87
88
  }
88
89
  ])
89
90
  await promise
@@ -111,14 +112,14 @@ describe('ShareDialogCozyToCozy', () => {
111
112
  await act(async () => {
112
113
  resolve([
113
114
  {
114
- name: recipientBob.public_name,
115
+ name: mockRecipientBob.public_name,
115
116
  id: 'SOME_ID',
116
- email: recipientBob.email
117
+ email: mockRecipientBob.email
117
118
  },
118
119
  {
119
- name: recipientClaude.public_name,
120
+ name: mockRecipientClaude.public_name,
120
121
  id: 'SOME_OTHER_ID',
121
- email: recipientClaude.email
122
+ email: mockRecipientClaude.email
122
123
  }
123
124
  ])
124
125
  await promise
@@ -173,9 +174,9 @@ describe('ShareDialogCozyToCozy', () => {
173
174
  await act(async () => {
174
175
  resolve([
175
176
  {
176
- name: recipientBob.public_name,
177
+ name: mockRecipientBob.public_name,
177
178
  id: 'SOME_ID',
178
- email: recipientBob.email,
179
+ email: mockRecipientBob.email,
179
180
  fingerprintPhrase: 'SOME_FINGERPRINT_PHRASE'
180
181
  }
181
182
  ])
@@ -192,7 +193,7 @@ describe('ShareDialogCozyToCozy', () => {
192
193
 
193
194
  expect(
194
195
  getByText(
195
- `Do you really want to reject contact ${recipientBob.public_name} (${recipientBob.email})?`
196
+ `Do you really want to reject contact ${mockRecipientBob.public_name} (${mockRecipientBob.email})?`
196
197
  )
197
198
  ).toBeTruthy()
198
199
 
@@ -203,7 +204,7 @@ describe('ShareDialogCozyToCozy', () => {
203
204
  })
204
205
  })
205
206
 
206
- const recipientAlice = {
207
+ const mockRecipientAlice = {
207
208
  status: 'owner',
208
209
  public_name: 'Alice',
209
210
  email: 'me@alice.cozy.localhost',
@@ -214,7 +215,7 @@ const recipientAlice = {
214
215
  avatarPath: '/sharings/SOME_SHARING_ID/recipients/0/avatar'
215
216
  }
216
217
 
217
- const recipientBob = {
218
+ const mockRecipientBob = {
218
219
  status: 'ready',
219
220
  public_name: 'Claude',
220
221
  email: 'me@claude.cozy.localhost',
@@ -225,7 +226,7 @@ const recipientBob = {
225
226
  avatarPath: '/sharings/SOME_SHARING_ID/recipients/1/avatar'
226
227
  }
227
228
 
228
- const recipientClaude = {
229
+ const mockRecipientClaude = {
229
230
  status: 'ready',
230
231
  public_name: 'Bob',
231
232
  email: 'me@bob.cozy.localhost',
@@ -333,9 +334,9 @@ const getMockProps = () => {
333
334
  link: null,
334
335
  permissions: [],
335
336
  recipients: [
336
- recipientAlice,
337
- recipientBob,
338
- recipientClaude,
337
+ mockRecipientAlice,
338
+ mockRecipientBob,
339
+ mockRecipientClaude,
339
340
  {
340
341
  status: 'pending',
341
342
  email: 'me@ben.cozy.localhost',
@@ -1,14 +1,13 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
- import { useClient, useQuery, hasQueryBeenLoaded } from 'cozy-client'
4
3
  import Recipient from './Recipient/Recipient'
5
4
  import LinkRecipient from './Recipient/LinkRecipient'
6
5
  import { useI18n } from 'cozy-ui/transpiled/react/I18n'
7
6
  import List from 'cozy-ui/transpiled/react/MuiCozyTheme/List'
8
7
 
9
- import { buildInstanceSettingsQuery } from '../queries/queries'
10
8
  import { filterAndReworkRecipients } from '../helpers/recipients'
11
9
  import { usePrevious } from '../helpers/hooks'
10
+ import OwnerRecipient from './Recipient/OwnerRecipient'
12
11
 
13
12
  /**
14
13
  * Displays a warning if some contacts are waiting for confirmation of their sharing
@@ -42,14 +41,6 @@ const WhoHasAccess = ({
42
41
  onUpdateShareLinkPermissions,
43
42
  onRevokeLink
44
43
  }) => {
45
- const client = useClient()
46
-
47
- const instanceSettingsQuery = buildInstanceSettingsQuery()
48
- const instanceSettingsResult = useQuery(
49
- instanceSettingsQuery.definition,
50
- instanceSettingsQuery.options
51
- )
52
-
53
44
  const previousLink = usePrevious(link)
54
45
  const previousRecipients = usePrevious(recipients)
55
46
 
@@ -60,8 +51,6 @@ const WhoHasAccess = ({
60
51
  previousRecipients
61
52
  )
62
53
 
63
- const public_name = instanceSettingsResult?.data?.attributes?.public_name
64
-
65
54
  return (
66
55
  <div className={className}>
67
56
  <RecipientWaitingForConfirmationAlert
@@ -82,14 +71,7 @@ const WhoHasAccess = ({
82
71
  />
83
72
  )}
84
73
 
85
- {hasQueryBeenLoaded(instanceSettingsResult) && (
86
- <Recipient
87
- isOwner={true}
88
- status="owner"
89
- instance={client.options.uri}
90
- public_name={public_name}
91
- />
92
- )}
74
+ <OwnerRecipient recipients={recipients} />
93
75
 
94
76
  {recipientsToDisplay.map(recipient => {
95
77
  const recipientConfirmationData = recipientsToBeConfirmed.find(
@@ -1,4 +1,4 @@
1
- @require 'settings/palette.styl'
1
+ palette=json('settings/palette.json', { hash: true })
2
2
 
3
3
  .shared-badge
4
4
  display flex
@@ -8,7 +8,8 @@
8
8
  background-clip padding-box
9
9
 
10
10
  &.--small
11
- border .125rem solid var(--white)
11
+ border .125rem solid
12
+ border-color: palette['white']
12
13
  width 1.5rem
13
14
  height 1.5rem
14
15
 
@@ -17,7 +18,8 @@
17
18
  height .75rem
18
19
 
19
20
  &.--xsmall
20
- border .0625rem solid var(--white)
21
+ border .0625rem solid
22
+ border-color: palette['white']
21
23
  width .75rem
22
24
  height .75rem
23
25
 
@@ -26,7 +28,7 @@
26
28
  height .375rem
27
29
 
28
30
  &.--by-me
29
- background-color var(--emerald)
31
+ background-color: palette['emerald']
30
32
 
31
33
  &.--with-me
32
- background-color #9169F2
34
+ background-color: palette['portage']
@@ -1,23 +1,22 @@
1
- @require 'settings/palette.styl'
2
-
1
+ palette=json('settings/palette.json', { hash: true })
3
2
  .coz-btn-shared
4
- border-color var(--emerald)
5
- background-color var(--emerald)
6
- color var(--white)
3
+ border-color: palette['emerald']
4
+ background-color: palette['emerald']
5
+ color: palette['white']
7
6
  transition all .2s ease-out
8
7
 
9
8
  &:focus
10
9
  &:not([disabled]):not([aria-disabled=true]):hover
11
- border-color var(--malachite)
12
- background-color var(--malachite)
10
+ border-color: palette['malachite']
11
+ background-color: palette['malachite']
13
12
 
14
13
  .coz-btn-sharedWithMe
15
- border-color var(--lightishPurple)
16
- background-color var(--lightishPurple)
17
- color var(--white)
14
+ border-color: palette['lightishPurple']
15
+ background-color: palette['lightishPurple']
16
+ color: palette['white']
18
17
  transition all .2s ease-out
19
18
 
20
19
  &:focus
21
20
  &:not([disabled]):not([aria-disabled=true]):hover
22
- border-color var(--barney)
23
- background-color var(--barney)
21
+ border-color: palette['barney']
22
+ background-color: palette['barney']