Skip to content

fix(shareddrives): hide leave sharing for owned shared drives#3931

Merged
doubleface merged 1 commit into
masterfrom
fix/noLeaveDriveForOwner
Jun 18, 2026
Merged

fix(shareddrives): hide leave sharing for owned shared drives#3931
doubleface merged 1 commit into
masterfrom
fix/noLeaveDriveForOwner

Conversation

@doubleface

@doubleface doubleface commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

  • Hide the "Leave sharing" action in the sharings list when the current user owns the federated shared drive.

Why

  • displayCondition only filtered org shared drives (B2B) via canLeave. Owners of federated shared drives still saw the action, which does not apply to them.

How

  • Add isOwner to the leaveSharedDrive action factory options. It is already exposed by the sharing context and propagated through buildSharingsActionsOptions, so no wiring change is needed upstream.
  • Extend displayCondition with !isOwner(docs[0]._id) alongside the existing isSharedDriveDoc and canLeave guards.
  • Add a colocated leaveSharedDrive.spec.js covering owner, recipient, org drive, non-shared-drive, and multi-selection cases.

https://app.notion.com/p/linagora/Owner-Sharings-hide-action-38262718bad180fcb671dbc1b04cc014

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Owners can no longer leave their own shared drives; the "leave shared drive" action is now hidden for drive owners.
  • Tests

    • Added comprehensive test coverage for the "leave shared drive" functionality and visibility conditions.

The "Leave sharing" action was shown in the sharings list even when
the current user owns the federated shared drive. The org shared drive
case (B2B) was already excluded via canLeave, but the owner case was
missing from displayCondition.

Add an isOwner check to hide the action for owners and cover it with
a dedicated spec.

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

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

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.

@coderabbitai

coderabbitai Bot commented Jun 17, 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: 689cc9c1-e073-4b90-850b-320f3848f811

📥 Commits

Reviewing files that changed from the base of the PR and between cea9d58 and 3b1adef.

📒 Files selected for processing (2)
  • src/modules/shareddrives/components/actions/leaveSharedDrive.js
  • src/modules/shareddrives/components/actions/leaveSharedDrive.spec.js

Walkthrough

leaveSharedDrive in leaveSharedDrive.js gains an isOwner parameter. Its displayCondition now evaluates three conditions in sequence: the selected document must be a shared drive, canLeave must return true for its _id, and isOwner(_id) must be false. The revoke flow and alert behavior are unchanged. A new Jest spec (leaveSharedDrive.spec.js) is added, covering displayCondition across multiple selection scenarios (recipient, owner, org/B2B recipient, outside-shared-drive, multiple docs) and verifying that action calls client.collection('io.cozy.sharings').revokeSelf with the correct drive ID and emits a success alert.

Possibly related PRs

  • linagora/twake-drive#3923: Modifies the same leaveSharedDrive.js file, extending the displayCondition gating logic and function signature in an earlier iteration of this feature.

Suggested labels

e2e

Suggested reviewers

  • JF-Cozy
  • rezk2ll
  • lethemanh
🚥 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 summarizes the main change: adding ownership checks to hide the leave sharing action for owned shared drives.
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 fix/noLeaveDriveForOwner

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@bundlemon

bundlemon Bot commented Jun 17, 2026

Copy link
Copy Markdown

BundleMon

Files updated (1)
Status Path Size Limits
static/js/main.(hash).js
48.12KB (+20B +0.04%) -
Unchanged files (19)
Status Path Size Limits
static/js/cozy.(hash).js
928.17KB -
static/resource/(hash).js
336.09KB -
services/qualificationMigration.js
283.39KB -
services/dacc.js
263.13KB -
static/js/lib-react.(hash).js
43.88KB -
static/css/cozy.(hash).css
30.13KB -
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
769B -
public/index.html
705B -
intents/index.html
645B -
assets/manifest.json
185B -

Total files change +23B 0%

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

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@doubleface doubleface merged commit 1600705 into master Jun 18, 2026
6 checks passed
@doubleface doubleface deleted the fix/noLeaveDriveForOwner branch June 18, 2026 07:03
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.

2 participants