Skip to content

feat: Hide "Leave sharing" for shared drives#3923

Merged
zatteo merged 2 commits into
masterfrom
feat/hide-leave-sharing-for-shared-drives
Jun 17, 2026
Merged

feat: Hide "Leave sharing" for shared drives#3923
zatteo merged 2 commits into
masterfrom
feat/hide-leave-sharing-for-shared-drives

Conversation

@zatteo

@zatteo zatteo commented Jun 16, 2026

Copy link
Copy Markdown
Member

For B2B shared drives, we want to hide "Leave sharing" as it is not wished.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the “Leave shared drive” action to respect additional permission checks, preventing unauthorized departures from shared drives.
  • Chores
    • Updated the cozy-sharing dependency to the latest patch version.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1c34c08-3ed6-434e-b863-e49311ddd11f

📥 Commits

Reviewing files that changed from the base of the PR and between 80e830c and 65701bd.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • package.json
  • src/modules/drive/Toolbar/components/MoreMenu.jsx
  • src/modules/shareddrives/components/actions/leaveSharedDrive.js
  • src/modules/views/Sharings/helpers.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/modules/shareddrives/components/actions/leaveSharedDrive.js
  • src/modules/views/Sharings/helpers.js
  • src/modules/drive/Toolbar/components/MoreMenu.jsx

Walkthrough

The changes introduce a canLeave permission check to gate the "Leave Shared Drive" action. The cozy-sharing dependency is bumped from ^33.4.2 to ^33.5.0 to support the new capability. buildSharingsActionsOptions in helpers.js now extracts canLeave from sharingContext and passes it into the actions options object. The leaveSharedDrive action accepts canLeave as a new parameter and incorporates canLeave(docs[0]._id) into its displayCondition alongside the existing single-document check. In MoreMenu, canLeave is destructured from useSharingContext() and added as a third required condition before rendering LeaveSharedDriveButtonItem.

Possibly related PRs

Suggested reviewers

  • JF-Cozy
  • lethemanh
  • rezk2ll
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding conditional logic to hide the 'Leave sharing' option for shared drives using the canLeave capability.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/hide-leave-sharing-for-shared-drives

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.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@bundlemon

bundlemon Bot commented Jun 16, 2026

Copy link
Copy Markdown

BundleMon

Files updated (2)
Status Path Size Limits
static/js/cozy.(hash).js
928.79KB (+87B +0.01%) -
static/js/main.(hash).js
48.1KB (+32B +0.07%) -
Unchanged files (18)
Status Path Size Limits
static/resource/(hash).js
336.09KB -
services/qualificationMigration.js
282.66KB -
services/dacc.js
262.48KB -
static/js/lib-react.(hash).js
43.88KB -
static/css/cozy.(hash).css
31.42KB -
static/js/lib-polyfill.(hash).js
22.77KB -
static/js/lib-router.(hash).js
21.86KB -
static/js/public.(hash).js
19.79KB -
static/css/main.(hash).css
13.57KB -
static/js/intents.(hash).js
9.2KB -
static/js/(chunkId).(hash).js
8.6KB -
manifest.webapp
3.09KB -
static/css/public.(hash).css
2.34KB -
static/js/async/(chunkId).(hash).js
2.06KB -
main/index.html
771B -
public/index.html
703B -
intents/index.html
644B -
assets/manifest.json
185B -

Total files change +118B +0.01%

Groups updated (1)
Status Path Size Limits
**/*.js
5.98MB (+119B 0%) -
Unchanged groups (2)
Status Path Size Limits
**/*.{png,svg,ico}
2.16MB -
**/*.css
78.72KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/modules/views/Sharings/helpers.js`:
- Around line 7-14: Update the `useSharingContext` hook declaration in
`src/declarations.d.ts` (lines 157-161) to include the `canLeave` property in
its return type. This property is currently being destructured and used in
`src/modules/views/Sharings/helpers.js` (at line 7) and propagated in the
returned object (at line 14), as well as being directly destructured in
`src/modules/drive/Toolbar/components/MoreMenu.jsx` (at line 49). Add `canLeave`
with the appropriate type to the `useSharingContext` declaration to align the
type contract with the actual usage pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 446f0d38-d37a-44ad-ba6a-23c0269d946f

📥 Commits

Reviewing files that changed from the base of the PR and between 8562648 and 80e830c.

📒 Files selected for processing (3)
  • src/modules/drive/Toolbar/components/MoreMenu.jsx
  • src/modules/shareddrives/components/actions/leaveSharedDrive.js
  • src/modules/views/Sharings/helpers.js

Comment on lines +7 to +14
const { allLoaded, refresh, isOwner, canLeave } = sharingContext

return {
...base,
...nativeSharing,
refresh,
isOwner,
canLeave,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify contract drift between useSharingContext declaration and runtime usages

set -euo pipefail

echo "== Declaration for useSharingContext =="
fd -i "declarations.d.ts" --exec sed -n '140,190p' {}

echo
echo "== Usages of useSharingContext destructuring canLeave =="
rg -n -C2 "useSharingContext\\(\\)|canLeave" --type js --type jsx --type ts --type tsx

echo
echo "== Files that call canLeave(...) =="
rg -n -P "\\bcanLeave\\s*\\(" --type js --type jsx --type ts --type tsx

Repository: linagora/twake-drive

Length of output: 1592


🏁 Script executed:

cat -n src/modules/views/Sharings/helpers.js | head -20

Repository: linagora/twake-drive

Length of output: 670


🏁 Script executed:

rg -n "canLeave" --type ts --type js

Repository: linagora/twake-drive

Length of output: 816


🏁 Script executed:

cat -n src/declarations.d.ts | grep -A 20 "useSharingContext"

Repository: linagora/twake-drive

Length of output: 797


Add canLeave to the useSharingContext declaration.

Line 7 of src/modules/views/Sharings/helpers.js destructures canLeave from sharingContext, and line 14 propagates it in the returned object. However, the useSharingContext declaration in src/declarations.d.ts:157-161 omits canLeave, creating a type contract drift. This also breaks typed usage in src/modules/drive/Toolbar/components/MoreMenu.jsx:49, which directly destructures canLeave from the hook.

🤖 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 `@src/modules/views/Sharings/helpers.js` around lines 7 - 14, Update the
`useSharingContext` hook declaration in `src/declarations.d.ts` (lines 157-161)
to include the `canLeave` property in its return type. This property is
currently being destructured and used in `src/modules/views/Sharings/helpers.js`
(at line 7) and propagated in the returned object (at line 14), as well as being
directly destructured in `src/modules/drive/Toolbar/components/MoreMenu.jsx` (at
line 49). Add `canLeave` with the appropriate type to the `useSharingContext`
declaration to align the type contract with the actual usage pattern.

zatteo added 2 commits June 17, 2026 09:26
For B2B shared drives, we want to hide "Leave sharing" as it is not
wished.
@zatteo zatteo force-pushed the feat/hide-leave-sharing-for-shared-drives branch from 80e830c to 65701bd Compare June 17, 2026 07:31

@codescene-delta-analysis codescene-delta-analysis 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.

Our agent can fix these. Install it.

Gates Passed
3 Quality Gates Passed

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@zatteo zatteo added the e2e Run the E2E suite on this PR label Jun 17, 2026
@zatteo zatteo merged commit 5450e3d into master Jun 17, 2026
8 checks passed
@zatteo zatteo deleted the feat/hide-leave-sharing-for-shared-drives branch June 17, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e Run the E2E suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants