Files
coder/site
blink-so[bot] cc89820d7c feat: add template export functionality to UI (#18214)
## 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>
2025-06-03 14:26:50 -04:00
..
2025-05-28 20:33:12 +05:00
2025-05-24 11:33:16 -03:00