cozy-viewer 13.2.2 → 13.2.4

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,25 @@
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.4](https://github.com/cozy/cozy-libs/compare/cozy-viewer@13.2.3...cozy-viewer@13.2.4) (2025-01-20)
7
+
8
+ **Note:** Version bump only for package cozy-viewer
9
+
10
+
11
+
12
+
13
+
14
+ ## [13.2.3](https://github.com/cozy/cozy-libs/compare/cozy-viewer@13.2.2...cozy-viewer@13.2.3) (2025-01-20)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **Viewer:** Now use the folder as a reference when sharing ([21f4d9a](https://github.com/cozy/cozy-libs/commit/21f4d9af0c926a780789483be800a7ed3f2882ae))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [13.2.2](https://github.com/cozy/cozy-libs/compare/cozy-viewer@13.2.1...cozy-viewer@13.2.2) (2025-01-16)
7
26
 
8
27
 
@@ -51,11 +51,16 @@ var Sharing = function Sharing(_ref) {
51
51
  getDocumentPermissions = _useSharingContext.getDocumentPermissions,
52
52
  getSharingLink = _useSharingContext.getSharingLink,
53
53
  allLoaded = _useSharingContext.allLoaded,
54
+ hasSharedParent = _useSharingContext.hasSharedParent,
54
55
  getRecipients = _useSharingContext.getRecipients;
55
56
 
56
- var recipients = getRecipients(file._id);
57
- var permissions = getDocumentPermissions(file._id);
58
- var link = getSharingLink(file._id);
57
+ var shareFileRefId = hasSharedParent(file.path) ? file.dir_id : file._id;
58
+ var recipients = getRecipients(shareFileRefId);
59
+ var permissions = getDocumentPermissions(shareFileRefId);
60
+ var link = getSharingLink(shareFileRefId);
61
+
62
+ var _isOwner = isOwner(shareFileRefId);
63
+
59
64
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ListItem.default, {
60
65
  size: "large",
61
66
  divider: true,
@@ -81,7 +86,7 @@ var Sharing = function Sharing(_ref) {
81
86
  return /*#__PURE__*/_react.default.createElement(_cozySharing.MemberRecipientLite, {
82
87
  key: recipient.index,
83
88
  recipient: recipient,
84
- isOwner: isOwner(file._id)
89
+ isOwner: _isOwner
85
90
  });
86
91
  }) : /*#__PURE__*/_react.default.createElement(_cozySharing.OwnerRecipientDefaultLite, null)), showModal && /*#__PURE__*/_react.default.createElement(_cozySharing.ShareModal, {
87
92
  document: file,
@@ -94,7 +94,8 @@ var ViewerContainer = function ViewerContainer(props) {
94
94
  (0, _I18n.useExtendI18n)(_locales.locales);
95
95
 
96
96
  var _useSharingContext = (0, _cozySharing.useSharingContext)(),
97
- hasWriteAccess = _useSharingContext.hasWriteAccess;
97
+ hasWriteAccess = _useSharingContext.hasWriteAccess,
98
+ hasSharedParent = _useSharingContext.hasSharedParent;
98
99
 
99
100
  var currentFile = files[currentIndex];
100
101
  var fileCount = files.length;
@@ -133,7 +134,7 @@ var ViewerContainer = function ViewerContainer(props) {
133
134
  break;
134
135
 
135
136
  case 6:
136
- _context.t0 = !hasWriteAccess(currentFile._id);
137
+ _context.t0 = !hasWriteAccess(hasSharedParent(currentFile.path) ? currentFile.dir_id : currentFile._id);
137
138
 
138
139
  case 7:
139
140
  res = _context.t0;
@@ -152,7 +153,7 @@ var ViewerContainer = function ViewerContainer(props) {
152
153
  }();
153
154
 
154
155
  getIsReadOnly();
155
- }, [client, currentFile, hasWriteAccess, isPublic]);
156
+ }, [client, currentFile, hasWriteAccess, hasSharedParent, isPublic]);
156
157
  return /*#__PURE__*/_react.default.createElement(_Alert.default, null, /*#__PURE__*/_react.default.createElement("div", {
157
158
  id: "viewer-wrapper",
158
159
  className: (0, _classnames.default)(styles['viewer-wrapper'], className)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-viewer",
3
- "version": "13.2.2",
3
+ "version": "13.2.4",
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.12",
30
+ "cozy-harvest-lib": "^32.2.14",
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": "fd145faacdefa1f529aaf8a45a2906066457512a"
62
+ "gitHead": "e3a7270d91f0c092b3d75ee3a5b43b845cdef605"
63
63
  }
@@ -26,12 +26,15 @@ const Sharing = ({ file, t }) => {
26
26
  getDocumentPermissions,
27
27
  getSharingLink,
28
28
  allLoaded,
29
+ hasSharedParent,
29
30
  getRecipients
30
31
  } = useSharingContext()
31
32
 
32
- const recipients = getRecipients(file._id)
33
- const permissions = getDocumentPermissions(file._id)
34
- const link = getSharingLink(file._id)
33
+ const shareFileRefId = hasSharedParent(file.path) ? file.dir_id : file._id
34
+ const recipients = getRecipients(shareFileRefId)
35
+ const permissions = getDocumentPermissions(shareFileRefId)
36
+ const link = getSharingLink(shareFileRefId)
37
+ const _isOwner = isOwner(shareFileRefId)
35
38
 
36
39
  return (
37
40
  <>
@@ -56,7 +59,7 @@ const Sharing = ({ file, t }) => {
56
59
  <MemberRecipientLite
57
60
  key={recipient.index}
58
61
  recipient={recipient}
59
- isOwner={isOwner(file._id)}
62
+ isOwner={_isOwner}
60
63
  />
61
64
  ))
62
65
  ) : (
@@ -35,7 +35,7 @@ const ViewerContainer = props => {
35
35
  const [isReadOnly, setIsReadOnly] = useState(true)
36
36
  const client = useClient()
37
37
  useExtendI18n(locales)
38
- const { hasWriteAccess } = useSharingContext()
38
+ const { hasWriteAccess, hasSharedParent } = useSharingContext()
39
39
 
40
40
  const currentFile = files[currentIndex]
41
41
  const fileCount = files.length
@@ -59,13 +59,17 @@ const ViewerContainer = props => {
59
59
  document: currentFile,
60
60
  client
61
61
  })
62
- : !hasWriteAccess(currentFile._id)
62
+ : !hasWriteAccess(
63
+ hasSharedParent(currentFile.path)
64
+ ? currentFile.dir_id
65
+ : currentFile._id
66
+ )
63
67
 
64
68
  setIsReadOnly(res)
65
69
  }
66
70
 
67
71
  getIsReadOnly()
68
- }, [client, currentFile, hasWriteAccess, isPublic])
72
+ }, [client, currentFile, hasWriteAccess, hasSharedParent, isPublic])
69
73
 
70
74
  return (
71
75
  <AlertProvider>