Skip to content

feat(snippets): build reusable snippet sharing modal (#188) - #225

Merged
SudiptaPaul-31 merged 2 commits into
SudiptaPaul-31:mainfrom
Gezziy:Sharing-Modal
Oct 25, 2026
Merged

SudiptaPaul-31 merged 2 commits into
SudiptaPaul-31:mainfrom
Gezziy:Sharing-Modal

Conversation

@Gezziy

@Gezziy Gezziy commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

closes #188

Summary of Changes

Reusable Sharing Modal (components/SnippetShareModal.tsx):
Implemented modal dialog matching platform design tokens and dark mode aesthetic.
Allows users to select visibility settings: Read-Only (read-only) or Public / Collaborative (read-write).
Implemented one-click clipboard copy (navigator.clipboard.writeText with legacy document.execCommand fallback).
Added inline copy confirmation ("Link copied!" with Check icon transition) and Sonner toast alerts.
Implemented active links listing (GET /api/share-links?snippetId=...) with created timestamps, visibility badges, and URL truncation/expansion.
Added one-click link revocation (DELETE /api/share-links/:id) that reactively removes the link from the UI.
Guarded against sensitive code exposure (only token, URL, visibility, and timestamps are rendered).
Snippet Detail Integration (components/SnippetDetailModal.tsx):
Added an accessible "Share" button with Share2 icon to the modal action bar that triggers SnippetShareModal.
API & Service Enhancements (app/api/share-links/, lib/share-link-management.service.ts):
Added findShareLink(id) lookup helper in ShareLinkManagementService.
Added authorizeSnippet helper ensuring callers have ownership/edit rights before creating, listing, or revoking links for owned snippets.
Normalized "public" visibility parameter to "read-write".
Automated Tests:
Added components/tests/SnippetShareModal.test.tsx verifying modal opening, active link retrieval, link generation, visibility toggling, clipboard copy, link revocation, and 403 permission error handling.
Added app/api/share-links/route.test.ts verifying POST, GET, DELETE endpoints, input validation, and authorization guards.

Reason for Changes

Resolves Issue #188 ("Build Snippet Sharing Modal"): Users needed a secure, intuitive UI workflow to generate, copy, view, and revoke shareable links for their code snippets with granular visibility controls and clear feedback.

…udiptaPaul-31#188)

- Create reusable SnippetShareModal component with visibility controls (Read-Only and Public/Collaborative)
- Add one-click copy-link functionality with inline confirmation and toast feedback
- Support active share link listing and immediate link revocation
- Integrate Share button and modal trigger into SnippetDetailModal
- Add findShareLink helper in ShareLinkManagementService and authorizeSnippet guard in share-link routes
- Add comprehensive unit and integration test suites for the modal and API routes
@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@Gezziy is attempting to deploy a commit to the Sudipta 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@Gezziy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@SudiptaPaul-31
SudiptaPaul-31 merged commit 26da0cb into SudiptaPaul-31:main Oct 25, 2026
0 of 2 checks passed
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.

Build Snippet Sharing Modal

2 participants