Skip to content

feat(layout): disable sidebar add/upload on readonly folders, redirect on no-folder sections#3950

Merged
doubleface merged 3 commits into
masterfrom
feat/disableAddAndUploadOnSharings
Jun 24, 2026
Merged

feat(layout): disable sidebar add/upload on readonly folders, redirect on no-folder sections#3950
doubleface merged 3 commits into
masterfrom
feat/disableAddAndUploadOnSharings

Conversation

@doubleface

@doubleface doubleface commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
  • Disable AddButton and UploadButton when current folder is readonly
  • On /recents, /sharings, /trash: navigate to root then execute the action
  • AddFolder auto-opens the name input after navigating from no-folder sections
  • UploadButton navigates to root immediately on file selection from no-folder sections

Summary by CodeRabbit

  • New Features

    • Streamlined “add folder” flow from root/no-folder: after navigating to the root, the app automatically opens the new-folder input.
    • Upload now accepts an explicit target folder (including root/no-folder scenarios) and provides an upload-start callback.
  • Improvements

    • Refined toolbar actions by section and permissions: “Add”/“Upload” are correctly enabled/disabled for read-only contexts.
    • Improved add-folder integration so menu actions can trigger the right folder-creation experience.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: fb73d3a0-7dce-4913-a254-153858cd4f61

📥 Commits

Reviewing files that changed from the base of the PR and between f8920fc and 099519d.

📒 Files selected for processing (5)
  • src/modules/drive/AddMenu/AddMenuProvider.jsx
  • src/modules/drive/Toolbar/components/AddFolderItem.jsx
  • src/modules/filelist/AddFolder.jsx
  • src/modules/layout/Layout.jsx
  • src/modules/upload/UploadButton.jsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/modules/upload/UploadButton.jsx
  • src/modules/drive/AddMenu/AddMenuProvider.jsx
  • src/modules/filelist/AddFolder.jsx
  • src/modules/layout/Layout.jsx

Walkthrough

Layout.jsx gains a module-level pendingCreateOnRoot flag and an exported consumeCreateOnRoot() function. A new goToRoot({ create }) helper sets the flag when create is true and navigates to /folder/${ROOT_DIR_ID}. Toolbar gating is reworked around derived isNoFolderSection (null or trash folder) and isReadOnly states. The no-folder desktop branch passes onAddFolder={goToRoot({create:true})} to AddMenuProvider and configures UploadButton with folderId={null} and onUploadStart. UploadButton gains folderId and onUploadStart props and renders without FileInput when disabled. AddMenuProvider and AddFolderItem propagate onAddFolder through context. AddFolder adds a mount effect that calls consumeCreateOnRoot() and auto-opens the folder input if the flag was set.

Possibly related PRs

  • linagora/twake-drive#3886: Changes Layout.jsx to gate sidebar Add/Upload based on useCurrentFolderWriteAccess, the same gating logic this PR replaces with isNoFolderSection/isReadOnly.

