cozy-viewer 7.0.2 → 8.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 CHANGED
@@ -3,6 +3,33 @@
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
+ # [8.0.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@7.0.2...cozy-viewer@8.0.0) (2024-12-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **Viewer:** It crashed for file without metadata ([85a25dd](https://github.com/cozy/cozy-libs/commit/85a25dd14d929f5326ba8d963e5929a2a3126771))
12
+ * **Viewer:** Last qualification divider wasn't displayed correctly ([2c24870](https://github.com/cozy/cozy-libs/commit/2c2487066866510f2352cb3a8aac32a0a730beb1))
13
+ * **Viewer:** Now hide qualification list if not relevant ([8deaa4a](https://github.com/cozy/cozy-libs/commit/8deaa4a4dd64c0cddeabde9218c2f8e356dbc52e))
14
+ * **Viewer:** Now qualification divider use correct tag ([09f29d1](https://github.com/cozy/cozy-libs/commit/09f29d1e6d35fc759e3b45ebc2c25f2e7e4f7c9a))
15
+ * **Viewer:** Now show correctly the owner in sharing block ([b88e24a](https://github.com/cozy/cozy-libs/commit/b88e24a707f619e24c6bb174107ffdb6d6f28668))
16
+ * **Viewer:** Sharing item style in panel wasn't correct ([7f76212](https://github.com/cozy/cozy-libs/commit/7f76212bfaf7a2f4b51c4001597367592c141456))
17
+
18
+
19
+ ### Features
20
+
21
+ * **Viewer:** Show always panel, not just for certified/connected files ([9bc42e7](https://github.com/cozy/cozy-libs/commit/9bc42e76735ff4da9e10c3a71c5c0e4443f2bfe5))
22
+ * **Viewer:** Upgrade peerDep ([1e199ec](https://github.com/cozy/cozy-libs/commit/1e199ecbfd9dacc59224b70106963a212ef8b2b1))
23
+
24
+
25
+ ### BREAKING CHANGES
26
+
27
+ * **Viewer:** You must have `cozy-sharing >= 16.11.0` and `cozy-harvest-lib >= 31.0.5`
28
+
29
+
30
+
31
+
32
+
6
33
  ## [7.0.2](https://github.com/cozy/cozy-libs/compare/cozy-viewer@7.0.1...cozy-viewer@7.0.2) (2024-12-05)
7
34
 
8
35
  **Note:** Version bump only for package cozy-viewer
@@ -4,7 +4,7 @@ declare function FooterContent({ file, toolbarRef, children, isPublic }: {
4
4
  toolbarRef: any;
5
5
  children: any;
6
6
  isPublic: any;
7
- }): JSX.Element | null;
7
+ }): JSX.Element;
8
8
  declare namespace FooterContent {
9
9
  namespace propTypes {
10
10
  const file: PropTypes.Validator<object>;
@@ -23,8 +23,6 @@ var _helpers = require("./helpers");
23
23
 
24
24
  var _PrintButton = _interopRequireDefault(require("../components/PrintButton"));
25
25
 
26
- var _helpers2 = require("../helpers");
27
-
28
26
  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); }
29
27
 
30
28
  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; }
@@ -79,34 +77,20 @@ var FooterContent = function FooterContent(_ref2) {
79
77
  isOpenMin: isPublic ? true : false,
80
78
  mediumHeightRatio: isPublic ? undefined : 0.5
81
79
  };
82
-
83
- if ((0, _helpers2.isValidForPanel)({
84
- file: file
85
- })) {
86
- return /*#__PURE__*/_react.default.createElement(_BottomSheet.default, {
87
- toolbarProps: toolbarProps,
88
- portalProps: {
89
- disablePortal: true
90
- },
91
- settings: bottomSheetSettings
92
- }, /*#__PURE__*/_react.default.createElement(_BottomSheet.BottomSheetHeader, {
93
- className: (0, _classnames.default)('u-ph-1 u-pb-1', styles.bottomSheetHeader)
94
- }, /*#__PURE__*/_react.default.createElement(FooterButtons, {
95
- file: file,
96
- FooterActionButtonsWithFile: FooterActionButtonsWithFile
97
- })), /*#__PURE__*/_react.default.createElement(_BottomSheetContent.default, {
98
- file: file,
99
- isPublic: isPublic
100
- }));
101
- } // If `FooterActionButtons` hasn't children
102
-
103
-
104
- if (!FooterActionButtonsWithFile) return null;
105
- return /*#__PURE__*/_react.default.createElement("div", {
106
- className: styles.footer
80
+ return /*#__PURE__*/_react.default.createElement(_BottomSheet.default, {
81
+ toolbarProps: toolbarProps,
82
+ portalProps: {
83
+ disablePortal: true
84
+ },
85
+ settings: bottomSheetSettings
86
+ }, /*#__PURE__*/_react.default.createElement(_BottomSheet.BottomSheetHeader, {
87
+ className: (0, _classnames.default)('u-ph-1 u-pb-1', styles.bottomSheetHeader)
107
88
  }, /*#__PURE__*/_react.default.createElement(FooterButtons, {
108
89
  file: file,
109
90
  FooterActionButtonsWithFile: FooterActionButtonsWithFile
91
+ })), /*#__PURE__*/_react.default.createElement(_BottomSheetContent.default, {
92
+ file: file,
93
+ isPublic: isPublic
110
94
  }));
111
95
  };
112
96
 
@@ -31,10 +31,14 @@ var _QualificationListItemOther = _interopRequireDefault(require("./Qualificatio
31
31
 
32
32
  var _QualificationListItemQualification = _interopRequireDefault(require("./QualificationListItemQualification"));
33
33
 
34
+ var _helpers = require("./helpers");
35
+
34
36
  var _ExpirationAlert = _interopRequireDefault(require("../components/ExpirationAlert"));
35
37
 
36
38
  var _withViewerLocales = require("../hoc/withViewerLocales");
37
39
 
40
+ var _useReferencedContactName = _interopRequireDefault(require("../hooks/useReferencedContactName"));
41
+
38
42
  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); }
39
43
 
40
44
  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; }
@@ -70,6 +74,11 @@ var Qualification = function Qualification(_ref) {
70
74
  optionFile = _useState2[0],
71
75
  setOptionFile = _useState2[1];
72
76
 
77
+ var _useReferencedContact = (0, _useReferencedContactName.default)(file),
78
+ contacts = _useReferencedContact.contacts;
79
+
80
+ var formattedContactValue = (0, _paper.formatContactValue)(contacts);
81
+
73
82
  var hideActionsMenu = function hideActionsMenu() {
74
83
  setOptionFile({
75
84
  id: '',
@@ -121,6 +130,8 @@ var Qualification = function Qualification(_ref) {
121
130
  return (_actionBtnRef$current = actionBtnRef.current[idx]) !== null && _actionBtnRef$current !== void 0 ? _actionBtnRef$current : /*#__PURE__*/(0, _react.createRef)();
122
131
  });
123
132
  }, [formattedMetadataQualification]);
133
+ var showMetadataList = formattedMetadataQualification.length !== 2 || formattedContactValue; // we have at minimum "qualification" and "contact" item
134
+
124
135
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _paper.isExpiringSoon)(file) && !isExpirationAlertHidden(file) && /*#__PURE__*/_react.default.createElement(_ExpirationAlert.default, {
125
136
  file: file
126
137
  }), /*#__PURE__*/_react.default.createElement(_QualificationListItemQualification.default, {
@@ -130,12 +141,12 @@ var Qualification = function Qualification(_ref) {
130
141
  toggleActionsMenu: function toggleActionsMenu(val) {
131
142
  return _toggleActionsMenu(0, formattedMetadataQualification[0].name, val);
132
143
  }
133
- }), /*#__PURE__*/_react.default.createElement(_List.default, null, formattedMetadataQualification.map(function (meta, idx) {
144
+ }), showMetadataList && /*#__PURE__*/_react.default.createElement(_List.default, null, formattedMetadataQualification.map(function (meta, idx) {
134
145
  var name = meta.name;
135
146
  if (name === 'qualification') return null;
136
147
  var metadataQualificationType = (0, _paper.getMetadataQualificationType)(name);
137
148
  var QualificationListItemComp = ComponentFromMetadataQualificationType[metadataQualificationType];
138
- var isLastItem = idx === formattedMetadataQualification.length - 1;
149
+ var hideDivider = (0, _helpers.makeHideDivider)(formattedMetadataQualification, idx);
139
150
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
140
151
  key: idx
141
152
  }, /*#__PURE__*/_react.default.createElement(QualificationListItemComp, {
@@ -145,7 +156,8 @@ var Qualification = function Qualification(_ref) {
145
156
  toggleActionsMenu: function toggleActionsMenu(val) {
146
157
  return _toggleActionsMenu(idx, name, val);
147
158
  }
148
- }), !isLastItem && /*#__PURE__*/_react.default.createElement(_Divider.default, {
159
+ }), !hideDivider && /*#__PURE__*/_react.default.createElement(_Divider.default, {
160
+ component: "li",
149
161
  variant: "inset"
150
162
  }));
151
163
  }), optionFile.name && /*#__PURE__*/_react.default.createElement(_ActionMenuWrapper.default, {
@@ -59,6 +59,26 @@ var QualificationListItemContact = function QualificationListItemContact(_ref) {
59
59
  optionFile = _useState2[0],
60
60
  setOptionFile = _useState2[1];
61
61
 
62
+ var _useReferencedContact = (0, _useReferencedContactName.default)(file),
63
+ contacts = _useReferencedContact.contacts,
64
+ isLoadingContacts = _useReferencedContact.isLoadingContacts;
65
+
66
+ if (isLoadingContacts) {
67
+ return /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_Spinner.default, {
68
+ color: "var(--secondaryTextColor)"
69
+ }));
70
+ }
71
+
72
+ var formattedValue = (0, _paper.formatContactValue)(contacts);
73
+
74
+ if (!formattedValue) {
75
+ return null;
76
+ }
77
+
78
+ var formattedTitle = (0, _paper.getTranslatedNameForContact)({
79
+ lang: lang
80
+ });
81
+
62
82
  var hideActionsMenu = function hideActionsMenu() {
63
83
  return setOptionFile({
64
84
  name: '',
@@ -79,25 +99,6 @@ var QualificationListItemContact = function QualificationListItemContact(_ref) {
79
99
  });
80
100
  };
81
101
 
82
- var _useReferencedContact = (0, _useReferencedContactName.default)(file),
83
- contacts = _useReferencedContact.contacts,
84
- isLoadingContacts = _useReferencedContact.isLoadingContacts;
85
-
86
- if (isLoadingContacts) {
87
- return /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_Spinner.default, {
88
- color: "var(--secondaryTextColor)"
89
- }));
90
- }
91
-
92
- var formattedTitle = (0, _paper.getTranslatedNameForContact)({
93
- lang: lang
94
- });
95
- var formattedValue = (0, _paper.formatContactValue)(contacts);
96
-
97
- if (!isLoadingContacts && !formattedValue) {
98
- return null;
99
- }
100
-
101
102
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
102
103
  icon: _People.default
103
104
  })), /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
@@ -15,8 +15,6 @@ var _react = _interopRequireWildcard(require("react"));
15
15
 
16
16
  var _cozySharing = require("cozy-sharing");
17
17
 
18
- var _Divider = _interopRequireDefault(require("cozy-ui/transpiled/react/Divider"));
19
-
20
18
  var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
21
19
 
22
20
  var _Right = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Right"));
@@ -56,7 +54,9 @@ var Sharing = function Sharing(_ref) {
56
54
  var recipients = getRecipients(file._id);
57
55
  var permissions = getDocumentPermissions(file._id);
58
56
  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, {
57
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ListItem.default, {
58
+ size: "large",
59
+ divider: true,
60
60
  button: true,
61
61
  onClick: function onClick() {
62
62
  return setShowModal(true);
@@ -71,18 +71,19 @@ var Sharing = function Sharing(_ref) {
71
71
  }
72
72
  }), /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
73
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, {
74
+ }))), /*#__PURE__*/_react.default.createElement(_List.default, null, /*#__PURE__*/_react.default.createElement(_cozySharing.LinkRecipientLite, {
75
75
  permissions: permissions,
76
76
  link: link
77
- }), recipients.map(function (recipient) {
77
+ }), recipients.length > 0 ? recipients.map(function (recipient) {
78
78
  return /*#__PURE__*/_react.default.createElement(_cozySharing.MemberRecipientLite, {
79
79
  key: recipient.index,
80
80
  recipient: recipient,
81
81
  isOwner: isOwner(file._id)
82
82
  });
83
- })), showModal && /*#__PURE__*/_react.default.createElement(_cozySharing.ShareModal, {
83
+ }) : /*#__PURE__*/_react.default.createElement(_cozySharing.OwnerRecipientDefaultLite, null)), showModal && /*#__PURE__*/_react.default.createElement(_cozySharing.ShareModal, {
84
84
  document: file,
85
85
  documentType: "Files",
86
+ sharingDesc: "",
86
87
  onClose: function onClose() {
87
88
  return setShowModal(false);
88
89
  }
@@ -56,6 +56,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
56
56
  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; }
57
57
 
58
58
  var Summary = function Summary(_ref) {
59
+ var _file$metadata;
60
+
59
61
  var file = _ref.file,
60
62
  t = _ref.t;
61
63
 
@@ -75,7 +77,7 @@ var Summary = function Summary(_ref) {
75
77
  showAlert = _useAlert.showAlert;
76
78
 
77
79
  var label = t('Viewer.panel.summary');
78
- var value = file.metadata.description;
80
+ var value = (_file$metadata = file.metadata) === null || _file$metadata === void 0 ? void 0 : _file$metadata.description;
79
81
  var actions = (0, _Actions.makeActions)([_Actions.copyToClipboard, _Actions.editAttribute]);
80
82
 
81
83
  var handleClick = /*#__PURE__*/function () {
@@ -38,11 +38,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
38
38
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
39
39
 
40
40
  var SummaryDialog = function SummaryDialog(_ref) {
41
+ var _file$metadata;
42
+
41
43
  var file = _ref.file,
42
44
  t = _ref.t,
43
45
  onClose = _ref.onClose;
44
46
 
45
- var _useState = (0, _react.useState)(file.metadata.description),
47
+ var _useState = (0, _react.useState)((_file$metadata = file.metadata) === null || _file$metadata === void 0 ? void 0 : _file$metadata.description),
46
48
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
47
49
  value = _useState2[0],
48
50
  setValue = _useState2[1];
@@ -2,3 +2,4 @@ export function makeFormat(file: any): string;
2
2
  export function makeDate(lang: string): string;
3
3
  export function makeSize(bytes: number): string;
4
4
  export function makePath(file: any): string;
5
+ export function makeHideDivider(formattedMetadataQualification: array, idx: number): boolean;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.makeSize = exports.makePath = exports.makeFormat = exports.makeDate = void 0;
6
+ exports.makeSize = exports.makePath = exports.makeHideDivider = exports.makeFormat = exports.makeDate = void 0;
7
7
 
8
8
  var _file = require("cozy-client/dist/models/file");
9
9
 
@@ -61,5 +61,22 @@ var makePath = function makePath(file) {
61
61
 
62
62
  return (_file$path = file.path) === null || _file$path === void 0 ? void 0 : _file$path.replace("/".concat(file.name), '');
63
63
  };
64
+ /**
65
+ *
66
+ * @param {array} formattedMetadataQualification
67
+ * @param {number} idx
68
+ * @returns {boolean}
69
+ */
70
+
71
+
72
+ exports.makePath = makePath;
73
+
74
+ var makeHideDivider = function makeHideDivider(formattedMetadataQualification, idx) {
75
+ var lastItem = formattedMetadataQualification.at(-1);
76
+ var isLastItem = idx === formattedMetadataQualification.length - 1;
77
+ var isSecondLastItem = idx === formattedMetadataQualification.length - 2;
78
+ var hideDivider = isLastItem || isSecondLastItem && lastItem.name === 'contact';
79
+ return hideDivider;
80
+ };
64
81
 
65
- exports.makePath = makePath;
82
+ exports.makeHideDivider = makeHideDivider;
@@ -0,0 +1 @@
1
+ export {};
@@ -37,8 +37,6 @@ var _Viewer = _interopRequireDefault(require("./Viewer"));
37
37
 
38
38
  var _ViewerInformationsWrapper = _interopRequireDefault(require("./ViewerInformationsWrapper"));
39
39
 
40
- var _helpers = require("./helpers");
41
-
42
40
  var _locales = require("./locales");
43
41
 
44
42
  var _proptypes2 = require("./proptypes");
@@ -83,9 +81,7 @@ var ViewerContainer = function ViewerContainer(props) {
83
81
  var fileCount = files.length;
84
82
  var hasPrevious = currentIndex > 0;
85
83
  var hasNext = currentIndex < fileCount - 1;
86
- var validForPanel = (0, _helpers.isValidForPanel)({
87
- file: currentFile
88
- }) && isDesktop && !disablePanel;
84
+ var validForPanel = isDesktop && !disablePanel;
89
85
 
90
86
  var componentsPropsWithDefault = _objectSpread(_objectSpread({}, componentsProps), {}, {
91
87
  toolbarProps: _objectSpread({
@@ -19,7 +19,6 @@ var styles = {
19
19
  "viewer-nav--next": "styles__viewer-nav--next___3mBHi",
20
20
  "viewer-controls": "styles__viewer-controls___2lf-z",
21
21
  "--expanded": "styles__--expanded___1sp4Q",
22
- "viewer-controls--display-content-top": "styles__viewer-controls--display-content-top___3wszk",
23
22
  "viewer-toolbar": "styles__viewer-toolbar___1GLOA",
24
23
  "viewer-toolbar--hidden": "styles__viewer-toolbar--hidden___Zq97m",
25
24
  "viewer-footer": "styles__viewer-footer___iGv8J"
@@ -27,7 +27,6 @@ var styles = {
27
27
  "viewer-nav--next": "styles__viewer-nav--next___3mBHi",
28
28
  "viewer-controls": "styles__viewer-controls___2lf-z",
29
29
  "--expanded": "styles__--expanded___1sp4Q",
30
- "viewer-controls--display-content-top": "styles__viewer-controls--display-content-top___3wszk",
31
30
  "viewer-toolbar": "styles__viewer-toolbar___1GLOA",
32
31
  "viewer-toolbar--hidden": "styles__viewer-toolbar--hidden___Zq97m",
33
32
  "viewer-footer": "styles__viewer-footer___iGv8J"
@@ -55,7 +55,6 @@ var styles = {
55
55
  "viewer-nav--next": "styles__viewer-nav--next___3mBHi",
56
56
  "viewer-controls": "styles__viewer-controls___2lf-z",
57
57
  "--expanded": "styles__--expanded___1sp4Q",
58
- "viewer-controls--display-content-top": "styles__viewer-controls--display-content-top___3wszk",
59
58
  "viewer-toolbar": "styles__viewer-toolbar___1GLOA",
60
59
  "viewer-toolbar--hidden": "styles__viewer-toolbar--hidden___Zq97m",
61
60
  "viewer-footer": "styles__viewer-footer___iGv8J"
@@ -41,8 +41,6 @@ var _Navigation = _interopRequireDefault(require("./Navigation"));
41
41
 
42
42
  var _Toolbar = _interopRequireDefault(require("./Toolbar"));
43
43
 
44
- var _helpers = require("../helpers");
45
-
46
44
  var _proptypes = require("../proptypes");
47
45
 
48
46
  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); }
@@ -61,7 +59,6 @@ var styles = {
61
59
  "viewer-nav--next": "styles__viewer-nav--next___3mBHi",
62
60
  "viewer-controls": "styles__viewer-controls___2lf-z",
63
61
  "--expanded": "styles__--expanded___1sp4Q",
64
- "viewer-controls--display-content-top": "styles__viewer-controls--display-content-top___3wszk",
65
62
  "viewer-toolbar": "styles__viewer-toolbar___1GLOA",
66
63
  "viewer-toolbar--hidden": "styles__viewer-toolbar--hidden___Zq97m",
67
64
  "viewer-footer": "styles__viewer-footer___iGv8J"
@@ -200,11 +197,8 @@ var ViewerControls = /*#__PURE__*/function (_Component) {
200
197
  toolbarRef = toolbarProps.toolbarRef,
201
198
  showFilePath = toolbarProps.showFilePath;
202
199
  var hidden = this.state.hidden;
203
- var shouldDisplayContentTop = (0, _helpers.isValidForPanel)({
204
- file: file
205
- });
206
200
  return /*#__PURE__*/_react.default.createElement("div", {
207
- className: (0, _classnames.default)(styles['viewer-controls'], (_cx = {}, (0, _defineProperty2.default)(_cx, styles['viewer-controls--expanded'], expanded), (0, _defineProperty2.default)(_cx, styles['viewer-controls--display-content-top'], shouldDisplayContentTop), (0, _defineProperty2.default)(_cx, classes.viewerControlsWithInfo, showInfoPanel), _cx)),
201
+ className: (0, _classnames.default)(styles['viewer-controls'], (_cx = {}, (0, _defineProperty2.default)(_cx, styles['viewer-controls--expanded'], expanded), (0, _defineProperty2.default)(_cx, classes.viewerControlsWithInfo, showInfoPanel), _cx)),
208
202
  ref: function ref(wrapped) {
209
203
  _this3.wrapped = wrapped;
210
204
  }
package/dist/helpers.d.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  export function getCurrentModel(metadataName: any): "information" | "contact" | "page" | undefined;
2
- export function isValidForPanel({ file }: {
3
- file: IOCozyFile;
4
- }): boolean;
5
2
  export function isFileEncrypted(file: any): any;
6
3
  export function formatDate({ f, lang, date }: {
7
4
  f: any;
package/dist/helpers.js CHANGED
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.removeFilenameFromPath = exports.normalizeAndSpreadAttributes = exports.makeWebLink = exports.isValidForPanel = exports.isFileEncrypted = exports.isEditableAttribute = exports.getCurrentModel = exports.formatDate = exports.buildEditAttributePath = void 0;
8
+ exports.removeFilenameFromPath = exports.normalizeAndSpreadAttributes = exports.makeWebLink = exports.isFileEncrypted = exports.isEditableAttribute = exports.getCurrentModel = exports.formatDate = exports.buildEditAttributePath = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
@@ -33,37 +33,19 @@ var getCurrentModel = function getCurrentModel(metadataName) {
33
33
  * @property {string} type - doctype of the document
34
34
  */
35
35
 
36
- /**
37
- * Checks if the file matches one of the following conditions:
38
- * - Is certified
39
- * - Is Qualified
40
- * - From a Connector
41
- *
42
- * @param {object} param
43
- * @param {IOCozyFile} param.file
44
- * @returns {boolean}
45
- */
46
-
47
36
 
48
37
  exports.getCurrentModel = getCurrentModel;
49
38
 
50
- var isValidForPanel = function isValidForPanel(_ref) {
51
- var file = _ref.file;
52
- return (0, _file.hasCertifications)(file) || (0, _file.hasQualifications)(file) || (0, _file.isFromKonnector)(file);
53
- };
54
-
55
- exports.isValidForPanel = isValidForPanel;
56
-
57
39
  var isFileEncrypted = function isFileEncrypted(file) {
58
40
  return (0, _file.isEncrypted)(file);
59
41
  };
60
42
 
61
43
  exports.isFileEncrypted = isFileEncrypted;
62
44
 
63
- var formatDate = function formatDate(_ref2) {
64
- var f = _ref2.f,
65
- lang = _ref2.lang,
66
- date = _ref2.date;
45
+ var formatDate = function formatDate(_ref) {
46
+ var f = _ref.f,
47
+ lang = _ref.lang,
48
+ date = _ref.date;
67
49
 
68
50
  if (lang === 'en') {
69
51
  return f(date, 'MM/DD/YYYY');
@@ -113,10 +95,10 @@ var normalizeAndSpreadAttributes = function normalizeAndSpreadAttributes(rawFile
113
95
 
114
96
  exports.normalizeAndSpreadAttributes = normalizeAndSpreadAttributes;
115
97
 
116
- var makeWebLink = function makeWebLink(_ref3) {
117
- var client = _ref3.client,
118
- slug = _ref3.slug,
119
- path = _ref3.path;
98
+ var makeWebLink = function makeWebLink(_ref2) {
99
+ var client = _ref2.client,
100
+ slug = _ref2.slug,
101
+ path = _ref2.path;
120
102
 
121
103
  try {
122
104
  var cozyURL = new URL(client.getStackClient().uri);
@@ -195,16 +195,16 @@
195
195
  width: 100%;
196
196
  height: 100%;
197
197
  }
198
- .styles__viewer-controls___2lf-z.styles__--expanded___1sp4Q .styles__viewer-nav___3V03k {
199
- margin-top: 0;
200
- width: 40%;
201
- }
202
198
  @media (max-width: 63.938rem) {
203
- .styles__viewer-controls--display-content-top___3wszk {
199
+ .styles__viewer-controls___2lf-z {
204
200
  justify-content: flex-start;
205
201
  padding-top: 4.5rem;
206
202
  }
207
203
  }
204
+ .styles__viewer-controls___2lf-z.styles__--expanded___1sp4Q .styles__viewer-nav___3V03k {
205
+ margin-top: 0;
206
+ width: 40%;
207
+ }
208
208
  .styles__viewer-toolbar___1GLOA {
209
209
  position: absolute;
210
210
  top: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-viewer",
3
- "version": "7.0.2",
3
+ "version": "8.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,7 +27,7 @@
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": "^31.0.5",
30
+ "cozy-harvest-lib": "^31.0.6",
31
31
  "cozy-intent": "^2.29.1",
32
32
  "cozy-logger": "^1.16.1",
33
33
  "cozy-sharing": "^16.11.0",
@@ -52,13 +52,13 @@
52
52
  "peerDependencies": {
53
53
  "cozy-client": ">=50.0.0",
54
54
  "cozy-device-helper": ">=2.0.0",
55
- "cozy-harvest-lib": ">=30.8.0",
55
+ "cozy-harvest-lib": ">=31.0.5",
56
56
  "cozy-intent": ">=2.26.0",
57
57
  "cozy-logger": ">=1.9.0",
58
- "cozy-sharing": ">=16.8.0",
58
+ "cozy-sharing": ">=16.11.0",
59
59
  "cozy-ui": ">=113.8.0",
60
60
  "react": ">=16.12.0",
61
61
  "react-dom": ">=16.12.0"
62
62
  },
63
- "gitHead": "99210fddf08b4701afcf0390c0042d3f7cfb97ec"
63
+ "gitHead": "5e8d5bd6ec3ba9f49fdacf8669cf54fb6cd8fc90"
64
64
  }
@@ -10,7 +10,6 @@ import { makeStyles } from 'cozy-ui/transpiled/react/styles'
10
10
  import BottomSheetContent from './BottomSheetContent'
11
11
  import { extractChildrenCompByName } from './helpers'
12
12
  import PrintButton from '../components/PrintButton'
13
- import { isValidForPanel } from '../helpers'
14
13
 
15
14
  const FooterButtons = ({
16
15
  file,
@@ -56,36 +55,22 @@ const FooterContent = ({ file, toolbarRef, children, isPublic }) => {
56
55
  mediumHeightRatio: isPublic ? undefined : 0.5
57
56
  }
58
57
 
59
- if (isValidForPanel({ file })) {
60
- return (
61
- <BottomSheet
62
- toolbarProps={toolbarProps}
63
- portalProps={{ disablePortal: true }}
64
- settings={bottomSheetSettings}
65
- >
66
- <BottomSheetHeader
67
- className={cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)}
68
- >
69
- <FooterButtons
70
- file={file}
71
- FooterActionButtonsWithFile={FooterActionButtonsWithFile}
72
- />
73
- </BottomSheetHeader>
74
- <BottomSheetContent file={file} isPublic={isPublic} />
75
- </BottomSheet>
76
- )
77
- }
78
-
79
- // If `FooterActionButtons` hasn't children
80
- if (!FooterActionButtonsWithFile) return null
81
-
82
58
  return (
83
- <div className={styles.footer}>
84
- <FooterButtons
85
- file={file}
86
- FooterActionButtonsWithFile={FooterActionButtonsWithFile}
87
- />
88
- </div>
59
+ <BottomSheet
60
+ toolbarProps={toolbarProps}
61
+ portalProps={{ disablePortal: true }}
62
+ settings={bottomSheetSettings}
63
+ >
64
+ <BottomSheetHeader
65
+ className={cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)}
66
+ >
67
+ <FooterButtons
68
+ file={file}
69
+ FooterActionButtonsWithFile={FooterActionButtonsWithFile}
70
+ />
71
+ </BottomSheetHeader>
72
+ <BottomSheetContent file={file} isPublic={isPublic} />
73
+ </BottomSheet>
89
74
  )
90
75
  }
91
76
 
@@ -12,6 +12,7 @@ import {
12
12
  isExpiringSoon,
13
13
  formatMetadataQualification,
14
14
  KNOWN_BILLS_ATTRIBUTES_NAMES,
15
+ formatContactValue,
15
16
  getMetadataQualificationType
16
17
  } from 'cozy-client/dist/models/paper'
17
18
  import Divider from 'cozy-ui/transpiled/react/Divider'
@@ -23,8 +24,10 @@ import QualificationListItemDate from './QualificationListItemDate'
23
24
  import QualificationListItemInformation from './QualificationListItemInformation'
24
25
  import QualificationListItemOther from './QualificationListItemOther'
25
26
  import QualificationListItemQualification from './QualificationListItemQualification'
27
+ import { makeHideDivider } from './helpers'
26
28
  import ExpirationAlert from '../components/ExpirationAlert'
27
29
  import { withViewerLocales } from '../hoc/withViewerLocales'
30
+ import useReferencedContactName from '../hooks/useReferencedContactName'
28
31
 
29
32
  const ComponentFromMetadataQualificationType = {
30
33
  contact: QualificationListItemContact,
@@ -46,6 +49,8 @@ const Qualification = ({ file }) => {
46
49
  name: '',
47
50
  value: ''
48
51
  })
52
+ const { contacts } = useReferencedContactName(file)
53
+ const formattedContactValue = formatContactValue(contacts)
49
54
 
50
55
  const hideActionsMenu = () => {
51
56
  setOptionFile({ id: '', name: '', value: '' })
@@ -83,6 +88,9 @@ const Qualification = ({ file }) => {
83
88
  )
84
89
  }, [formattedMetadataQualification])
85
90
 
91
+ const showMetadataList =
92
+ formattedMetadataQualification.length !== 2 || formattedContactValue // we have at minimum "qualification" and "contact" item
93
+
86
94
  return (
87
95
  <>
88
96
  {isExpiringSoon(file) && !isExpirationAlertHidden(file) && (
@@ -96,38 +104,43 @@ const Qualification = ({ file }) => {
96
104
  toggleActionsMenu(0, formattedMetadataQualification[0].name, val)
97
105
  }
98
106
  />
99
- <List>
100
- {formattedMetadataQualification.map((meta, idx) => {
101
- const { name } = meta
102
- if (name === 'qualification') return null
103
-
104
- const metadataQualificationType = getMetadataQualificationType(name)
105
- const QualificationListItemComp =
106
- ComponentFromMetadataQualificationType[metadataQualificationType]
107
-
108
- const isLastItem = idx === formattedMetadataQualification.length - 1
109
-
110
- return (
111
- <Fragment key={idx}>
112
- <QualificationListItemComp
113
- file={file}
114
- ref={actionBtnRef.current[idx]}
115
- formattedMetadataQualification={meta}
116
- toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
117
- />
118
- {!isLastItem && <Divider variant="inset" />}
119
- </Fragment>
120
- )
121
- })}
122
- {optionFile.name && (
123
- <ActionMenuWrapper
124
- onClose={hideActionsMenu}
125
- file={file}
126
- optionFile={optionFile}
127
- ref={actionBtnRef.current[optionFile.id]}
128
- />
129
- )}
130
- </List>
107
+ {showMetadataList && (
108
+ <List>
109
+ {formattedMetadataQualification.map((meta, idx) => {
110
+ const { name } = meta
111
+ if (name === 'qualification') return null
112
+
113
+ const metadataQualificationType = getMetadataQualificationType(name)
114
+ const QualificationListItemComp =
115
+ ComponentFromMetadataQualificationType[metadataQualificationType]
116
+
117
+ const hideDivider = makeHideDivider(
118
+ formattedMetadataQualification,
119
+ idx
120
+ )
121
+
122
+ return (
123
+ <Fragment key={idx}>
124
+ <QualificationListItemComp
125
+ file={file}
126
+ ref={actionBtnRef.current[idx]}
127
+ formattedMetadataQualification={meta}
128
+ toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
129
+ />
130
+ {!hideDivider && <Divider component="li" variant="inset" />}
131
+ </Fragment>
132
+ )
133
+ })}
134
+ {optionFile.name && (
135
+ <ActionMenuWrapper
136
+ onClose={hideActionsMenu}
137
+ file={file}
138
+ optionFile={optionFile}
139
+ ref={actionBtnRef.current[optionFile.id]}
140
+ />
141
+ )}
142
+ </List>
143
+ )}
131
144
  </>
132
145
  )
133
146
  }
@@ -26,14 +26,6 @@ const QualificationListItemContact = ({ file }) => {
26
26
  name: '',
27
27
  value: ''
28
28
  })
29
-
30
- const hideActionsMenu = () => setOptionFile({ name: '', value: '' })
31
- const toggleActionsMenu = (name, value) =>
32
- setOptionFile(prev => {
33
- if (prev.value) return { name: '', value: '' }
34
- return { name, value }
35
- })
36
-
37
29
  const { contacts, isLoadingContacts } = useReferencedContactName(file)
38
30
 
39
31
  if (isLoadingContacts) {
@@ -44,13 +36,21 @@ const QualificationListItemContact = ({ file }) => {
44
36
  )
45
37
  }
46
38
 
47
- const formattedTitle = getTranslatedNameForContact({ lang })
48
39
  const formattedValue = formatContactValue(contacts)
49
40
 
50
- if (!isLoadingContacts && !formattedValue) {
41
+ if (!formattedValue) {
51
42
  return null
52
43
  }
53
44
 
45
+ const formattedTitle = getTranslatedNameForContact({ lang })
46
+
47
+ const hideActionsMenu = () => setOptionFile({ name: '', value: '' })
48
+ const toggleActionsMenu = (name, value) =>
49
+ setOptionFile(prev => {
50
+ if (prev.value) return { name: '', value: '' }
51
+ return { name, value }
52
+ })
53
+
54
54
  return (
55
55
  <>
56
56
  <ListItem>
@@ -5,9 +5,9 @@ import {
5
5
  ShareModal,
6
6
  useSharingContext,
7
7
  MemberRecipientLite,
8
+ OwnerRecipientDefaultLite,
8
9
  LinkRecipientLite
9
10
  } from 'cozy-sharing'
10
- import Divider from 'cozy-ui/transpiled/react/Divider'
11
11
  import Icon from 'cozy-ui/transpiled/react/Icon'
12
12
  import RightIcon from 'cozy-ui/transpiled/react/Icons/Right'
13
13
  import List from 'cozy-ui/transpiled/react/List'
@@ -34,37 +34,39 @@ const Sharing = ({ file, t }) => {
34
34
 
35
35
  return (
36
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 />
37
+ <ListItem size="large" divider button onClick={() => setShowModal(true)}>
38
+ <ListItemText
39
+ primary={
40
+ <>
41
+ {t('Viewer.panel.sharing')}
42
+ {!allLoaded && <Spinner className="u-ml-half" noMargin />}
43
+ </>
44
+ }
45
+ primaryTypographyProps={{ variant: 'h6' }}
46
+ />
47
+ <ListItemIcon>
48
+ <Icon icon={RightIcon} />
49
+ </ListItemIcon>
50
+ </ListItem>
54
51
  <List>
55
52
  <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
- ))}
53
+ {recipients.length > 0 ? (
54
+ recipients.map(recipient => (
55
+ <MemberRecipientLite
56
+ key={recipient.index}
57
+ recipient={recipient}
58
+ isOwner={isOwner(file._id)}
59
+ />
60
+ ))
61
+ ) : (
62
+ <OwnerRecipientDefaultLite />
63
+ )}
63
64
  </List>
64
65
  {showModal && (
65
66
  <ShareModal
66
67
  document={file}
67
68
  documentType="Files"
69
+ sharingDesc=""
68
70
  onClose={() => setShowModal(false)}
69
71
  />
70
72
  )}
@@ -31,7 +31,7 @@ const Summary = ({ file, t }) => {
31
31
  const { showAlert } = useAlert()
32
32
 
33
33
  const label = t('Viewer.panel.summary')
34
- const value = file.metadata.description
34
+ const value = file.metadata?.description
35
35
  const actions = makeActions([copyToClipboard, editAttribute])
36
36
 
37
37
  const handleClick = async () => {
@@ -9,7 +9,7 @@ import TextField from 'cozy-ui/transpiled/react/TextField'
9
9
  import { withViewerLocales } from '../hoc/withViewerLocales'
10
10
 
11
11
  const SummaryDialog = ({ file, t, onClose }) => {
12
- const [value, setValue] = useState(file.metadata.description)
12
+ const [value, setValue] = useState(file.metadata?.description)
13
13
  const [busy, setBusy] = useState(false)
14
14
  const client = useClient()
15
15
 
@@ -41,3 +41,19 @@ export const makeSize = bytes => {
41
41
  * @returns {string}
42
42
  */
43
43
  export const makePath = file => file.path?.replace(`/${file.name}`, '')
44
+
45
+ /**
46
+ *
47
+ * @param {array} formattedMetadataQualification
48
+ * @param {number} idx
49
+ * @returns {boolean}
50
+ */
51
+ export const makeHideDivider = (formattedMetadataQualification, idx) => {
52
+ const lastItem = formattedMetadataQualification.at(-1)
53
+ const isLastItem = idx === formattedMetadataQualification.length - 1
54
+ const isSecondLastItem = idx === formattedMetadataQualification.length - 2
55
+ const hideDivider =
56
+ isLastItem || (isSecondLastItem && lastItem.name === 'contact')
57
+
58
+ return hideDivider
59
+ }
@@ -0,0 +1,40 @@
1
+ import { makeHideDivider } from './helpers'
2
+
3
+ describe('makeHideDivider', () => {
4
+ describe('should hide the divider', () => {
5
+ it('if contact is the only qualification', () => {
6
+ const res = makeHideDivider([{ name: 'contact' }], 0)
7
+
8
+ expect(res).toBeTruthy()
9
+ })
10
+
11
+ it('for the last qualification', () => {
12
+ const res = makeHideDivider(
13
+ [{ name: 'contact' }, { name: 'issueDate' }],
14
+ 1
15
+ )
16
+
17
+ expect(res).toBeTruthy()
18
+ })
19
+
20
+ it('for the first qualificaiton if contact is the second and last one', () => {
21
+ const res = makeHideDivider(
22
+ [{ name: 'issueDate' }, { name: 'contact' }],
23
+ 0
24
+ )
25
+
26
+ expect(res).toBeTruthy()
27
+ })
28
+ })
29
+
30
+ describe('should show the divider', () => {
31
+ it('for contact if is the first and not only one qualification', () => {
32
+ const res = makeHideDivider(
33
+ [{ name: 'contact' }, { name: 'issueDate' }],
34
+ 0
35
+ )
36
+
37
+ expect(res).toBeFalsy()
38
+ })
39
+ })
40
+ })
package/src/Readme.md CHANGED
@@ -58,7 +58,6 @@ import DemoProvider from './providers/DemoProvider'
58
58
  import Button from 'cozy-ui/transpiled/react/Buttons'
59
59
  import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
60
60
  import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share'
61
- import { isValidForPanel } from 'cozy-ui/transpiled/react/Viewer/helpers'
62
61
  import getPanelBlocks, { panelBlocksSpecs } from 'cozy-ui/transpiled/react/Viewer/Panel/getPanelBlocks'
63
62
  import Sprite from 'cozy-ui/transpiled/react/Icon/Sprite'
64
63
  import IconButton from 'cozy-ui/transpiled/react/IconButton'
@@ -12,7 +12,6 @@ import { useExtendI18n } from 'cozy-ui/transpiled/react/providers/I18n'
12
12
 
13
13
  import Viewer from './Viewer'
14
14
  import ViewerInformationsWrapper from './ViewerInformationsWrapper'
15
- import { isValidForPanel } from './helpers'
16
15
  import { locales } from './locales'
17
16
  import { toolbarPropsPropType } from './proptypes'
18
17
  import { ActionMenuProvider } from './providers/ActionMenuProvider'
@@ -37,8 +36,7 @@ const ViewerContainer = props => {
37
36
  const fileCount = files.length
38
37
  const hasPrevious = currentIndex > 0
39
38
  const hasNext = currentIndex < fileCount - 1
40
- const validForPanel =
41
- isValidForPanel({ file: currentFile }) && isDesktop && !disablePanel
39
+ const validForPanel = isDesktop && !disablePanel
42
40
 
43
41
  const componentsPropsWithDefault = {
44
42
  ...componentsProps,
@@ -11,7 +11,6 @@ import { infoWidth } from './InformationPanel'
11
11
  import Navigation from './Navigation'
12
12
  import Toolbar from './Toolbar'
13
13
  import styles from './styles.styl'
14
- import { isValidForPanel } from '../helpers'
15
14
  import { toolbarPropsPropType } from '../proptypes'
16
15
 
17
16
  const ACTIONS_HIDE_DELAY = 3000
@@ -125,14 +124,10 @@ class ViewerControls extends Component {
125
124
  const { showToolbar, showClose, toolbarRef, showFilePath } = toolbarProps
126
125
  const { hidden } = this.state
127
126
 
128
- const shouldDisplayContentTop = isValidForPanel({ file })
129
-
130
127
  return (
131
128
  <div
132
129
  className={cx(styles['viewer-controls'], {
133
130
  [styles['viewer-controls--expanded']]: expanded,
134
- [styles['viewer-controls--display-content-top']]:
135
- shouldDisplayContentTop,
136
131
  [classes.viewerControlsWithInfo]: showInfoPanel
137
132
  })}
138
133
  ref={wrapped => {
@@ -50,15 +50,14 @@
50
50
  width 100%
51
51
  height 100%
52
52
 
53
- .viewer-controls.--expanded .viewer-nav
54
- margin-top 0
55
- width 40%
56
-
57
- .viewer-controls--display-content-top
58
53
  +medium-screen()
59
54
  justify-content flex-start
60
55
  padding-top $toolbarHeightMedium - $viewerMarginTopMedium + 1rem
61
56
 
57
+ .viewer-controls.--expanded .viewer-nav
58
+ margin-top 0
59
+ width 40%
60
+
62
61
  .viewer-toolbar
63
62
  position absolute
64
63
  top 0
package/src/helpers.js CHANGED
@@ -2,8 +2,6 @@ import { generateWebLink } from 'cozy-client'
2
2
  import {
3
3
  isEncrypted,
4
4
  isFromKonnector,
5
- hasQualifications,
6
- hasCertifications,
7
5
  normalize
8
6
  } from 'cozy-client/dist/models/file'
9
7
  import {
@@ -30,22 +28,6 @@ export const getCurrentModel = metadataName => {
30
28
  * @property {string} type - doctype of the document
31
29
  */
32
30
 
33
- /**
34
- * Checks if the file matches one of the following conditions:
35
- * - Is certified
36
- * - Is Qualified
37
- * - From a Connector
38
- *
39
- * @param {object} param
40
- * @param {IOCozyFile} param.file
41
- * @returns {boolean}
42
- */
43
- export const isValidForPanel = ({ file }) => {
44
- return (
45
- hasCertifications(file) || hasQualifications(file) || isFromKonnector(file)
46
- )
47
- }
48
-
49
31
  export const isFileEncrypted = file => isEncrypted(file)
50
32
 
51
33
  export const formatDate = ({ f, lang, date }) => {