cozy-viewer 13.2.1 → 13.2.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 +11 -0
- package/dist/Panel/ActionMenuWrapper.js +1 -1
- package/dist/Panel/Qualification.js +3 -3
- package/dist/Panel/QualificationListItemContact.d.ts +2 -11
- package/dist/Panel/QualificationListItemContact.js +7 -47
- package/package.json +3 -3
- package/src/Panel/ActionMenuWrapper.jsx +4 -1
- package/src/Panel/Qualification.jsx +2 -2
- package/src/Panel/QualificationListItemContact.jsx +51 -70
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.2.2](https://github.com/cozy/cozy-libs/compare/cozy-viewer@13.2.1...cozy-viewer@13.2.2) (2025-01-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **Viewer:** Editing a contact use now the correct intent path ([44881c3](https://github.com/cozy/cozy-libs/commit/44881c3cefcc2bae3d331e789424cecf8a3ee126))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [13.2.1](https://github.com/cozy/cozy-libs/compare/cozy-viewer@13.2.0...cozy-viewer@13.2.1) (2025-01-16)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package cozy-viewer
|
|
@@ -49,7 +49,7 @@ var ActionMenuWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
49
49
|
showAlert = _useAlert.showAlert;
|
|
50
50
|
|
|
51
51
|
var isEditable = (0, _helpers.isEditableAttribute)(name, file) && !isReadOnly;
|
|
52
|
-
var editPath = "".concat(file.metadata.qualification.label, "/").concat(file._id, "/edit/information?metadata=").concat(optionFile.name);
|
|
52
|
+
var editPath = name === 'contact' ? "".concat(file.metadata.qualification.label, "/").concat(file._id, "/edit/contact") : "".concat(file.metadata.qualification.label, "/").concat(file._id, "/edit/information?metadata=").concat(optionFile.name);
|
|
53
53
|
|
|
54
54
|
var handleCopy = /*#__PURE__*/function () {
|
|
55
55
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
@@ -151,11 +151,11 @@ var Qualification = function Qualification(_ref) {
|
|
|
151
151
|
variant: "inset"
|
|
152
152
|
}));
|
|
153
153
|
}), optionFile.name && /*#__PURE__*/_react.default.createElement(_ActionMenuWrapper.default, {
|
|
154
|
-
|
|
154
|
+
ref: actionBtnRef.current[optionFile.id],
|
|
155
155
|
file: file,
|
|
156
156
|
optionFile: optionFile,
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
isReadOnly: isPublic ? true : isReadOnly,
|
|
158
|
+
onClose: hideActionsMenu
|
|
159
159
|
})));
|
|
160
160
|
};
|
|
161
161
|
|
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
export default QualificationListItemContact;
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
isReadOnly: any;
|
|
5
|
-
}): JSX.Element | null;
|
|
6
|
-
declare namespace QualificationListItemContact {
|
|
7
|
-
namespace propTypes {
|
|
8
|
-
const file: PropTypes.Validator<object>;
|
|
9
|
-
const isReadOnly: PropTypes.Requireable<boolean>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
import PropTypes from "prop-types";
|
|
2
|
+
declare const QualificationListItemContact: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
3
|
+
import React from "react";
|
|
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
|
|
12
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
11
|
|
|
14
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -33,8 +31,6 @@ var _Spinner = _interopRequireDefault(require("cozy-ui/transpiled/react/Spinner"
|
|
|
33
31
|
|
|
34
32
|
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
35
33
|
|
|
36
|
-
var _ActionMenuWrapper = _interopRequireDefault(require("./ActionMenuWrapper"));
|
|
37
|
-
|
|
38
34
|
var _QualificationListItemText = _interopRequireDefault(require("./QualificationListItemText"));
|
|
39
35
|
|
|
40
36
|
var _IntentOpener = _interopRequireDefault(require("../components/IntentOpener"));
|
|
@@ -45,23 +41,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
45
41
|
|
|
46
42
|
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; }
|
|
47
43
|
|
|
48
|
-
var QualificationListItemContact = function
|
|
44
|
+
var QualificationListItemContact = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
49
45
|
var file = _ref.file,
|
|
50
|
-
isReadOnly = _ref.isReadOnly
|
|
46
|
+
isReadOnly = _ref.isReadOnly,
|
|
47
|
+
toggleActionsMenu = _ref.toggleActionsMenu;
|
|
51
48
|
|
|
52
49
|
var _useI18n = (0, _I18n.useI18n)(),
|
|
53
50
|
lang = _useI18n.lang;
|
|
54
51
|
|
|
55
|
-
var actionBtnRef = (0, _react.useRef)();
|
|
56
|
-
|
|
57
|
-
var _useState = (0, _react.useState)({
|
|
58
|
-
name: '',
|
|
59
|
-
value: ''
|
|
60
|
-
}),
|
|
61
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
62
|
-
optionFile = _useState2[0],
|
|
63
|
-
setOptionFile = _useState2[1];
|
|
64
|
-
|
|
65
52
|
var _useReferencedContact = (0, _useReferencedContactName.default)(file),
|
|
66
53
|
contacts = _useReferencedContact.contacts,
|
|
67
54
|
isLoadingContacts = _useReferencedContact.isLoadingContacts;
|
|
@@ -82,27 +69,6 @@ var QualificationListItemContact = function QualificationListItemContact(_ref) {
|
|
|
82
69
|
lang: lang
|
|
83
70
|
});
|
|
84
71
|
var qualificationLabel = file.metadata.qualification.label;
|
|
85
|
-
|
|
86
|
-
var hideActionsMenu = function hideActionsMenu() {
|
|
87
|
-
return setOptionFile({
|
|
88
|
-
name: '',
|
|
89
|
-
value: ''
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
var toggleActionsMenu = function toggleActionsMenu(name, value) {
|
|
94
|
-
return setOptionFile(function (prev) {
|
|
95
|
-
if (prev.value) return {
|
|
96
|
-
name: '',
|
|
97
|
-
value: ''
|
|
98
|
-
};
|
|
99
|
-
return {
|
|
100
|
-
name: name,
|
|
101
|
-
value: value
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
|
|
106
72
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_IntentOpener.default, {
|
|
107
73
|
action: "OPEN",
|
|
108
74
|
doctype: "io.cozy.files.paper",
|
|
@@ -118,21 +84,15 @@ var QualificationListItemContact = function QualificationListItemContact(_ref) {
|
|
|
118
84
|
primary: formattedTitle,
|
|
119
85
|
secondary: formattedValue
|
|
120
86
|
}), /*#__PURE__*/_react.default.createElement(_ListItemSecondaryAction.default, null, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
121
|
-
ref:
|
|
87
|
+
ref: ref,
|
|
122
88
|
onClick: function onClick() {
|
|
123
89
|
return toggleActionsMenu('contact', formattedValue);
|
|
124
90
|
}
|
|
125
91
|
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
126
92
|
icon: _Dots.default
|
|
127
|
-
})))))
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
optionFile: optionFile,
|
|
131
|
-
ref: actionBtnRef,
|
|
132
|
-
isReadOnly: isReadOnly
|
|
133
|
-
}));
|
|
134
|
-
};
|
|
135
|
-
|
|
93
|
+
}))))));
|
|
94
|
+
});
|
|
95
|
+
QualificationListItemContact.displayName = 'QualificationListItemContact';
|
|
136
96
|
QualificationListItemContact.propTypes = {
|
|
137
97
|
file: _propTypes.default.object.isRequired,
|
|
138
98
|
isReadOnly: _propTypes.default.bool
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "13.2.
|
|
3
|
+
"version": "13.2.2",
|
|
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.12",
|
|
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": "fd145faacdefa1f529aaf8a45a2906066457512a"
|
|
63
63
|
}
|
|
@@ -17,7 +17,10 @@ const ActionMenuWrapper = forwardRef(
|
|
|
17
17
|
const { showAlert } = useAlert()
|
|
18
18
|
|
|
19
19
|
const isEditable = isEditableAttribute(name, file) && !isReadOnly
|
|
20
|
-
const editPath =
|
|
20
|
+
const editPath =
|
|
21
|
+
name === 'contact'
|
|
22
|
+
? `${file.metadata.qualification.label}/${file._id}/edit/contact`
|
|
23
|
+
: `${file.metadata.qualification.label}/${file._id}/edit/information?metadata=${optionFile.name}`
|
|
21
24
|
|
|
22
25
|
const handleCopy = async () => {
|
|
23
26
|
try {
|
|
@@ -120,11 +120,11 @@ const Qualification = ({ file, isPublic, isReadOnly }) => {
|
|
|
120
120
|
})}
|
|
121
121
|
{optionFile.name && (
|
|
122
122
|
<ActionMenuWrapper
|
|
123
|
-
|
|
123
|
+
ref={actionBtnRef.current[optionFile.id]}
|
|
124
124
|
file={file}
|
|
125
125
|
optionFile={optionFile}
|
|
126
|
-
ref={actionBtnRef.current[optionFile.id]}
|
|
127
126
|
isReadOnly={isPublic ? true : isReadOnly}
|
|
127
|
+
onClose={hideActionsMenu}
|
|
128
128
|
/>
|
|
129
129
|
)}
|
|
130
130
|
</List>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
getTranslatedNameForContact,
|
|
@@ -15,85 +15,66 @@ import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryA
|
|
|
15
15
|
import Spinner from 'cozy-ui/transpiled/react/Spinner'
|
|
16
16
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
17
17
|
|
|
18
|
-
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
19
18
|
import QualificationListItemText from './QualificationListItemText'
|
|
20
19
|
import IntentOpener from '../components/IntentOpener'
|
|
21
20
|
import useReferencedContactName from '../hooks/useReferencedContactName'
|
|
22
21
|
|
|
23
|
-
const QualificationListItemContact = (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name: '',
|
|
28
|
-
value: ''
|
|
29
|
-
})
|
|
30
|
-
const { contacts, isLoadingContacts } = useReferencedContactName(file)
|
|
22
|
+
const QualificationListItemContact = forwardRef(
|
|
23
|
+
({ file, isReadOnly, toggleActionsMenu }, ref) => {
|
|
24
|
+
const { lang } = useI18n()
|
|
25
|
+
const { contacts, isLoadingContacts } = useReferencedContactName(file)
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const formattedValue = formatContactValue(contacts)
|
|
27
|
+
if (isLoadingContacts) {
|
|
28
|
+
return (
|
|
29
|
+
<ListItem>
|
|
30
|
+
<Spinner color="var(--secondaryTextColor)" />
|
|
31
|
+
</ListItem>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
41
34
|
|
|
42
|
-
|
|
43
|
-
return null
|
|
44
|
-
}
|
|
35
|
+
const formattedValue = formatContactValue(contacts)
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
if (!formattedValue) {
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setOptionFile(prev => {
|
|
52
|
-
if (prev.value) return { name: '', value: '' }
|
|
53
|
-
return { name, value }
|
|
54
|
-
})
|
|
41
|
+
const formattedTitle = getTranslatedNameForContact({ lang })
|
|
42
|
+
const qualificationLabel = file.metadata.qualification.label
|
|
55
43
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<IntentOpener
|
|
47
|
+
action="OPEN"
|
|
48
|
+
doctype="io.cozy.files.paper"
|
|
49
|
+
options={{
|
|
50
|
+
path: `${qualificationLabel}/${file._id}/edit/contact`
|
|
51
|
+
}}
|
|
52
|
+
disabled={!!formattedValue || isReadOnly}
|
|
53
|
+
>
|
|
54
|
+
<ListItem button={!formattedValue && !isReadOnly}>
|
|
55
|
+
<ListItemIcon>
|
|
56
|
+
<Icon icon={PeopleIcon} />
|
|
57
|
+
</ListItemIcon>
|
|
58
|
+
<QualificationListItemText
|
|
59
|
+
primary={formattedTitle}
|
|
60
|
+
secondary={formattedValue}
|
|
61
|
+
/>
|
|
62
|
+
<ListItemSecondaryAction>
|
|
63
|
+
<IconButton
|
|
64
|
+
ref={ref}
|
|
65
|
+
onClick={() => toggleActionsMenu('contact', formattedValue)}
|
|
66
|
+
>
|
|
67
|
+
<Icon icon={Dots} />
|
|
68
|
+
</IconButton>
|
|
69
|
+
</ListItemSecondaryAction>
|
|
70
|
+
</ListItem>
|
|
71
|
+
</IntentOpener>
|
|
72
|
+
</>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
)
|
|
84
76
|
|
|
85
|
-
|
|
86
|
-
<ActionMenuWrapper
|
|
87
|
-
onClose={hideActionsMenu}
|
|
88
|
-
file={file}
|
|
89
|
-
optionFile={optionFile}
|
|
90
|
-
ref={actionBtnRef}
|
|
91
|
-
isReadOnly={isReadOnly}
|
|
92
|
-
/>
|
|
93
|
-
)}
|
|
94
|
-
</>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
77
|
+
QualificationListItemContact.displayName = 'QualificationListItemContact'
|
|
97
78
|
|
|
98
79
|
QualificationListItemContact.propTypes = {
|
|
99
80
|
file: PropTypes.object.isRequired,
|