Suggested reviewers

  • JF-Cozy
  • lethemanh
  • zatteo
  • 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 describes the main changes: disabling sidebar add/upload on readonly folders and redirecting on no-folder sections, which aligns with the PR's core objectives.
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/disableAddAndUploadOnSharings

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.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@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/layout/Layout.jsx`:
- Line 61: The isSharingRoot check currently compares pathname to the exact
string '/sharings', which fails to match when the route has a trailing slash
like '/sharings/'. To fix this, normalize the pathname comparison by removing
trailing slashes from the pathname before checking if it equals '/sharings', or
adjust the logic to match both '/sharings' and '/sharings/' paths. This ensures
the Add/Upload controls are properly disabled at the sharings root regardless of
trailing slash variations.
🪄 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: c0d4234b-8b08-4dc1-9145-fc73fd3f6bca

📥 Commits

Reviewing files that changed from the base of the PR and between 3238597 and 4b322c4.

📒 Files selected for processing (6)
  • src/locales/en.json
  • src/locales/fr.json
  • src/locales/ru.json
  • src/locales/vi.json
  • src/modules/layout/Layout.jsx
  • src/modules/upload/UploadButton.jsx

Comment thread src/modules/layout/Layout.jsx Outdated
@rezk2ll

rezk2ll commented Jun 22, 2026

Copy link
Copy Markdown
Member

can you please confirm with bob if this is needed

@doubleface

Copy link
Copy Markdown
Contributor Author

can you please confirm with bob if this is needed

@rezk2ll he asked me to do it

@doubleface doubleface force-pushed the feat/disableAddAndUploadOnSharings branch 2 times, most recently from bd6739b to 9f99c2d Compare June 22, 2026 18:42
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@bundlemon

bundlemon Bot commented Jun 22, 2026

Copy link
Copy Markdown

BundleMon

Files updated (3)
Status Path Size Limits
static/js/(chunkId).(hash).js
82.05KB (+73.45KB +854.28%) -
static/js/public.(hash).js
25.84KB (+6.06KB +30.62%) -
static/js/main.(hash).js
54.03KB (+5.14KB +10.52%) -
Unchanged files (17)
Status Path Size Limits
static/js/cozy.(hash).js
928.67KB -
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/css/main.(hash).css
13.57KB -
static/js/intents.(hash).js
8.99KB -
static/js/async/(chunkId).(hash).js
7.5KB -
manifest.webapp
3.09KB -
static/css/public.(hash).css
2.34KB -
index.html
771B -
public/index.html
705B -
intents/index.html
643B -
assets/manifest.json
185B -

Total files change +84.66KB +4.14%

Groups updated (1)
Status Path Size Limits
**/*.js
5.99MB (+5.25KB +0.09%) -
Unchanged groups (2)
Status Path Size Limits
**/*.{png,svg,ico}
2.16MB -
**/*.css
77.43KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@zatteo

zatteo commented Jun 23, 2026

Copy link
Copy Markdown
Member

So now we have:

  1. in "normal folder": create or upload files in current folder
  2. in some special folders (e.g. "Recent"): create or upload files at root
  3. in some other special folders (e.g. "Sharings"): button disabled

Can't we remove the number 2. ?

@doubleface

Copy link
Copy Markdown
Contributor Author

So now we have:

1. in "normal folder": create or upload files in current folder

2. in some special folders (e.g. "Recent"): create or upload files  at root

3. in some other special folders (e.g. "Sharings"): button disabled

Can't we remove the number 2. ?

Right, I think we should also disable those buttons in recents

@doubleface doubleface marked this pull request as draft June 23, 2026 09:47
@doubleface doubleface force-pushed the feat/disableAddAndUploadOnSharings branch from 9f99c2d to 99bfd55 Compare June 23, 2026 14:53
codescene-delta-analysis[bot]

This comment was marked as outdated.

@doubleface doubleface changed the title feat(sharings): disable add and upload buttons at sharings root feat(layout): disable sidebar add/upload on readonly folders, redirect on no-folder sections Jun 23, 2026
@doubleface doubleface force-pushed the feat/disableAddAndUploadOnSharings branch from 99bfd55 to ae6b906 Compare June 23, 2026 15:06
codescene-delta-analysis[bot]

This comment was marked as outdated.

@doubleface doubleface marked this pull request as ready for review June 23, 2026 15:09

@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

Caution

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

⚠️ Outside diff range comments (1)
src/modules/layout/Layout.jsx (1)

93-117: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Align the no-folder toolbar with the agreed /recents behavior.

This branch still keeps Add/Upload active for isNoFolderSection and routes to root, which preserves the “navigate-then-act” path instead of disabling the controls in /recents as agreed in the PR discussion.

🤖 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/layout/Layout.jsx` around lines 93 - 117, The AddMenuProvider and
UploadButton components are currently enabled for the isNoFolderSection case
with navigation to root, but the agreed behavior is to disable these controls
when in the no-folder section (/recents). Modify the AddMenuProvider by setting
disabled={true} instead of disabled={false}, remove the onAddFolder callback
that navigates to root, and similarly update the UploadButton to disable uploads
for this scenario by setting an appropriate disabled state or removing the
onUploadStart navigation callback. This aligns with disabling controls in the
no-folder section rather than routing users to root when they attempt these
actions.
🤖 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/drive/Toolbar/components/AddFolderItem.jsx`:
- Around line 33-34: In the AddFolderItem.jsx component, the click handler is
unconditionally calling both onAddFolder?.() and addFolder() in sequence,
causing the new-folder flow to be triggered twice. Instead, addFolder() should
only be called as a fallback when onAddFolder is not provided. Modify the code
to either use onAddFolder?.() || addFolder() pattern or add a conditional check
that calls addFolder() only when onAddFolder is undefined/not provided.

---

Outside diff comments:
In `@src/modules/layout/Layout.jsx`:
- Around line 93-117: The AddMenuProvider and UploadButton components are
currently enabled for the isNoFolderSection case with navigation to root, but
the agreed behavior is to disable these controls when in the no-folder section
(/recents). Modify the AddMenuProvider by setting disabled={true} instead of
disabled={false}, remove the onAddFolder callback that navigates to root, and
similarly update the UploadButton to disable uploads for this scenario by
setting an appropriate disabled state or removing the onUploadStart navigation
callback. This aligns with disabling controls in the no-folder section rather
than routing users to root when they attempt these actions.
🪄 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: cba8bd5d-cb8a-41c3-b101-b1bbf4fe599f

📥 Commits

Reviewing files that changed from the base of the PR and between 9f99c2d and ae6b906.

📒 Files selected for processing (5)
  • src/modules/drive/AddMenu/AddMenuProvider.jsx
  • src/modules/drive/Toolbar/components/AddFolderItem.jsx
  • src/modules/filelist/AddFolder.jsx
  • src/modules/layout/Layout.jsx
  • src/modules/upload/UploadButton.jsx
✅ Files skipped from review due to trivial changes (1)
  • src/modules/drive/AddMenu/AddMenuProvider.jsx

Comment thread src/modules/drive/Toolbar/components/AddFolderItem.jsx Outdated
@doubleface doubleface force-pushed the feat/disableAddAndUploadOnSharings branch from ae6b906 to f8920fc Compare June 23, 2026 15:17
codescene-delta-analysis[bot]

This comment was marked as outdated.

@doubleface doubleface force-pushed the feat/disableAddAndUploadOnSharings branch from f8920fc to 505697b Compare June 23, 2026 16:15
- Extract button element into a variable to avoid duplication
- Render a plain div wrapper when disabled (no FileInput picker)
- Show sidebar buttons for all desktop views, not only writable folders
- Disable AddMenuProvider and UploadButton when current folder is readonly
- Detect no-folder sections (/recents, /sharings, /trash) to keep them enabled
- On /recents, /sharings, /trash: AddMenu opens normally, "New folder" navigates
  to root and auto-opens the folder name input on arrival
- UploadButton navigates to root immediately when files are selected
- Pass folderId=null to uploadFiles so the action-level redirect kicks in
- Use module-level flag consumed by AddFolder to avoid React Router timing issues
@doubleface doubleface force-pushed the feat/disableAddAndUploadOnSharings branch from 505697b to 099519d Compare June 23, 2026 16:16
codescene-delta-analysis[bot]

This comment was marked as outdated.

@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 left a comment

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.

Is there still code related to "create by default in root" that is not relevant anymore?

@doubleface doubleface merged commit 68dcffa into master Jun 24, 2026
7 checks passed
@doubleface doubleface deleted the feat/disableAddAndUploadOnSharings branch June 24, 2026 07:15
doubleface added a commit that referenced this pull request Jun 26, 2026
Since #3950 we now disable
add and upload buttons on readonly folders and shared drives
rezk2ll pushed a commit that referenced this pull request Jun 26, 2026
Since #3950 we now disable
add and upload buttons on readonly folders and shared drives
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