cozy-sharing 3.12.7 → 4.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 +62 -0
- package/dist/ShareButton.js +15 -3
- package/dist/ShareButton.spec.js +60 -0
- package/dist/SharingProvider.js +2 -1
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +3 -1
- package/package.json +3 -3
- package/src/ShareButton.jsx +7 -4
- package/src/ShareButton.spec.jsx +45 -0
- package/src/SharingProvider.jsx +1 -0
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
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.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.10...cozy-sharing@4.0.0) (2022-01-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **eslint:** Propose Eslint plugin promise ([1fded18](https://github.com/cozy/cozy-libs/commit/1fded18))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **eslint:** Most errors are not auto fixable,
|
|
17
|
+
if needed, use // disable-next-line
|
|
18
|
+
|
|
19
|
+
Or insert in .eslintrc:
|
|
20
|
+
{
|
|
21
|
+
"rules": {
|
|
22
|
+
"promise/always-return": "warn",
|
|
23
|
+
"promise/no-return-wrap": "warn",
|
|
24
|
+
"promise/param-names": "warn",
|
|
25
|
+
"promise/catch-or-return": "warn",
|
|
26
|
+
"promise/no-native": "warn",
|
|
27
|
+
"promise/no-nesting": "warn",
|
|
28
|
+
"promise/no-promise-in-callback": "warn",
|
|
29
|
+
"promise/no-callback-in-promise": "warn",
|
|
30
|
+
"promise/avoid-new": "warn",
|
|
31
|
+
"promise/no-new-statics": "warn",
|
|
32
|
+
"promise/no-return-in-finally": "warn",
|
|
33
|
+
"promise/valid-params": "warn"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [3.12.10](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.9...cozy-sharing@3.12.10) (2022-01-06)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package cozy-sharing
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [3.12.9](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.8...cozy-sharing@3.12.9) (2021-12-31)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Bug Fixes
|
|
53
|
+
|
|
54
|
+
* **sharing:** ShareButton should not pass I18n props to Cozy-UI Button ([587cd2e](https://github.com/cozy/cozy-libs/commit/587cd2e))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## [3.12.8](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.7...cozy-sharing@3.12.8) (2021-12-28)
|
|
61
|
+
|
|
62
|
+
**Note:** Version bump only for package cozy-sharing
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
6
68
|
## [3.12.7](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.6...cozy-sharing@3.12.7) (2021-12-24)
|
|
7
69
|
|
|
8
70
|
|
package/dist/ShareButton.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
4
|
var _excluded = ["docId", "useShortLabel"];
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
+
|
|
4
10
|
import React from 'react';
|
|
5
11
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
6
12
|
import SharingContext from './context';
|
|
@@ -14,16 +20,22 @@ export var ShareButton = withLocales(function (_ref) {
|
|
|
14
20
|
var _useI18n = useI18n(),
|
|
15
21
|
t = _useI18n.t;
|
|
16
22
|
|
|
23
|
+
var restProps = _objectSpread(_objectSpread({}, rest), {}, {
|
|
24
|
+
t: null,
|
|
25
|
+
f: null,
|
|
26
|
+
lang: null
|
|
27
|
+
});
|
|
28
|
+
|
|
17
29
|
return /*#__PURE__*/React.createElement(SharingContext.Consumer, null, function (_ref2) {
|
|
18
30
|
var byDocId = _ref2.byDocId,
|
|
19
31
|
documentType = _ref2.documentType,
|
|
20
32
|
isOwner = _ref2.isOwner;
|
|
21
33
|
return !byDocId[docId] ? /*#__PURE__*/React.createElement(DumbShareButton, _extends({
|
|
22
34
|
label: t("".concat(documentType, ".share.cta"))
|
|
23
|
-
},
|
|
35
|
+
}, restProps)) : isOwner(docId) ? /*#__PURE__*/React.createElement(SharedByMeButton, _extends({
|
|
24
36
|
label: useShortLabel ? t("".concat(documentType, ".share.shared")) : t("".concat(documentType, ".share.sharedByMe"))
|
|
25
|
-
},
|
|
37
|
+
}, restProps)) : /*#__PURE__*/React.createElement(SharedWithMeButton, _extends({
|
|
26
38
|
label: useShortLabel ? t("".concat(documentType, ".share.shared")) : t("".concat(documentType, ".share.sharedWithMe"))
|
|
27
|
-
},
|
|
39
|
+
}, restProps));
|
|
28
40
|
});
|
|
29
41
|
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ShareButton } from './ShareButton';
|
|
4
|
+
jest.mock('cozy-ui/transpiled/react', function () {
|
|
5
|
+
return {
|
|
6
|
+
Button: function Button(props) {
|
|
7
|
+
if (props.t || props.t || props.lang) {
|
|
8
|
+
throw 'do not pass html button invalid props';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
jest.mock('cozy-ui/transpiled/react/I18n', function () {
|
|
16
|
+
return {
|
|
17
|
+
useI18n: jest.fn().mockReturnValue({
|
|
18
|
+
t: jest.fn()
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
jest.mock('./withLocales', function () {
|
|
23
|
+
return (// eslint-disable-next-line react/display-name
|
|
24
|
+
function (Component) {
|
|
25
|
+
return function (props) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, Component(props));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
jest.mock('./context', function () {
|
|
32
|
+
return {
|
|
33
|
+
// eslint-disable-next-line react/display-name
|
|
34
|
+
Consumer: function Consumer(props) {
|
|
35
|
+
var Component = function Component() {
|
|
36
|
+
return props.children({
|
|
37
|
+
byDocId: {
|
|
38
|
+
docId: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement(Component, null);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
describe('ShareButton', function () {
|
|
48
|
+
it('should not send incorrect props to CozyUI button', function () {
|
|
49
|
+
// When
|
|
50
|
+
var _render = render( /*#__PURE__*/React.createElement(ShareButton, {
|
|
51
|
+
f: "incorrect prop",
|
|
52
|
+
t: "incorrect prop",
|
|
53
|
+
lang: "incorrect prop"
|
|
54
|
+
})),
|
|
55
|
+
container = _render.container; // Then
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
expect(container).toBeDefined();
|
|
59
|
+
});
|
|
60
|
+
});
|
package/dist/SharingProvider.js
CHANGED
|
@@ -636,7 +636,8 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
636
636
|
}));
|
|
637
637
|
this.setState({
|
|
638
638
|
hasLoadedAtLeastOnePage: true
|
|
639
|
-
});
|
|
639
|
+
}); // eslint-disable-next-line promise/catch-or-return
|
|
640
|
+
|
|
640
641
|
fetchNextPermissions(permissions, this.dispatch, client).then(function () {
|
|
641
642
|
return _this2.setState({
|
|
642
643
|
allLoaded: true
|
|
@@ -207,13 +207,15 @@ var ShareDialogTwoStepsConfirmationContainer = function ShareDialogTwoStepsConfi
|
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
var onConfirmRecipient = function onConfirmRecipient() {
|
|
210
|
+
// eslint-disable-next-line promise/catch-or-return,promise/always-return
|
|
210
211
|
confirmRecipient(recipientConfirmationData).then(function () {
|
|
211
212
|
getRecipientsToBeConfirmed();
|
|
212
213
|
});
|
|
213
214
|
};
|
|
214
215
|
|
|
215
216
|
var onRejectRecipient = function onRejectRecipient() {
|
|
216
|
-
setStatus('loading');
|
|
217
|
+
setStatus('loading'); // eslint-disable-next-line promise/catch-or-return,promise/always-return
|
|
218
|
+
|
|
217
219
|
rejectRecipient(recipientConfirmationData).then(function () {
|
|
218
220
|
getRecipientsToBeConfirmed();
|
|
219
221
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@cozy/minilog": "^1.0.0",
|
|
29
29
|
"classnames": "^2.2.6",
|
|
30
30
|
"copy-text-to-clipboard": "^2.1.1",
|
|
31
|
-
"cozy-device-helper": "^1.
|
|
31
|
+
"cozy-device-helper": "^1.15.0",
|
|
32
32
|
"cozy-doctypes": "^1.83.3",
|
|
33
33
|
"lodash": "^4.17.19",
|
|
34
34
|
"react-autosuggest": "^9.4.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"sideEffects": [
|
|
62
62
|
"*.css"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "d0157461fc7919473be52fa994fed99c23b24ec2"
|
|
65
65
|
}
|
package/src/ShareButton.jsx
CHANGED
|
@@ -12,12 +12,15 @@ import {
|
|
|
12
12
|
|
|
13
13
|
export const ShareButton = withLocales(({ docId, useShortLabel, ...rest }) => {
|
|
14
14
|
const { t } = useI18n()
|
|
15
|
-
|
|
15
|
+
const restProps = { ...rest, t: null, f: null, lang: null }
|
|
16
16
|
return (
|
|
17
17
|
<SharingContext.Consumer>
|
|
18
18
|
{({ byDocId, documentType, isOwner }) => {
|
|
19
19
|
return !byDocId[docId] ? (
|
|
20
|
-
<DumbShareButton
|
|
20
|
+
<DumbShareButton
|
|
21
|
+
label={t(`${documentType}.share.cta`)}
|
|
22
|
+
{...restProps}
|
|
23
|
+
/>
|
|
21
24
|
) : isOwner(docId) ? (
|
|
22
25
|
<SharedByMeButton
|
|
23
26
|
label={
|
|
@@ -25,7 +28,7 @@ export const ShareButton = withLocales(({ docId, useShortLabel, ...rest }) => {
|
|
|
25
28
|
? t(`${documentType}.share.shared`)
|
|
26
29
|
: t(`${documentType}.share.sharedByMe`)
|
|
27
30
|
}
|
|
28
|
-
{...
|
|
31
|
+
{...restProps}
|
|
29
32
|
/>
|
|
30
33
|
) : (
|
|
31
34
|
<SharedWithMeButton
|
|
@@ -34,7 +37,7 @@ export const ShareButton = withLocales(({ docId, useShortLabel, ...rest }) => {
|
|
|
34
37
|
? t(`${documentType}.share.shared`)
|
|
35
38
|
: t(`${documentType}.share.sharedWithMe`)
|
|
36
39
|
}
|
|
37
|
-
{...
|
|
40
|
+
{...restProps}
|
|
38
41
|
/>
|
|
39
42
|
)
|
|
40
43
|
}}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { ShareButton } from './ShareButton'
|
|
4
|
+
|
|
5
|
+
jest.mock('cozy-ui/transpiled/react', () => ({
|
|
6
|
+
Button: props => {
|
|
7
|
+
if (props.t || props.t || props.lang) {
|
|
8
|
+
throw 'do not pass html button invalid props'
|
|
9
|
+
}
|
|
10
|
+
return <></>
|
|
11
|
+
}
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
jest.mock('cozy-ui/transpiled/react/I18n', () => ({
|
|
15
|
+
useI18n: jest.fn().mockReturnValue({ t: jest.fn() })
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
jest.mock('./withLocales', () =>
|
|
19
|
+
// eslint-disable-next-line react/display-name
|
|
20
|
+
Component => props => <>{Component(props)}</>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
jest.mock('./context', () => ({
|
|
24
|
+
// eslint-disable-next-line react/display-name
|
|
25
|
+
Consumer: props => {
|
|
26
|
+
const Component = () => props.children({ byDocId: { docId: false } })
|
|
27
|
+
return <Component />
|
|
28
|
+
}
|
|
29
|
+
}))
|
|
30
|
+
|
|
31
|
+
describe('ShareButton', () => {
|
|
32
|
+
it('should not send incorrect props to CozyUI button', () => {
|
|
33
|
+
// When
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<ShareButton
|
|
36
|
+
f="incorrect prop"
|
|
37
|
+
t="incorrect prop"
|
|
38
|
+
lang="incorrect prop"
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
// Then
|
|
43
|
+
expect(container).toBeDefined()
|
|
44
|
+
})
|
|
45
|
+
})
|
package/src/SharingProvider.jsx
CHANGED
|
@@ -185,6 +185,7 @@ export class SharingProvider extends Component {
|
|
|
185
185
|
})
|
|
186
186
|
)
|
|
187
187
|
this.setState({ hasLoadedAtLeastOnePage: true })
|
|
188
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
188
189
|
fetchNextPermissions(permissions, this.dispatch, client).then(() =>
|
|
189
190
|
this.setState({ allLoaded: true })
|
|
190
191
|
)
|
|
@@ -173,6 +173,7 @@ const ShareDialogTwoStepsConfirmationContainer = ({
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
const onConfirmRecipient = () => {
|
|
176
|
+
// eslint-disable-next-line promise/catch-or-return,promise/always-return
|
|
176
177
|
confirmRecipient(recipientConfirmationData).then(() => {
|
|
177
178
|
getRecipientsToBeConfirmed()
|
|
178
179
|
})
|
|
@@ -180,6 +181,7 @@ const ShareDialogTwoStepsConfirmationContainer = ({
|
|
|
180
181
|
|
|
181
182
|
const onRejectRecipient = () => {
|
|
182
183
|
setStatus('loading')
|
|
184
|
+
// eslint-disable-next-line promise/catch-or-return,promise/always-return
|
|
183
185
|
rejectRecipient(recipientConfirmationData).then(() => {
|
|
184
186
|
getRecipientsToBeConfirmed()
|
|
185
187
|
})
|