Disable share option for non-example files#22
Disable share option for non-example files#22warunalakshitha merged 1 commit intoballerina-platform:mainfrom
Conversation
📝 WalkthroughWalkthroughThe PR adds conditional rendering for the Share menu item in the app sidebar, restricting it to only shareable paths. A new utility function Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/src/components/app-sidebar.tsx`:
- Around line 150-155: The UI currently hides the Share action with
isShareablePath, but the core share logic still accepts any path; add the same
guard inside the share handler(s) so non-shareable paths are rejected at
runtime. Update copyShareLink and/or generateShareUrl to call
isShareablePath(path) up front and return early (or throw) when false, and
ensure any callers (e.g., background/share utilities) handle the failure; use
the same error/log message so the invariant is enforced server-side of the UI.
🪄 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: dd42f56d-4003-4244-9772-a03784a71333
📒 Files selected for processing (2)
apps/web/src/components/app-sidebar.tsxapps/web/src/lib/fs/core/path-utils.ts
Purpose
$subject
Summary
This pull request restricts the share functionality in the application's file management interface to a specific set of allowed paths.
Changes Made
New Utility Function
isShareablePath()utility function toapps/web/src/lib/fs/core/path-utils.tsthat determines whether a given path can be shared by checking if it belongs to either the examples or shared root directories.UI Updates
apps/web/src/components/app-sidebar.tsxto conditionally render the "Share" option in the dropdown menu only for files and directories that pass theisShareablePath()check.Impact
The share option is now restricted to files and directories within designated example and shared paths, preventing users from sharing arbitrary user-created files through the share functionality.