cozy-viewer 13.0.2 → 13.1.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 +18 -0
- package/dist/Footer/BottomSheetContent.d.ts +3 -1
- package/dist/Footer/BottomSheetContent.js +6 -3
- package/dist/Footer/FooterContent.d.ts +3 -1
- package/dist/Footer/FooterContent.js +5 -2
- package/dist/Panel/ActionMenuWrapper.js +3 -1
- package/dist/Panel/Qualification.js +6 -4
- package/dist/Panel/QualificationListItemContact.js +2 -1
- package/dist/ViewerContainer.js +24 -5
- package/dist/ViewerInformationsWrapper.js +2 -1
- package/dist/components/ViewerControls.js +1 -1
- package/package.json +3 -3
- package/src/Footer/BottomSheetContent.jsx +4 -3
- package/src/Footer/FooterContent.jsx +13 -2
- package/src/Panel/ActionMenuWrapper.jsx +45 -42
- package/src/Panel/Qualification.jsx +5 -4
- package/src/Panel/QualificationListItemContact.jsx +1 -0
- package/src/ViewerContainer.jsx +10 -5
- package/src/ViewerInformationsWrapper.jsx +1 -0
- package/src/components/ViewerControls.jsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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
|
+
# [13.1.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@13.0.2...cozy-viewer@13.1.0) (2025-01-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **Viewer:** Now hide edit option on mobile if read only ([ce2f287](https://github.com/cozy/cozy-libs/commit/ce2f287494a943547762d5f189a74d38554d9f05))
|
|
12
|
+
* **Viewer:** Now isReadOnly manage public and private share ([6e0aba3](https://github.com/cozy/cozy-libs/commit/6e0aba3abd9dee753656e9aef82ecb53931e14aa))
|
|
13
|
+
* **Viewer:** Now show edit option on qualification according to share ([73034bf](https://github.com/cozy/cozy-libs/commit/73034bf13bb18ba269aa70902902f214b31d87fb))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **Viewer:** Disable qualification modification on public ([f41540e](https://github.com/cozy/cozy-libs/commit/f41540ea791d31878dfa2325bca4cc7f867c010a))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [13.0.2](https://github.com/cozy/cozy-libs/compare/cozy-viewer@13.0.1...cozy-viewer@13.0.2) (2025-01-13)
|
|
7
25
|
|
|
8
26
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export default BottomSheetContent;
|
|
2
|
-
declare function BottomSheetContent({ file, isPublic }: {
|
|
2
|
+
declare function BottomSheetContent({ file, isPublic, isReadOnly }: {
|
|
3
3
|
file: any;
|
|
4
4
|
isPublic: any;
|
|
5
|
+
isReadOnly: any;
|
|
5
6
|
}): JSX.Element[];
|
|
6
7
|
declare namespace BottomSheetContent {
|
|
7
8
|
namespace propTypes {
|
|
8
9
|
const file: PropTypes.Validator<object>;
|
|
9
10
|
const isPublic: PropTypes.Requireable<boolean>;
|
|
11
|
+
const isReadOnly: PropTypes.Requireable<boolean>;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
import PropTypes from "prop-types";
|
|
@@ -21,7 +21,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
21
|
|
|
22
22
|
var BottomSheetContent = function BottomSheetContent(_ref) {
|
|
23
23
|
var file = _ref.file,
|
|
24
|
-
isPublic = _ref.isPublic
|
|
24
|
+
isPublic = _ref.isPublic,
|
|
25
|
+
isReadOnly = _ref.isReadOnly;
|
|
25
26
|
var panelBlocks = (0, _getPanelBlocks.default)({
|
|
26
27
|
panelBlocksSpecs: (0, _getPanelBlocks.getPanelBlocksSpecs)(isPublic),
|
|
27
28
|
file: file
|
|
@@ -33,14 +34,16 @@ var BottomSheetContent = function BottomSheetContent(_ref) {
|
|
|
33
34
|
disableElevation: index === panelBlocks.length - 1
|
|
34
35
|
}, /*#__PURE__*/_react.default.createElement(PanelBlock, {
|
|
35
36
|
file: file,
|
|
36
|
-
isPublic: isPublic
|
|
37
|
+
isPublic: isPublic,
|
|
38
|
+
isReadOnly: isReadOnly
|
|
37
39
|
}));
|
|
38
40
|
});
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
BottomSheetContent.propTypes = {
|
|
42
44
|
file: _propTypes.default.object.isRequired,
|
|
43
|
-
isPublic: _propTypes.default.bool
|
|
45
|
+
isPublic: _propTypes.default.bool,
|
|
46
|
+
isReadOnly: _propTypes.default.bool
|
|
44
47
|
};
|
|
45
48
|
|
|
46
49
|
var _default = exports.default = BottomSheetContent;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export default FooterContent;
|
|
2
|
-
declare function FooterContent({ file, toolbarRef, children, isPublic }: {
|
|
2
|
+
declare function FooterContent({ file, toolbarRef, children, isPublic, isReadOnly }: {
|
|
3
3
|
file: any;
|
|
4
4
|
toolbarRef: any;
|
|
5
5
|
children: any;
|
|
6
6
|
isPublic: any;
|
|
7
|
+
isReadOnly: any;
|
|
7
8
|
}): JSX.Element;
|
|
8
9
|
declare namespace FooterContent {
|
|
9
10
|
namespace propTypes {
|
|
10
11
|
const file: PropTypes.Validator<object>;
|
|
11
12
|
const toolbarRef: PropTypes.Requireable<object>;
|
|
12
13
|
const isPublic: PropTypes.Requireable<boolean>;
|
|
14
|
+
const isReadOnly: PropTypes.Requireable<boolean>;
|
|
13
15
|
const children: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -61,7 +61,8 @@ var FooterContent = function FooterContent(_ref2) {
|
|
|
61
61
|
var file = _ref2.file,
|
|
62
62
|
toolbarRef = _ref2.toolbarRef,
|
|
63
63
|
children = _ref2.children,
|
|
64
|
-
isPublic = _ref2.isPublic
|
|
64
|
+
isPublic = _ref2.isPublic,
|
|
65
|
+
isReadOnly = _ref2.isReadOnly;
|
|
65
66
|
var styles = useStyles();
|
|
66
67
|
var toolbarProps = (0, _react.useMemo)(function () {
|
|
67
68
|
return {
|
|
@@ -90,7 +91,8 @@ var FooterContent = function FooterContent(_ref2) {
|
|
|
90
91
|
FooterActionButtonsWithFile: FooterActionButtonsWithFile
|
|
91
92
|
})), /*#__PURE__*/_react.default.createElement(_BottomSheetContent.default, {
|
|
92
93
|
file: file,
|
|
93
|
-
isPublic: isPublic
|
|
94
|
+
isPublic: isPublic,
|
|
95
|
+
isReadOnly: isReadOnly
|
|
94
96
|
}));
|
|
95
97
|
};
|
|
96
98
|
|
|
@@ -98,6 +100,7 @@ FooterContent.propTypes = {
|
|
|
98
100
|
file: _propTypes.default.object.isRequired,
|
|
99
101
|
toolbarRef: _propTypes.default.object,
|
|
100
102
|
isPublic: _propTypes.default.bool,
|
|
103
|
+
isReadOnly: _propTypes.default.bool,
|
|
101
104
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.arrayOf(_propTypes.default.node)])
|
|
102
105
|
};
|
|
103
106
|
|
|
@@ -34,6 +34,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
34
34
|
var ActionMenuWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
35
35
|
var file = _ref.file,
|
|
36
36
|
optionFile = _ref.optionFile,
|
|
37
|
+
isReadOnly = _ref.isReadOnly,
|
|
37
38
|
onClose = _ref.onClose;
|
|
38
39
|
var name = optionFile.name,
|
|
39
40
|
value = optionFile.value;
|
|
@@ -47,7 +48,7 @@ var ActionMenuWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
47
48
|
var _useAlert = (0, _Alert.useAlert)(),
|
|
48
49
|
showAlert = _useAlert.showAlert;
|
|
49
50
|
|
|
50
|
-
var isEditable = (0, _helpers.isEditableAttribute)(name, file);
|
|
51
|
+
var isEditable = (0, _helpers.isEditableAttribute)(name, file) && !isReadOnly;
|
|
51
52
|
var editPath = "".concat(file.metadata.qualification.label, "/").concat(file._id, "/edit/information?metadata=").concat(optionFile.name);
|
|
52
53
|
|
|
53
54
|
var handleCopy = /*#__PURE__*/function () {
|
|
@@ -134,6 +135,7 @@ ActionMenuWrapper.propTypes = {
|
|
|
134
135
|
name: _propTypes.default.string,
|
|
135
136
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
136
137
|
}),
|
|
138
|
+
isReadOnly: _propTypes.default.bool,
|
|
137
139
|
onClose: _propTypes.default.func
|
|
138
140
|
};
|
|
139
141
|
|
|
@@ -59,6 +59,7 @@ var ComponentFromMetadataQualificationType = {
|
|
|
59
59
|
|
|
60
60
|
var Qualification = function Qualification(_ref) {
|
|
61
61
|
var file = _ref.file,
|
|
62
|
+
isPublic = _ref.isPublic,
|
|
62
63
|
isReadOnly = _ref.isReadOnly;
|
|
63
64
|
var _file$metadata = file.metadata,
|
|
64
65
|
metadata = _file$metadata === void 0 ? {} : _file$metadata;
|
|
@@ -115,13 +116,13 @@ var Qualification = function Qualification(_ref) {
|
|
|
115
116
|
file: file
|
|
116
117
|
}), (0, _qualification.hasSupportedQualification)(file) ? /*#__PURE__*/_react.default.createElement(_QualificationListItemQualification.default, {
|
|
117
118
|
file: file,
|
|
118
|
-
isReadOnly: isReadOnly,
|
|
119
|
+
isReadOnly: isPublic ? true : isReadOnly,
|
|
119
120
|
onClick: function onClick() {
|
|
120
121
|
return setShowQualifModal(true);
|
|
121
122
|
}
|
|
122
123
|
}) : /*#__PURE__*/_react.default.createElement(_QualificationListItemQualificationEmpty.default, {
|
|
123
124
|
file: file,
|
|
124
|
-
isReadOnly: isReadOnly,
|
|
125
|
+
isReadOnly: isPublic ? true : isReadOnly,
|
|
125
126
|
onClick: function onClick() {
|
|
126
127
|
return setShowQualifModal(true);
|
|
127
128
|
}
|
|
@@ -139,7 +140,7 @@ var Qualification = function Qualification(_ref) {
|
|
|
139
140
|
key: idx
|
|
140
141
|
}, /*#__PURE__*/_react.default.createElement(QualificationListItemComp, {
|
|
141
142
|
file: file,
|
|
142
|
-
isReadOnly: isReadOnly,
|
|
143
|
+
isReadOnly: isPublic ? true : isReadOnly,
|
|
143
144
|
ref: actionBtnRef.current[idx],
|
|
144
145
|
formattedMetadataQualification: meta,
|
|
145
146
|
toggleActionsMenu: function toggleActionsMenu(val) {
|
|
@@ -153,7 +154,8 @@ var Qualification = function Qualification(_ref) {
|
|
|
153
154
|
onClose: hideActionsMenu,
|
|
154
155
|
file: file,
|
|
155
156
|
optionFile: optionFile,
|
|
156
|
-
ref: actionBtnRef.current[optionFile.id]
|
|
157
|
+
ref: actionBtnRef.current[optionFile.id],
|
|
158
|
+
isReadOnly: isPublic ? true : isReadOnly
|
|
157
159
|
})));
|
|
158
160
|
};
|
|
159
161
|
|
package/dist/ViewerContainer.js
CHANGED
|
@@ -29,6 +29,8 @@ var _cozyClient = require("cozy-client");
|
|
|
29
29
|
|
|
30
30
|
var _permission = require("cozy-client/dist/models/permission");
|
|
31
31
|
|
|
32
|
+
var _cozySharing = require("cozy-sharing");
|
|
33
|
+
|
|
32
34
|
var _Modal = _interopRequireDefault(require("cozy-ui/transpiled/react/Modal"));
|
|
33
35
|
|
|
34
36
|
var _proptypes = require("cozy-ui/transpiled/react/proptypes");
|
|
@@ -90,6 +92,10 @@ var ViewerContainer = function ViewerContainer(props) {
|
|
|
90
92
|
|
|
91
93
|
var client = (0, _cozyClient.useClient)();
|
|
92
94
|
(0, _I18n.useExtendI18n)(_locales.locales);
|
|
95
|
+
|
|
96
|
+
var _useSharingContext = (0, _cozySharing.useSharingContext)(),
|
|
97
|
+
hasWriteAccess = _useSharingContext.hasWriteAccess;
|
|
98
|
+
|
|
93
99
|
var currentFile = files[currentIndex];
|
|
94
100
|
var fileCount = files.length;
|
|
95
101
|
var hasPrevious = currentIndex > 0;
|
|
@@ -110,17 +116,30 @@ var ViewerContainer = function ViewerContainer(props) {
|
|
|
110
116
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
111
117
|
while (1) switch (_context.prev = _context.next) {
|
|
112
118
|
case 0:
|
|
113
|
-
|
|
119
|
+
if (!isPublic) {
|
|
120
|
+
_context.next = 6;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
_context.next = 3;
|
|
114
125
|
return (0, _permission.isDocumentReadOnly)({
|
|
115
126
|
document: currentFile,
|
|
116
127
|
client: client
|
|
117
128
|
});
|
|
118
129
|
|
|
119
|
-
case
|
|
120
|
-
|
|
130
|
+
case 3:
|
|
131
|
+
_context.t0 = _context.sent;
|
|
132
|
+
_context.next = 7;
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case 6:
|
|
136
|
+
_context.t0 = !hasWriteAccess(currentFile._id);
|
|
137
|
+
|
|
138
|
+
case 7:
|
|
139
|
+
res = _context.t0;
|
|
121
140
|
setIsReadOnly(res);
|
|
122
141
|
|
|
123
|
-
case
|
|
142
|
+
case 9:
|
|
124
143
|
case "end":
|
|
125
144
|
return _context.stop();
|
|
126
145
|
}
|
|
@@ -133,7 +152,7 @@ var ViewerContainer = function ViewerContainer(props) {
|
|
|
133
152
|
}();
|
|
134
153
|
|
|
135
154
|
getIsReadOnly();
|
|
136
|
-
}, [client, currentFile]);
|
|
155
|
+
}, [client, currentFile, hasWriteAccess, isPublic]);
|
|
137
156
|
return /*#__PURE__*/_react.default.createElement(_Alert.default, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
138
157
|
id: "viewer-wrapper",
|
|
139
158
|
className: (0, _classnames.default)(styles['viewer-wrapper'], className)
|
|
@@ -50,7 +50,8 @@ var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
|
|
|
50
50
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !disableFooter && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_FooterContent.default, {
|
|
51
51
|
file: currentFile,
|
|
52
52
|
toolbarRef: toolbarRef,
|
|
53
|
-
isPublic: isPublic
|
|
53
|
+
isPublic: isPublic,
|
|
54
|
+
isReadOnly: isReadOnly
|
|
54
55
|
}, children)), validForPanel && /*#__PURE__*/_react.default.createElement(_InformationPanel.default, null, /*#__PURE__*/_react.default.createElement(_PanelContent.default, {
|
|
55
56
|
file: currentFile,
|
|
56
57
|
isPublic: isPublic,
|
|
@@ -207,7 +207,7 @@ var ViewerControls = /*#__PURE__*/function (_Component) {
|
|
|
207
207
|
showFilePath: showFilePath,
|
|
208
208
|
onMouseEnter: this.showControls,
|
|
209
209
|
onMouseLeave: this.hideControls,
|
|
210
|
-
onClose: showClose
|
|
210
|
+
onClose: showClose ? onClose : undefined
|
|
211
211
|
}, children), showNavigation && isDesktop && hasPrevious && /*#__PURE__*/_react.default.createElement(_Navigation.default, {
|
|
212
212
|
className: styles['viewer-nav--previous'],
|
|
213
213
|
hidden: hidden,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.1.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,7 +27,7 @@
|
|
|
27
27
|
"babel-preset-cozy-app": "^2.8.1",
|
|
28
28
|
"cozy-client": "^52.1.0",
|
|
29
29
|
"cozy-device-helper": "2.0.0",
|
|
30
|
-
"cozy-harvest-lib": "^32.2.
|
|
30
|
+
"cozy-harvest-lib": "^32.2.9",
|
|
31
31
|
"cozy-intent": "^2.29.1",
|
|
32
32
|
"cozy-logger": "^1.16.1",
|
|
33
33
|
"cozy-sharing": "^19.0.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"react": ">=16.12.0",
|
|
60
60
|
"react-dom": ">=16.12.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "56e9eed8725f3adc458230177ed0f62cf970bc35"
|
|
63
63
|
}
|
|
@@ -5,7 +5,7 @@ import { BottomSheetItem } from 'cozy-ui/transpiled/react/BottomSheet'
|
|
|
5
5
|
|
|
6
6
|
import getPanelBlocks, { getPanelBlocksSpecs } from '../Panel/getPanelBlocks'
|
|
7
7
|
|
|
8
|
-
const BottomSheetContent = ({ file, isPublic }) => {
|
|
8
|
+
const BottomSheetContent = ({ file, isPublic, isReadOnly }) => {
|
|
9
9
|
const panelBlocks = getPanelBlocks({
|
|
10
10
|
panelBlocksSpecs: getPanelBlocksSpecs(isPublic),
|
|
11
11
|
file
|
|
@@ -17,14 +17,15 @@ const BottomSheetContent = ({ file, isPublic }) => {
|
|
|
17
17
|
disableGutters
|
|
18
18
|
disableElevation={index === panelBlocks.length - 1}
|
|
19
19
|
>
|
|
20
|
-
<PanelBlock file={file} isPublic={isPublic} />
|
|
20
|
+
<PanelBlock file={file} isPublic={isPublic} isReadOnly={isReadOnly} />
|
|
21
21
|
</BottomSheetItem>
|
|
22
22
|
))
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
BottomSheetContent.propTypes = {
|
|
26
26
|
file: PropTypes.object.isRequired,
|
|
27
|
-
isPublic: PropTypes.bool
|
|
27
|
+
isPublic: PropTypes.bool,
|
|
28
|
+
isReadOnly: PropTypes.bool
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export default BottomSheetContent
|
|
@@ -39,7 +39,13 @@ const useStyles = makeStyles(theme => ({
|
|
|
39
39
|
}
|
|
40
40
|
}))
|
|
41
41
|
|
|
42
|
-
const FooterContent = ({
|
|
42
|
+
const FooterContent = ({
|
|
43
|
+
file,
|
|
44
|
+
toolbarRef,
|
|
45
|
+
children,
|
|
46
|
+
isPublic,
|
|
47
|
+
isReadOnly
|
|
48
|
+
}) => {
|
|
43
49
|
const styles = useStyles()
|
|
44
50
|
|
|
45
51
|
const toolbarProps = useMemo(() => ({ ref: toolbarRef }), [toolbarRef])
|
|
@@ -69,7 +75,11 @@ const FooterContent = ({ file, toolbarRef, children, isPublic }) => {
|
|
|
69
75
|
FooterActionButtonsWithFile={FooterActionButtonsWithFile}
|
|
70
76
|
/>
|
|
71
77
|
</BottomSheetHeader>
|
|
72
|
-
<BottomSheetContent
|
|
78
|
+
<BottomSheetContent
|
|
79
|
+
file={file}
|
|
80
|
+
isPublic={isPublic}
|
|
81
|
+
isReadOnly={isReadOnly}
|
|
82
|
+
/>
|
|
73
83
|
</BottomSheet>
|
|
74
84
|
)
|
|
75
85
|
}
|
|
@@ -78,6 +88,7 @@ FooterContent.propTypes = {
|
|
|
78
88
|
file: PropTypes.object.isRequired,
|
|
79
89
|
toolbarRef: PropTypes.object,
|
|
80
90
|
isPublic: PropTypes.bool,
|
|
91
|
+
isReadOnly: PropTypes.bool,
|
|
81
92
|
children: PropTypes.oneOfType([
|
|
82
93
|
PropTypes.node,
|
|
83
94
|
PropTypes.arrayOf(PropTypes.node)
|
|
@@ -9,38 +9,54 @@ import ActionMenuDesktop from './ActionMenuDesktop'
|
|
|
9
9
|
import ActionMenuMobile from './ActionMenuMobile'
|
|
10
10
|
import { isEditableAttribute } from '../helpers'
|
|
11
11
|
|
|
12
|
-
const ActionMenuWrapper = forwardRef(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const ActionMenuWrapper = forwardRef(
|
|
13
|
+
({ file, optionFile, isReadOnly, onClose }, ref) => {
|
|
14
|
+
const { name, value } = optionFile
|
|
15
|
+
const { isMobile } = useBreakpoints()
|
|
16
|
+
const { t } = useI18n()
|
|
17
|
+
const { showAlert } = useAlert()
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const isEditable = isEditableAttribute(name, file) && !isReadOnly
|
|
20
|
+
const editPath = `${file.metadata.qualification.label}/${file._id}/edit/information?metadata=${optionFile.name}`
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
const handleCopy = async () => {
|
|
23
|
+
try {
|
|
24
|
+
await navigator.clipboard.writeText(value)
|
|
25
|
+
showAlert({
|
|
26
|
+
message: t(`Viewer.snackbar.copiedToClipboard.success`),
|
|
27
|
+
severity: 'success',
|
|
28
|
+
variant: 'filled',
|
|
29
|
+
icon: false
|
|
30
|
+
})
|
|
31
|
+
} catch (error) {
|
|
32
|
+
showAlert({
|
|
33
|
+
message: t(`Viewer.snackbar.copiedToClipboard.error`),
|
|
34
|
+
severity: 'error',
|
|
35
|
+
variant: 'filled',
|
|
36
|
+
icon: false
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
onClose()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (isMobile) {
|
|
43
|
+
return (
|
|
44
|
+
<ActionMenuMobile
|
|
45
|
+
file={file}
|
|
46
|
+
optionFile={optionFile}
|
|
47
|
+
actions={{
|
|
48
|
+
copy: { onClick: handleCopy },
|
|
49
|
+
edit: { path: editPath }
|
|
50
|
+
}}
|
|
51
|
+
isEditable={isEditable}
|
|
52
|
+
onClose={onClose}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
37
55
|
}
|
|
38
|
-
onClose()
|
|
39
|
-
}
|
|
40
56
|
|
|
41
|
-
if (isMobile) {
|
|
42
57
|
return (
|
|
43
|
-
<
|
|
58
|
+
<ActionMenuDesktop
|
|
59
|
+
ref={ref}
|
|
44
60
|
file={file}
|
|
45
61
|
optionFile={optionFile}
|
|
46
62
|
actions={{
|
|
@@ -52,21 +68,7 @@ const ActionMenuWrapper = forwardRef(({ file, optionFile, onClose }, ref) => {
|
|
|
52
68
|
/>
|
|
53
69
|
)
|
|
54
70
|
}
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<ActionMenuDesktop
|
|
58
|
-
ref={ref}
|
|
59
|
-
file={file}
|
|
60
|
-
optionFile={optionFile}
|
|
61
|
-
actions={{
|
|
62
|
-
copy: { onClick: handleCopy },
|
|
63
|
-
edit: { path: editPath }
|
|
64
|
-
}}
|
|
65
|
-
isEditable={isEditable}
|
|
66
|
-
onClose={onClose}
|
|
67
|
-
/>
|
|
68
|
-
)
|
|
69
|
-
})
|
|
71
|
+
)
|
|
70
72
|
|
|
71
73
|
ActionMenuWrapper.displayName = 'ActionMenuWrapper'
|
|
72
74
|
|
|
@@ -76,6 +78,7 @@ ActionMenuWrapper.propTypes = {
|
|
|
76
78
|
name: PropTypes.string,
|
|
77
79
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
78
80
|
}),
|
|
81
|
+
isReadOnly: PropTypes.bool,
|
|
79
82
|
onClose: PropTypes.func
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -34,7 +34,7 @@ const ComponentFromMetadataQualificationType = {
|
|
|
34
34
|
bills: QualificationListItemInformation
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const Qualification = ({ file, isReadOnly }) => {
|
|
37
|
+
const Qualification = ({ file, isPublic, isReadOnly }) => {
|
|
38
38
|
const { metadata = {} } = file
|
|
39
39
|
const actionBtnRef = useRef([])
|
|
40
40
|
const [showQualifModal, setShowQualifModal] = useState(false)
|
|
@@ -75,13 +75,13 @@ const Qualification = ({ file, isReadOnly }) => {
|
|
|
75
75
|
{hasSupportedQualification(file) ? (
|
|
76
76
|
<QualificationListItemQualification
|
|
77
77
|
file={file}
|
|
78
|
-
isReadOnly={isReadOnly}
|
|
78
|
+
isReadOnly={isPublic ? true : isReadOnly}
|
|
79
79
|
onClick={() => setShowQualifModal(true)}
|
|
80
80
|
/>
|
|
81
81
|
) : (
|
|
82
82
|
<QualificationListItemQualificationEmpty
|
|
83
83
|
file={file}
|
|
84
|
-
isReadOnly={isReadOnly}
|
|
84
|
+
isReadOnly={isPublic ? true : isReadOnly}
|
|
85
85
|
onClick={() => setShowQualifModal(true)}
|
|
86
86
|
/>
|
|
87
87
|
)}
|
|
@@ -109,7 +109,7 @@ const Qualification = ({ file, isReadOnly }) => {
|
|
|
109
109
|
<Fragment key={idx}>
|
|
110
110
|
<QualificationListItemComp
|
|
111
111
|
file={file}
|
|
112
|
-
isReadOnly={isReadOnly}
|
|
112
|
+
isReadOnly={isPublic ? true : isReadOnly}
|
|
113
113
|
ref={actionBtnRef.current[idx]}
|
|
114
114
|
formattedMetadataQualification={meta}
|
|
115
115
|
toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
|
|
@@ -124,6 +124,7 @@ const Qualification = ({ file, isReadOnly }) => {
|
|
|
124
124
|
file={file}
|
|
125
125
|
optionFile={optionFile}
|
|
126
126
|
ref={actionBtnRef.current[optionFile.id]}
|
|
127
|
+
isReadOnly={isPublic ? true : isReadOnly}
|
|
127
128
|
/>
|
|
128
129
|
)}
|
|
129
130
|
</List>
|
package/src/ViewerContainer.jsx
CHANGED
|
@@ -4,6 +4,7 @@ import React, { createRef, useState, useEffect } from 'react'
|
|
|
4
4
|
|
|
5
5
|
import { useClient } from 'cozy-client'
|
|
6
6
|
import { isDocumentReadOnly } from 'cozy-client/dist/models/permission'
|
|
7
|
+
import { useSharingContext } from 'cozy-sharing'
|
|
7
8
|
import Modal from 'cozy-ui/transpiled/react/Modal'
|
|
8
9
|
import { FileDoctype } from 'cozy-ui/transpiled/react/proptypes'
|
|
9
10
|
import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert'
|
|
@@ -34,6 +35,8 @@ const ViewerContainer = props => {
|
|
|
34
35
|
const [isReadOnly, setIsReadOnly] = useState(true)
|
|
35
36
|
const client = useClient()
|
|
36
37
|
useExtendI18n(locales)
|
|
38
|
+
const { hasWriteAccess } = useSharingContext()
|
|
39
|
+
|
|
37
40
|
const currentFile = files[currentIndex]
|
|
38
41
|
const fileCount = files.length
|
|
39
42
|
const hasPrevious = currentIndex > 0
|
|
@@ -51,16 +54,18 @@ const ViewerContainer = props => {
|
|
|
51
54
|
|
|
52
55
|
useEffect(() => {
|
|
53
56
|
const getIsReadOnly = async () => {
|
|
54
|
-
const res =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const res = isPublic
|
|
58
|
+
? await isDocumentReadOnly({
|
|
59
|
+
document: currentFile,
|
|
60
|
+
client
|
|
61
|
+
})
|
|
62
|
+
: !hasWriteAccess(currentFile._id)
|
|
58
63
|
|
|
59
64
|
setIsReadOnly(res)
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
getIsReadOnly()
|
|
63
|
-
}, [client, currentFile])
|
|
68
|
+
}, [client, currentFile, hasWriteAccess, isPublic])
|
|
64
69
|
|
|
65
70
|
return (
|
|
66
71
|
<AlertProvider>
|
|
@@ -141,7 +141,7 @@ class ViewerControls extends Component {
|
|
|
141
141
|
showFilePath={showFilePath}
|
|
142
142
|
onMouseEnter={this.showControls}
|
|
143
143
|
onMouseLeave={this.hideControls}
|
|
144
|
-
onClose={showClose
|
|
144
|
+
onClose={showClose ? onClose : undefined}
|
|
145
145
|
>
|
|
146
146
|
{children}
|
|
147
147
|
</Toolbar>
|