cozy-sharing 4.5.9 → 4.6.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,28 @@
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.6.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.5.10...cozy-sharing@4.6.0) (2022-11-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * Reactivate sharing cozy to cozy for notes ([d54138e](https://github.com/cozy/cozy-libs/commit/d54138e29ed2d966f8b1da4b4b4caae2b17a3264))
12
+
13
+
14
+
15
+
16
+
17
+ ## 4.5.10 (2022-11-09)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Paginated permission were not normalized ([eac18f4](https://github.com/cozy/cozy-libs/commit/eac18f4cc90bf4b06d91b7e59343bb4efcf81dcd))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [4.5.9](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.5.8...cozy-sharing@4.5.9) (2022-10-03)
7
29
 
8
30
  **Note:** Version bump only for package cozy-sharing
@@ -610,8 +610,6 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
610
610
  key: "fetchAllSharings",
611
611
  value: function () {
612
612
  var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
613
- var _this2 = this;
614
-
615
613
  var _this$props5, doctype, client, _yield$Promise$all, _yield$Promise$all2, sharings, permissions, apps, sharedDocIds, resp, folderPaths, filePaths;
616
614
 
617
615
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
@@ -638,11 +636,9 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
638
636
  hasLoadedAtLeastOnePage: true
639
637
  }); // eslint-disable-next-line promise/catch-or-return
640
638
 
641
- fetchNextPermissions(permissions, this.dispatch, client).then(function () {
642
- return _this2.setState({
643
- allLoaded: true
644
- });
645
- });
639
+ fetchNextPermissions(permissions, this.dispatch, this.permissionCol).then(this.setState({
640
+ allLoaded: true
641
+ }));
646
642
 
647
643
  if (!(doctype !== 'io.cozy.files')) {
648
644
  _context12.next = 13;
@@ -1,3 +1,4 @@
1
+ import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
1
2
  import _extends from "@babel/runtime/helpers/extends";
2
3
  import React from 'react';
3
4
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
@@ -45,7 +46,7 @@ var SharingTitle = function SharingTitle(_ref2) {
45
46
  };
46
47
 
47
48
  var ConfirmTrustedRecipientsDialog = function ConfirmTrustedRecipientsDialog(_ref3) {
48
- var props = _extends({}, _ref3);
49
+ var props = _extends({}, (_objectDestructuringEmpty(_ref3), _ref3));
49
50
 
50
51
  return /*#__PURE__*/React.createElement(ShareDialogTwoStepsConfirmationContainer, _extends({}, props, {
51
52
  dialogContentOnShare: SharingContent,
@@ -52,7 +52,9 @@ describe('EditableSharingModal', function () {
52
52
 
53
53
  it('will set to false the shared parent / child if the document has no path', function () {
54
54
  var _setup = setup({
55
- document: {}
55
+ document: {
56
+ attributes: {}
57
+ }
56
58
  }),
57
59
  component = _setup.component;
58
60
 
@@ -66,7 +68,8 @@ describe('EditableSharingModal', function () {
66
68
 
67
69
  var _setup2 = setup({
68
70
  document: {
69
- path: '/a'
71
+ path: '/a',
72
+ attributes: {}
70
73
  }
71
74
  }),
72
75
  component = _setup2.component;
@@ -81,7 +84,9 @@ describe('EditableSharingModal', function () {
81
84
  });
82
85
  it('will set to true the sharedChild if a child is shared and the document path fetched latter', function () {
83
86
  var _setup3 = setup({
84
- document: {}
87
+ document: {
88
+ attributes: {}
89
+ }
85
90
  }),
86
91
  component = _setup3.component;
87
92
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import flag from 'cozy-flags';
3
4
  import { contactsResponseType, groupsResponseType } from '../propTypes';
4
5
  import ShareDialogCozyToCozy from './ShareDialogCozyToCozy';
5
6
  import ShareDialogOnlyByLink from './ShareDialogOnlyByLink';
@@ -27,11 +28,12 @@ export var ShareModal = function ShareModal(_ref) {
27
28
  sharing = _ref.sharing,
28
29
  sharingDesc = _ref.sharingDesc,
29
30
  twoStepsConfirmationMethods = _ref.twoStepsConfirmationMethods;
30
- var showShareByEmail = documentType !== 'Notes' && documentType !== 'Albums' && !hasSharedParent && !hasSharedChild;
31
+ var showShareCozyToCozyForNotes = flag('notes.sharing-cozy-to-cozy') !== null && flag('notes.sharing-cozy-to-cozy') && documentType === 'Notes';
32
+ var showShareByEmail = showShareCozyToCozyForNotes && documentType !== 'Albums' && !hasSharedParent && !hasSharedChild;
31
33
  var showShareByLink = documentType !== 'Organizations';
32
34
  var showShareOnlyByLink = hasSharedParent || hasSharedChild;
33
35
  var showWhoHasAccess = documentType !== 'Albums';
34
- return /*#__PURE__*/React.createElement(React.Fragment, null, (documentType === 'Notes' || documentType === 'Albums') && /*#__PURE__*/React.createElement(ShareDialogOnlyByLink, {
36
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (!showShareCozyToCozyForNotes || documentType === 'Albums') && /*#__PURE__*/React.createElement(ShareDialogOnlyByLink, {
35
37
  document: document,
36
38
  documentType: documentType,
37
39
  link: link,
@@ -40,7 +42,7 @@ export var ShareModal = function ShareModal(_ref) {
40
42
  onShareByLink: onShareByLink,
41
43
  onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
42
44
  permissions: permissions
43
- }), documentType !== 'Notes' && documentType !== 'Albums' && /*#__PURE__*/React.createElement(ShareDialogCozyToCozy, {
45
+ }), showShareCozyToCozyForNotes && documentType !== 'Albums' && /*#__PURE__*/React.createElement(ShareDialogCozyToCozy, {
44
46
  contacts: contacts,
45
47
  createContact: createContact,
46
48
  document: document,
@@ -10,7 +10,7 @@ import { addSharingLink } from './state';
10
10
  */
11
11
 
12
12
  export var fetchNextPermissions = /*#__PURE__*/function () {
13
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(permissions, dispatch, client) {
13
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(permissions, dispatch, permissionCol) {
14
14
  var resp;
15
15
  return _regeneratorRuntime.wrap(function _callee$(_context) {
16
16
  while (1) {
@@ -22,12 +22,12 @@ export var fetchNextPermissions = /*#__PURE__*/function () {
22
22
  }
23
23
 
24
24
  _context.next = 3;
25
- return client.getStackClient().fetchJSON('GET', permissions.links.next);
25
+ return permissionCol.fetchPermissionsByLink(permissions);
26
26
 
27
27
  case 3:
28
28
  resp = _context.sent;
29
29
  dispatch(addSharingLink(resp.data));
30
- return _context.abrupt("return", fetchNextPermissions(resp, dispatch, client));
30
+ return _context.abrupt("return", fetchNextPermissions(resp, dispatch, permissionCol));
31
31
 
32
32
  case 6:
33
33
  case "end":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "4.5.9",
3
+ "version": "4.6.0",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -41,7 +41,7 @@
41
41
  "babel-jest": "26.6.3",
42
42
  "babel-plugin-css-modules-transform": "1.6.2",
43
43
  "babel-plugin-inline-react-svg": "1.1.2",
44
- "cozy-client": "23.19.1",
44
+ "cozy-client": "34.1.0",
45
45
  "cozy-ui": "62.1.2",
46
46
  "enzyme": "3.11.0",
47
47
  "enzyme-adapter-react-16": "1.15.6",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@material-ui/core": "4",
56
- "cozy-client": "^16",
56
+ "cozy-client": "^34.1.0",
57
57
  "cozy-realtime": "^3.11.0",
58
58
  "cozy-ui": "^45.1.0",
59
59
  "prop-types": "^15.7.2",
@@ -63,5 +63,5 @@
63
63
  "sideEffects": [
64
64
  "*.css"
65
65
  ],
66
- "gitHead": "8b93988a24a0601626891f874d09f335ff324b85"
66
+ "gitHead": "e216ec318820e96f5ee5ff6108ce77033d4d5c3e"
67
67
  }
@@ -186,7 +186,7 @@ export class SharingProvider extends Component {
186
186
  )
187
187
  this.setState({ hasLoadedAtLeastOnePage: true })
188
188
  // eslint-disable-next-line promise/catch-or-return
189
- fetchNextPermissions(permissions, this.dispatch, client).then(() =>
189
+ fetchNextPermissions(permissions, this.dispatch, this.permissionCol).then(
190
190
  this.setState({ allLoaded: true })
191
191
  )
192
192
  if (doctype !== 'io.cozy.files') return
@@ -44,7 +44,11 @@ describe('EditableSharingModal', () => {
44
44
  }
45
45
 
46
46
  it('will set to false the shared parent / child if the document has no path', () => {
47
- const { component } = setup({ document: {} })
47
+ const { component } = setup({
48
+ document: {
49
+ attributes: {}
50
+ }
51
+ })
48
52
 
49
53
  const mod = component.find(DumbShareModal)
50
54
  expect(mod.length).toBe(1)
@@ -54,7 +58,12 @@ describe('EditableSharingModal', () => {
54
58
 
55
59
  it('will set to true the sharedChild if a child is shared and document has path from the beginning', () => {
56
60
  useFetchDocumentPath.mockReturnValue(['/a'])
57
- const { component } = setup({ document: { path: '/a' } })
61
+ const { component } = setup({
62
+ document: {
63
+ path: '/a',
64
+ attributes: {}
65
+ }
66
+ })
58
67
 
59
68
  const provider = component.find(SharingProvider)
60
69
  provider.instance().dispatch(receivePaths(['/a/b']))
@@ -68,7 +77,11 @@ describe('EditableSharingModal', () => {
68
77
  })
69
78
 
70
79
  it('will set to true the sharedChild if a child is shared and the document path fetched latter', () => {
71
- const { component } = setup({ document: {} })
80
+ const { component } = setup({
81
+ document: {
82
+ attributes: {}
83
+ }
84
+ })
72
85
  useFetchDocumentPath.mockReturnValue(['/a'])
73
86
 
74
87
  const provider = component.find(SharingProvider)
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
+ import flag from 'cozy-flags'
3
4
 
4
5
  import { contactsResponseType, groupsResponseType } from '../propTypes'
5
6
 
@@ -29,8 +30,13 @@ export const ShareModal = ({
29
30
  sharingDesc,
30
31
  twoStepsConfirmationMethods
31
32
  }) => {
33
+ const showShareCozyToCozyForNotes =
34
+ flag('notes.sharing-cozy-to-cozy') !== null &&
35
+ flag('notes.sharing-cozy-to-cozy') &&
36
+ documentType === 'Notes'
37
+
32
38
  const showShareByEmail =
33
- documentType !== 'Notes' &&
39
+ showShareCozyToCozyForNotes &&
34
40
  documentType !== 'Albums' &&
35
41
  !hasSharedParent &&
36
42
  !hasSharedChild
@@ -40,7 +46,7 @@ export const ShareModal = ({
40
46
 
41
47
  return (
42
48
  <>
43
- {(documentType === 'Notes' || documentType === 'Albums') && (
49
+ {(!showShareCozyToCozyForNotes || documentType === 'Albums') && (
44
50
  <ShareDialogOnlyByLink
45
51
  document={document}
46
52
  documentType={documentType}
@@ -52,7 +58,7 @@ export const ShareModal = ({
52
58
  permissions={permissions}
53
59
  />
54
60
  )}
55
- {documentType !== 'Notes' && documentType !== 'Albums' && (
61
+ {showShareCozyToCozyForNotes && documentType !== 'Albums' && (
56
62
  <ShareDialogCozyToCozy
57
63
  contacts={contacts}
58
64
  createContact={createContact}
@@ -6,12 +6,14 @@ import { addSharingLink } from './state'
6
6
  * @param {Function} dispatch
7
7
  * @param {Object} client
8
8
  */
9
- export const fetchNextPermissions = async (permissions, dispatch, client) => {
9
+ export const fetchNextPermissions = async (
10
+ permissions,
11
+ dispatch,
12
+ permissionCol
13
+ ) => {
10
14
  if (permissions.links && permissions.links.next) {
11
- const resp = await client
12
- .getStackClient()
13
- .fetchJSON('GET', permissions.links.next)
15
+ const resp = await permissionCol.fetchPermissionsByLink(permissions)
14
16
  dispatch(addSharingLink(resp.data))
15
- return fetchNextPermissions(resp, dispatch, client)
17
+ return fetchNextPermissions(resp, dispatch, permissionCol)
16
18
  }
17
19
  }