cozy-sharing 27.1.0 → 27.1.2
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 +10 -0
- package/dist/state.js +14 -2
- package/dist/state.spec.js +51 -0
- package/package.json +3 -3
- package/src/state.js +11 -3
- package/src/state.spec.js +79 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [27.1.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@27.1.1...cozy-sharing@27.1.2) (2025-12-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cozy-sharing
|
|
9
|
+
|
|
10
|
+
## [27.1.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@27.1.0...cozy-sharing@27.1.1) (2025-11-27)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **cozy-sharing:** Fix shared drive write access display for recipients ([3f2eaa2](https://github.com/cozy/cozy-libs/commit/3f2eaa25c3a2023f92040c98e972cdfa6e277133))
|
|
15
|
+
|
|
6
16
|
# [27.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@27.0.6...cozy-sharing@27.1.0) (2025-11-25)
|
|
7
17
|
|
|
8
18
|
### Features
|
package/dist/state.js
CHANGED
|
@@ -541,12 +541,24 @@ export var getSharingForSelf = function getSharingForSelf(state, docId) {
|
|
|
541
541
|
return getDocumentSharing(state, docId);
|
|
542
542
|
};
|
|
543
543
|
export var getSharingType = function getSharingType(state, docId, instanceUri) {
|
|
544
|
+
var _sharing$attributes;
|
|
545
|
+
|
|
544
546
|
var sharing = getSharingForSelf(state, docId);
|
|
545
547
|
if (!sharing) return false;
|
|
546
548
|
var type = getDocumentSharingType(sharing, docId);
|
|
547
|
-
if (sharing.attributes.owner) return type;
|
|
549
|
+
if ((_sharing$attributes = sharing.attributes) !== null && _sharing$attributes !== void 0 && _sharing$attributes.owner) return type;
|
|
548
550
|
var me = sharing.attributes.members.find(matchingInstanceName(instanceUri));
|
|
549
|
-
|
|
551
|
+
if (!me) return type;
|
|
552
|
+
|
|
553
|
+
if (me.read_only) {
|
|
554
|
+
return 'one-way';
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (sharing.attributes.drive) {
|
|
558
|
+
return 'two-way';
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return type;
|
|
550
562
|
};
|
|
551
563
|
export var getDocumentSharing = function getDocumentSharing(state, docId) {
|
|
552
564
|
return getDocumentSharings(state, docId)[0] || null;
|
package/dist/state.spec.js
CHANGED
|
@@ -552,6 +552,57 @@ describe('getSharingType selector', function () {
|
|
|
552
552
|
}));
|
|
553
553
|
expect(getSharingType(newState, SHARING_READ_ONLY.attributes.rules[0].values[0], '')).toBe('one-way');
|
|
554
554
|
});
|
|
555
|
+
it('should return two-way for a shared drive member with write access', function () {
|
|
556
|
+
var SHARED_DRIVE = _objectSpread(_objectSpread({}, SHARING_3), {}, {
|
|
557
|
+
id: 'shared_drive',
|
|
558
|
+
attributes: _objectSpread(_objectSpread({}, SHARING_3.attributes), {}, {
|
|
559
|
+
drive: true,
|
|
560
|
+
owner: false,
|
|
561
|
+
members: [{
|
|
562
|
+
status: 'owner',
|
|
563
|
+
name: 'Jane Doe',
|
|
564
|
+
email: 'jane@doe.com',
|
|
565
|
+
instance: 'http://cozy.tools:8080'
|
|
566
|
+
}, {
|
|
567
|
+
status: 'ready',
|
|
568
|
+
name: 'John Doe',
|
|
569
|
+
email: 'john@doe.com',
|
|
570
|
+
instance: 'http://cozy.local:8080'
|
|
571
|
+
}]
|
|
572
|
+
})
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
var newState = reducer({}, receiveSharings({
|
|
576
|
+
sharings: [SHARED_DRIVE]
|
|
577
|
+
}));
|
|
578
|
+
expect(getSharingType(newState, SHARED_DRIVE.attributes.rules[0].values[0], 'http://cozy.local:8080')).toBe('two-way');
|
|
579
|
+
});
|
|
580
|
+
it('should return one-way for a shared drive member with read-only access', function () {
|
|
581
|
+
var SHARED_DRIVE_READ_ONLY = _objectSpread(_objectSpread({}, SHARING_3), {}, {
|
|
582
|
+
id: 'shared_drive_read_only',
|
|
583
|
+
attributes: _objectSpread(_objectSpread({}, SHARING_3.attributes), {}, {
|
|
584
|
+
drive: true,
|
|
585
|
+
owner: false,
|
|
586
|
+
members: [{
|
|
587
|
+
status: 'owner',
|
|
588
|
+
name: 'Jane Doe',
|
|
589
|
+
email: 'jane@doe.com',
|
|
590
|
+
instance: 'http://cozy.tools:8080'
|
|
591
|
+
}, {
|
|
592
|
+
status: 'ready',
|
|
593
|
+
name: 'John Doe',
|
|
594
|
+
email: 'john@doe.com',
|
|
595
|
+
instance: 'http://cozy.local:8080',
|
|
596
|
+
read_only: true
|
|
597
|
+
}]
|
|
598
|
+
})
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
var newState = reducer({}, receiveSharings({
|
|
602
|
+
sharings: [SHARED_DRIVE_READ_ONLY]
|
|
603
|
+
}));
|
|
604
|
+
expect(getSharingType(newState, SHARED_DRIVE_READ_ONLY.attributes.rules[0].values[0], 'http://cozy.local:8080')).toBe('one-way');
|
|
605
|
+
});
|
|
555
606
|
});
|
|
556
607
|
describe('getDocumentSharingType', function () {
|
|
557
608
|
it('should return null if no sharing', function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "27.1.
|
|
3
|
+
"version": "27.1.2",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"cozy-intent": "^2.30.1",
|
|
60
60
|
"cozy-minilog": "^3.10.0",
|
|
61
61
|
"cozy-ui": "^128.3.5",
|
|
62
|
-
"cozy-ui-plus": "^3.
|
|
62
|
+
"cozy-ui-plus": "^3.1.0",
|
|
63
63
|
"jest": "26.6.3",
|
|
64
64
|
"jest-environment-jsdom": "26.6.2",
|
|
65
65
|
"react": "16.12.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"sideEffects": [
|
|
82
82
|
"*.css"
|
|
83
83
|
],
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "ce62be365a280a855babdd6a50998c8ed1ec24c6"
|
|
85
85
|
}
|
package/src/state.js
CHANGED
|
@@ -448,10 +448,19 @@ export const getSharingForSelf = (state, docId) =>
|
|
|
448
448
|
export const getSharingType = (state, docId, instanceUri) => {
|
|
449
449
|
const sharing = getSharingForSelf(state, docId)
|
|
450
450
|
if (!sharing) return false
|
|
451
|
+
|
|
451
452
|
const type = getDocumentSharingType(sharing, docId)
|
|
452
|
-
if (sharing.attributes
|
|
453
|
+
if (sharing.attributes?.owner) return type
|
|
454
|
+
|
|
453
455
|
const me = sharing.attributes.members.find(matchingInstanceName(instanceUri))
|
|
454
|
-
|
|
456
|
+
if (!me) return type
|
|
457
|
+
if (me.read_only) {
|
|
458
|
+
return 'one-way'
|
|
459
|
+
}
|
|
460
|
+
if (sharing.attributes.drive) {
|
|
461
|
+
return 'two-way'
|
|
462
|
+
}
|
|
463
|
+
return type
|
|
455
464
|
}
|
|
456
465
|
|
|
457
466
|
export const getDocumentSharing = (state, docId) =>
|
|
@@ -619,7 +628,6 @@ export const getDocumentSharingType = (sharing, docId) => {
|
|
|
619
628
|
const rule = getSharingRule(sharing, docId)
|
|
620
629
|
const directorySharingType = getDirectorySharingType(rule)
|
|
621
630
|
const fileSharingType = getFileSharingType(rule)
|
|
622
|
-
|
|
623
631
|
return directorySharingType === SHARING_TYPE.TWO_WAY ||
|
|
624
632
|
fileSharingType === SHARING_TYPE.TWO_WAY
|
|
625
633
|
? SHARING_TYPE.TWO_WAY
|
package/src/state.spec.js
CHANGED
|
@@ -708,6 +708,85 @@ describe('getSharingType selector', () => {
|
|
|
708
708
|
)
|
|
709
709
|
).toBe('one-way')
|
|
710
710
|
})
|
|
711
|
+
|
|
712
|
+
it('should return two-way for a shared drive member with write access', () => {
|
|
713
|
+
const SHARED_DRIVE = {
|
|
714
|
+
...SHARING_3,
|
|
715
|
+
id: 'shared_drive',
|
|
716
|
+
attributes: {
|
|
717
|
+
...SHARING_3.attributes,
|
|
718
|
+
drive: true,
|
|
719
|
+
owner: false,
|
|
720
|
+
members: [
|
|
721
|
+
{
|
|
722
|
+
status: 'owner',
|
|
723
|
+
name: 'Jane Doe',
|
|
724
|
+
email: 'jane@doe.com',
|
|
725
|
+
instance: 'http://cozy.tools:8080'
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
status: 'ready',
|
|
729
|
+
name: 'John Doe',
|
|
730
|
+
email: 'john@doe.com',
|
|
731
|
+
instance: 'http://cozy.local:8080'
|
|
732
|
+
}
|
|
733
|
+
]
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
const newState = reducer(
|
|
737
|
+
{},
|
|
738
|
+
receiveSharings({
|
|
739
|
+
sharings: [SHARED_DRIVE]
|
|
740
|
+
})
|
|
741
|
+
)
|
|
742
|
+
expect(
|
|
743
|
+
getSharingType(
|
|
744
|
+
newState,
|
|
745
|
+
SHARED_DRIVE.attributes.rules[0].values[0],
|
|
746
|
+
'http://cozy.local:8080'
|
|
747
|
+
)
|
|
748
|
+
).toBe('two-way')
|
|
749
|
+
})
|
|
750
|
+
|
|
751
|
+
it('should return one-way for a shared drive member with read-only access', () => {
|
|
752
|
+
const SHARED_DRIVE_READ_ONLY = {
|
|
753
|
+
...SHARING_3,
|
|
754
|
+
id: 'shared_drive_read_only',
|
|
755
|
+
attributes: {
|
|
756
|
+
...SHARING_3.attributes,
|
|
757
|
+
drive: true,
|
|
758
|
+
owner: false,
|
|
759
|
+
members: [
|
|
760
|
+
{
|
|
761
|
+
status: 'owner',
|
|
762
|
+
name: 'Jane Doe',
|
|
763
|
+
email: 'jane@doe.com',
|
|
764
|
+
instance: 'http://cozy.tools:8080'
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
status: 'ready',
|
|
768
|
+
name: 'John Doe',
|
|
769
|
+
email: 'john@doe.com',
|
|
770
|
+
instance: 'http://cozy.local:8080',
|
|
771
|
+
read_only: true
|
|
772
|
+
}
|
|
773
|
+
]
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
const newState = reducer(
|
|
777
|
+
{},
|
|
778
|
+
receiveSharings({
|
|
779
|
+
sharings: [SHARED_DRIVE_READ_ONLY]
|
|
780
|
+
})
|
|
781
|
+
)
|
|
782
|
+
expect(
|
|
783
|
+
getSharingType(
|
|
784
|
+
newState,
|
|
785
|
+
SHARED_DRIVE_READ_ONLY.attributes.rules[0].values[0],
|
|
786
|
+
'http://cozy.local:8080'
|
|
787
|
+
)
|
|
788
|
+
).toBe('one-way')
|
|
789
|
+
})
|
|
711
790
|
})
|
|
712
791
|
|
|
713
792
|
describe('getDocumentSharingType', () => {
|