Skip to content

fix(cozy-sharing): Allow sharing shared drive folder root by email#3023

Merged
doubleface merged 1 commit into
masterfrom
fix/hideMailSharingRootSharedDrive
Jun 10, 2026
Merged

fix(cozy-sharing): Allow sharing shared drive folder root by email#3023
doubleface merged 1 commit into
masterfrom
fix/hideMailSharingRootSharedDrive

Conversation

@doubleface

@doubleface doubleface commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Get the associated sharing to know if a folder is the root of the sharing or not

This was a regression from #3017

https://app.notion.com/p/linagora/5d2f7429646042378356ecb072890d35?v=1c062718bad180d3847f000cd4c97139&p=37a62718bad180ab88bbf091063ce599&pm=s

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@doubleface, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 57 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0b6d0b1a-576b-423a-b8a8-c51fae61f127

📥 Commits

Reviewing files that changed from the base of the PR and between 40a56f0 and dcb4f98.

📒 Files selected for processing (2)
  • packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.jsx
  • packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.spec.jsx

Walkthrough

FederatedFolderModalContent replaces its hasParentRestriction check (previously based on existingDocument?.driveId or path-based parent sharing) with logic that fetches shared-drive sharing rules via getSharingById and determines whether the current document is the federated shared-drive root node. This refactored check directly controls whether the modal shows share-by-email UI or displays an "only by link" restriction message. The test suite adds mocking for the new hook function and a new test case verifying that documents at the federated folder root enable the "Add users" action.

Possibly related PRs

  • linagora/cozy-libs#3017: Modifies the same FederatedFolderModalContent and test file to alter canShareByEmail logic and UI rendering (Add users vs only-by-link messaging).
  • linagora/cozy-libs#3009: Updates FederatedFolderModal.jsx and spec to change federated shared-folder modal share-by-email UI behavior through refactoring modal rendering and actions.
  • linagora/cozy-libs#3015: Adjusts shared-drive behavior in FederatedFolderModal.jsx by adding contact-creation controls to the share-by-email UI.

Suggested reviewers

  • rezk2ll
  • zatteo
  • JF-Cozy
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: allowing email sharing for shared drive folder roots, which directly corresponds to the PR's objective to re-enable this functionality and fix a regression.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/hideMailSharingRootSharedDrive

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.jsx (1)

38-44: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Duplicate getSharingById declaration will cause a parse error.

getSharingById is destructured twice at lines 38 and 40, which is invalid JavaScript syntax and will fail to compile.

Proposed fix: remove the duplicate declaration
   const {
     share,
     getSharingLink,
     getFederatedShareLink,
     getDocumentPermissions,
     getOwner,
     getSharingById,
     getRecipients,
-    getSharingById,
     hasSharedChild,
     hasSharedParent,
     revoke
   } = useSharingContext()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.jsx`
around lines 38 - 44, The destructuring from useSharingContext() in
FederatedFolderModal.jsx mistakenly includes getSharingById twice which causes a
parse error; remove the duplicate getSharingById from the destructuring list
(keep a single getSharingById alongside getRecipients, hasSharedChild,
hasSharedParent, revoke) so the destructure expression in the
useSharingContext() assignment is valid.

Source: Linters/SAST tools

packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.spec.jsx (1)

22-33: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

getSharingById is not wired into the useSharingContext mock.

mockGetSharingById is defined at line 16 and initialized in beforeEach, but it's missing from the mock return value. The new test at lines 168-192 will fail because the component will receive undefined for getSharingById.

Proposed fix: add getSharingById to the mock
 jest.mock('../../hooks/useSharingContext', () => ({
   useSharingContext: () => ({
     share: mockShare,
     revoke: mockRevoke,
     getSharingLink: mockGetSharingLink,
     getFederatedShareLink: mockGetFederatedShareLink,
     getDocumentPermissions: jest.fn().mockReturnValue([]),
+    getOwner: jest.fn(),
+    getSharingById: mockGetSharingById,
     getRecipients: mockGetRecipients,
     hasSharedChild: mockHasSharedChild,
     hasSharedParent: mockHasSharedParent
   })
 }))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.spec.jsx`
around lines 22 - 33, The useSharingContext mock is missing getSharingById so
the component receives undefined; update the jest.mock return to include
getSharingById: mockGetSharingById (the mock defined at line 16 and initialized
in beforeEach) so components calling getSharingById get the mocked
implementation; modify the object returned by useSharingContext (in the mocked
module) to add a getSharingById property pointing to mockGetSharingById.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.jsx`:
- Around line 38-44: The destructuring from useSharingContext() in
FederatedFolderModal.jsx mistakenly includes getSharingById twice which causes a
parse error; remove the duplicate getSharingById from the destructuring list
(keep a single getSharingById alongside getRecipients, hasSharedChild,
hasSharedParent, revoke) so the destructure expression in the
useSharingContext() assignment is valid.

In
`@packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.spec.jsx`:
- Around line 22-33: The useSharingContext mock is missing getSharingById so the
component receives undefined; update the jest.mock return to include
getSharingById: mockGetSharingById (the mock defined at line 16 and initialized
in beforeEach) so components calling getSharingById get the mocked
implementation; modify the object returned by useSharingContext (in the mocked
module) to add a getSharingById property pointing to mockGetSharingById.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27c6d68f-1482-43f7-a8d4-bd822cbcbb87

📥 Commits

Reviewing files that changed from the base of the PR and between aeaf0cb and 40a56f0.

📒 Files selected for processing (2)
  • packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.jsx
  • packages/cozy-sharing/src/components/FederatedFolder/FederatedFolderModal.spec.jsx

@doubleface doubleface force-pushed the fix/hideMailSharingRootSharedDrive branch from 40a56f0 to 6ee73e6 Compare June 9, 2026 08:48
@doubleface doubleface force-pushed the fix/hideMailSharingRootSharedDrive branch from 6ee73e6 to dcb4f98 Compare June 9, 2026 08:54
)
const isInsideSharedDrive = Boolean(
existingDocument?.driveId && !isSharedDriveRoot
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for recipient right? For the owner it will be catched by hasSharedParentByPath?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's it

@doubleface doubleface requested a review from zatteo June 10, 2026 07:22
@doubleface doubleface merged commit 5110b4f into master Jun 10, 2026
3 checks passed
@doubleface doubleface deleted the fix/hideMailSharingRootSharedDrive branch June 10, 2026 08:24
doubleface added a commit that referenced this pull request Jun 10, 2026
This resulted from a merge of
#3023 without rebase
doubleface added a commit to linagora/twake-drive that referenced this pull request Jun 10, 2026
- Bump `cozy-sharing` from `33.1.1` to `33.2.2`

- [linagora/cozy-libs#2994](linagora/cozy-libs#2994) (`fix(cozy-sharing): Make matching diacritic-insensitive`)
- [linagora/cozy-libs#3021](linagora/cozy-libs#3021) (`feat(cozy-sharing): Show progress icon on done button during share`)
- [linagora/cozy-libs#3022](linagora/cozy-libs#3022) (`fix(cozy-sharing): Refresh link state in share modal`)
- [linagora/cozy-libs#3023](linagora/cozy-libs#3023) (`fix(cozy-sharing): Allow sharing shared drive folder root by email`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants