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.
Files changed (67) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/components/FederatedFolder/FederatedFolderModal.js +56 -19
  3. package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +101 -254
  4. package/dist/components/Recipient/RecipientList.js +0 -15
  5. package/dist/components/ShareModal/ShareModal.js +8 -8
  6. package/dist/components/SharedDrive/EditSharedDriveModal.js +32 -55
  7. package/dist/components/SharedDrive/SharedDriveForm.js +23 -5
  8. package/dist/components/SharedDrive/useSharedDrive.js +8 -37
  9. package/dist/components/SharedDrive/useSharedDrive.spec.js +8 -81
  10. package/dist/components/WhoHasAccess.js +4 -1
  11. package/dist/state.js +6 -1
  12. package/package.json +4 -4
  13. package/src/components/FederatedFolder/FederatedFolderModal.jsx +65 -19
  14. package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +28 -150
  15. package/src/components/Recipient/RecipientList.jsx +0 -18
  16. package/src/components/ShareModal/ShareModal.jsx +5 -5
  17. package/src/components/SharedDrive/EditSharedDriveModal.jsx +42 -47
  18. package/src/components/SharedDrive/SharedDriveForm.jsx +18 -2
  19. package/src/components/SharedDrive/useSharedDrive.js +15 -35
  20. package/src/components/SharedDrive/useSharedDrive.spec.js +4 -39
  21. package/src/components/WhoHasAccess.jsx +3 -1
  22. package/src/state.js +5 -1
  23. package/.claude/settings.local.json +0 -27
  24. package/AGENTS.md +0 -7
  25. package/dist/RefreshableSharings.spec.js +0 -40
  26. package/dist/assets/illustrations/illustration-shared-drives.svg +0 -1
  27. package/dist/components/EditLinkPermissionDialog.js +0 -72
  28. package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
  29. package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +0 -65
  30. package/dist/components/FederatedFolder/DumbFederatedFolderModal.spec.js +0 -107
  31. package/dist/components/FederatedFolder/FederatedFolderModal.jsx.tmp.179197.1773939270471 +0 -172
  32. package/dist/components/Recipient/actions/revokeGroup.js +0 -42
  33. package/dist/components/Recipient/actions/revokeMember.js +0 -42
  34. package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
  35. package/dist/components/ShareModal/ShareModal copy.js +0 -43
  36. package/dist/components/ShareModal/ShareModal.spec.js +0 -197
  37. package/dist/components/ShareModal/ShareModalBatchContainer.js +0 -276
  38. package/dist/components/ShareModal/ShareModalBatchContainer.spec.js +0 -131
  39. package/dist/components/ShareModal/SharedDriveEditModal.js +0 -59
  40. package/dist/components/SharedDrive/DumbSharedDriveModal.js +0 -78
  41. package/dist/components/SharedDrive/DumbSharedDriveModal.spec.js +0 -126
  42. package/dist/components/SharedDrive/SharedDriveEditModal.js +0 -110
  43. package/dist/components/SharedDrive/SharedDriveModal copy.js +0 -356
  44. package/dist/components/SharedDrive/SharedDriveRecipient.js +0 -61
  45. package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +0 -109
  46. package/dist/components/SharedDrive/SharedDriveRecipientStatus.js +0 -22
  47. package/dist/components/SharedDrive/helpers.js +0 -102
  48. package/dist/components/SharedDrive/helpers.spec.js +0 -208
  49. package/dist/components/SharedDriveEditModal.js +0 -43
  50. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +0 -145
  51. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.spec.js +0 -321
  52. package/dist/components/SharedStatus.js +0 -61
  53. package/dist/components/SharedStatus.spec.js +0 -44
  54. package/dist/components/Sharesubmit.js +0 -28
  55. package/dist/components/__snapshots__/SharedStatus.spec.js.snap +0 -94
  56. package/dist/helpers/owner.js +0 -14
  57. package/dist/helpers/owner.spec.js +0 -34
  58. package/dist/hooks/useConfirmDiscardChanges.js +0 -33
  59. package/dist/hooks/useContactsAndGroups.js +0 -65
  60. package/dist/hooks/useSharedDrive.js +0 -130
  61. package/dist/hooks/useSharedDriveContactsAndGroups.js +0 -65
  62. package/dist/propTypes.js +0 -26
  63. package/dist/styles/shareddrive.styl +0 -8
  64. package/src/components/SharedDrive/SharedDriveRecipient.jsx +0 -62
  65. package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +0 -78
  66. package/src/components/SharedDrive/SharedDriveRecipientStatus.jsx +0 -23
  67. package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +0 -161
@@ -1,17 +1,13 @@
1
1
  import { useState } from 'react'
2
2
 
3
3
  import { useClient } from 'cozy-client'
4
- import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
5
- import { useI18n } from 'twake-i18n'
6
4
 
7
5
  import { getOrCreateFromArray } from '../../helpers/contacts'
