cozy-viewer 5.1.0 → 6.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 +25 -0
- package/dist/Footer/Sharing.js +2 -4
- package/dist/Panel/Sharing.d.ts +2 -0
- package/dist/Panel/Sharing.js +99 -0
- package/dist/Panel/getPanelBlocks.js +8 -0
- package/dist/locales/index.js +2 -0
- package/package.json +5 -5
- package/src/Footer/Sharing.jsx +1 -2
- package/src/Panel/Sharing.jsx +80 -0
- package/src/Panel/getPanelBlocks.jsx +5 -0
- package/src/Panel/getPanelBlocks.spec.jsx +8 -0
- package/src/locales/en.json +1 -0
- package/src/locales/fr.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
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
|
+
# [6.0.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@5.1.1...cozy-viewer@6.0.0) (2024-12-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **Viewer:** Add sharing block ([1de9627](https://github.com/cozy/cozy-libs/commit/1de962750c277b91a4332c6b6d247d7783ce9b6a))
|
|
12
|
+
* **Viewer:** Upgrade cozy-sharing ([de71cfd](https://github.com/cozy/cozy-libs/commit/de71cfdaf17874670ac6c993c59e2d6ca3314a44))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* **Viewer:** You must have `cozy-sharing => 16.8.0`
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [5.1.1](https://github.com/cozy/cozy-libs/compare/cozy-viewer@5.1.0...cozy-viewer@5.1.1) (2024-11-28)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package cozy-viewer
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
6
31
|
# [5.1.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@5.0.0...cozy-viewer@5.1.0) (2024-11-28)
|
|
7
32
|
|
|
8
33
|
|
package/dist/Footer/Sharing.js
CHANGED
|
@@ -15,9 +15,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
15
15
|
|
|
16
16
|
var _cozyClient = require("cozy-client");
|
|
17
17
|
|
|
18
|
-
var _cozySharing = require("cozy-sharing");
|
|
19
|
-
|
|
20
|
-
var _SharingProvider = require("cozy-sharing/dist/SharingProvider");
|
|
18
|
+
var _cozySharing = _interopRequireWildcard(require("cozy-sharing"));
|
|
21
19
|
|
|
22
20
|
var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
23
21
|
|
|
@@ -54,7 +52,7 @@ var Sharing = function Sharing(_ref) {
|
|
|
54
52
|
return setShowShareModal(true);
|
|
55
53
|
}
|
|
56
54
|
});
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_cozySharing.default, {
|
|
58
56
|
client: client,
|
|
59
57
|
doctype: "io.cozy.files",
|
|
60
58
|
documentType: "Files"
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _cozySharing = require("cozy-sharing");
|
|
17
|
+
|
|
18
|
+
var _Divider = _interopRequireDefault(require("cozy-ui/transpiled/react/Divider"));
|
|
19
|
+
|
|
20
|
+
var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
21
|
+
|
|
22
|
+
var _Right = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Right"));
|
|
23
|
+
|
|
24
|
+
var _List = _interopRequireDefault(require("cozy-ui/transpiled/react/List"));
|
|
25
|
+
|
|
26
|
+
var _ListItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItem"));
|
|
27
|
+
|
|
28
|
+
var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
|
|
29
|
+
|
|
30
|
+
var _ListItemText = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemText"));
|
|
31
|
+
|
|
32
|
+
var _Spinner = _interopRequireDefault(require("cozy-ui/transpiled/react/Spinner"));
|
|
33
|
+
|
|
34
|
+
var _withViewerLocales = require("../hoc/withViewerLocales");
|
|
35
|
+
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
|
+
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
+
|
|
40
|
+
var Sharing = function Sharing(_ref) {
|
|
41
|
+
var file = _ref.file,
|
|
42
|
+
t = _ref.t;
|
|
43
|
+
|
|
44
|
+
var _useState = (0, _react.useState)(false),
|
|
45
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
46
|
+
showModal = _useState2[0],
|
|
47
|
+
setShowModal = _useState2[1];
|
|
48
|
+
|
|
49
|
+
var _useSharingContext = (0, _cozySharing.useSharingContext)(),
|
|
50
|
+
isOwner = _useSharingContext.isOwner,
|
|
51
|
+
getDocumentPermissions = _useSharingContext.getDocumentPermissions,
|
|
52
|
+
getSharingLink = _useSharingContext.getSharingLink,
|
|
53
|
+
allLoaded = _useSharingContext.allLoaded,
|
|
54
|
+
getRecipients = _useSharingContext.getRecipients;
|
|
55
|
+
|
|
56
|
+
var recipients = getRecipients(file._id);
|
|
57
|
+
var permissions = getDocumentPermissions(file._id);
|
|
58
|
+
var link = getSharingLink(file._id);
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_List.default, null, /*#__PURE__*/_react.default.createElement(_ListItem.default, {
|
|
60
|
+
button: true,
|
|
61
|
+
onClick: function onClick() {
|
|
62
|
+
return setShowModal(true);
|
|
63
|
+
}
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
|
|
65
|
+
primary: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, t('Viewer.panel.sharing'), !allLoaded && /*#__PURE__*/_react.default.createElement(_Spinner.default, {
|
|
66
|
+
className: "u-ml-half",
|
|
67
|
+
noMargin: true
|
|
68
|
+
})),
|
|
69
|
+
primaryTypographyProps: {
|
|
70
|
+
variant: 'h6'
|
|
71
|
+
}
|
|
72
|
+
}), /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
73
|
+
icon: _Right.default
|
|
74
|
+
})))), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement(_List.default, null, /*#__PURE__*/_react.default.createElement(_cozySharing.LinkRecipientLite, {
|
|
75
|
+
permissions: permissions,
|
|
76
|
+
link: link
|
|
77
|
+
}), recipients.map(function (recipient) {
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement(_cozySharing.MemberRecipientLite, {
|
|
79
|
+
key: recipient.index,
|
|
80
|
+
recipient: recipient,
|
|
81
|
+
isOwner: isOwner(file._id)
|
|
82
|
+
});
|
|
83
|
+
})), showModal && /*#__PURE__*/_react.default.createElement(_cozySharing.ShareModal, {
|
|
84
|
+
document: file,
|
|
85
|
+
documentType: "Files",
|
|
86
|
+
onClose: function onClose() {
|
|
87
|
+
return setShowModal(false);
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Sharing.propTypes = {
|
|
93
|
+
file: _propTypes.default.object.isRequired,
|
|
94
|
+
t: _propTypes.default.func
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var _default = (0, _withViewerLocales.withViewerLocales)(Sharing);
|
|
98
|
+
|
|
99
|
+
exports.default = _default;
|
|
@@ -15,6 +15,8 @@ var _Informations = _interopRequireDefault(require("./Informations"));
|
|
|
15
15
|
|
|
16
16
|
var _Qualification = _interopRequireDefault(require("./Qualification"));
|
|
17
17
|
|
|
18
|
+
var _Sharing = _interopRequireDefault(require("./Sharing"));
|
|
19
|
+
|
|
18
20
|
var _Summary = _interopRequireDefault(require("./Summary"));
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -56,6 +58,12 @@ var getPanelBlocksSpecs = function getPanelBlocksSpecs() {
|
|
|
56
58
|
return true;
|
|
57
59
|
},
|
|
58
60
|
component: _Informations.default
|
|
61
|
+
},
|
|
62
|
+
sharing: {
|
|
63
|
+
condition: function condition() {
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
component: _Sharing.default
|
|
59
67
|
}
|
|
60
68
|
};
|
|
61
69
|
};
|
package/dist/locales/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var en = {
|
|
|
33
33
|
openInOnlyOffice: "Open with Only Office",
|
|
34
34
|
panel: {
|
|
35
35
|
summary: "Summary",
|
|
36
|
+
sharing: "Who has access?",
|
|
36
37
|
informations: {
|
|
37
38
|
format: {
|
|
38
39
|
title: "%{format} Document",
|
|
@@ -112,6 +113,7 @@ var fr = {
|
|
|
112
113
|
openInOnlyOffice: "Ouvrir avec Only Office",
|
|
113
114
|
panel: {
|
|
114
115
|
summary: "R\xE9sum\xE9",
|
|
116
|
+
sharing: "Qui a acc\xE8s ?",
|
|
115
117
|
informations: {
|
|
116
118
|
format: {
|
|
117
119
|
title: "Document %{format}",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Cozy-Viewer provides a component to show files in a viewer.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"babel-preset-cozy-app": "^2.8.1",
|
|
28
28
|
"cozy-client": "50.0.0",
|
|
29
29
|
"cozy-device-helper": "2.0.0",
|
|
30
|
-
"cozy-harvest-lib": "^
|
|
30
|
+
"cozy-harvest-lib": "^31.0.1",
|
|
31
31
|
"cozy-intent": "^2.29.1",
|
|
32
32
|
"cozy-logger": "^1.16.1",
|
|
33
|
-
"cozy-sharing": "
|
|
33
|
+
"cozy-sharing": "^16.8.0",
|
|
34
34
|
"cozy-ui": "^113.7.0",
|
|
35
35
|
"enzyme": "3.11.0",
|
|
36
36
|
"enzyme-adapter-react-16": "1.15.6",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"cozy-harvest-lib": ">=30.8.0",
|
|
56
56
|
"cozy-intent": ">=2.26.0",
|
|
57
57
|
"cozy-logger": ">=1.9.0",
|
|
58
|
-
"cozy-sharing": ">=
|
|
58
|
+
"cozy-sharing": ">=16.8.0",
|
|
59
59
|
"cozy-ui": ">=113.7.0",
|
|
60
60
|
"react": ">=16.12.0",
|
|
61
61
|
"react-dom": ">=16.12.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "1ef3aa4ead2e15345ae0274fea1580d0cb175023"
|
|
64
64
|
}
|
package/src/Footer/Sharing.jsx
CHANGED
|
@@ -2,8 +2,7 @@ import PropTypes from 'prop-types'
|
|
|
2
2
|
import React, { useState } from 'react'
|
|
3
3
|
|
|
4
4
|
import { useClient } from 'cozy-client'
|
|
5
|
-
import { ShareModal, ShareButton } from 'cozy-sharing'
|
|
6
|
-
import { SharingProvider } from 'cozy-sharing/dist/SharingProvider'
|
|
5
|
+
import SharingProvider, { ShareModal, ShareButton } from 'cozy-sharing'
|
|
7
6
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
8
7
|
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
9
8
|
import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share'
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React, { useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ShareModal,
|
|
6
|
+
useSharingContext,
|
|
7
|
+
MemberRecipientLite,
|
|
8
|
+
LinkRecipientLite
|
|
9
|
+
} from 'cozy-sharing'
|
|
10
|
+
import Divider from 'cozy-ui/transpiled/react/Divider'
|
|
11
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
12
|
+
import RightIcon from 'cozy-ui/transpiled/react/Icons/Right'
|
|
13
|
+
import List from 'cozy-ui/transpiled/react/List'
|
|
14
|
+
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
15
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
16
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
17
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner'
|
|
18
|
+
|
|
19
|
+
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
20
|
+
|
|
21
|
+
const Sharing = ({ file, t }) => {
|
|
22
|
+
const [showModal, setShowModal] = useState(false)
|
|
23
|
+
const {
|
|
24
|
+
isOwner,
|
|
25
|
+
getDocumentPermissions,
|
|
26
|
+
getSharingLink,
|
|
27
|
+
allLoaded,
|
|
28
|
+
getRecipients
|
|
29
|
+
} = useSharingContext()
|
|
30
|
+
|
|
31
|
+
const recipients = getRecipients(file._id)
|
|
32
|
+
const permissions = getDocumentPermissions(file._id)
|
|
33
|
+
const link = getSharingLink(file._id)
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<List>
|
|
38
|
+
<ListItem button onClick={() => setShowModal(true)}>
|
|
39
|
+
<ListItemText
|
|
40
|
+
primary={
|
|
41
|
+
<>
|
|
42
|
+
{t('Viewer.panel.sharing')}
|
|
43
|
+
{!allLoaded && <Spinner className="u-ml-half" noMargin />}
|
|
44
|
+
</>
|
|
45
|
+
}
|
|
46
|
+
primaryTypographyProps={{ variant: 'h6' }}
|
|
47
|
+
/>
|
|
48
|
+
<ListItemIcon>
|
|
49
|
+
<Icon icon={RightIcon} />
|
|
50
|
+
</ListItemIcon>
|
|
51
|
+
</ListItem>
|
|
52
|
+
</List>
|
|
53
|
+
<Divider />
|
|
54
|
+
<List>
|
|
55
|
+
<LinkRecipientLite permissions={permissions} link={link} />
|
|
56
|
+
{recipients.map(recipient => (
|
|
57
|
+
<MemberRecipientLite
|
|
58
|
+
key={recipient.index}
|
|
59
|
+
recipient={recipient}
|
|
60
|
+
isOwner={isOwner(file._id)}
|
|
61
|
+
/>
|
|
62
|
+
))}
|
|
63
|
+
</List>
|
|
64
|
+
{showModal && (
|
|
65
|
+
<ShareModal
|
|
66
|
+
document={file}
|
|
67
|
+
documentType="Files"
|
|
68
|
+
onClose={() => setShowModal(false)}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
</>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Sharing.propTypes = {
|
|
76
|
+
file: PropTypes.object.isRequired,
|
|
77
|
+
t: PropTypes.func
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default withViewerLocales(Sharing)
|
|
@@ -6,6 +6,7 @@ import KonnectorBlock from 'cozy-harvest-lib/dist/components/KonnectorBlock'
|
|
|
6
6
|
|
|
7
7
|
import Informations from './Informations'
|
|
8
8
|
import Qualification from './Qualification'
|
|
9
|
+
import Sharing from './Sharing'
|
|
9
10
|
import Summary from './Summary'
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -39,6 +40,10 @@ export const getPanelBlocksSpecs = (isPublic = false) => ({
|
|
|
39
40
|
informations: {
|
|
40
41
|
condition: () => true,
|
|
41
42
|
component: Informations
|
|
43
|
+
},
|
|
44
|
+
sharing: {
|
|
45
|
+
condition: () => true,
|
|
46
|
+
component: Sharing
|
|
42
47
|
}
|
|
43
48
|
})
|
|
44
49
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
1
3
|
import getPanelBlocks, { getPanelBlocksSpecs } from './getPanelBlocks'
|
|
2
4
|
|
|
5
|
+
jest.mock('./Sharing', () => () => <div data-testid="SharingBlock" />)
|
|
6
|
+
|
|
3
7
|
jest.mock('cozy-harvest-lib/dist/components/KonnectorBlock', () => jest.fn())
|
|
4
8
|
const block1Component = jest.fn()
|
|
5
9
|
const block2Component = jest.fn()
|
|
@@ -77,6 +81,10 @@ describe('getPanelBlocksSpecs', () => {
|
|
|
77
81
|
informations: {
|
|
78
82
|
condition: expect.any(Function),
|
|
79
83
|
component: expect.anything()
|
|
84
|
+
},
|
|
85
|
+
sharing: {
|
|
86
|
+
condition: expect.any(Function),
|
|
87
|
+
component: expect.anything()
|
|
80
88
|
}
|
|
81
89
|
})
|
|
82
90
|
})
|
package/src/locales/en.json
CHANGED