cozy-sharing 4.9.0 → 5.0.1
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 +28 -0
- package/dist/SharingBanner/components/getHomeLinkHref.js +5 -0
- package/dist/SharingBanner/components/getHomeLinkHref.spec.js +9 -0
- package/dist/SharingBanner/hooks/useSharingInfos.js +3 -2
- package/dist/SharingBanner/index.js +7 -2
- package/dist/components/EditLinkPermissionDialog.js +72 -0
- package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
- package/dist/components/Recipient/AvatarPlusX.js +41 -0
- package/dist/components/Recipient/Identity.js +43 -0
- package/dist/components/Recipient/LinkRecipient.js +72 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
- package/dist/components/Recipient/OwnerIdentity.js +44 -0
- package/dist/components/Recipient/Recipient.js +72 -0
- package/dist/components/Recipient/Recipient.spec.js +178 -0
- package/dist/components/Recipient/RecipientAvatar.js +33 -0
- package/dist/components/Recipient/RecipientConfirm.js +63 -0
- package/dist/components/Recipient/RecipientPermissions.js +126 -0
- package/dist/components/Recipient/RecipientPlusX.js +45 -0
- package/dist/components/Recipient/RecipientStatus.js +64 -0
- package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
- package/dist/components/Recipient/RecipientsAvatars.js +100 -0
- package/dist/components/Recipient/RecipientsAvatars.spec.js +145 -0
- package/dist/components/Recipient/recipient.styl +82 -0
- package/dist/components/ShareButtonWithRecipients.js +8 -0
- package/dist/components/badge.styl +1 -1
- package/dist/helpers/documentType.js +6 -0
- package/dist/helpers/link.js +5 -0
- package/dist/helpers/permissions.js +8 -0
- package/dist/helpers/recipients.js +24 -0
- package/dist/helpers/synchronousJobQueue.js +67 -0
- package/dist/helpers/synchronousJobQueue.spec.js +97 -0
- package/dist/queries/queries.js +72 -0
- package/dist/stylesheet.css +1 -1
- package/package.json +2 -3
- package/src/SharingBanner/hooks/useSharingInfos.jsx +3 -3
- package/src/SharingBanner/index.jsx +7 -3
- package/src/components/badge.styl +1 -1
- package/LICENSE +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 5.0.1 (2023-02-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add custom previewPath
|
|
12
|
+
|
|
13
|
+
# 5.0.0 (2023-01-09)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* Color for badge with me ([bd7def0](https://github.com/cozy/cozy-libs/commit/bd7def03e0db9d8771a1e96965684d8785f6c91b))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **harvest:** Update router packages ([3f08dd2](https://github.com/cozy/cozy-libs/commit/3f08dd2a99fb516c45ff938ca528dece63d10ca3))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### BREAKING CHANGES
|
|
27
|
+
|
|
28
|
+
* **harvest:** `react-router-dom` is `>=4` as peer dependencies.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
# [4.9.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.8.2...cozy-sharing@4.9.0) (2022-12-20)
|
|
7
35
|
|
|
8
36
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import getHomeLinkHref from './getHomeLinkHref';
|
|
2
|
+
describe('getHomeLinkHref', function () {
|
|
3
|
+
it('Should add the origin parameter', function () {
|
|
4
|
+
expect(getHomeLinkHref('cozy.io')).toEqual('https://manager.cozycloud.cc/cozy/create?pk_campaign=cozy.io&pk_kwd=cozy');
|
|
5
|
+
});
|
|
6
|
+
it('Should not add the origin parameter', function () {
|
|
7
|
+
expect(getHomeLinkHref('')).toEqual('https://manager.cozycloud.cc/cozy/create?&pk_kwd=cozy');
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -14,6 +14,7 @@ var getSharingId = function getSharingId(permission) {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export var useSharingInfos = function useSharingInfos() {
|
|
17
|
+
var previewPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/preview';
|
|
17
18
|
var client = useClient();
|
|
18
19
|
|
|
19
20
|
var _useState = useState(),
|
|
@@ -92,12 +93,12 @@ export var useSharingInfos = function useSharingInfos() {
|
|
|
92
93
|
};
|
|
93
94
|
}();
|
|
94
95
|
|
|
95
|
-
if (window.location.pathname ===
|
|
96
|
+
if (window.location.pathname === previewPath) {
|
|
96
97
|
loadSharingDiscoveryLink();
|
|
97
98
|
} else {
|
|
98
99
|
setLoading(false);
|
|
99
100
|
}
|
|
100
|
-
}, [client]);
|
|
101
|
+
}, [client, previewPath]);
|
|
101
102
|
return {
|
|
102
103
|
sharing: sharing,
|
|
103
104
|
loading: loading,
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import withLocales from '../withLocales';
|
|
3
4
|
import { useSharingInfos } from './hooks/useSharingInfos';
|
|
4
5
|
import { SharingBanner } from './components/SharingBanner';
|
|
5
6
|
|
|
6
|
-
var Plugin = function Plugin() {
|
|
7
|
-
var
|
|
7
|
+
var Plugin = function Plugin(_ref) {
|
|
8
|
+
var previewPath = _ref.previewPath;
|
|
9
|
+
var sharingInfos = useSharingInfos(previewPath);
|
|
8
10
|
return /*#__PURE__*/React.createElement(SharingBanner, {
|
|
9
11
|
sharingInfos: sharingInfos
|
|
10
12
|
});
|
|
11
13
|
};
|
|
12
14
|
|
|
15
|
+
Plugin.propTypes = {
|
|
16
|
+
previewPath: PropTypes.string
|
|
17
|
+
};
|
|
13
18
|
export var SharingBannerPlugin = withLocales(Plugin);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
5
|
+
import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
6
|
+
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
7
|
+
import Radio from 'cozy-ui/transpiled/react/Radios';
|
|
8
|
+
import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup';
|
|
9
|
+
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel';
|
|
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;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
4
|
+
import { createMockClient } from 'cozy-client';
|
|
5
|
+
import AppLike from '../../test/AppLike';
|
|
6
|
+
import EditLinkPermissionDialog from './EditLinkPermissionDialog';
|
|
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
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import uniqueId from 'lodash/uniqueId';
|
|
4
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
5
|
+
import { SharingTooltip, TooltipRecipientList } from '../Tooltip';
|
|
6
|
+
|
|
7
|
+
var AvatarPlusX = function AvatarPlusX(_ref) {
|
|
8
|
+
var className = _ref.className,
|
|
9
|
+
size = _ref.size,
|
|
10
|
+
_ref$extraRecipients = _ref.extraRecipients,
|
|
11
|
+
extraRecipients = _ref$extraRecipients === void 0 ? [] : _ref$extraRecipients;
|
|
12
|
+
var sharingTooltipId = uniqueId('extra-recipients-avatar-');
|
|
13
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
14
|
+
"data-tip": true,
|
|
15
|
+
"data-for": sharingTooltipId,
|
|
16
|
+
className: "u-db"
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
18
|
+
className: className,
|
|
19
|
+
size: size,
|
|
20
|
+
text: "+".concat(Math.min(extraRecipients.length, 99)),
|
|
21
|
+
style: {
|
|
22
|
+
backgroundColor: 'var(--genericRecipientBackground)',
|
|
23
|
+
color: 'var(--genericRecipientColor)'
|
|
24
|
+
}
|
|
25
|
+
}), /*#__PURE__*/React.createElement(SharingTooltip, {
|
|
26
|
+
id: sharingTooltipId
|
|
27
|
+
}, /*#__PURE__*/React.createElement(TooltipRecipientList, {
|
|
28
|
+
recipientNames: extraRecipients
|
|
29
|
+
})));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
AvatarPlusX.propTypes = {
|
|
33
|
+
extraRecipients: PropTypes.arrayOf(PropTypes.string),
|
|
34
|
+
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
35
|
+
className: PropTypes.string
|
|
36
|
+
};
|
|
37
|
+
AvatarPlusX.defaultProps = {
|
|
38
|
+
extraRecipients: [],
|
|
39
|
+
size: 'medium'
|
|
40
|
+
};
|
|
41
|
+
export default AvatarPlusX;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
var styles = {
|
|
5
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
6
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
7
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
8
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
9
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
10
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
11
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
12
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
13
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
14
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
15
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
16
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
17
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
18
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
19
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
20
|
+
"spin": "recipient__spin___3_Uja",
|
|
21
|
+
"shake": "recipient__shake___TrWC0"
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var Identity = function Identity(_ref) {
|
|
25
|
+
var name = _ref.name,
|
|
26
|
+
details = _ref.details;
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: classNames(styles['recipient-idents'], 'u-ml-1')
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: styles['recipient-user']
|
|
31
|
+
}, name), /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: styles['recipient-details']
|
|
33
|
+
}, details));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Identity.propTypes = {
|
|
37
|
+
name: PropTypes.string.isRequired,
|
|
38
|
+
details: PropTypes.string
|
|
39
|
+
};
|
|
40
|
+
Identity.defaultProps = {
|
|
41
|
+
details: '-'
|
|
42
|
+
};
|
|
43
|
+
export default Identity;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
5
|
+
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon';
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
9
|
+
import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
|
|
10
|
+
import Circle from 'cozy-ui/transpiled/react/Circle';
|
|
11
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
12
|
+
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
13
|
+
import { FADE_IN_DURATION } from '../../helpers/recipients';
|
|
14
|
+
import RecipientConfirm from './RecipientConfirm';
|
|
15
|
+
import LinkRecipientPermissions from './LinkRecipientPermissions';
|
|
16
|
+
var styles = {
|
|
17
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
18
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
19
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
20
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
21
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
22
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
23
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
24
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
25
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
26
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
27
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
28
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
29
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
30
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
31
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
32
|
+
"spin": "recipient__spin___3_Uja",
|
|
33
|
+
"shake": "recipient__shake___TrWC0"
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var LinkRecipient = function LinkRecipient(props) {
|
|
37
|
+
var _useI18n = useI18n(),
|
|
38
|
+
t = _useI18n.t;
|
|
39
|
+
|
|
40
|
+
var recipientConfirmationData = props.recipientConfirmationData,
|
|
41
|
+
verifyRecipient = props.verifyRecipient,
|
|
42
|
+
link = props.link,
|
|
43
|
+
fadeIn = props.fadeIn;
|
|
44
|
+
var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
|
|
45
|
+
recipientConfirmationData: recipientConfirmationData,
|
|
46
|
+
verifyRecipient: verifyRecipient
|
|
47
|
+
}) : /*#__PURE__*/React.createElement(LinkRecipientPermissions, _extends({}, props, {
|
|
48
|
+
className: "u-flex-shrink-0"
|
|
49
|
+
}));
|
|
50
|
+
return /*#__PURE__*/React.createElement(Fade, {
|
|
51
|
+
in: true,
|
|
52
|
+
timeout: fadeIn ? FADE_IN_DURATION : 0
|
|
53
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
54
|
+
disableGutters: true
|
|
55
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Circle, {
|
|
56
|
+
size: "small",
|
|
57
|
+
className: styles['link-recipient-icon-circle']
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
59
|
+
icon: LinkIcon
|
|
60
|
+
}))), /*#__PURE__*/React.createElement(ListItemText, {
|
|
61
|
+
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
62
|
+
className: "u-ellipsis",
|
|
63
|
+
variant: "body1"
|
|
64
|
+
}, t('Share.recipients.anyoneWithTheLink')),
|
|
65
|
+
secondary: link
|
|
66
|
+
}), RightPart));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
LinkRecipient.propTypes = {
|
|
70
|
+
link: PropTypes.string.isRequired
|
|
71
|
+
};
|
|
72
|
+
export default LinkRecipient;
|
|
@@ -0,0 +1,159 @@
|
|
|
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 { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
6
|
+
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
7
|
+
import ActionMenu, { ActionMenuItem, ActionMenuRadio } from 'cozy-ui/transpiled/react/ActionMenu';
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
10
|
+
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
11
|
+
import Alerter from 'cozy-ui/transpiled/react/Alerter';
|
|
12
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
13
|
+
import { checkIsReadOnlyPermissions } from '../../helpers/permissions';
|
|
14
|
+
import { isOnlyReadOnlyLinkAllowed } from '../../helpers/link';
|
|
15
|
+
import logger from '../../logger';
|
|
16
|
+
|
|
17
|
+
var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
18
|
+
var className = _ref.className,
|
|
19
|
+
document = _ref.document,
|
|
20
|
+
documentType = _ref.documentType,
|
|
21
|
+
permissions = _ref.permissions,
|
|
22
|
+
onChangePermissions = _ref.onChangePermissions,
|
|
23
|
+
onDisable = _ref.onDisable;
|
|
24
|
+
|
|
25
|
+
var _useI18n = useI18n(),
|
|
26
|
+
t = _useI18n.t;
|
|
27
|
+
|
|
28
|
+
var buttonRef = useRef();
|
|
29
|
+
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
menuIsOpen = _useState2[0],
|
|
33
|
+
setMenuIsOpen = _useState2[1];
|
|
34
|
+
|
|
35
|
+
var _useState3 = useState(false),
|
|
36
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
|
+
loading = _useState4[0],
|
|
38
|
+
setLoading = _useState4[1];
|
|
39
|
+
|
|
40
|
+
var isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions);
|
|
41
|
+
|
|
42
|
+
var toggleMenu = function toggleMenu() {
|
|
43
|
+
setMenuIsOpen(!menuIsOpen);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var deleteShareLink = /*#__PURE__*/function () {
|
|
47
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
_context.prev = 0;
|
|
53
|
+
setLoading(true);
|
|
54
|
+
_context.next = 4;
|
|
55
|
+
return onDisable(document);
|
|
56
|
+
|
|
57
|
+
case 4:
|
|
58
|
+
_context.next = 10;
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case 6:
|
|
62
|
+
_context.prev = 6;
|
|
63
|
+
_context.t0 = _context["catch"](0);
|
|
64
|
+
Alerter.error(t("".concat(documentType, ".share.error.revoke")));
|
|
65
|
+
logger.log(_context.t0);
|
|
66
|
+
|
|
67
|
+
case 10:
|
|
68
|
+
_context.prev = 10;
|
|
69
|
+
setLoading(false);
|
|
70
|
+
return _context.finish(10);
|
|
71
|
+
|
|
72
|
+
case 13:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, _callee, null, [[0, 6, 10, 13]]);
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
return function deleteShareLink() {
|
|
81
|
+
return _ref2.apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
}();
|
|
84
|
+
|
|
85
|
+
var updateLinkPermissions = function updateLinkPermissions(_ref3) {
|
|
86
|
+
var isReadOnly = _ref3.isReadOnly;
|
|
87
|
+
var verbs = isReadOnly ? ['GET'] : ['GET', 'POST', 'PUT', 'PATCH'];
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
onChangePermissions(document, verbs);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
Alerter.error(t("".concat(documentType, ".share.shareByLink.permserror")));
|
|
93
|
+
logger.log(err);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: className
|
|
99
|
+
}, loading && /*#__PURE__*/React.createElement(Spinner, null), !loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
100
|
+
onClick: toggleMenu,
|
|
101
|
+
ref: buttonRef,
|
|
102
|
+
textVariant: "body2"
|
|
103
|
+
}, t("Share.type.".concat(isReadOnlyPermissions ? 'one-way' : 'two-way')).toLowerCase()), menuIsOpen && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
104
|
+
onClose: toggleMenu,
|
|
105
|
+
popperOptions: {
|
|
106
|
+
placement: 'bottom-end',
|
|
107
|
+
strategy: 'fixed'
|
|
108
|
+
},
|
|
109
|
+
anchorElRef: buttonRef
|
|
110
|
+
}, /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
111
|
+
left: /*#__PURE__*/React.createElement(ActionMenuRadio, {
|
|
112
|
+
name: "permissionLinkMenu",
|
|
113
|
+
value: "true",
|
|
114
|
+
checked: isReadOnlyPermissions
|
|
115
|
+
}),
|
|
116
|
+
onClick: function onClick() {
|
|
117
|
+
toggleMenu();
|
|
118
|
+
updateLinkPermissions({
|
|
119
|
+
isReadOnly: true
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.seeFolder") : t("Share.permissionLink.seeFile"), /*#__PURE__*/React.createElement(Typography, {
|
|
123
|
+
className: "u-mt-half",
|
|
124
|
+
variant: "caption",
|
|
125
|
+
color: "textSecondary"
|
|
126
|
+
}, t('Share.permissionLink.readDescription')))), !isOnlyReadOnlyLinkAllowed({
|
|
127
|
+
documentType: documentType
|
|
128
|
+
}) && /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
129
|
+
left: /*#__PURE__*/React.createElement(ActionMenuRadio, {
|
|
130
|
+
name: "permissionLinkMenu",
|
|
131
|
+
value: "false",
|
|
132
|
+
checked: !isReadOnlyPermissions
|
|
133
|
+
}),
|
|
134
|
+
onClick: function onClick() {
|
|
135
|
+
toggleMenu();
|
|
136
|
+
updateLinkPermissions({
|
|
137
|
+
isReadOnly: false
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.modifyFolder") : t("Share.permissionLink.modifyFile"), /*#__PURE__*/React.createElement(Typography, {
|
|
141
|
+
className: "u-mt-half",
|
|
142
|
+
variant: "caption",
|
|
143
|
+
color: "textSecondary"
|
|
144
|
+
}, t('Share.permissionLink.writeDescription')))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
145
|
+
left: /*#__PURE__*/React.createElement(Icon, {
|
|
146
|
+
icon: TrashIcon,
|
|
147
|
+
color: "var(--errorColor)"
|
|
148
|
+
}),
|
|
149
|
+
onClick: function onClick() {
|
|
150
|
+
toggleMenu();
|
|
151
|
+
deleteShareLink();
|
|
152
|
+
}
|
|
153
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
154
|
+
className: "u-error",
|
|
155
|
+
variant: "body1"
|
|
156
|
+
}, t('Share.permissionLink.deactivate'))))));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default LinkRecipientPermissions;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["url", "size"];
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
5
|
+
var styles = {
|
|
6
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
7
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
8
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
9
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
10
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
11
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
12
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
13
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
14
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
15
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
16
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
17
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
18
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
19
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
20
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
21
|
+
"spin": "recipient__spin___3_Uja",
|
|
22
|
+
"shake": "recipient__shake___TrWC0"
|
|
23
|
+
};
|
|
24
|
+
import { getDisplayName, getInitials } from '../../models';
|
|
25
|
+
import Identity from './Identity';
|
|
26
|
+
|
|
27
|
+
var OwnerIdentity = function OwnerIdentity(_ref) {
|
|
28
|
+
var url = _ref.url,
|
|
29
|
+
size = _ref.size,
|
|
30
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
31
|
+
|
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: styles['avatar']
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
35
|
+
text: getInitials(rest),
|
|
36
|
+
size: size,
|
|
37
|
+
textId: getDisplayName(rest)
|
|
38
|
+
}), /*#__PURE__*/React.createElement(Identity, {
|
|
39
|
+
name: getDisplayName(rest),
|
|
40
|
+
details: url
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default OwnerIdentity;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["instance", "isOwner", "status", "recipientConfirmationData", "verifyRecipient", "fadeIn"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { useClient } from 'cozy-client';
|
|
7
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
8
|
+
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
|
|
9
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon';
|
|
10
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
11
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
12
|
+
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
13
|
+
import { FADE_IN_DURATION } from '../../helpers/recipients';
|
|
14
|
+
import { getDisplayName } from '../../models';
|
|
15
|
+
import RecipientConfirm from './RecipientConfirm';
|
|
16
|
+
import RecipientPermissions from './RecipientPermissions';
|
|
17
|
+
import RecipientAvatar from './RecipientAvatar';
|
|
18
|
+
import RecipientStatus from './RecipientStatus';
|
|
19
|
+
var DEFAULT_DISPLAY_NAME = 'Share.contacts.defaultDisplayName';
|
|
20
|
+
|
|
21
|
+
var Recipient = function Recipient(props) {
|
|
22
|
+
var _useI18n = useI18n(),
|
|
23
|
+
t = _useI18n.t;
|
|
24
|
+
|
|
25
|
+
var client = useClient();
|
|
26
|
+
|
|
27
|
+
var instance = props.instance,
|
|
28
|
+
isOwner = props.isOwner,
|
|
29
|
+
status = props.status,
|
|
30
|
+
recipientConfirmationData = props.recipientConfirmationData,
|
|
31
|
+
verifyRecipient = props.verifyRecipient,
|
|
32
|
+
fadeIn = props.fadeIn,
|
|
33
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
34
|
+
|
|
35
|
+
var isMe = isOwner && status === 'owner' || instance === client.options.uri;
|
|
36
|
+
var defaultDisplayName = t(DEFAULT_DISPLAY_NAME);
|
|
37
|
+
var name = getDisplayName(rest, defaultDisplayName);
|
|
38
|
+
var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
|
|
39
|
+
recipientConfirmationData: recipientConfirmationData,
|
|
40
|
+
verifyRecipient: verifyRecipient
|
|
41
|
+
}) : /*#__PURE__*/React.createElement(RecipientPermissions, _extends({}, props, {
|
|
42
|
+
className: "u-flex-shrink-0"
|
|
43
|
+
}));
|
|
44
|
+
return /*#__PURE__*/React.createElement(Fade, {
|
|
45
|
+
in: true,
|
|
46
|
+
timeout: fadeIn ? FADE_IN_DURATION : 0
|
|
47
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
48
|
+
disableGutters: true
|
|
49
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(RecipientAvatar, {
|
|
50
|
+
size: "small",
|
|
51
|
+
recipient: props
|
|
52
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
53
|
+
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
54
|
+
className: "u-ellipsis",
|
|
55
|
+
variant: "body1"
|
|
56
|
+
}, isMe ? t('Share.recipients.you') : name),
|
|
57
|
+
secondary: /*#__PURE__*/React.createElement(RecipientStatus, {
|
|
58
|
+
status: status,
|
|
59
|
+
isMe: isMe,
|
|
60
|
+
instance: instance
|
|
61
|
+
})
|
|
62
|
+
}), RightPart));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
Recipient.propTypes = {
|
|
66
|
+
instance: PropTypes.string,
|
|
67
|
+
isOwner: PropTypes.bool,
|
|
68
|
+
status: PropTypes.string,
|
|
69
|
+
recipientConfirmationData: PropTypes.object,
|
|
70
|
+
verifyRecipient: PropTypes.func
|
|
71
|
+
};
|
|
72
|
+
export default Recipient;
|