8
6
  import { usePendingRecipients } from '../../hooks/usePendingRecipients'
9
7
  import { Contact } from '../../models'
10
8
 
11
- export const useSharedDrive = ({ onSuccess }) => {
9
+ export const useSharedDrive = () => {
12
10
  const client = useClient()
13
- const { t } = useI18n()
14
- const { showAlert } = useAlert()
15
11
 
16
12
  const [sharedDriveName, setSharedDriveName] = useState('')
17
13
  const {
@@ -28,36 +24,20 @@ export const useSharedDrive = ({ onSuccess }) => {
28
24
  const createContact = contact => client.create(Contact.doctype, contact)
29
25
 
30
26
  const onCreate = async () => {
31
- try {
32
- const contacts = await getOrCreateFromArray(
33
- client,
34
- pendingRecipients,
35
- createContact
36
- )
37
- const readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts
38
- const readOnlyRecipients = selectedOption === 'readOnly' ? contacts : []
39
-
40
- await client.collection('io.cozy.sharings').createSharedDrive({
41
- name: sharedDriveName,
42
- description: sharedDriveName,
43
- recipients: readWriteRecipients,
44
- readOnlyRecipients
45
- })
46
-
47
- showAlert({
48
- message: t('SharedDrive.sharedDriveModal.successNotification'),
49
- severity: 'success',
50
- variant: 'filled'
51
- })
52
-
53
- onSuccess()
54
- } catch (_err) {
55
- showAlert({
56
- message: t('SharedDrive.sharedDriveModal.errorNotification'),
57
- severity: 'error',
58
- variant: 'filled'
59
- })
60
- }
27
+ const contacts = await getOrCreateFromArray(
28
+ client,
29
+ pendingRecipients,
30
+ createContact
31
+ )
32
+ const readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts
33
+ const readOnlyRecipients = selectedOption === 'readOnly' ? contacts : []
34
+
35
+ await client.collection('io.cozy.sharings').createSharedDrive({
36
+ name: sharedDriveName,
37
+ description: sharedDriveName,
38
+ recipients: readWriteRecipients,
39
+ readOnlyRecipients
40
+ })
61
41
  }
62
42
 
63
43
  return {
@@ -2,12 +2,10 @@ import { renderHook, act } from '@testing-library/react-hooks'
2
2
 
3
3
  import { useSharedDrive } from './useSharedDrive'
4
4
 
5
- const mockShowAlert = jest.fn()
6
5
  const mockCreateSharedDrive = jest.fn()
7
6
  const mockCollection = jest.fn(() => ({
8
7
  createSharedDrive: mockCreateSharedDrive
9
8
  }))
10
- const mockT = jest.fn(key => key)
11
9
 
12
10
  jest.mock('cozy-client', () => ({
13
11
  useClient: jest.fn(() => ({
@@ -16,14 +14,6 @@ jest.mock('cozy-client', () => ({
16
14
  }))
17
15
  }))
18
16
 
19
- jest.mock('cozy-ui/transpiled/react/providers/Alert', () => ({
20
- useAlert: jest.fn(() => ({ showAlert: mockShowAlert }))
21
- }))
22
-
23
- jest.mock('twake-i18n', () => ({
24
- useI18n: jest.fn(() => ({ t: mockT }))
25
- }))
26
-
27
17
  jest.mock('../../models', () => ({
28
18
  Contact: { doctype: 'io.cozy.contacts' }
29
19
  }))
@@ -40,18 +30,14 @@ describe('useSharedDrive', () => {
40
30
  })
41
31
 
42
32
  it('returns empty initial state', () => {
43
- const { result } = renderHook(() =>
44
- useSharedDrive({ onSuccess: jest.fn() })
45
- )
33
+ const { result } = renderHook(() => useSharedDrive())
46
34
  expect(result.current.sharedDriveName).toBe('')
47
35
  expect(result.current.pendingRecipients).toEqual([])
48
36
  expect(result.current.selectedOption).toBe('readWrite')
49
37
  })
50
38
 
51
39
  it('handleSharedDriveNameChange updates the name', () => {
52
- const { result } = renderHook(() =>
53
- useSharedDrive({ onSuccess: jest.fn() })
54
- )
40
+ const { result } = renderHook(() => useSharedDrive())
55
41
  act(() => {
56
42
  result.current.handleSharedDriveNameChange({
57
43
  target: { value: 'My Drive' }
@@ -60,11 +46,10 @@ describe('useSharedDrive', () => {
60
46
  expect(result.current.sharedDriveName).toBe('My Drive')
61
47
  })
62
48
 
63
- it('onCreate calls createSharedDrive and onSuccess', async () => {
64
- const onSuccess = jest.fn()
49
+ it('onCreate calls createSharedDrive', async () => {
65
50
  mockCreateSharedDrive.mockResolvedValue({})
66
51
 
67
- const { result } = renderHook(() => useSharedDrive({ onSuccess }))
52
+ const { result } = renderHook(() => useSharedDrive())
68
53
 
69
54
  act(() => {
70
55
  result.current.handleSharedDriveNameChange({
@@ -83,25 +68,5 @@ describe('useSharedDrive', () => {
83
68
  recipients: [{ email: 'a@b.c' }],
84
69
  readOnlyRecipients: []
85
70
  })
86
- expect(mockShowAlert).toHaveBeenCalledWith(
87
- expect.objectContaining({ severity: 'success' })
88
- )
89
- expect(onSuccess).toHaveBeenCalledTimes(1)
90
- })
91
-
92
- it('onCreate shows error alert and does not call onSuccess on failure', async () => {
93
- const onSuccess = jest.fn()
94
- mockCreateSharedDrive.mockRejectedValue(new Error('network error'))
95
-
96
- const { result } = renderHook(() => useSharedDrive({ onSuccess }))
97
-
98
- await act(async () => {
99
- await result.current.onCreate()
100
- })
101
-
102
- expect(mockShowAlert).toHaveBeenCalledWith(
103
- expect.objectContaining({ severity: 'error' })
104
- )
105
- expect(onSuccess).not.toHaveBeenCalled()
106
71
  })
107
72
  })
@@ -29,6 +29,7 @@ const RecipientWaitingForConfirmationAlert = ({ recipientsToBeConfirmed }) => {
29
29
  const WhoHasAccess = ({
30
30
  isOwner = false,
31
31
  isSharedDrive = false,
32
+ showOwner = true,
32
33
  recipients,
33
34
  recipientsToBeConfirmed = [],
34
35
  document,
@@ -61,7 +62,7 @@ const WhoHasAccess = ({
61
62
  />
62
63
  )}
63
64
 
64
- <OwnerRecipient recipients={recipients} />
65
+ {showOwner && <OwnerRecipient recipients={recipients} />}
65
66
 
66
67
  <RecipientList
67
68
  recipients={recipients}
@@ -82,6 +83,7 @@ const WhoHasAccess = ({
82
83
 
83
84
  WhoHasAccess.propTypes = {
84
85
  isOwner: PropTypes.bool,
86
+ showOwner: PropTypes.bool,
85
87
  recipients: PropTypes.array.isRequired,
86
88
  recipientsToBeConfirmed: PropTypes.arrayOf(
87
89
  PropTypes.shape({
package/src/state.js CHANGED
@@ -326,7 +326,11 @@ export const isSharedDrive = (state, docId) => {
326
326
  export const canReshare = (state, docId, instanceUri) => {
327
327
  const sharing = getDocumentSharing(state, docId)
328
328
  const me = sharing.attributes.members.find(matchingInstanceName(instanceUri))
329
- return sharing.attributes.open_sharing === true && me && !me.read_only
329
+ if (sharing.drive) {
330
+ return me && !me.read_only
331
+ } else {
332
+ return sharing.attributes.open_sharing === true && me && !me.read_only
333
+ }
330
334
  }
331
335
 
332
336
  export const getOwner = (state, docId) =>
@@ -1,27 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(yarn test:*)",
5
- "Bash(git stash)",
6
- "Bash(git stash pop)",
7
- "Bash(find /home/doubleface/Workspace/cozy-libs -path \"*/node_modules/cozy-client*\" -name \"*.js\" 2>/dev/null | head -3)",
8
- "Bash(find /home/doubleface/Workspace/cozy-libs/packages -path \"*/cozy-client/src*\" -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\\\\b\" 2>/dev/null | head -3)",
9
- "Bash(find /home/doubleface/Workspace/cozy-libs/packages/cozy-client -name \"PermissionsCollection*\" 2>/dev/null | head -5)",
10
- "Bash(find /home/doubleface/Workspace/cozy-libs/packages/cozy-sharing/node_modules -path \"*/cozy-client/dist*\" -name \"collections.js\" 2>/dev/null | head -3)",
11
- "Bash(find /home/doubleface/Workspace/cozy-libs/packages/cozy-sharing/node_modules -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\" 2>/dev/null | head -5)",
12
- "Bash(find /home/doubleface/Workspace/cozy-libs/node_modules -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\" 2>/dev/null | head -5)",
13
- "Bash(find /home/doubleface/.cache/yarn -name \"*.js\" 2>/dev/null | xargs grep -l \"PermissionsCollection\" 2>/dev/null | head -3)",
14
- "Bash(find /home/doubleface/.cache/yarn -name \"*.js\" 2>/dev/null | xargs grep -l \"class PermissionsCollection\" 2>/dev/null | head -3)",
15
- "Bash(find /home/doubleface/.cache/yarn -path \"*cozy-client-60*\" -name \"*.js\" 2>/dev/null | head -5; find /home/doubleface/.cache/yarn -name \"package.json\" 2>/dev/null | xargs grep -l '\"name\": \"cozy-client\"' 2>/dev/null | head -3)",
16
- "Bash(npx jest:*)",
17
- "Bash(git:*)",
18
- "Bash(grep -v \"^$\")",
19
- "Bash(grep -v \"^\\\\-\\\\-$\")",
20
- "Bash(grep -v \"console\\\\.\\\\|^--$\\\\|JSS\\\\|CozyThemeContext\")"
21
- ]
22
- },
23
- "sandbox": {
24
- "enabled": true,
25
- "autoAllowBashIfSandboxed": true
26
- }
27
- }
package/AGENTS.md DELETED
@@ -1,7 +0,0 @@
1
- - Package manager: `yarn`.
2
- - Run all tests: `corepack yarn test`
3
- - Run a single test file: `corepack yarn test path/to/file.spec.js`
4
- - Run eslint (with fix): `corepack yarn lint --fix`
5
- - Run eslint (with fix) on one file: `corepack yarn lint --fix path/to/file.js`
6
-
7
- No need to build the package. The user will handle this
@@ -1,40 +0,0 @@
1
- import { mount } from 'enzyme';
2
- import React from 'react';
3
- import { createMockClient } from 'cozy-client';
4
- import { RefreshableSharings } from './RefreshableSharings';
5
- import { SharingProvider } from './SharingProvider';
6
- import AppLike from '../test/AppLike';
7
-
8
- var DumbComponent = function DumbComponent() {
9
- return /*#__PURE__*/React.createElement("div", null, "test ");
10
- };
11
-
12
- var AppWrapper = function AppWrapper(_ref) {
13
- var children = _ref.children,
14
- client = _ref.client;
15
- return /*#__PURE__*/React.createElement(AppLike, {
16
- client: client
17
- }, /*#__PURE__*/React.createElement(SharingProvider, {
18
- client: client
19
- }, children));
20
- };
21
-
22
- describe('RefreshableSharings', function () {
23
- it('should test', function () {
24
- var client = createMockClient({});
25
- var component = mount( /*#__PURE__*/React.createElement(AppWrapper, {
26
- client: client
27
- }, /*#__PURE__*/React.createElement(RefreshableSharings, null, function (_ref2) {
28
- var refresh = _ref2.refresh;
29
- return /*#__PURE__*/React.createElement(DumbComponent, {
30
- client: client,
31
- t: function t(x) {
32
- return x;
33
- },
34
- refreshSharings: refresh
35
- });
36
- })));
37
- var refreshMethod = component.find(DumbComponent).prop('refreshSharings');
38
- expect(typeof refreshMethod).toBe('function');
39
- });
40
- });
@@ -1 +0,0 @@
1
- <svg width="200" height="136" viewBox="0 0 200 136" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M161 14.592c-1.888.222-7.568-.664-15.182-5.982-9.518-6.647-13.847-8.724-22.434-4.183C115 8.86 115.227 23.012 115 27" stroke="#CEBEF7" stroke-width="4" stroke-linecap="round"/><path d="M165.844 92c5.431-3.51 16.097-12.335 15.315-19.555-.977-9.025-12.708-11.281-22.81-10.78-10.101.502-17.596 4.513-28.349 1.504" stroke="#B9F6F7" stroke-width="4" stroke-linecap="round"/><path d="M23.495 72c-.329 4.729-2.425 21.765 5.479 27.308 9.88 6.928 23.668-1.244 30.831-5.203C66.97 90.146 79.072 83.217 85 85.527" stroke="#FFD799" stroke-width="4" stroke-linecap="round"/><circle cx="100" cy="64" fill="#297EF2" r="48"/><circle cx="148" cy="104" r="24" fill="#B9F6F7"/><path fill-rule="evenodd" clip-rule="evenodd" d="M148 106c-4.418 0-8-4.029-8-9 0-4.97 3.582-9 8-9s8 4.03 8 9c0 4.971-3.582 9-8 9Zm-16 10c0-2 4-8 8-8s2 2 8 2 4-2 8-2 8 6 8 8 0 4-2 4h-28c-2 0-2-2-2-4Z" fill="#38D1D3"/><circle cx="148" cy="104" r="20" stroke="#B9F6F7" stroke-width="8"/><circle cx="24" cy="65" r="24" fill="#FFD799"/><path fill-rule="evenodd" clip-rule="evenodd" d="M24 67c-4.418 0-8-4.03-8-9s3.582-9 8-9 8 4.03 8 9-3.582 9-8 9ZM8 77c0-2 4-8 8-8s2 2 8 2 4-2 8-2 8 6 8 8 0 4-2 4H10c-2 0-2-2-2-4Z" fill="#FF9300"/><circle cx="24" cy="65" r="20" stroke="#FFD799" stroke-width="8"/><circle cx="172" cy="28" r="24" fill="#CEBEF7"/><path fill-rule="evenodd" clip-rule="evenodd" d="M172 30c-4.418 0-8-4.03-8-9s3.582-9 8-9 8 4.03 8 9-3.582 9-8 9Zm-16 10c0-2 4-8 8-8s2 2 8 2 4-2 8-2 8 6 8 8 0 4-2 4h-28c-2 0-2-2-2-4Z" fill="#855CEA"/><circle cx="172" cy="28" r="20" stroke="#CEBEF7" stroke-width="8"/><path d="M66.418 133.29a81.818 81.818 0 0 0 16.142 2.244c16.166.948 38.758.424 48.325-1.346 9.567-1.771 10.083-4.465-14.448-5.812-20.925-1.147-45.26.474-50.362 2.894-1.52.648-1.447 1.371.343 2.02Z" fill="#BBD9FD"/><path d="M80.198 64.752a6 6 0 0 1 4.686-2.252h30.232c1.823 0 3.547.828 4.685 2.252l3.213 4.015c.638.798.986 1.79.986 2.812V76H76v-4.421a4.5 4.5 0 0 1 .986-2.812l3.212-4.015ZM80.198 43.752a6 6 0 0 1 4.686-2.252h30.232c1.823 0 3.547.828 4.685 2.252l3.213 4.015c.638.798.986 1.79.986 2.811V55H76v-4.422a4.5 4.5 0 0 1 .986-2.81l3.212-4.016Z" fill="#fff"/><path d="M76 71.5a3 3 0 0 1 3-3h42a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H79a3 3 0 0 1-3-3v-12ZM76 50.5a3 3 0 0 1 3-3h42a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H79a3 3 0 0 1-3-3v-12Z" fill="#B2D3FF"/><path d="M88 77.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM88 56.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" fill="#fff"/><path d="M194.751 99.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.607.061 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.061-.546.303-.121.666-.121.969-.242ZM48.112 111.445c1.212-.045 1.17-1.968-.043-1.968-.216 0-.433 0-.65.134v-.627c-.043-.537-.389-.984-.952-.984-.476 0-.995.447-.952.984v.537H45.3c-.13-.044-.217 0-.347 0-.649 0-.952.671-.952 1.164 0 .492.26.715.65.85.259.134.562.044.865.044 0 .135.043.269.043.448.044 1.297 1.992 1.297 1.905 0 0-.134 0-.269-.043-.403.216-.089.476-.089.692-.179ZM176.04 97.024c.121.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.301 1.03-.121.242-.121.485-.06.788Z" fill="#BBD9FD"/><path d="M185.045 86.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.545 0 .788ZM28.09 29.576c1.695-.06 1.634-2.667-.061-2.667-.303 0-.605 0-.908.182V26.243c-.06-.788-.545-1.394-1.332-1.394-.666 0-1.392.606-1.332 1.333v.727h-.303c-.181-.06-.302 0-.484 0-.908 0-1.332.91-1.332 1.576 0 .667.364.97.908 1.152.364.181.787.06 1.211.06 0 .182.06.364.06.606.061 1.758 2.785 1.758 2.664 0 0-.182 0-.364-.06-.545.303 0 .666-.06.968-.182ZM78.751 8.667C80.446 8.607 80.386 6 78.691 6c-.303 0-.606 0-.909.182v-.849C77.722 4.606 77.239 4 76.451 4c-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.21.06 0 .182.061.364.061.607.06 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.06-.546.302-.121.665-.121.968-.242Z" fill="#3281EE"/><path d="M107.751 10.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.606.061 1.758 2.785 1.758 2.664 0 0-.181 0-.363-.061-.545.303-.06.666-.121.969-.242ZM21.612 7.879h-1.634v-1.03c0-2.304-3.633-2.304-3.572 0 0 .424 0 .848.06 1.272-.181 0-.847-.06-.968-.121-2.18-.727-3.148 2.727-.969 3.454.545.182 1.574.182 2.119.182v.788c0 2.303 3.632 2.303 3.572 0v-.97c.484 0 .968-.06 1.513-.06 2.18.06 2.18-3.515-.12-3.515ZM8.9 32.485c.12.424.423.788.665.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.485-2.363-.908-.546-1.998.06-2.3 1.03-.121.242-.121.546-.06.788ZM44.04 41.024c.12.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.3 1.03-.122.242-.122.546-.061.788ZM58.066 16.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.485-2.363-.908-.546-1.998.06-2.3 1.03a.87.87 0 0 0-.061.788Z" fill="#BBD9FD"/><path d="M43.89 7.576c.12.424.423.788.666.97.666.424 1.695.302 2.179-.425.484-.667.545-1.757-.545-2.363-.908-.546-1.998.06-2.3 1.03-.06.242-.06.545 0 .788ZM84.026 28.97c.12.424.424.787.666.969.666.424 1.695.303 2.18-.424.483-.667.544-1.758-.546-2.364-.908-.545-1.997.06-2.3 1.03a1.73 1.73 0 0 0 0 .788Z" fill="#3281EE"/><path d="M20.04 107.024c.12.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.3 1.03-.122.242-.122.546-.061.788ZM5.04 88.024c.12.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.484-2.363-.908-.546-1.998.06-2.3 1.03-.122.242-.122.545-.061.788Z" fill="#BBD9FD"/><path d="M191.311 54.758h-1.634v-1.03c0-2.304-3.632-2.304-3.572 0 0 .423 0 .848.061 1.272-.182 0-.848-.06-.969-.121-2.179-.727-3.148 2.727-.969 3.454.545.182 1.574.182 2.119.182v.788c0 2.303 3.633 2.303 3.572 0v-.97c.484 0 .969-.06 1.513-.06 2.24.06 2.24-3.515-.121-3.515Z" fill="#3281EE"/><path d="M136.045 21.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.485 0 .788Z" fill="#BBD9FD"/><path d="M129.045 10.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.545-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.546 0 .788ZM46.07 26.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.546-2.363-.908-.546-1.997.06-2.3 1.03-.06.242-.121.546 0 .788ZM11.751 99.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.21.06 0 .182.061.364.061.607.06 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.06-.546.363-.06.665-.121.968-.242ZM164.751 74.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.606.061 1.758 2.785 1.758 2.664 0 0-.181 0-.363-.061-.545.364-.06.666-.121.969-.242ZM153.045 56.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.545-1.757-.545-2.363-.908-.546-1.998.06-2.301 1.03-.06.242-.06.546 0 .788Z" fill="#3281EE"/><path d="M193.07 73.024c.121.424.424.788.666.97.666.424 1.695.303 2.179-.425.484-.666.545-1.757-.545-2.363-.908-.546-1.997.06-2.3 1.03-.061.242-.121.545 0 .788ZM194.751 7.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.211.06 0 .182.06.364.06.607.061 1.757 2.785 1.757 2.664 0 0-.182 0-.364-.061-.546.303-.121.666-.182.969-.242Z" fill="#BBD9FD"/><path d="M49.751 89.667c1.695-.06 1.635-2.667-.06-2.667-.303 0-.606 0-.909.182v-.849c-.06-.727-.544-1.333-1.331-1.333-.666 0-1.393.606-1.332 1.333v.728h-.303c-.181-.061-.303 0-.484 0-.908 0-1.332.909-1.332 1.575 0 .667.363.97.908 1.152.363.182.787.06 1.21.06 0 .182.061.364.061.606.06 1.758 2.785 1.758 2.664 0 0-.181 0-.363-.06-.545.302-.121.665-.182.968-.242ZM59.045 105.024c.121.424.424.788.666.97.666.424 1.695.303 2.18-.425.484-.666.544-1.757-.545-2.363-.908-.546-1.998.06-2.3 1.03-.061.243-.061.546 0 .788Z" fill="#3281EE"/></svg>
@@ -1,72 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import PropTypes from 'prop-types';
3
- import React, { useState } from 'react';
4
- import Button from 'cozy-ui/transpiled/react/Buttons';
5
- import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
6
- import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel';
7
- import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup';
8
- import Radio from 'cozy-ui/transpiled/react/Radios';
9
- import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
10
-
11
- var EditLinkPermissionDialog = function EditLinkPermissionDialog(_ref) {
12
- var open = _ref.open,
13
- onClose = _ref.onClose,
14
- document = _ref.document,
15
- onPermissionsSelected = _ref.onPermissionsSelected;
16
-
17
- var _useI18n = useI18n(),
18
- t = _useI18n.t;
19
-
20
- var _useState = useState(true),
21
- _useState2 = _slicedToArray(_useState, 2),
22
- isReadOnlyPermissions = _useState2[0],
23
- setIsReadOnlyPermissions = _useState2[1];
24
-
25
- var onChange = function onChange(event) {
26
- setIsReadOnlyPermissions(event.target.value === 'true');
27
- };
28
-
29
- var onConfirm = function onConfirm() {
30
- var verbs = isReadOnlyPermissions ? ['GET'] : ['GET', 'POST', 'PUT', 'PATCH'];
31
- onPermissionsSelected({
32
- verbs: verbs
33
- });
34
- onClose();
35
- };
36
-
37
- return /*#__PURE__*/React.createElement(ConfirmDialog, {
38
- open: open,
39
- onClose: onClose,
40
- title: t('Share.permissionLink.title'),
41
- content: /*#__PURE__*/React.createElement(RadioGroup, {
42
- "aria-label": "radio",
43
- value: isReadOnlyPermissions.toString(),
44
- onChange: onChange
45
- }, /*#__PURE__*/React.createElement(FormControlLabel, {
46
- value: "true",
47
- label: (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.seeFolder") : t("Share.permissionLink.seeFile"),
48
- control: /*#__PURE__*/React.createElement(Radio, null)
49
- }), /*#__PURE__*/React.createElement(FormControlLabel, {
50
- value: "false",
51
- label: (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.modifyFolder") : t("Share.permissionLink.modifyFile"),
52
- control: /*#__PURE__*/React.createElement(Radio, null)
53
- })),
54
- actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
55
- variant: "secondary",
56
- label: t('Share.permissionLink.cancel'),
57
- onClick: onClose
58
- }), /*#__PURE__*/React.createElement(Button, {
59
- variant: "primary",
60
- label: t('Share.permissionLink.confirm'),
61
- onClick: onConfirm
62
- }))
63
- });
64
- };
65
-
66
- EditLinkPermissionDialog.propTypes = {
67
- open: PropTypes.bool.isRequired,
68
- onClose: PropTypes.func.isRequired,
69
- document: PropTypes.object.isRequired,
70
- onPermissionsSelected: PropTypes.func.isRequired
71
- };
72
- export default EditLinkPermissionDialog;
@@ -1,48 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import { render, fireEvent } from '@testing-library/react';
3
- import React from 'react';
4
- import { createMockClient } from 'cozy-client';
5
- import EditLinkPermissionDialog from './EditLinkPermissionDialog';
6
- import AppLike from '../../test/AppLike';
7
- describe('EditLinkPermissionDialog', function () {
8
- var client = createMockClient({});
9
-
10
- var setup = function setup(props) {
11
- return render( /*#__PURE__*/React.createElement(AppLike, {
12
- client: client
13
- }, /*#__PURE__*/React.createElement(EditLinkPermissionDialog, _extends({
14
- open: true,
15
- onClose: function onClose() {}
16
- }, props))));
17
- };
18
-
19
- it('should select read permissions', function () {
20
- var onPermissionsSelected = jest.fn();
21
- var props = {
22
- onPermissionsSelected: onPermissionsSelected
23
- };
24
-
25
- var _setup = setup(props),
26
- getByText = _setup.getByText;
27
-
28
- fireEvent.click(getByText('OK'));
29
- expect(onPermissionsSelected).toHaveBeenCalledWith({
30
- verbs: ['GET']
31
- });
32
- });
33
- it('should select write permissions', function () {
34
- var onPermissionsSelected = jest.fn();
35
- var props = {
36
- onPermissionsSelected: onPermissionsSelected
37
- };
38
-
39
- var _setup2 = setup(props),
40
- getByText = _setup2.getByText;
41
-
42
- fireEvent.click(getByText('Modify file'));
43
- fireEvent.click(getByText('OK'));
44
- expect(onPermissionsSelected).toHaveBeenCalledWith({
45
- verbs: ['GET', 'POST', 'PUT', 'PATCH']
46
- });
47
- });
48
- });
@@ -1,65 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import { useI18n } from 'twake-i18n';
4
- import withLocales from '../../hoc/withLocales';
5
- import { DumbBatchSharedFolderModal } from '../SharedFolder/DumbBatchSharedFolderModal';
6
- export var DumbFederatedFolderModal = withLocales(function (_ref) {
7
- var title = _ref.title,
8
- document = _ref.document,
9
- createContact = _ref.createContact,
10
- recipients = _ref.recipients,
11
- readOnlyRecipients = _ref.readOnlyRecipients,
12
- currentRecipients = _ref.currentRecipients,
13
- onRevoke = _ref.onRevoke,
14
- onSetType = _ref.onSetType,
15
- onSend = _ref.onSend,
16
- onClose = _ref.onClose,
17
- onShare = _ref.onShare,
18
- sharingLink = _ref.sharingLink,
19
- showShareByEmail = _ref.showShareByEmail,
20
- autoOpenShareRestriction = _ref.autoOpenShareRestriction,
21
- showGenerateLinkButton = _ref.showGenerateLinkButton;
22
-
23
- var _useI18n = useI18n(),
24
- t = _useI18n.t;
25
-
26
- return /*#__PURE__*/React.createElement(DumbBatchSharedFolderModal, {
27
- title: title,
28
- document: document,
29
- createContact: createContact,
30
- recipients: recipients,
31
- readOnlyRecipients: readOnlyRecipients,
32
- currentRecipients: currentRecipients,
33
- onRevoke: onRevoke,
34
- onSetType: onSetType,
35
- onSend: onSend,
36
- onClose: onClose,
37
- onShare: onShare,
38
- sharingLink: sharingLink,
39
- showNameField: false,
40
- addPeopleLabel: t('FederatedFolder.addPeople'),
41
- addButtonLabel: t('FederatedFolder.add'),
42
- shareLabel: t('FederatedFolder.share'),
43
- showShareByEmail: showShareByEmail,
44
- autoOpenShareRestriction: autoOpenShareRestriction,
45
- showGenerateLinkButton: showGenerateLinkButton
46
- });
47
- });
48
- DumbFederatedFolderModal.propTypes = {
49
- title: PropTypes.string,
50
- document: PropTypes.object,
51
- createContact: PropTypes.func.isRequired,
52
- recipients: PropTypes.array,
53
- readOnlyRecipients: PropTypes.array,
54
- currentRecipients: PropTypes.array,
55
- onRevoke: PropTypes.func.isRequired,
56
- onSetType: PropTypes.func.isRequired,
57
- onSend: PropTypes.func.isRequired,
58
- onClose: PropTypes.func.isRequired,
59
- onShare: PropTypes.func.isRequired,
60
- sharingLink: PropTypes.string,
61
- showShareByEmail: PropTypes.bool,
62
- autoOpenShareRestriction: PropTypes.bool,
63
- showGenerateLinkButton: PropTypes.bool
64
- };
65
- export default DumbFederatedFolderModal;
@@ -1,107 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import { render } from '@testing-library/react';
3
- import React from 'react';
4
- import { DumbFederatedFolderModal } from './DumbFederatedFolderModal';
5
- var mockDumbBatchSharedFolderModal = jest.fn();
6
- jest.mock('../SharedFolder/DumbBatchSharedFolderModal', function () {
7
- return {
8
- __esModule: true,
9
- default: function _default(props) {
10
- mockDumbBatchSharedFolderModal(props);
11
- return /*#__PURE__*/React.createElement("div", {
12
- "data-testid": "dumb-batch-shared-folder-modal"
13
- }, "DumbBatchSharedFolderModal");
14
- }
15
- };
16
- });
17
- jest.mock('../../hoc/withLocales', function () {
18
- return {
19
- __esModule: true,
20
- default: function _default(Component) {
21
- return Component;
22
- }
23
- };
24
- });
25
- jest.mock('twake-i18n', function () {
26
- return {
27
- useI18n: jest.fn().mockReturnValue({
28
- t: jest.fn(function (key) {
29
- return key;
30
- })
31
- })
32
- };
33
- });
34
- describe('DumbFederatedFolderModal', function () {
35
- var defaultProps = {
36
- title: 'Test Folder',
37
- document: {
38
- _id: 'doc-123',
39
- name: 'Test'
40
- },
41
- createContact: jest.fn(),
42
- recipients: [{
43
- _id: 'r1',
44
- email: 'test@test.com'
45
- }],
46
- currentRecipients: [],
47
- onRevoke: jest.fn(),
48
- onSetType: jest.fn(),
49
- onSend: jest.fn(),
50
- onClose: jest.fn(),
51
- onShare: jest.fn(),
52
- sharingLink: 'https://share.link/123',
53
- hasRecipientsInitially: false
54
- };
55
-
56
- var setup = function setup() {
57
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
58
- mockDumbBatchSharedFolderModal.mockClear();
59
- return render( /*#__PURE__*/React.createElement(DumbFederatedFolderModal, _extends({}, defaultProps, props)));
60
- };
61
-
62
- it('should render DumbBatchSharedFolderModal with correct props', function () {
63
- setup();
64
- expect(mockDumbBatchSharedFolderModal).toHaveBeenCalledWith(expect.objectContaining({
65
- title: 'Test Folder',
66
- document: defaultProps.document,
67
- createContact: defaultProps.createContact,
68
- recipients: defaultProps.recipients,
69
- currentRecipients: defaultProps.currentRecipients,
70
- onRevoke: defaultProps.onRevoke,
71
- onSetType: defaultProps.onSetType,
72
- onSend: defaultProps.onSend,
73
- onClose: defaultProps.onClose,
74
- onShare: defaultProps.onShare,
75
- sharingLink: 'https://share.link/123',
76
- hasRecipientsInitially: false,
77
- showNameField: false
78
- }));
79
- });
80
- it('should pass correct i18n labels to DumbBatchSharedFolderModal', function () {
81
- setup();
82
- var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
83
- expect(passedProps.addPeopleLabel).toBe('SharedDrive.sharedDriveModal.addPeople');
84
- expect(passedProps.addButtonLabel).toBe('SharedDrive.sharedDriveModal.add');
85
- expect(passedProps.shareLabel).toBe('SharedDrive.sharedDriveModal.share');
86
- });
87
- it('should always set showNameField to false', function () {
88
- setup({
89
- showNameField: true
90
- });
91
- var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
92
- expect(passedProps.showNameField).toBe(false);
93
- });
94
- it('should handle hasRecipientsInitially prop correctly', function () {
95
- setup({
96
- hasRecipientsInitially: true
97
- });
98
- var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
99
- expect(passedProps.hasRecipientsInitially).toBe(true);
100
- });
101
- it('should render the mocked component', function () {
102
- var _setup = setup(),
103
- getByTestId = _setup.getByTestId;
104
-
105
- expect(getByTestId('dumb-batch-shared-folder-modal')).toBeInTheDocument();
106
- });
107
- });