Skip to content

Disable share option for non-example files#22

Merged
warunalakshitha merged 1 commit intoballerina-platform:mainfrom
snelusha:chore/disable-file-share
Apr 2, 2026
Merged

Disable share option for non-example files#22
warunalakshitha merged 1 commit intoballerina-platform:mainfrom
snelusha:chore/disable-file-share

Conversation

@snelusha
Copy link
Copy Markdown
Contributor

@snelusha snelusha commented Apr 1, 2026

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

  • Added isShareablePath() utility function to apps/web/src/lib/fs/core/path-utils.ts that determines whether a given path can be shared by checking if it belongs to either the examples or shared root directories.

UI Updates

  • Updated apps/web/src/components/app-sidebar.tsx to conditionally render the "Share" option in the dropdown menu only for files and directories that pass the isShareablePath() check.
  • Other file actions (Rename, Fork, Delete) remain available as before.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

The PR adds conditional rendering for the Share menu item in the app sidebar, restricting it to only shareable paths. A new utility function isShareablePath() is introduced to check if a path belongs to examples or shared roots.

Changes

Cohort / File(s) Summary
Share Action Gate
apps/web/src/components/app-sidebar.tsx
Imported isShareablePath and updated both file and directory menu rendering to conditionally show the Share dropdown menu item only when the path is shareable.
Path Utility Addition
apps/web/src/lib/fs/core/path-utils.ts
Added new exported isShareablePath() function that checks if a path is under examples or shared roots by combining existing isExamplesPath and isSharedPath checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • warunalakshitha

Poem

🐰✨ A rabbit hops through paths so grand,
Deciding which to share across the land!
With shareable checks, both wise and true,
Only examples and shared roots shine through! 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is severely incomplete, containing only '$subject' placeholder text instead of the required template sections like Purpose, Goals, Approach, and other documentation. Complete the pull request description using the repository template, including Purpose, Goals, Approach, User stories, Release note, Documentation, and other required sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Disable share option for non-example files' clearly and specifically describes the main change: restricting the share menu item to only shareable paths (examples and shared directories).

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@snelusha snelusha marked this pull request as ready for review April 1, 2026 20:35
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a1cbe0 and 4d9f7de.

📒 Files selected for processing (2)
  • apps/web/src/components/app-sidebar.tsx
  • apps/web/src/lib/fs/core/path-utils.ts

Copy link
Copy Markdown
Contributor

@warunalakshitha warunalakshitha left a comment

Choose a reason for hiding this comment

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

LGTM

@warunalakshitha warunalakshitha merged commit a25f2d4 into ballerina-platform:main Apr 2, 2026
3 checks passed
@snelusha snelusha deleted the chore/disable-file-share branch April 2, 2026 05:24
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