cozy-sharing 32.3.1 → 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 +6 -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/state.js +6 -1
- package/package.json +2 -2
- 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/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,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
|
-
});
|
|
@@ -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
|
-
});
|