cozy-sharing 4.4.1 → 4.5.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 +11 -0
- package/dist/ShareModal.js +14 -10
- package/package.json +2 -2
- package/src/ShareModal.jsx +23 -14
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
|
+
# [4.5.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.4.1...cozy-sharing@4.5.0) (2022-07-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Allow sharemodal to use Location ([032f963](https://github.com/cozy/cozy-libs/commit/032f963c7296dcd296c5ef21a8814407ef9cf2cf))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [4.4.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.4.0...cozy-sharing@4.4.1) (2022-07-11)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package cozy-sharing
|
package/dist/ShareModal.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["document"]
|
|
4
|
-
_excluded2 = ["document"];
|
|
3
|
+
var _excluded = ["document"];
|
|
5
4
|
import React from 'react';
|
|
5
|
+
import omit from 'lodash/omit';
|
|
6
|
+
import { useLocation } from 'react-router';
|
|
7
|
+
import EditableSharingModal from './components/EditableSharingModal';
|
|
6
8
|
import SharingContext from './context';
|
|
7
9
|
import withLocales from './withLocales';
|
|
8
10
|
import { SharingDetailsModal } from './SharingDetailsModal';
|
|
9
|
-
import EditableSharingModal from './components/EditableSharingModal';
|
|
10
11
|
|
|
11
12
|
var SharingModal = function SharingModal(_ref) {
|
|
12
13
|
var document = _ref.document,
|
|
@@ -29,14 +30,17 @@ var SharingModal = function SharingModal(_ref) {
|
|
|
29
30
|
});
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
export var ShareModal = withLocales(function (
|
|
33
|
-
var
|
|
34
|
-
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
33
|
+
export var ShareModal = withLocales(function (props) {
|
|
34
|
+
var _location$state;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
var location = useLocation();
|
|
37
|
+
var locationProps = (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.modalProps;
|
|
38
|
+
var document = (locationProps === null || locationProps === void 0 ? void 0 : locationProps.document) || props.document;
|
|
39
|
+
var rest = omit(locationProps || props, 'document');
|
|
40
|
+
return /*#__PURE__*/React.createElement(SharingContext.Consumer, null, function (_ref3) {
|
|
41
|
+
var byDocId = _ref3.byDocId,
|
|
42
|
+
isOwner = _ref3.isOwner,
|
|
43
|
+
canReshare = _ref3.canReshare;
|
|
40
44
|
return !byDocId[document.id] || isOwner(document.id) || canReshare(document.id) ? /*#__PURE__*/React.createElement(EditableSharingModal, _extends({
|
|
41
45
|
document: document
|
|
42
46
|
}, rest)) : /*#__PURE__*/React.createElement(SharingModal, _extends({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"sideEffects": [
|
|
64
64
|
"*.css"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "cae03c6aa378bb8a476ce4d598f894db5a93f595"
|
|
67
67
|
}
|
package/src/ShareModal.jsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import omit from 'lodash/omit'
|
|
3
|
+
import { useLocation } from 'react-router'
|
|
2
4
|
|
|
5
|
+
import EditableSharingModal from './components/EditableSharingModal'
|
|
3
6
|
import SharingContext from './context'
|
|
4
7
|
import withLocales from './withLocales'
|
|
5
8
|
import { SharingDetailsModal } from './SharingDetailsModal'
|
|
6
|
-
import EditableSharingModal from './components/EditableSharingModal'
|
|
7
9
|
|
|
8
10
|
const SharingModal = ({ document, ...rest }) => (
|
|
9
11
|
<SharingContext.Consumer>
|
|
@@ -27,16 +29,23 @@ const SharingModal = ({ document, ...rest }) => (
|
|
|
27
29
|
</SharingContext.Consumer>
|
|
28
30
|
)
|
|
29
31
|
|
|
30
|
-
export const ShareModal = withLocales(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
export const ShareModal = withLocales(props => {
|
|
33
|
+
const location = useLocation()
|
|
34
|
+
const locationProps = location.state?.modalProps
|
|
35
|
+
const document = locationProps?.document || props.document
|
|
36
|
+
const rest = omit(locationProps || props, 'document')
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<SharingContext.Consumer>
|
|
40
|
+
{({ byDocId, isOwner, canReshare }) =>
|
|
41
|
+
!byDocId[document.id] ||
|
|
42
|
+
isOwner(document.id) ||
|
|
43
|
+
canReshare(document.id) ? (
|
|
44
|
+
<EditableSharingModal document={document} {...rest} />
|
|
45
|
+
) : (
|
|
46
|
+
<SharingModal document={document} {...rest} />
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
</SharingContext.Consumer>
|
|
50
|
+
)
|
|
51
|
+
})
|