mirror of
https://github.com/coder/coder.git
synced 2026-06-05 05:58:20 +00:00
cc89820d7c
## Summary This PR adds template export functionality to the Coder UI, addressing issue #17859. Users can now export templates directly from the web interface without requiring CLI access. ## Changes ### Frontend API - Added `downloadTemplateVersion` function to `site/src/api/api.ts` - Supports both TAR (default) and ZIP formats - Uses existing `/api/v2/files/{fileId}` endpoint with format parameter ### UI Enhancement - Added "Export as TAR" and "Export as ZIP" options to template dropdown menu - Positioned logically between "Duplicate" and "Delete" actions - Uses download icon from Lucide React for consistency ### User Experience - Files automatically named as `{templateName}-{templateVersion}.{extension}` - Immediate download trigger on click - Proper error handling with console logging - Clean blob URL management to prevent memory leaks ## Testing The implementation has been tested for: - ✅ TypeScript compilation - ✅ Proper function signatures and types - ✅ UI component integration - ✅ Error handling structure ## Screenshots The export options appear in the template dropdown menu: - Export as TAR (default format, compatible with `coder template pull`) - Export as ZIP (compressed format for easier handling) ## Fixes Closes #17859 ## Notes This enhancement makes template management more accessible for users who: - Don't have CLI access - Manage deployments on devices without Coder CLI - Prefer web-based workflows - Need to transfer templates between environments The implementation follows existing patterns in the codebase and maintains consistency with the current UI design. --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> Co-authored-by: Kyle Carberry <kyle@coder.com>