cozy-sharing 26.5.2 → 26.6.1

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,18 @@
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
+ ## [26.6.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@26.6.0...cozy-sharing@26.6.1) (2025-10-15)
7
+
8
+ ### Bug Fixes
9
+
10
+ - Change the way to check write access of shared drive :bug: ([e75c3ba](https://github.com/cozy/cozy-libs/commit/e75c3ba6ba044639b4ab13021067e15649ecc864))
11
+
12
+ # [26.6.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@26.5.2...cozy-sharing@26.6.0) (2025-10-09)
13
+
14
+ ### Features
15
+
16
+ - Toggle sharing deadline by flag :sparkles: ([69436d1](https://github.com/cozy/cozy-libs/commit/69436d1eab1f76c22c5bb5e2fed56eac31ba558e))
17
+
6
18
  ## [26.5.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@26.5.1...cozy-sharing@26.5.2) (2025-10-07)
7
19
 
8
20
  ### Bug Fixes
@@ -5,6 +5,7 @@ import { addDays } from 'date-fns';
5
5
  import PropTypes from 'prop-types';
6
6
  import React, { useState } from 'react';
7
7
  import { generateWebLink, useClient } from 'cozy-client';
8
+ import flag from 'cozy-flags';
8
9
  import Button from 'cozy-ui/transpiled/react/Buttons';
9
10
  import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
10
11
  import Icon from 'cozy-ui/transpiled/react/Icon';
@@ -69,7 +70,7 @@ export var ShareRestrictionModal = function ShareRestrictionModal(_ref) {
69
70
  selectedDate = _useState10[0],
70
71
  setSelectedDate = _useState10[1];
71
72
 
72
- var _useState11 = useState(permissions.length > 0 ? hasExpiresDate : true),
73
+ var _useState11 = useState(permissions.length > 0 ? hasExpiresDate : flag('sharing.date-toggle.enabled')),
73
74
  _useState12 = _slicedToArray(_useState11, 2),
74
75
  dateToggle = _useState12[0],
75
76
  setDateToggle = _useState12[1];
package/dist/state.js CHANGED
@@ -797,22 +797,6 @@ export var getSharedDocIdsBySharings = function getSharedDocIdsBySharings(sharin
797
797
  });
798
798
  return docs;
799
799
  };
800
- /**
801
- * Resolves shared drive sharing type.
802
- *
803
- * @param {object} sharing
804
- * @returns {'two-way'|'one-way'|null}
805
- */
806
-
807
- var resolveDriveSharingTypeFromRule = function resolveDriveSharingTypeFromRule(sharing) {
808
- var _sharing$attributes;
809
-
810
- if (!(sharing !== null && sharing !== void 0 && (_sharing$attributes = sharing.attributes) !== null && _sharing$attributes !== void 0 && (_sharing$attributes = _sharing$attributes.rules) !== null && _sharing$attributes !== void 0 && _sharing$attributes.length)) return null;
811
- var rule = sharing.attributes.rules[0];
812
- var dirType = getDirectorySharingType(rule);
813
- var fileType = getFileSharingType(rule);
814
- return dirType === SHARING_TYPE.TWO_WAY || fileType === SHARING_TYPE.TWO_WAY ? SHARING_TYPE.TWO_WAY : SHARING_TYPE.ONE_WAY;
815
- };
816
800
  /**
817
801
  * Computes the effective sharing type for a drive.
818
802
  *
@@ -822,15 +806,12 @@ var resolveDriveSharingTypeFromRule = function resolveDriveSharingTypeFromRule(s
822
806
  * @returns {string|null} - the sharing type
823
807
  */
824
808
 
825
-
826
809
  export var getSharedDriveSharingType = function getSharedDriveSharingType(state, driveId, instanceUri) {
827
810
  var _sharing$attributes$m;
828
811
 
829
812
  var sharing = getSharingById(state, driveId);
830
813
  if (!sharing) return null;
831
- var baseType = resolveDriveSharingTypeFromRule(sharing);
832
- if (sharing.attributes.owner) return baseType;
833
814
  var me = (_sharing$attributes$m = sharing.attributes.members) === null || _sharing$attributes$m === void 0 ? void 0 : _sharing$attributes$m.find(matchingInstanceName(instanceUri));
834
- if (!me) return baseType;
835
- return me.read_only ? SHARING_TYPE.ONE_WAY : baseType;
815
+ if (!me) return null;
816
+ return me.read_only ? SHARING_TYPE.ONE_WAY : SHARING_TYPE.TWO_WAY;
836
817
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "26.5.2",
3
+ "version": "26.6.1",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -79,5 +79,5 @@
79
79
  "sideEffects": [
80
80
  "*.css"
81
81
  ],
82
- "gitHead": "4ff71a0d8c2f1483f60b2a5febad0a92b49e8aa2"
82
+ "gitHead": "94812ab94b4a3a279eda58ec1e225b4691c904b1"
83
83
  }
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
3
3
  import React, { useState } from 'react'
4
4
 
5
5
  import { generateWebLink, useClient } from 'cozy-client'
6
+ import flag from 'cozy-flags'
6
7
  import Button from 'cozy-ui/transpiled/react/Buttons'
7
8
  import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
8
9
  import Icon from 'cozy-ui/transpiled/react/Icon'
@@ -59,7 +60,9 @@ export const ShareRestrictionModal = ({ file, onClose }) => {
59
60
 
60
61
  const [selectedDate, setSelectedDate] = useState(defaultDate)
61
62
  const [dateToggle, setDateToggle] = useState(
62
- permissions.length > 0 ? hasExpiresDate : true
63
+ permissions.length > 0
64
+ ? hasExpiresDate
65
+ : flag('sharing.date-toggle.enabled')
63
66
  )
64
67
  const [passwordToggle, setPasswordToggle] = useState(hasPassword)
65
68
  const [editingRights, setEditingRights] = useState(
package/src/state.js CHANGED
@@ -677,24 +677,6 @@ export const getSharedDocIdsBySharings = sharings => {
677
677
  return docs
678
678
  }
679
679
 
680
- /**
681
- * Resolves shared drive sharing type.
682
- *
683
- * @param {object} sharing
684
- * @returns {'two-way'|'one-way'|null}
685
- */
686
- const resolveDriveSharingTypeFromRule = sharing => {
687
- if (!sharing?.attributes?.rules?.length) return null
688
-
689
- const rule = sharing.attributes.rules[0]
690
- const dirType = getDirectorySharingType(rule)
691
- const fileType = getFileSharingType(rule)
692
-
693
- return dirType === SHARING_TYPE.TWO_WAY || fileType === SHARING_TYPE.TWO_WAY
694
- ? SHARING_TYPE.TWO_WAY
695
- : SHARING_TYPE.ONE_WAY
696
- }
697
-
698
680
  /**
699
681
  * Computes the effective sharing type for a drive.
700
682
  *
@@ -707,11 +689,8 @@ export const getSharedDriveSharingType = (state, driveId, instanceUri) => {
707
689
  const sharing = getSharingById(state, driveId)
708
690
  if (!sharing) return null
709
691
 
710
- const baseType = resolveDriveSharingTypeFromRule(sharing)
711
- if (sharing.attributes.owner) return baseType
712
-
713
692
  const me = sharing.attributes.members?.find(matchingInstanceName(instanceUri))
714
- if (!me) return baseType
693
+ if (!me) return null
715
694
 
716
- return me.read_only ? SHARING_TYPE.ONE_WAY : baseType
695
+ return me.read_only ? SHARING_TYPE.ONE_WAY : SHARING_TYPE.TWO_WAY
717
696
  }