cozy-sharing 32.1.2 → 32.3.2
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/components/FederatedFolder/FederatedFolderModal.js +96 -22
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +137 -219
- package/dist/components/Recipient/RecipientList.js +0 -15
- package/dist/components/ShareAutosuggest.js +1 -0
- package/dist/components/ShareAutosuggest.spec.js +12 -4
- package/dist/components/ShareDialogCozyToCozy.spec.js +55 -8
- package/dist/components/ShareDiscardChangesModal.js +35 -0
- package/dist/components/ShareModal/ShareModal.js +8 -8
- package/dist/components/ShareRecipientsInput.js +13 -3
- package/dist/components/ShareRecipientsInput.spec.js +63 -4
- package/dist/state.js +6 -1
- package/locales/en.json +10 -5
- package/locales/fr.json +10 -5
- package/locales/ru.json +10 -5
- package/locales/vi.json +10 -5
- package/package.json +2 -2
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +230 -138
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +59 -134
- package/src/components/Recipient/RecipientList.jsx +0 -18
- package/src/components/ShareAutosuggest.jsx +1 -0
- package/src/components/ShareAutosuggest.spec.jsx +10 -5
- package/src/components/ShareDialogCozyToCozy.spec.jsx +50 -4
- package/src/components/ShareDiscardChangesModal.jsx +40 -0
- package/src/components/ShareModal/ShareModal.jsx +5 -5
- package/src/components/ShareRecipientsInput.jsx +11 -6
- package/src/components/ShareRecipientsInput.spec.jsx +59 -0
- package/src/state.js +5 -1
- 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/SharedFolder/DumbBatchSharedFolderModal.js +0 -145
- 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
|
@@ -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 (
|
|
@@ -51,17 +51,22 @@ describe('ShareAutosuggest', () => {
|
|
|
51
51
|
})
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
it('should show loading
|
|
54
|
+
it('should show loading indicator when loading prop is true (autoFocus triggers onFocus on mount)', () => {
|
|
55
55
|
const onPick = jest.fn()
|
|
56
56
|
const onRemove = jest.fn()
|
|
57
57
|
|
|
58
58
|
setup({ onPick, onRemove, loading: true })
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
// autoFocus triggers onFocus on mount, which sets isLoadingDisplayed
|
|
61
|
+
expect(screen.getByText('loading')).toBeInTheDocument()
|
|
62
|
+
})
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
it('should not show loading indicator when loading prop is false', () => {
|
|
65
|
+
const onPick = jest.fn()
|
|
66
|
+
const onRemove = jest.fn()
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
setup({ onPick, onRemove, loading: false })
|
|
69
|
+
|
|
70
|
+
expect(screen.queryByText('loading')).toBeNull()
|
|
66
71
|
})
|
|
67
72
|
})
|
|
@@ -169,20 +169,66 @@ describe('ShareDialogCozyToCozy', () => {
|
|
|
169
169
|
).not.toBeInTheDocument()
|
|
170
170
|
})
|
|
171
171
|
|
|
172
|
-
it('main
|
|
172
|
+
it('main Done button calls onClose when there are no pending chips', () => {
|
|
173
173
|
const onClose = jest.fn()
|
|
174
174
|
const onShare = jest.fn()
|
|
175
175
|
const props = { ...getMockProps(), onClose, onShare }
|
|
176
176
|
|
|
177
177
|
const { getByRole } = setup(props)
|
|
178
178
|
|
|
179
|
-
fireEvent.click(getByRole('button', { name: '
|
|
179
|
+
fireEvent.click(getByRole('button', { name: 'Done' }))
|
|
180
180
|
|
|
181
181
|
expect(onShare).not.toHaveBeenCalled()
|
|
182
182
|
expect(onClose).toHaveBeenCalledTimes(1)
|
|
183
183
|
})
|
|
184
184
|
|
|
185
|
-
it('
|
|
185
|
+
it('close action closes dialog when there are no pending chips', () => {
|
|
186
|
+
const onClose = jest.fn()
|
|
187
|
+
const props = { ...getMockProps(), onClose }
|
|
188
|
+
|
|
189
|
+
const { getByRole } = setup(props)
|
|
190
|
+
|
|
191
|
+
fireEvent.click(getByRole('button', { name: 'Close' }))
|
|
192
|
+
|
|
193
|
+
expect(onClose).toHaveBeenCalledTimes(1)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
it('close action closes dialog when there are pending chips', () => {
|
|
197
|
+
const onClose = jest.fn()
|
|
198
|
+
const props = { ...getMockProps(), onClose }
|
|
199
|
+
|
|
200
|
+
const { getByPlaceholderText, getByRole, queryByText } = setup(props)
|
|
201
|
+
|
|
202
|
+
act(() => {
|
|
203
|
+
fireEvent.change(
|
|
204
|
+
getByPlaceholderText(
|
|
205
|
+
'Enter the email address or name of the recipient'
|
|
206
|
+
),
|
|
207
|
+
{
|
|
208
|
+
target: { value: 'new@cozycloud.cc' }
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
})
|
|
212
|
+
act(() => {
|
|
213
|
+
fireEvent.keyPress(
|
|
214
|
+
getByPlaceholderText(
|
|
215
|
+
'Enter the email address or name of the recipient'
|
|
216
|
+
),
|
|
217
|
+
{
|
|
218
|
+
key: 'Enter',
|
|
219
|
+
code: 'Enter',
|
|
220
|
+
charCode: 13
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
fireEvent.click(getByRole('button', { name: 'Close' }))
|
|
226
|
+
|
|
227
|
+
expect(queryByText("Discard the changes you haven't saved?")).toBe(null)
|
|
228
|
+
expect(onClose).toHaveBeenCalledTimes(1)
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it('main Done button calls onShare with chips then closes', async () => {
|
|
186
232
|
const onClose = jest.fn()
|
|
187
233
|
const onShare = jest.fn().mockResolvedValue(undefined)
|
|
188
234
|
const props = { ...getMockProps(), onClose, onShare }
|
|
@@ -213,7 +259,7 @@ describe('ShareDialogCozyToCozy', () => {
|
|
|
213
259
|
})
|
|
214
260
|
|
|
215
261
|
await act(async () => {
|
|
216
|
-
fireEvent.click(getByRole('button', { name: '
|
|
262
|
+
fireEvent.click(getByRole('button', { name: 'Done' }))
|
|
217
263
|
})
|
|
218
264
|
|
|
219
265
|
expect(onShare).toHaveBeenCalledWith(
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
5
|
+
import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
6
|
+
import { useI18n } from 'twake-i18n'
|
|
7
|
+
|
|
8
|
+
const ShareDiscardChangesModal = ({ onCancel, onConfirm }) => {
|
|
9
|
+
const { t } = useI18n()
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ConfirmDialog
|
|
13
|
+
open
|
|
14
|
+
title={t('ShareDiscardChangesModal.title')}
|
|
15
|
+
actions={
|
|
16
|
+
<>
|
|
17
|
+
<Button
|
|
18
|
+
variant="secondary"
|
|
19
|
+
label={t('ShareDiscardChangesModal.cancel')}
|
|
20
|
+
className="u-fz-small"
|
|
21
|
+
onClick={onCancel}
|
|
22
|
+
/>
|
|
23
|
+
<Button
|
|
24
|
+
variant="primary"
|
|
25
|
+
label={t('ShareDiscardChangesModal.discard')}
|
|
26
|
+
className="u-fz-small"
|
|
27
|
+
onClick={onConfirm}
|
|
28
|
+
/>
|
|
29
|
+
</>
|
|
30
|
+
}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ShareDiscardChangesModal.propTypes = {
|
|
36
|
+
onCancel: PropTypes.func.isRequired,
|
|
37
|
+
onConfirm: PropTypes.func.isRequired
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { ShareDiscardChangesModal }
|
|
@@ -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
|
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
* We retrieve all the contacts that are reachable and the groups they belong to.
|
|
18
18
|
* In order to display the total number of members in each group, we also retrieve the contacts that are not reachable.
|
|
19
19
|
*/
|
|
20
|
+
const isCurrentUser = contact => contact.me === true
|
|
21
|
+
|
|
20
22
|
const ShareRecipientsInput = ({
|
|
21
23
|
currentRecipients,
|
|
22
24
|
recipients,
|
|
@@ -57,6 +59,12 @@ const ShareRecipientsInput = ({
|
|
|
57
59
|
(isQueryLoading(unreachableContactsWithGroupsResult) ||
|
|
58
60
|
unreachableContactsWithGroupsResult.hasMore))
|
|
59
61
|
|
|
62
|
+
const reachableContacts = (reachableContactsResult.data || []).filter(
|
|
63
|
+
contact => !isCurrentUser(contact)
|
|
64
|
+
)
|
|
65
|
+
const unreachableContactsWithGroups = (
|
|
66
|
+
unreachableContactsWithGroupsResult.data || []
|
|
67
|
+
).filter(contact => !isCurrentUser(contact))
|
|
60
68
|
const currentRecipientGroups = currentRecipients
|
|
61
69
|
.map(({ id }) => id)
|
|
62
70
|
.filter(Boolean)
|
|
@@ -68,7 +76,7 @@ const ShareRecipientsInput = ({
|
|
|
68
76
|
)
|
|
69
77
|
.map(contactGroup => {
|
|
70
78
|
const reachableMembers = getContactsFromGroupId(
|
|
71
|
-
|
|
79
|
+
reachableContacts,
|
|
72
80
|
contactGroup.id
|
|
73
81
|
).map(contact => ({
|
|
74
82
|
...contact,
|
|
@@ -83,7 +91,7 @@ const ShareRecipientsInput = ({
|
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
const unreachableMembers = getContactsFromGroupId(
|
|
86
|
-
|
|
94
|
+
unreachableContactsWithGroups,
|
|
87
95
|
contactGroup.id
|
|
88
96
|
).map(contact => ({
|
|
89
97
|
...contact,
|
|
@@ -96,10 +104,7 @@ const ShareRecipientsInput = ({
|
|
|
96
104
|
}
|
|
97
105
|
})
|
|
98
106
|
|
|
99
|
-
const contactsAndGroups = [
|
|
100
|
-
...(reachableContactsResult.data || []),
|
|
101
|
-
...contactGroups
|
|
102
|
-
]
|
|
107
|
+
const contactsAndGroups = [...reachableContacts, ...contactGroups]
|
|
103
108
|
|
|
104
109
|
return (
|
|
105
110
|
<ShareAutosuggest
|
|
@@ -116,6 +116,65 @@ describe('ShareRecipientsInput component', () => {
|
|
|
116
116
|
).toBeInTheDocument()
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
+
it('should exclude current user from suggestions when me is true', async () => {
|
|
120
|
+
const contacts = [
|
|
121
|
+
{
|
|
122
|
+
id: 'df563cc4-6440',
|
|
123
|
+
_id: 'df563cc4-6440',
|
|
124
|
+
_type: 'io.cozy.contacts',
|
|
125
|
+
me: true,
|
|
126
|
+
name: {
|
|
127
|
+
givenName: 'My',
|
|
128
|
+
familyName: 'Self'
|
|
129
|
+
},
|
|
130
|
+
relationships: {
|
|
131
|
+
groups: {
|
|
132
|
+
data: [
|
|
133
|
+
{
|
|
134
|
+
_id: 'group-id',
|
|
135
|
+
_type: 'io.cozy.contacts.groups'
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: '5a3b4ccf-c257',
|
|
143
|
+
_id: '5a3b4ccf-c257',
|
|
144
|
+
_type: 'io.cozy.contacts',
|
|
145
|
+
name: {
|
|
146
|
+
givenName: 'Teagan',
|
|
147
|
+
familyName: 'Wolf'
|
|
148
|
+
},
|
|
149
|
+
relationships: {
|
|
150
|
+
groups: {
|
|
151
|
+
data: [
|
|
152
|
+
{
|
|
153
|
+
_id: 'group-id',
|
|
154
|
+
_type: 'io.cozy.contacts.groups'
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
const contactGroups = [
|
|
163
|
+
{
|
|
164
|
+
id: 'group-id',
|
|
165
|
+
name: 'Friends',
|
|
166
|
+
_id: 'group-id',
|
|
167
|
+
_type: 'io.cozy.contacts.groups'
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
setup({ contacts, contactGroups })
|
|
172
|
+
|
|
173
|
+
expect(screen.queryByText('My Self')).not.toBeInTheDocument()
|
|
174
|
+
expect(screen.getByText('Teagan Wolf')).toBeInTheDocument()
|
|
175
|
+
expect(screen.getByText('Friends - 1 members')).toBeInTheDocument()
|
|
176
|
+
})
|
|
177
|
+
|
|
119
178
|
it('should include unreachable members when flag sharing.show-recipient-groups is activated', async () => {
|
|
120
179
|
flag.mockReturnValue(true)
|
|
121
180
|
|
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
|
-
|
|
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,61 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["fadeIn", "members"];
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
7
|
-
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
8
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
9
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
10
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
11
|
-
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
12
|
-
import { useI18n } from 'twake-i18n';
|
|
13
|
-
import SharedDriveRecipientPermissions from './SharedDriveRecipientPermissions';
|
|
14
|
-
import SharedDriveRecipientStatus from './SharedDriveRecipientStatus';
|
|
15
|
-
import { FADE_IN_DURATION, DEFAULT_DISPLAY_NAME } from '../../helpers/recipients';
|
|
16
|
-
import { getDisplayName } from '../../models';
|
|
17
|
-
import { GroupAvatar } from '../Avatar/GroupAvatar';
|
|
18
|
-
import { MemberAvatar } from '../Avatar/MemberAvatar';
|
|
19
|
-
|
|
20
|
-
var SharedDriveRecipient = function SharedDriveRecipient(props) {
|
|
21
|
-
var _useI18n = useI18n(),
|
|
22
|
-
t = _useI18n.t;
|
|
23
|
-
|
|
24
|
-
var _useBreakpoints = useBreakpoints(),
|
|
25
|
-
isMobile = _useBreakpoints.isMobile;
|
|
26
|
-
|
|
27
|
-
var fadeIn = props.fadeIn,
|
|
28
|
-
members = props.members,
|
|
29
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
30
|
-
|
|
31
|
-
var defaultDisplayName = t(DEFAULT_DISPLAY_NAME);
|
|
32
|
-
var name = getDisplayName(rest, defaultDisplayName);
|
|
33
|
-
return /*#__PURE__*/React.createElement(Fade, {
|
|
34
|
-
in: true,
|
|
35
|
-
timeout: fadeIn ? FADE_IN_DURATION : 0
|
|
36
|
-
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
37
|
-
gutters: isMobile ? 'default' : 'double',
|
|
38
|
-
size: "small"
|
|
39
|
-
}, /*#__PURE__*/React.createElement(ListItemIcon, null, members ? /*#__PURE__*/React.createElement(GroupAvatar, {
|
|
40
|
-
size: "m"
|
|
41
|
-
}) : /*#__PURE__*/React.createElement(MemberAvatar, {
|
|
42
|
-
size: "m",
|
|
43
|
-
recipient: props
|
|
44
|
-
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
45
|
-
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
46
|
-
variant: "body1"
|
|
47
|
-
}, name),
|
|
48
|
-
secondary: /*#__PURE__*/React.createElement(SharedDriveRecipientStatus, props)
|
|
49
|
-
}), /*#__PURE__*/React.createElement(SharedDriveRecipientPermissions, _extends({}, props, {
|
|
50
|
-
className: "u-flex-shrink-0"
|
|
51
|
-
}))));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
SharedDriveRecipient.propTypes = {
|
|
55
|
-
instance: PropTypes.string,
|
|
56
|
-
isOwner: PropTypes.bool,
|
|
57
|
-
status: PropTypes.string,
|
|
58
|
-
recipientConfirmationData: PropTypes.object,
|
|
59
|
-
verifyRecipient: PropTypes.func
|
|
60
|
-
};
|
|
61
|
-
export default SharedDriveRecipient;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
import React, { useState, useRef } from 'react';
|
|
5
|
-
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
6
|
-
import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
7
|
-
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
8
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
9
|
-
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
10
|
-
import CrossCircleOutlineIcon from 'cozy-ui/transpiled/react/Icons/CrossCircleOutline';
|
|
11
|
-
import { useI18n } from 'twake-i18n';
|
|
12
|
-
import { setReadOnlySharedPermission } from '../Recipient/actions/setReadOnlySharedPermission';
|
|
13
|
-
import { setReadWriteSharedPermission } from '../Recipient/actions/setReadWriteSharedPermission';
|
|
14
|
-
|
|
15
|
-
var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_ref) {
|
|
16
|
-
var index = _ref.index,
|
|
17
|
-
onSetType = _ref.onSetType,
|
|
18
|
-
type = _ref.type,
|
|
19
|
-
onRevoke = _ref.onRevoke;
|
|
20
|
-
|
|
21
|
-
var _useI18n = useI18n(),
|
|
22
|
-
t = _useI18n.t;
|
|
23
|
-
|
|
24
|
-
var buttonRef = useRef();
|
|
25
|
-
|
|
26
|
-
var _useState = useState(false),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
isMenuDisplayed = _useState2[0],
|
|
29
|
-
setMenuDisplayed = _useState2[1];
|
|
30
|
-
|
|
31
|
-
var toggleMenu = function toggleMenu() {
|
|
32
|
-
return setMenuDisplayed(!isMenuDisplayed);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var hideMenu = function hideMenu() {
|
|
36
|
-
return setMenuDisplayed(false);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var handleRevocation = /*#__PURE__*/function () {
|
|
40
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
41
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
|
-
while (1) switch (_context.prev = _context.next) {
|
|
43
|
-
case 0:
|
|
44
|
-
onRevoke(index);
|
|
45
|
-
hideMenu();
|
|
46
|
-
|
|
47
|
-
case 2:
|
|
48
|
-
case "end":
|
|
49
|
-
return _context.stop();
|
|
50
|
-
}
|
|
51
|
-
}, _callee);
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
return function handleRevocation() {
|
|
55
|
-
return _ref2.apply(this, arguments);
|
|
56
|
-
};
|
|
57
|
-
}();
|
|
58
|
-
|
|
59
|
-
var setType = /*#__PURE__*/function () {
|
|
60
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(newType) {
|
|
61
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
62
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
63
|
-
case 0:
|
|
64
|
-
if (newType !== type) {
|
|
65
|
-
onSetType(index, newType);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
hideMenu();
|
|
69
|
-
|
|
70
|
-
case 2:
|
|
71
|
-
case "end":
|
|
72
|
-
return _context2.stop();
|
|
73
|
-
}
|
|
74
|
-
}, _callee2);
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
return function setType(_x) {
|
|
78
|
-
return _ref3.apply(this, arguments);
|
|
79
|
-
};
|
|
80
|
-
}();
|
|
81
|
-
|
|
82
|
-
var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission], {
|
|
83
|
-
t: t,
|
|
84
|
-
type: type,
|
|
85
|
-
setType: setType
|
|
86
|
-
});
|
|
87
|
-
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
88
|
-
ref: buttonRef,
|
|
89
|
-
"aria-controls": "simple-menu",
|
|
90
|
-
"aria-haspopup": "true",
|
|
91
|
-
onClick: toggleMenu,
|
|
92
|
-
textVariant: "body2"
|
|
93
|
-
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
94
|
-
ref: buttonRef,
|
|
95
|
-
open: isMenuDisplayed,
|
|
96
|
-
actions: actions,
|
|
97
|
-
autoClose: true,
|
|
98
|
-
onClose: hideMenu
|
|
99
|
-
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
100
|
-
onClick: handleRevocation,
|
|
101
|
-
size: "small",
|
|
102
|
-
className: "u-ml-half",
|
|
103
|
-
"aria-label": t('Share.members.revoke')
|
|
104
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
105
|
-
icon: CrossCircleOutlineIcon
|
|
106
|
-
})));
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default ShareDriveRecipientPermissions;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
3
|
-
import { useI18n } from 'twake-i18n';
|
|
4
|
-
|
|
5
|
-
var SharedDriveRecipientStatus = function SharedDriveRecipientStatus(_ref) {
|
|
6
|
-
var members = _ref.members,
|
|
7
|
-
email = _ref.email;
|
|
8
|
-
|
|
9
|
-
var _useI18n = useI18n(),
|
|
10
|
-
t = _useI18n.t;
|
|
11
|
-
|
|
12
|
-
var text = members ? t('GroupRecipient.secondary', {
|
|
13
|
-
memberCount: members.length,
|
|
14
|
-
smart_count: members.length
|
|
15
|
-
}) : email;
|
|
16
|
-
return /*#__PURE__*/React.createElement(Typography, {
|
|
17
|
-
variant: "caption",
|
|
18
|
-
color: "textSecondary"
|
|
19
|
-
}, text);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default SharedDriveRecipientStatus;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
4
|
-
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
5
|
-
import TextField from 'cozy-ui/transpiled/react/TextField';
|
|
6
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
7
|
-
import { useI18n } from 'twake-i18n';
|
|
8
|
-
import withLocales from '../../hoc/withLocales';
|
|
9
|
-
import AntivirusAlert from '../AntivirusAlert';
|
|
10
|
-
import { default as DumbShareByEmail } from '../ShareByEmail';
|
|
11
|
-
import ShareByLink from '../ShareByLink';
|
|
12
|
-
import WhoHasAccess from '../WhoHasAccess';
|
|
13
|
-
export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
14
|
-
var title = _ref.title,
|
|
15
|
-
document = _ref.document,
|
|
16
|
-
folderName = _ref.folderName,
|
|
17
|
-
handleFolderNameChange = _ref.handleFolderNameChange,
|
|
18
|
-
recipients = _ref.recipients,
|
|
19
|
-
currentRecipients = _ref.currentRecipients,
|
|
20
|
-
onRevoke = _ref.onRevoke,
|
|
21
|
-
onSend = _ref.onSend,
|
|
22
|
-
onClose = _ref.onClose,
|
|
23
|
-
_ref$showNameField = _ref.showNameField,
|
|
24
|
-
showNameField = _ref$showNameField === void 0 ? false : _ref$showNameField,
|
|
25
|
-
sharingLink = _ref.sharingLink,
|
|
26
|
-
nameLabel = _ref.nameLabel,
|
|
27
|
-
shareLabel = _ref.shareLabel,
|
|
28
|
-
_ref$showShareByEmail = _ref.showShareByEmail,
|
|
29
|
-
showShareByEmail = _ref$showShareByEmail === void 0 ? true : _ref$showShareByEmail,
|
|
30
|
-
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
31
|
-
showGenerateLinkButton = _ref.showGenerateLinkButton,
|
|
32
|
-
pendingRecipients = _ref.pendingRecipients,
|
|
33
|
-
onPendingRecipientsChange = _ref.onPendingRecipientsChange,
|
|
34
|
-
selectedOption = _ref.selectedOption,
|
|
35
|
-
onSelectedOptionChange = _ref.onSelectedOptionChange;
|
|
36
|
-
|
|
37
|
-
var _useI18n = useI18n(),
|
|
38
|
-
t = _useI18n.t;
|
|
39
|
-
|
|
40
|
-
var actionButtons = function () {
|
|
41
|
-
if (!showShareByEmail) {
|
|
42
|
-
return /*#__PURE__*/React.createElement(ShareByLink, {
|
|
43
|
-
link: sharingLink,
|
|
44
|
-
document: document,
|
|
45
|
-
documentType: "Files",
|
|
46
|
-
showGenerateLinkButton: showGenerateLinkButton,
|
|
47
|
-
autoOpenShareRestriction: autoOpenShareRestriction
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!showNameField) {
|
|
52
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareByLink, {
|
|
53
|
-
link: sharingLink,
|
|
54
|
-
document: document,
|
|
55
|
-
documentType: "Files",
|
|
56
|
-
showGenerateLinkButton: showGenerateLinkButton,
|
|
57
|
-
autoOpenShareRestriction: autoOpenShareRestriction
|
|
58
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
59
|
-
variant: "primary",
|
|
60
|
-
label: shareLabel,
|
|
61
|
-
disabled: !onSend,
|
|
62
|
-
onClick: onSend
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return null;
|
|
67
|
-
}();
|
|
68
|
-
|
|
69
|
-
return /*#__PURE__*/React.createElement(FixedDialog, {
|
|
70
|
-
open: true,
|
|
71
|
-
disableGutters: true,
|
|
72
|
-
onClose: onClose,
|
|
73
|
-
title: title,
|
|
74
|
-
classes: {
|
|
75
|
-
paper: 'u-ov-visible'
|
|
76
|
-
},
|
|
77
|
-
componentsProps: {
|
|
78
|
-
dialogContent: {
|
|
79
|
-
className: 'u-ov-visible'
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
content: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
className: "u-ph-2"
|
|
84
|
-
}, /*#__PURE__*/React.createElement(AntivirusAlert, {
|
|
85
|
-
document: document
|
|
86
|
-
}), showNameField && handleFolderNameChange && /*#__PURE__*/React.createElement(TextField, {
|
|
87
|
-
required: true,
|
|
88
|
-
label: nameLabel,
|
|
89
|
-
variant: "outlined",
|
|
90
|
-
size: "small",
|
|
91
|
-
className: "u-w-100 u-mt-1-half",
|
|
92
|
-
value: folderName !== null && folderName !== void 0 ? folderName : '',
|
|
93
|
-
onChange: handleFolderNameChange
|
|
94
|
-
}), /*#__PURE__*/React.createElement(Typography, {
|
|
95
|
-
variant: "h6",
|
|
96
|
-
className: "u-mt-1-half u-mb-half"
|
|
97
|
-
}, t('Share.contacts.addUsers')), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
98
|
-
currentRecipients: currentRecipients,
|
|
99
|
-
document: document,
|
|
100
|
-
documentType: "Files",
|
|
101
|
-
pendingRecipients: pendingRecipients,
|
|
102
|
-
onPendingRecipientsChange: onPendingRecipientsChange,
|
|
103
|
-
selectedOption: selectedOption,
|
|
104
|
-
onSelectedOptionChange: onSelectedOptionChange
|
|
105
|
-
})), /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
106
|
-
isOwner: true,
|
|
107
|
-
isSharedDrive: true,
|
|
108
|
-
recipients: recipients,
|
|
109
|
-
document: document,
|
|
110
|
-
documentType: "Files",
|
|
111
|
-
className: "u-w-100",
|
|
112
|
-
onRevoke: onRevoke,
|
|
113
|
-
link: sharingLink
|
|
114
|
-
})),
|
|
115
|
-
actions: actionButtons
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
DumbBatchSharedFolderModal.propTypes = {
|
|
119
|
-
title: PropTypes.string,
|
|
120
|
-
document: PropTypes.object,
|
|
121
|
-
folderName: PropTypes.string,
|
|
122
|
-
handleFolderNameChange: PropTypes.func,
|
|
123
|
-
recipients: PropTypes.array,
|
|
124
|
-
currentRecipients: PropTypes.array,
|
|
125
|
-
onRevoke: PropTypes.func.isRequired,
|
|
126
|
-
onCreate: PropTypes.func,
|
|
127
|
-
onSend: PropTypes.func,
|
|
128
|
-
onClose: PropTypes.func.isRequired,
|
|
129
|
-
onRename: PropTypes.func,
|
|
130
|
-
showNameField: PropTypes.bool,
|
|
131
|
-
sharingLink: PropTypes.string,
|
|
132
|
-
nameLabel: PropTypes.string,
|
|
133
|
-
addPeopleLabel: PropTypes.string,
|
|
134
|
-
cancelLabel: PropTypes.string,
|
|
135
|
-
createLabel: PropTypes.string,
|
|
136
|
-
shareLabel: PropTypes.string,
|
|
137
|
-
saveLabel: PropTypes.string,
|
|
138
|
-
showShareByEmail: PropTypes.bool,
|
|
139
|
-
autoOpenShareRestriction: PropTypes.bool,
|
|
140
|
-
showGenerateLinkButton: PropTypes.bool,
|
|
141
|
-
pendingRecipients: PropTypes.array,
|
|
142
|
-
onPendingRecipientsChange: PropTypes.func,
|
|
143
|
-
selectedOption: PropTypes.oneOf(['readWrite', 'readOnly']),
|
|
144
|
-
onSelectedOptionChange: PropTypes.func
|
|
145
|
-
};
|