Skip to content

feat: add template export functionality to UI #18214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025
Merged

Conversation

blink-so[bot]
Copy link
Contributor

@blink-so blink-so bot commented Jun 3, 2025

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.

- Add downloadTemplateVersion function to frontend API
- Add Export as TAR and Export as ZIP options to template dropdown menu
- Implement file download with proper naming convention
- Support both tar and zip formats as requested in issue #17859

Fixes #17859
Copy link

github-actions bot commented Jun 3, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

blink-so bot and others added 2 commits June 3, 2025 17:49
Fix import ordering to comply with biome linting rules by moving
API import to the correct position in the import order.
Copy link

github-actions bot commented Jun 3, 2025


🚀 Deploying PR 18214 ...

@kylecarbs
Copy link
Member

image

This is what it looks like!

@BrunoQuaresma
Copy link
Collaborator

BrunoQuaresma commented Jun 3, 2025

I would change the design just a bit.

  • Use the copy "Download tar" and "Download zip" instead of "Export as"
  • Add a divider to divide the download actions

But not a blocker.

@kylecarbs
Copy link
Member

I kinda like the way it is as-is. I'll test locally then merge if all is good.

@kylecarbs kylecarbs merged commit cc89820 into main Jun 3, 2025
35 of 38 checks passed
@kylecarbs kylecarbs deleted the feat/template-export-ui branch June 3, 2025 18:26
@github-actions github-actions bot locked and limited conversation to collaborators Jun 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow exporting templates from UI
2 participants