cozy-sharing 32.3.1 → 33.0.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 +22 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +56 -19
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +101 -254
- package/dist/components/Recipient/RecipientList.js +0 -15
- package/dist/components/ShareModal/ShareModal.js +8 -8
- package/dist/components/SharedDrive/EditSharedDriveModal.js +32 -55
- package/dist/components/SharedDrive/SharedDriveForm.js +23 -5
- package/dist/components/SharedDrive/useSharedDrive.js +8 -37
- package/dist/components/SharedDrive/useSharedDrive.spec.js +8 -81
- package/dist/components/WhoHasAccess.js +4 -1
- package/dist/state.js +6 -1
- package/package.json +4 -4
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +65 -19
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +28 -150
- package/src/components/Recipient/RecipientList.jsx +0 -18
- package/src/components/ShareModal/ShareModal.jsx +5 -5
- package/src/components/SharedDrive/EditSharedDriveModal.jsx +42 -47
- package/src/components/SharedDrive/SharedDriveForm.jsx +18 -2
- package/src/components/SharedDrive/useSharedDrive.js +15 -35
- package/src/components/SharedDrive/useSharedDrive.spec.js +4 -39
- package/src/components/WhoHasAccess.jsx +3 -1
- package/src/state.js +5 -1
- package/.claude/settings.local.json +0 -27
- package/AGENTS.md +0 -7
- package/dist/RefreshableSharings.spec.js +0 -40
- package/dist/assets/illustrations/illustration-shared-drives.svg +0 -1
- package/dist/components/EditLinkPermissionDialog.js +0 -72
- package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +0 -65
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.spec.js +0 -107
- package/dist/components/FederatedFolder/FederatedFolderModal.jsx.tmp.179197.1773939270471 +0 -172
- package/dist/components/Recipient/actions/revokeGroup.js +0 -42
- package/dist/components/Recipient/actions/revokeMember.js +0 -42
- package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
- package/dist/components/ShareModal/ShareModal copy.js +0 -43
- package/dist/components/ShareModal/ShareModal.spec.js +0 -197
- package/dist/components/ShareModal/ShareModalBatchContainer.js +0 -276
- package/dist/components/ShareModal/ShareModalBatchContainer.spec.js +0 -131
- package/dist/components/ShareModal/SharedDriveEditModal.js +0 -59
- package/dist/components/SharedDrive/DumbSharedDriveModal.js +0 -78
- package/dist/components/SharedDrive/DumbSharedDriveModal.spec.js +0 -126
- package/dist/components/SharedDrive/SharedDriveEditModal.js +0 -110
- package/dist/components/SharedDrive/SharedDriveModal copy.js +0 -356
- package/dist/components/SharedDrive/SharedDriveRecipient.js +0 -61
- package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +0 -109
- package/dist/components/SharedDrive/SharedDriveRecipientStatus.js +0 -22
- package/dist/components/SharedDrive/helpers.js +0 -102
- package/dist/components/SharedDrive/helpers.spec.js +0 -208
- package/dist/components/SharedDriveEditModal.js +0 -43
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +0 -145
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.spec.js +0 -321
- package/dist/components/SharedStatus.js +0 -61
- package/dist/components/SharedStatus.spec.js +0 -44
- package/dist/components/Sharesubmit.js +0 -28
- package/dist/components/__snapshots__/SharedStatus.spec.js.snap +0 -94
- package/dist/helpers/owner.js +0 -14
- package/dist/helpers/owner.spec.js +0 -34
- package/dist/hooks/useConfirmDiscardChanges.js +0 -33
- package/dist/hooks/useContactsAndGroups.js +0 -65
- package/dist/hooks/useSharedDrive.js +0 -130
- package/dist/hooks/useSharedDriveContactsAndGroups.js +0 -65
- package/dist/propTypes.js +0 -26
- package/dist/styles/shareddrive.styl +0 -8
- package/src/components/SharedDrive/SharedDriveRecipient.jsx +0 -62
- package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +0 -78
- package/src/components/SharedDrive/SharedDriveRecipientStatus.jsx +0 -23
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +0 -161
|
@@ -3,6 +3,8 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { useClient } from 'cozy-client'
|
|
5
5
|
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
6
|
+
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
7
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
6
8
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
|
|
7
9
|
import ConfirmDialogProvider, {
|
|
8
10
|
useConfirmDialog
|
|
@@ -13,7 +15,10 @@ import { getOrCreateFromArray } from '../../helpers/contacts'
|
|
|
13
15
|
import withLocales from '../../hoc/withLocales'
|
|
14
16
|
import { usePendingRecipients } from '../../hooks/usePendingRecipients'
|
|
15
17
|
import { useSharingContext } from '../../hooks/useSharingContext'
|
|
16
|
-
import
|
|
18
|
+
import AntivirusAlert from '../AntivirusAlert'
|
|
19
|
+
import { default as DumbShareByEmail } from '../ShareByEmail'
|
|
20
|
+
import ShareByLink from '../ShareByLink'
|
|
21
|
+
import WhoHasAccess from '../WhoHasAccess'
|
|
17
22
|
|
|
18
23
|
const FederatedFolderModalContent = ({
|
|
19
24
|
onClose,
|
|
@@ -121,7 +126,7 @@ const FederatedFolderModalContent = ({
|
|
|
121
126
|
const folderName = existingDocument?.name || ''
|
|
122
127
|
|
|
123
128
|
const onSend = async () => {
|
|
124
|
-
if (pendingRecipients.length === 0) {
|
|
129
|
+
if (isSending || pendingRecipients.length === 0) {
|
|
125
130
|
onClose()
|
|
126
131
|
return
|
|
127
132
|
}
|
|
@@ -171,26 +176,67 @@ const FederatedFolderModalContent = ({
|
|
|
171
176
|
: []
|
|
172
177
|
|
|
173
178
|
const modalTitle = t('FederatedFolder.shareTitle', { name: folderName })
|
|
174
|
-
const isSharedDrive = Boolean(existingDocument?.driveId)
|
|
175
179
|
|
|
176
180
|
return (
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
recipients={isSending ? frozenRecipients : existingRecipients}
|
|
181
|
-
currentRecipients={isSending ? frozenRecipients : existingRecipients}
|
|
182
|
-
onRevoke={revoke}
|
|
183
|
-
onSend={onSend}
|
|
181
|
+
<FixedDialog
|
|
182
|
+
open
|
|
183
|
+
disableGutters
|
|
184
184
|
onClose={handleCloseRequest}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
title={modalTitle}
|
|
186
|
+
classes={{ paper: 'u-ov-visible' }}
|
|
187
|
+
componentsProps={{
|
|
188
|
+
dialogContent: { className: 'u-ov-visible' }
|
|
189
|
+
}}
|
|
190
|
+
content={
|
|
191
|
+
<div>
|
|
192
|
+
<div className="u-ph-2">
|
|
193
|
+
<AntivirusAlert
|
|
194
|
+
document={isSending ? frozenDoc : existingDocument}
|
|
195
|
+
/>
|
|
196
|
+
<Typography variant="h6" className="u-mt-1-half u-mb-half">
|
|
197
|
+
{t('Share.contacts.addUsers')}
|
|
198
|
+
</Typography>
|
|
199
|
+
<DumbShareByEmail
|
|
200
|
+
currentRecipients={
|
|
201
|
+
isSending ? frozenRecipients : existingRecipients
|
|
202
|
+
}
|
|
203
|
+
document={isSending ? frozenDoc : existingDocument}
|
|
204
|
+
documentType="Files"
|
|
205
|
+
pendingRecipients={pendingRecipients}
|
|
206
|
+
onPendingRecipientsChange={setPendingRecipients}
|
|
207
|
+
selectedOption={selectedOption}
|
|
208
|
+
onSelectedOptionChange={setSelectedOption}
|
|
209
|
+
/>
|
|
210
|
+
</div>
|
|
211
|
+
<WhoHasAccess
|
|
212
|
+
isOwner
|
|
213
|
+
isSharedDrive
|
|
214
|
+
recipients={isSending ? frozenRecipients : existingRecipients}
|
|
215
|
+
document={isSending ? frozenDoc : existingDocument}
|
|
216
|
+
documentType="Files"
|
|
217
|
+
className="u-w-100"
|
|
218
|
+
onRevoke={revoke}
|
|
219
|
+
link={sharingLink}
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
}
|
|
223
|
+
actions={
|
|
224
|
+
<>
|
|
225
|
+
<ShareByLink
|
|
226
|
+
link={sharingLink}
|
|
227
|
+
document={isSending ? frozenDoc : existingDocument}
|
|
228
|
+
documentType="Files"
|
|
229
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
230
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
231
|
+
/>
|
|
232
|
+
<Button
|
|
233
|
+
variant="primary"
|
|
234
|
+
label={t('FederatedFolder.share')}
|
|
235
|
+
disabled={isSending}
|
|
236
|
+
onClick={onSend}
|
|
237
|
+
/>
|
|
238
|
+
</>
|
|
239
|
+
}
|
|
194
240
|
/>
|
|
195
241
|
)
|
|
196
242
|
}
|
|
@@ -41,41 +41,6 @@ jest.mock('../../hooks/usePendingRecipients', () => ({
|
|
|
41
41
|
usePendingRecipients: jest.fn()
|
|
42
42
|
}))
|
|
43
43
|
|
|
44
|
-
jest.mock('../SharedFolder/DumbBatchSharedFolderModal', () => ({
|
|
45
|
-
DumbBatchSharedFolderModal: ({
|
|
46
|
-
title,
|
|
47
|
-
recipients,
|
|
48
|
-
onRevoke,
|
|
49
|
-
onSend,
|
|
50
|
-
onClose,
|
|
51
|
-
sharingLink,
|
|
52
|
-
pendingRecipients,
|
|
53
|
-
selectedOption
|
|
54
|
-
}) => (
|
|
55
|
-
<div data-testid="dumb-modal">
|
|
56
|
-
<span data-testid="title">{title}</span>
|
|
57
|
-
<span data-testid="sharing-link">{sharingLink}</span>
|
|
58
|
-
<span data-testid="recipients-count">{recipients.length}</span>
|
|
59
|
-
<span data-testid="pending-recipients-count">
|
|
60
|
-
{pendingRecipients.length}
|
|
61
|
-
</span>
|
|
62
|
-
<span data-testid="selected-option">{selectedOption}</span>
|
|
63
|
-
<button data-testid="btn-send" onClick={onSend}>
|
|
64
|
-
Send
|
|
65
|
-
</button>
|
|
66
|
-
<button
|
|
67
|
-
data-testid="btn-revoke"
|
|
68
|
-
onClick={() => onRevoke({ _id: 'folder-123' }, 'abc', 1)}
|
|
69
|
-
>
|
|
70
|
-
Revoke
|
|
71
|
-
</button>
|
|
72
|
-
<button data-testid="btn-close" onClick={onClose}>
|
|
73
|
-
Close
|
|
74
|
-
</button>
|
|
75
|
-
</div>
|
|
76
|
-
)
|
|
77
|
-
}))
|
|
78
|
-
|
|
79
44
|
const mockDocument = {
|
|
80
45
|
_id: 'folder-123',
|
|
81
46
|
name: 'My Test Folder',
|
|
@@ -145,46 +110,22 @@ describe('FederatedFolderModal', () => {
|
|
|
145
110
|
|
|
146
111
|
describe('initialization', () => {
|
|
147
112
|
it('should pass document name as title', async () => {
|
|
148
|
-
const {
|
|
113
|
+
const { findByText } = setup()
|
|
149
114
|
|
|
150
|
-
await
|
|
151
|
-
expect(getByTestId('title').textContent).toBe('Share "My Test Folder"')
|
|
152
|
-
})
|
|
115
|
+
await findByText('Share "My Test Folder"')
|
|
153
116
|
})
|
|
154
117
|
|
|
155
118
|
it('should pass default title when document has no name', async () => {
|
|
156
119
|
const documentWithoutName = { _id: 'folder-456', path: '/test' }
|
|
157
|
-
const {
|
|
158
|
-
|
|
159
|
-
await waitFor(() => {
|
|
160
|
-
expect(getByTestId('title').textContent).toBe('Share ""')
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
it('should pass sharing link to DumbBatchSharedFolderModal', async () => {
|
|
165
|
-
const { getByTestId } = setup()
|
|
166
|
-
|
|
167
|
-
await waitFor(() => {
|
|
168
|
-
expect(getByTestId('sharing-link').textContent).toBe(
|
|
169
|
-
'https://example.com/share/abc123'
|
|
170
|
-
)
|
|
171
|
-
})
|
|
172
|
-
})
|
|
120
|
+
const { findByText } = setup({ document: documentWithoutName })
|
|
173
121
|
|
|
174
|
-
|
|
175
|
-
const { getByTestId } = setup({ document: undefined })
|
|
176
|
-
|
|
177
|
-
await waitFor(() => {
|
|
178
|
-
expect(getByTestId('sharing-link').textContent).toBe('')
|
|
179
|
-
})
|
|
122
|
+
await findByText('Share ""')
|
|
180
123
|
})
|
|
181
124
|
|
|
182
|
-
it('should
|
|
183
|
-
const {
|
|
125
|
+
it('should show Copy link', async () => {
|
|
126
|
+
const { findByText } = setup()
|
|
184
127
|
|
|
185
|
-
await
|
|
186
|
-
expect(getByTestId('selected-option').textContent).toBe('readWrite')
|
|
187
|
-
})
|
|
128
|
+
await findByText('Copy link')
|
|
188
129
|
})
|
|
189
130
|
})
|
|
190
131
|
|
|
@@ -193,13 +134,11 @@ describe('FederatedFolderModal', () => {
|
|
|
193
134
|
|
|
194
135
|
it('should call onClose and skip share when there are no pending recipients', async () => {
|
|
195
136
|
// pendingRecipients defaults to [] via beforeEach
|
|
196
|
-
const {
|
|
137
|
+
const { findByText } = setup()
|
|
197
138
|
|
|
198
|
-
await
|
|
199
|
-
expect(getByTestId('btn-send')).toBeTruthy()
|
|
200
|
-
})
|
|
139
|
+
const sendButton = await findByText('Done')
|
|
201
140
|
|
|
202
|
-
fireEvent.click(
|
|
141
|
+
fireEvent.click(sendButton)
|
|
203
142
|
|
|
204
143
|
await waitFor(() => {
|
|
205
144
|
expect(mockOnClose).toHaveBeenCalled()
|
|
@@ -216,13 +155,11 @@ describe('FederatedFolderModal', () => {
|
|
|
216
155
|
})
|
|
217
156
|
getOrCreateFromArray.mockResolvedValue([pendingRecipient])
|
|
218
157
|
mockShare.mockResolvedValueOnce({})
|
|
219
|
-
const {
|
|
158
|
+
const { findByText } = setup()
|
|
220
159
|
|
|
221
|
-
await
|
|
222
|
-
expect(getByTestId('btn-send')).toBeTruthy()
|
|
223
|
-
})
|
|
160
|
+
const sendButton = await findByText('Done')
|
|
224
161
|
|
|
225
|
-
fireEvent.click(
|
|
162
|
+
fireEvent.click(sendButton)
|
|
226
163
|
|
|
227
164
|
await waitFor(() => {
|
|
228
165
|
expect(mockShare).toHaveBeenCalledWith({
|
|
@@ -245,13 +182,11 @@ describe('FederatedFolderModal', () => {
|
|
|
245
182
|
})
|
|
246
183
|
getOrCreateFromArray.mockResolvedValue([pendingRecipient])
|
|
247
184
|
mockShare.mockResolvedValueOnce({})
|
|
248
|
-
const {
|
|
185
|
+
const { findByText } = setup()
|
|
249
186
|
|
|
250
|
-
await
|
|
251
|
-
expect(getByTestId('btn-send')).toBeTruthy()
|
|
252
|
-
})
|
|
187
|
+
const sendButton = await findByText('Done')
|
|
253
188
|
|
|
254
|
-
fireEvent.click(
|
|
189
|
+
fireEvent.click(sendButton)
|
|
255
190
|
|
|
256
191
|
await waitFor(() => {
|
|
257
192
|
expect(mockShowAlert).toHaveBeenCalledWith({
|
|
@@ -272,13 +207,11 @@ describe('FederatedFolderModal', () => {
|
|
|
272
207
|
})
|
|
273
208
|
getOrCreateFromArray.mockResolvedValue([pendingRecipient])
|
|
274
209
|
mockShare.mockRejectedValueOnce(new Error('Share failed'))
|
|
275
|
-
const {
|
|
210
|
+
const { findByText } = setup()
|
|
276
211
|
|
|
277
|
-
await
|
|
278
|
-
expect(getByTestId('btn-send')).toBeTruthy()
|
|
279
|
-
})
|
|
212
|
+
const sendButton = await findByText('Done')
|
|
280
213
|
|
|
281
|
-
fireEvent.click(
|
|
214
|
+
fireEvent.click(sendButton)
|
|
282
215
|
|
|
283
216
|
await waitFor(() => {
|
|
284
217
|
expect(mockShowAlert).toHaveBeenCalledWith({
|
|
@@ -291,32 +224,13 @@ describe('FederatedFolderModal', () => {
|
|
|
291
224
|
})
|
|
292
225
|
})
|
|
293
226
|
|
|
294
|
-
describe('onRevoke callback', () => {
|
|
295
|
-
it('should call revoke from sharing context for existing members', async () => {
|
|
296
|
-
mockRevoke.mockResolvedValueOnce({})
|
|
297
|
-
const { getByTestId } = setup()
|
|
298
|
-
|
|
299
|
-
await waitFor(() => {
|
|
300
|
-
expect(getByTestId('dumb-modal')).toBeTruthy()
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
fireEvent.click(getByTestId('btn-revoke'))
|
|
304
|
-
|
|
305
|
-
await waitFor(() => {
|
|
306
|
-
expect(mockRevoke).toHaveBeenCalledWith({ _id: 'folder-123' }, 'abc', 1)
|
|
307
|
-
})
|
|
308
|
-
})
|
|
309
|
-
})
|
|
310
|
-
|
|
311
227
|
describe('onClose callback', () => {
|
|
312
228
|
it('should call onClose when close button is clicked', async () => {
|
|
313
|
-
const {
|
|
229
|
+
const { findByRole } = setup()
|
|
314
230
|
|
|
315
|
-
await
|
|
316
|
-
expect(getByTestId('btn-close')).toBeTruthy()
|
|
317
|
-
})
|
|
231
|
+
const closeButton = await findByRole('button', { name: /close/i })
|
|
318
232
|
|
|
319
|
-
fireEvent.click(
|
|
233
|
+
fireEvent.click(closeButton)
|
|
320
234
|
|
|
321
235
|
expect(mockOnClose).toHaveBeenCalled()
|
|
322
236
|
})
|
|
@@ -329,13 +243,11 @@ describe('FederatedFolderModal', () => {
|
|
|
329
243
|
setSelectedOption: jest.fn()
|
|
330
244
|
})
|
|
331
245
|
|
|
332
|
-
const { getByRole,
|
|
246
|
+
const { getByRole, findByRole, getByText } = setup()
|
|
333
247
|
|
|
334
|
-
await
|
|
335
|
-
expect(getByTestId('btn-close')).toBeTruthy()
|
|
336
|
-
})
|
|
248
|
+
const closeButton = await findByRole('button', { name: /close/i })
|
|
337
249
|
|
|
338
|
-
fireEvent.click(
|
|
250
|
+
fireEvent.click(closeButton)
|
|
339
251
|
|
|
340
252
|
expect(getByText("Discard the changes you haven't saved?")).toBeTruthy()
|
|
341
253
|
expect(mockOnClose).not.toHaveBeenCalled()
|
|
@@ -353,13 +265,11 @@ describe('FederatedFolderModal', () => {
|
|
|
353
265
|
setSelectedOption: jest.fn()
|
|
354
266
|
})
|
|
355
267
|
|
|
356
|
-
const { getByRole,
|
|
268
|
+
const { getByRole, findByRole, getByText } = setup()
|
|
357
269
|
|
|
358
|
-
await
|
|
359
|
-
expect(getByTestId('btn-close')).toBeTruthy()
|
|
360
|
-
})
|
|
270
|
+
const closeButton = await findByRole('button', { name: /close/i })
|
|
361
271
|
|
|
362
|
-
fireEvent.click(
|
|
272
|
+
fireEvent.click(closeButton)
|
|
363
273
|
|
|
364
274
|
expect(getByText("Discard the changes you haven't saved?")).toBeTruthy()
|
|
365
275
|
|
|
@@ -368,36 +278,4 @@ describe('FederatedFolderModal', () => {
|
|
|
368
278
|
expect(mockOnClose).toHaveBeenCalledTimes(1)
|
|
369
279
|
})
|
|
370
280
|
})
|
|
371
|
-
|
|
372
|
-
describe('existing recipients', () => {
|
|
373
|
-
const existingRecipients = [
|
|
374
|
-
{
|
|
375
|
-
index: 'sharing-abc-member-0',
|
|
376
|
-
name: 'Charlie',
|
|
377
|
-
email: 'charlie@example.com',
|
|
378
|
-
status: 'owner',
|
|
379
|
-
type: 'two-way',
|
|
380
|
-
sharingId: 'abc',
|
|
381
|
-
memberIndex: 0
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
index: 'sharing-abc-member-1',
|
|
385
|
-
name: 'Diana',
|
|
386
|
-
email: 'diana@example.com',
|
|
387
|
-
status: 'ready',
|
|
388
|
-
type: 'one-way',
|
|
389
|
-
sharingId: 'abc',
|
|
390
|
-
memberIndex: 1
|
|
391
|
-
}
|
|
392
|
-
]
|
|
393
|
-
|
|
394
|
-
it('should display existing recipients from getRecipients', async () => {
|
|
395
|
-
mockGetRecipients.mockReturnValue(existingRecipients)
|
|
396
|
-
const { getByTestId } = setup()
|
|
397
|
-
|
|
398
|
-
await waitFor(() => {
|
|
399
|
-
expect(getByTestId('recipients-count').textContent).toBe('2')
|
|
400
|
-
})
|
|
401
|
-
})
|
|
402
|
-
})
|
|
403
281
|
})
|
|
@@ -4,7 +4,6 @@ import { GroupRecipient } from './GroupRecipient'
|
|
|
4
4
|
import MemberRecipient from './MemberRecipient'
|
|
5
5
|
import { usePrevious } from '../../helpers/hooks'
|
|
6
6
|
import { filterAndReworkRecipients } from '../../helpers/recipients'
|
|
7
|
-
import SharedDriveRecipient from '../SharedDrive/SharedDriveRecipient'
|
|
8
7
|
|
|
9
8
|
const RecipientList = ({
|
|
10
9
|
recipients,
|
|
@@ -15,7 +14,6 @@ const RecipientList = ({
|
|
|
15
14
|
documentType,
|
|
16
15
|
onRevoke,
|
|
17
16
|
onRevokeSelf,
|
|
18
|
-
onSetType,
|
|
19
17
|
verifyRecipient
|
|
20
18
|
}) => {
|
|
21
19
|
const previousRecipients = usePrevious(recipients)
|
|
@@ -29,22 +27,6 @@ const RecipientList = ({
|
|
|
29
27
|
user => user.email === recipient.email
|
|
30
28
|
)
|
|
31
29
|
|
|
32
|
-
const isSharedDriveRecipient = recipient?.index
|
|
33
|
-
?.toString()
|
|
34
|
-
.startsWith('virtual-shared-drive')
|
|
35
|
-
|
|
36
|
-
if (isSharedDriveRecipient) {
|
|
37
|
-
return (
|
|
38
|
-
<SharedDriveRecipient
|
|
39
|
-
{...recipient}
|
|
40
|
-
key={recipient.index}
|
|
41
|
-
onRevoke={onRevoke}
|
|
42
|
-
onSetType={onSetType}
|
|
43
|
-
fadeIn={recipient.hasBeenJustAdded}
|
|
44
|
-
/>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
30
|
const isGroupRecipient = recipient.members
|
|
49
31
|
if (isGroupRecipient) {
|
|
50
32
|
return (
|
|
@@ -34,15 +34,15 @@ export const ShareModal = withLocales(props => {
|
|
|
34
34
|
onRevokeSuccess?.(document)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const isFederatedMode = flag('drive.federated-shared-folder.enabled')
|
|
38
|
-
if (isFederatedMode && allLoaded) {
|
|
39
|
-
return <FederatedFolderModal document={document} {...rest} />
|
|
40
|
-
}
|
|
41
|
-
|
|
42
37
|
const isEditable =
|
|
43
38
|
!byDocId[document.id] || isOwner(document.id) || canReshare(document.id)
|
|
44
39
|
|
|
45
40
|
if (isEditable) {
|
|
41
|
+
const isFederatedMode = flag('drive.federated-shared-folder.enabled')
|
|
42
|
+
if (isFederatedMode && allLoaded) {
|
|
43
|
+
return <FederatedFolderModal document={document} {...rest} />
|
|
44
|
+
}
|
|
45
|
+
|
|
46
46
|
return <EditableSharingModal document={document} {...rest} />
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -6,7 +6,7 @@ import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
|
6
6
|
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
7
7
|
import TextField from 'cozy-ui/transpiled/react/TextField'
|
|
8
8
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
9
|
-
import {
|
|
9
|
+
import { useSubmitWithLoader } from 'cozy-ui/transpiled/react/hooks/useSubmitWithLoader'
|
|
10
10
|
import { useI18n } from 'twake-i18n'
|
|
11
11
|
|
|
12
12
|
import SharedDriveHeader from './SharedDriveHeader'
|
|
@@ -21,62 +21,41 @@ export const EditSharedDriveModal = withLocales(({ onClose, document }) => {
|
|
|
21
21
|
const client = useClient()
|
|
22
22
|
const { t } = useI18n()
|
|
23
23
|
const { share, getRecipients, revoke } = useSharingContext()
|
|
24
|
-
const { showAlert } = useAlert()
|
|
25
24
|
const {
|
|
26
25
|
pendingRecipients,
|
|
27
26
|
setPendingRecipients,
|
|
28
27
|
selectedOption,
|
|
29
28
|
setSelectedOption
|
|
30
29
|
} = usePendingRecipients()
|
|
30
|
+
const { onSubmit, isLoading } = useSubmitWithLoader()
|
|
31
31
|
|
|
32
32
|
const [driveName, setDriveName] = useState(document.name)
|
|
33
|
-
const [isSaving, setIsSaving] = useState(false)
|
|
34
33
|
|
|
35
34
|
const onSave = async () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
const readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts
|
|
46
|
-
const readOnlyRecipients = selectedOption === 'readOnly' ? contacts : []
|
|
35
|
+
// We add contacts
|
|
36
|
+
const contacts = await getOrCreateFromArray(
|
|
37
|
+
client,
|
|
38
|
+
pendingRecipients,
|
|
39
|
+
contact => client.create('io.cozy.contacts', contact)
|
|
40
|
+
)
|
|
41
|
+
const readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts
|
|
42
|
+
const readOnlyRecipients = selectedOption === 'readOnly' ? contacts : []
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// We rename the shared drive
|
|
57
|
-
if (document?.name !== driveName) {
|
|
58
|
-
await client.collection('io.cozy.files').update({
|
|
59
|
-
...document,
|
|
60
|
-
name: driveName,
|
|
61
|
-
_rev: document._rev || document.meta.rev
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
showAlert({
|
|
66
|
-
message: t('SharedDrive.editSharedDriveModal.successNotification'),
|
|
67
|
-
severity: 'success',
|
|
68
|
-
variant: 'filled'
|
|
69
|
-
})
|
|
44
|
+
await share({
|
|
45
|
+
document: document,
|
|
46
|
+
recipients: readWriteRecipients,
|
|
47
|
+
readOnlyRecipients,
|
|
48
|
+
sharedDrive: true,
|
|
49
|
+
openSharing: false
|
|
50
|
+
})
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
// We rename the shared drive
|
|
53
|
+
if (document?.name !== driveName) {
|
|
54
|
+
await client.collection('io.cozy.files').update({
|
|
55
|
+
...document,
|
|
56
|
+
name: driveName,
|
|
57
|
+
_rev: document._rev || document.meta.rev
|
|
77
58
|
})
|
|
78
|
-
} finally {
|
|
79
|
-
setIsSaving(false)
|
|
80
59
|
}
|
|
81
60
|
}
|
|
82
61
|
|
|
@@ -110,8 +89,8 @@ export const EditSharedDriveModal = withLocales(({ onClose, document }) => {
|
|
|
110
89
|
{t('Share.contacts.addUsers')}
|
|
111
90
|
</Typography>
|
|
112
91
|
<DumbShareByEmail
|
|
113
|
-
currentRecipients={[]}
|
|
114
92
|
documentType="Files"
|
|
93
|
+
currentRecipients={existingRecipients}
|
|
115
94
|
pendingRecipients={pendingRecipients}
|
|
116
95
|
onPendingRecipientsChange={setPendingRecipients}
|
|
117
96
|
selectedOption={selectedOption}
|
|
@@ -121,6 +100,7 @@ export const EditSharedDriveModal = withLocales(({ onClose, document }) => {
|
|
|
121
100
|
<WhoHasAccess
|
|
122
101
|
isOwner
|
|
123
102
|
isSharedDrive
|
|
103
|
+
showOwner={false}
|
|
124
104
|
recipients={existingRecipients}
|
|
125
105
|
document={document}
|
|
126
106
|
documentType="Files"
|
|
@@ -134,14 +114,29 @@ export const EditSharedDriveModal = withLocales(({ onClose, document }) => {
|
|
|
134
114
|
className="u-w-100 u-m-1"
|
|
135
115
|
size="large"
|
|
136
116
|
onClick={onClose}
|
|
117
|
+
disabled={isLoading}
|
|
137
118
|
/>
|
|
138
119
|
<Button
|
|
139
120
|
variant="primary"
|
|
140
121
|
label={t('SharedDrive.sharedDriveModal.save')}
|
|
141
122
|
className="u-w-100 u-m-1"
|
|
142
123
|
size="large"
|
|
143
|
-
|
|
144
|
-
|
|
124
|
+
onClick={() =>
|
|
125
|
+
onSubmit({
|
|
126
|
+
submit: onSave,
|
|
127
|
+
success: {
|
|
128
|
+
action: onClose,
|
|
129
|
+
message: t(
|
|
130
|
+
'SharedDrive.editSharedDriveModal.successNotification'
|
|
131
|
+
)
|
|
132
|
+
},
|
|
133
|
+
error: {
|
|
134
|
+
message: () =>
|
|
135
|
+
t('SharedDrive.editSharedDriveModal.errorNotification')
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
busy={isLoading}
|
|
145
140
|
/>
|
|
146
141
|
</div>
|
|
147
142
|
</div>
|
|
@@ -4,6 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
5
5
|
import TextField from 'cozy-ui/transpiled/react/TextField'
|
|
6
6
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
7
|
+
import { useSubmitWithLoader } from 'cozy-ui/transpiled/react/hooks/useSubmitWithLoader'
|
|
7
8
|
import { useI18n } from 'twake-i18n'
|
|
8
9
|
|
|
9
10
|
import withLocales from '../../hoc/withLocales'
|
|
@@ -21,7 +22,8 @@ export const SharedDriveForm = withLocales(({ onSuccess, onCancel }) => {
|
|
|
21
22
|
selectedOption,
|
|
22
23
|
setSelectedOption,
|
|
23
24
|
onCreate
|
|
24
|
-
} = useSharedDrive(
|
|
25
|
+
} = useSharedDrive()
|
|
26
|
+
const { onSubmit, isLoading } = useSubmitWithLoader()
|
|
25
27
|
|
|
26
28
|
return (
|
|
27
29
|
<div>
|
|
@@ -55,13 +57,27 @@ export const SharedDriveForm = withLocales(({ onSuccess, onCancel }) => {
|
|
|
55
57
|
className="u-w-100 u-m-1"
|
|
56
58
|
size="large"
|
|
57
59
|
onClick={onCancel}
|
|
60
|
+
disabled={isLoading}
|
|
58
61
|
/>
|
|
59
62
|
<Button
|
|
60
63
|
variant="primary"
|
|
61
64
|
label={t('SharedDrive.sharedDriveModal.create')}
|
|
62
65
|
className="u-w-100 u-m-1"
|
|
63
66
|
size="large"
|
|
64
|
-
onClick={
|
|
67
|
+
onClick={() =>
|
|
68
|
+
onSubmit({
|
|
69
|
+
submit: onCreate,
|
|
70
|
+
success: {
|
|
71
|
+
action: onSuccess,
|
|
72
|
+
message: t('SharedDrive.sharedDriveModal.successNotification')
|
|
73
|
+
},
|
|
74
|
+
error: {
|
|
75
|
+
message: () =>
|
|
76
|
+
t('SharedDrive.sharedDriveModal.errorNotification')
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
busy={isLoading}
|
|
65
81
|
/>
|
|
66
82
|
</div>
|
|
67
83
|
</div>
|