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
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { useState, useEffect } from 'react'
|
|
3
|
-
|
|
4
|
-
import { useClient } from 'cozy-client'
|
|
5
|
-
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
|
|
6
|
-
import { useI18n } from 'twake-i18n'
|
|
7
|
-
|
|
8
|
-
import { DumbFederatedFolderModal } from './DumbFederatedFolderModal'
|
|
9
|
-
import withLocales from '../../hoc/withLocales'
|
|
10
|
-
import { useSharingContext } from '../../hooks/useSharingContext'
|
|
11
|
-
import {
|
|
12
|
-
formatRecipients,
|
|
13
|
-
mergeAndDeduplicateRecipients,
|
|
14
|
-
moveRecipientToReadWrite,
|
|
15
|
-
moveRecipientToReadOnly,
|
|
16
|
-
RECIPIENT_INDEX_PREFIX
|
|
17
|
-
} from '../SharedDrive/helpers'
|
|
18
|
-
|
|
19
|
-
export const FederatedFolderModal = withLocales(
|
|
20
|
-
({ onClose, document: existingDocument }) => {
|
|
21
|
-
const client = useClient()
|
|
22
|
-
const { t } = useI18n()
|
|
23
|
-
const {
|
|
24
|
-
share,
|
|
25
|
-
getSharingLink,
|
|
26
|
-
getFederatedShareLink,
|
|
27
|
-
getDocumentPermissions,
|
|
28
|
-
getOwner,
|
|
29
|
-
getSharingById,
|
|
30
|
-
getRecipients,
|
|
31
|
-
revoke
|
|
32
|
-
} = useSharingContext()
|
|
33
|
-
const { showAlert } = useAlert()
|
|
34
|
-
|
|
35
|
-
const [sharingLink, setSharingLink] = useState(null)
|
|
36
|
-
|
|
37
|
-
const documentPermissions = existingDocument
|
|
38
|
-
? getDocumentPermissions(existingDocument._id)
|
|
39
|
-
: []
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
const fetchSharingLink = async () => {
|
|
43
|
-
if (!existingDocument) return
|
|
44
|
-
|
|
45
|
-
if (existingDocument.driveId) {
|
|
46
|
-
const link = await getFederatedShareLink(existingDocument)
|
|
47
|
-
setSharingLink(link)
|
|
48
|
-
} else {
|
|
49
|
-
setSharingLink(getSharingLink(existingDocument._id))
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
fetchSharingLink()
|
|
54
|
-
}, [
|
|
55
|
-
existingDocument,
|
|
56
|
-
documentPermissions,
|
|
57
|
-
getFederatedShareLink,
|
|
58
|
-
getSharingLink,
|
|
59
|
-
getOwner,
|
|
60
|
-
getSharingById
|
|
61
|
-
])
|
|
62
|
-
|
|
63
|
-
const [federatedRecipients, setFederatedRecipients] = useState({
|
|
64
|
-
recipients: [],
|
|
65
|
-
readOnlyRecipients: []
|
|
66
|
-
})
|
|
67
|
-
const [folderName] = useState(existingDocument?.name || '')
|
|
68
|
-
|
|
69
|
-
const onShare = params => {
|
|
70
|
-
setFederatedRecipients(prev => ({
|
|
71
|
-
recipients: mergeAndDeduplicateRecipients([
|
|
72
|
-
prev.recipients,
|
|
73
|
-
params.recipients || []
|
|
74
|
-
]),
|
|
75
|
-
readOnlyRecipients: mergeAndDeduplicateRecipients([
|
|
76
|
-
prev.readOnlyRecipients,
|
|
77
|
-
params.readOnlyRecipients || []
|
|
78
|
-
])
|
|
79
|
-
}))
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const onSend = async () => {
|
|
83
|
-
try {
|
|
84
|
-
await share({
|
|
85
|
-
description: folderName,
|
|
86
|
-
document: existingDocument,
|
|
87
|
-
recipients: federatedRecipients.recipients,
|
|
88
|
-
readOnlyRecipients: federatedRecipients.readOnlyRecipients,
|
|
89
|
-
sharedDrive: true,
|
|
90
|
-
openSharing: false
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
showAlert({
|
|
94
|
-
message: t('FederatedFolder.successNotification'),
|
|
95
|
-
severity: 'success',
|
|
96
|
-
variant: 'filled'
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
onClose()
|
|
100
|
-
} catch (_err) {
|
|
101
|
-
showAlert({
|
|
102
|
-
message: t('FederatedFolder.errorNotification'),
|
|
103
|
-
severity: 'error',
|
|
104
|
-
variant: 'filled'
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const onSetType = (index, newType) => {
|
|
110
|
-
const _id = index.split(RECIPIENT_INDEX_PREFIX)[1]
|
|
111
|
-
|
|
112
|
-
if (newType === 'two-way') {
|
|
113
|
-
setFederatedRecipients(prev => moveRecipientToReadWrite(prev, _id))
|
|
114
|
-
} else {
|
|
115
|
-
setFederatedRecipients(prev => moveRecipientToReadOnly(prev, _id))
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const onRevoke = async (documentOrIndex, sharingId, memberIndex) => {
|
|
120
|
-
if (
|
|
121
|
-
typeof documentOrIndex === 'string' &&
|
|
122
|
-
documentOrIndex.startsWith(RECIPIENT_INDEX_PREFIX)
|
|
123
|
-
) {
|
|
124
|
-
const _id = documentOrIndex.split(RECIPIENT_INDEX_PREFIX)[1]
|
|
125
|
-
setFederatedRecipients(prev => ({
|
|
126
|
-
recipients: prev.recipients.filter(r => r._id !== _id),
|
|
127
|
-
readOnlyRecipients: prev.readOnlyRecipients.filter(r => r._id !== _id)
|
|
128
|
-
}))
|
|
129
|
-
} else {
|
|
130
|
-
await revoke(documentOrIndex, sharingId, memberIndex)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const existingRecipients = existingDocument
|
|
135
|
-
? getRecipients(existingDocument._id)
|
|
136
|
-
: []
|
|
137
|
-
|
|
138
|
-
const recipients = [
|
|
139
|
-
...existingRecipients,
|
|
140
|
-
...formatRecipients(federatedRecipients)
|
|
141
|
-
]
|
|
142
|
-
|
|
143
|
-
const modalTitle = t('FederatedFolder.shareTitle', { name: folderName })
|
|
144
|
-
|
|
145
|
-
const isSharedDrive = Boolean(existingDocument?.driveId)
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<DumbFederatedFolderModal
|
|
149
|
-
title={modalTitle}
|
|
150
|
-
document={existingDocument}
|
|
151
|
-
createContact={contact => client.create('io.cozy.contacts', contact)}
|
|
152
|
-
recipients={recipients}
|
|
153
|
-
readOnlyRecipients={federatedRecipients.readOnlyRecipients}
|
|
154
|
-
currentRecipients={existingRecipients}
|
|
155
|
-
onRevoke={onRevoke}
|
|
156
|
-
onSetType={onSetType}
|
|
157
|
-
onSend={onSend}
|
|
158
|
-
onClose={onClose}
|
|
159
|
-
onShare={onShare}
|
|
160
|
-
sharingLink={sharingLink}
|
|
161
|
-
showShareByEmail={!isSharedDrive}
|
|
162
|
-
/>
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
FederatedFolderModal.propTypes = {
|
|
168
|
-
onClose: PropTypes.func.isRequired,
|
|
169
|
-
document: PropTypes.object.isRequired
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export default FederatedFolderModal
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
3
|
-
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
-
import ForbiddenIcon from 'cozy-ui/transpiled/react/Icons/Forbidden';
|
|
6
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
7
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
-
|
|
10
|
-
var revokeGroup = function revokeGroup(_ref) {
|
|
11
|
-
var t = _ref.t,
|
|
12
|
-
isOwner = _ref.isOwner,
|
|
13
|
-
isSharedDrive = _ref.isSharedDrive,
|
|
14
|
-
handleRevocation = _ref.handleRevocation;
|
|
15
|
-
var revokeType = isOwner ? 'revoke' : 'revokeSelf';
|
|
16
|
-
var title = t("RevokeGroupItem.".concat(revokeType, ".title"));
|
|
17
|
-
var desc = isOwner && isSharedDrive ? t("RevokeGroupItem.revoke.sharedDriveDesc") : t("RevokeGroupItem.".concat(revokeType, ".desc"));
|
|
18
|
-
var icon = ForbiddenIcon;
|
|
19
|
-
return {
|
|
20
|
-
name: 'revokeMember',
|
|
21
|
-
label: title,
|
|
22
|
-
icon: icon,
|
|
23
|
-
action: function action() {
|
|
24
|
-
handleRevocation();
|
|
25
|
-
},
|
|
26
|
-
Component: /*#__PURE__*/forwardRef(function RevokeMemberItem(props, ref) {
|
|
27
|
-
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
28
|
-
ref: ref
|
|
29
|
-
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
-
icon: icon,
|
|
31
|
-
color: "var(--errorColor)"
|
|
32
|
-
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
33
|
-
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
34
|
-
color: "error"
|
|
35
|
-
}, title),
|
|
36
|
-
secondary: desc
|
|
37
|
-
}));
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export { revokeGroup };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
3
|
-
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
-
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
6
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
7
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
-
|
|
10
|
-
var revokeMember = function revokeMember(_ref) {
|
|
11
|
-
var t = _ref.t,
|
|
12
|
-
isOwner = _ref.isOwner,
|
|
13
|
-
isSharedDrive = _ref.isSharedDrive,
|
|
14
|
-
handleRevocation = _ref.handleRevocation;
|
|
15
|
-
var revokeType = isOwner ? 'revoke' : 'revokeSelf';
|
|
16
|
-
var title = t("RevokeMemberItem.".concat(revokeType, ".title"));
|
|
17
|
-
var desc = isOwner && isSharedDrive ? t("RevokeMemberItem.revoke.sharedDriveDesc") : t("RevokeMemberItem.".concat(revokeType, ".desc"));
|
|
18
|
-
var icon = TrashIcon;
|
|
19
|
-
return {
|
|
20
|
-
name: 'revokeMember',
|
|
21
|
-
label: title,
|
|
22
|
-
icon: icon,
|
|
23
|
-
action: function action() {
|
|
24
|
-
handleRevocation();
|
|
25
|
-
},
|
|
26
|
-
Component: /*#__PURE__*/forwardRef(function RevokeMemberItem(props, ref) {
|
|
27
|
-
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
28
|
-
ref: ref
|
|
29
|
-
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
-
icon: icon,
|
|
31
|
-
color: "var(--errorColor)"
|
|
32
|
-
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
33
|
-
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
34
|
-
color: "error"
|
|
35
|
-
}, title),
|
|
36
|
-
secondary: desc
|
|
37
|
-
}));
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export { revokeMember };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
3
|
-
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
-
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
6
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
7
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
-
|
|
10
|
-
var makeComponent = function makeComponent(title) {
|
|
11
|
-
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
|
-
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
13
|
-
ref: ref
|
|
14
|
-
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
15
|
-
icon: TrashIcon,
|
|
16
|
-
color: "var(--errorColor)"
|
|
17
|
-
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
18
|
-
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
19
|
-
color: "error"
|
|
20
|
-
}, title)
|
|
21
|
-
}));
|
|
22
|
-
});
|
|
23
|
-
Component.displayName = 'RevokeSharedDriveMember';
|
|
24
|
-
return Component;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
var revokeSharedDriveMember = function revokeSharedDriveMember(_ref) {
|
|
28
|
-
var t = _ref.t,
|
|
29
|
-
handleRevocation = _ref.handleRevocation;
|
|
30
|
-
var title = t("RevokeSharedDriveMemberItem.revoke.title");
|
|
31
|
-
return {
|
|
32
|
-
name: 'revokeSharedDriveMember',
|
|
33
|
-
label: title,
|
|
34
|
-
action: function action() {
|
|
35
|
-
handleRevocation();
|
|
36
|
-
},
|
|
37
|
-
Component: makeComponent(title)
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { revokeSharedDriveMember };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import omit from 'lodash/omit';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { useLocation } from 'react-router';
|
|
5
|
-
import EditableSharingModal from './EditableSharingModal';
|
|
6
|
-
import { SharingDetailsModal } from './SharingDetailsModal';
|
|
7
|
-
import withLocales from '../../hoc/withLocales';
|
|
8
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
9
|
-
export var ShareModal = withLocales(function (props) {
|
|
10
|
-
var _location$state;
|
|
11
|
-
|
|
12
|
-
var location = useLocation === null || useLocation === void 0 ? void 0 : useLocation();
|
|
13
|
-
var locationProps = location === null || location === void 0 || (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.modalProps;
|
|
14
|
-
var document = (locationProps === null || locationProps === void 0 ? void 0 : locationProps.document) || props.document;
|
|
15
|
-
var rest = omit(locationProps || props, 'document');
|
|
16
|
-
|
|
17
|
-
var _useSharingContext = useSharingContext(),
|
|
18
|
-
byDocId = _useSharingContext.byDocId,
|
|
19
|
-
isOwner = _useSharingContext.isOwner,
|
|
20
|
-
canReshare = _useSharingContext.canReshare,
|
|
21
|
-
documentType = _useSharingContext.documentType,
|
|
22
|
-
getOwner = _useSharingContext.getOwner,
|
|
23
|
-
getSharingType = _useSharingContext.getSharingType,
|
|
24
|
-
getRecipients = _useSharingContext.getRecipients,
|
|
25
|
-
revokeSelf = _useSharingContext.revokeSelf;
|
|
26
|
-
|
|
27
|
-
var isEditable = !byDocId[document.id] || isOwner(document.id) || canReshare(document.id);
|
|
28
|
-
|
|
29
|
-
if (isEditable) {
|
|
30
|
-
return /*#__PURE__*/React.createElement(EditableSharingModal, _extends({
|
|
31
|
-
document: document
|
|
32
|
-
}, rest));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return /*#__PURE__*/React.createElement(SharingDetailsModal, _extends({
|
|
36
|
-
document: document,
|
|
37
|
-
documentType: documentType,
|
|
38
|
-
owner: getOwner(document.id),
|
|
39
|
-
sharingType: getSharingType(document.id),
|
|
40
|
-
recipients: getRecipients(document.id),
|
|
41
|
-
onRevoke: revokeSelf
|
|
42
|
-
}, rest));
|
|
43
|
-
});
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import flag from "cozy-flags";
|
|
5
|
-
import { ShareModal } from "./ShareModal";
|
|
6
|
-
import { useSharingContext } from "../../hooks/useSharingContext";
|
|
7
|
-
var mockOnClose = jest.fn();
|
|
8
|
-
var mockOnShare = jest.fn();
|
|
9
|
-
var mockOnRevoke = jest.fn();
|
|
10
|
-
jest.mock("cozy-flags");
|
|
11
|
-
jest.mock("../../hooks/useSharingContext", function () {
|
|
12
|
-
return {
|
|
13
|
-
useSharingContext: jest.fn()
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
jest.mock("./EditableSharingModal", function () {
|
|
17
|
-
return {
|
|
18
|
-
__esModule: true,
|
|
19
|
-
default: function _default() {
|
|
20
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
-
"data-testid": "editable-sharing-modal"
|
|
22
|
-
}, "EditableSharingModal");
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
jest.mock("./SharingDetailsModal", function () {
|
|
27
|
-
return {
|
|
28
|
-
SharingDetailsModal: function SharingDetailsModal() {
|
|
29
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
-
"data-testid": "sharing-details-modal"
|
|
31
|
-
}, "SharingDetailsModal");
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
jest.mock("../FederatedFolder/FederatedFolderModal", function () {
|
|
36
|
-
return {
|
|
37
|
-
FederatedFolderModal: function FederatedFolderModal() {
|
|
38
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
39
|
-
"data-testid": "federated-folder-modal"
|
|
40
|
-
}, "FederatedFolderModal");
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
jest.mock("../../hoc/withLocales", function () {
|
|
45
|
-
return {
|
|
46
|
-
__esModule: true,
|
|
47
|
-
default: function _default(Component) {
|
|
48
|
-
return Component;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
describe("ShareModal", function () {
|
|
53
|
-
var defaultDocument = {
|
|
54
|
-
id: "doc-123",
|
|
55
|
-
_id: "doc-123",
|
|
56
|
-
name: "Test Document"
|
|
57
|
-
};
|
|
58
|
-
var defaultProps = {
|
|
59
|
-
document: defaultDocument,
|
|
60
|
-
onClose: mockOnClose,
|
|
61
|
-
onShare: mockOnShare,
|
|
62
|
-
onRevoke: mockOnRevoke
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
var setup = function setup() {
|
|
66
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
-
return render( /*#__PURE__*/React.createElement(ShareModal, _extends({}, defaultProps, props)));
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
beforeEach(function () {
|
|
71
|
-
jest.clearAllMocks();
|
|
72
|
-
flag.mockImplementation(function () {
|
|
73
|
-
return false;
|
|
74
|
-
});
|
|
75
|
-
useSharingContext.mockReturnValue({
|
|
76
|
-
byDocId: {},
|
|
77
|
-
isOwner: function isOwner() {
|
|
78
|
-
return true;
|
|
79
|
-
},
|
|
80
|
-
canReshare: function canReshare() {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe("federated mode", function () {
|
|
86
|
-
it("should render FederatedFolderModal when federated mode is enabled and no sharings exist", function () {
|
|
87
|
-
flag.mockImplementation(function (flagName) {
|
|
88
|
-
if (flagName === "drive.federated-shared-folder.enabled") {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return false;
|
|
93
|
-
});
|
|
94
|
-
useSharingContext.mockReturnValue({
|
|
95
|
-
byDocId: {
|
|
96
|
-
"doc-123": {
|
|
97
|
-
sharings: []
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
isOwner: function isOwner() {
|
|
101
|
-
return true;
|
|
102
|
-
},
|
|
103
|
-
canReshare: function canReshare() {
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
var _setup = setup(),
|
|
109
|
-
getByTestId = _setup.getByTestId;
|
|
110
|
-
|
|
111
|
-
expect(getByTestId("federated-folder-modal")).toBeInTheDocument();
|
|
112
|
-
});
|
|
113
|
-
it("should render EditableSharingModal when federated mode is enabled but sharings exist", function () {
|
|
114
|
-
flag.mockImplementation(function (flagName) {
|
|
115
|
-
if (flagName === "drive.federated-shared-folder.enabled") {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return false;
|
|
120
|
-
});
|
|
121
|
-
useSharingContext.mockReturnValue({
|
|
122
|
-
byDocId: {
|
|
123
|
-
"doc-123": {
|
|
124
|
-
sharings: [{
|
|
125
|
-
id: "sharing-1"
|
|
126
|
-
}]
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
isOwner: function isOwner() {
|
|
130
|
-
return true;
|
|
131
|
-
},
|
|
132
|
-
canReshare: function canReshare() {
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
var _setup2 = setup(),
|
|
138
|
-
getByTestId = _setup2.getByTestId;
|
|
139
|
-
|
|
140
|
-
expect(getByTestId("editable-sharing-modal")).toBeInTheDocument();
|
|
141
|
-
});
|
|
142
|
-
it("should render EditableSharingModal when federated mode is disabled", function () {
|
|
143
|
-
flag.mockImplementation(function () {
|
|
144
|
-
return false;
|
|
145
|
-
});
|
|
146
|
-
useSharingContext.mockReturnValue({
|
|
147
|
-
byDocId: {
|
|
148
|
-
"doc-123": {
|
|
149
|
-
sharings: []
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
isOwner: function isOwner() {
|
|
153
|
-
return true;
|
|
154
|
-
},
|
|
155
|
-
canReshare: function canReshare() {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
var _setup3 = setup(),
|
|
161
|
-
getByTestId = _setup3.getByTestId;
|
|
162
|
-
|
|
163
|
-
expect(getByTestId("editable-sharing-modal")).toBeInTheDocument();
|
|
164
|
-
});
|
|
165
|
-
it("should render FederatedFolderModal when document has no sharings entry", function () {
|
|
166
|
-
flag.mockImplementation(function (flagName) {
|
|
167
|
-
if (flagName === "drive.federated-shared-folder.enabled") {
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return false;
|
|
172
|
-
});
|
|
173
|
-
useSharingContext.mockReturnValue({
|
|
174
|
-
byDocId: {},
|
|
175
|
-
isOwner: function isOwner() {
|
|
176
|
-
return true;
|
|
177
|
-
},
|
|
178
|
-
canReshare: function canReshare() {
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
var _setup4 = setup(),
|
|
184
|
-
getByTestId = _setup4.getByTestId;
|
|
185
|
-
|
|
186
|
-
expect(getByTestId("federated-folder-modal")).toBeInTheDocument();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
describe("regular mode", function () {
|
|
190
|
-
it("should render EditableSharingModal by default", function () {
|
|
191
|
-
var _setup5 = setup(),
|
|
192
|
-
getByTestId = _setup5.getByTestId;
|
|
193
|
-
|
|
194
|
-
expect(getByTestId("editable-sharing-modal")).toBeInTheDocument();
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
});
|