Repository navigation
feat(snippets): build reusable snippet sharing modal (#188) - #225
Merged
Merged
Conversation
…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
|
@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. |
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.