Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 3 commits intomainfromfeat/template-export-ui
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1084,6 +1084,31 @@ class ApiMethods {
return response.data;
};

/**
* Downloads a template version as a tar or zip archive
* @param fileId The file ID from the template version's job
* @param format Optional format: "zip" for zip archive, empty/undefined for tar
* @returns Promise that resolves to a Blob containing the archive
*/
downloadTemplateVersion = async (
fileId: string,
format?: "zip",
): Promise<Blob> => {
const params = new URLSearchParams();
if (format) {
params.set("format", format);
}

const response = await this.axios.get(
`/api/v2/files/${fileId}?${params.toString()}`,
{
responseType: "blob",
},
);

return response.data;
};

updateTemplateMeta = async (
templateId: string,
data: TypesGen.UpdateTemplateMeta,
Expand Down
34 changes: 33 additions & 1 deletionsite/src/pages/TemplatePage/TemplatePageHeader.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import EditIcon from "@mui/icons-material/EditOutlined";
import Button from "@mui/material/Button";
import { API } from "api/api";
import { workspaces } from "api/queries/workspaces";
import type {
AuthorizationResponse,
Expand All@@ -26,7 +27,7 @@ import {
} from "components/PageHeader/PageHeader";
import { Pill } from "components/Pill/Pill";
import { Stack } from "components/Stack/Stack";
import { CopyIcon } from "lucide-react";
import { CopyIcon, DownloadIcon } from "lucide-react";
import {
EllipsisVertical,
PlusIcon,
Expand All@@ -46,6 +47,7 @@ type TemplateMenuProps = {
templateName: string;
templateVersion: string;
templateId: string;
fileId: string;
onDelete: () => void;
};

Expand All@@ -54,6 +56,7 @@ const TemplateMenu: FC<TemplateMenuProps> = ({
templateName,
templateVersion,
templateId,
fileId,
onDelete,
}) => {
const dialogState = useDeletionDialogState(templateId, onDelete);
Expand All@@ -68,6 +71,24 @@ const TemplateMenu: FC<TemplateMenuProps> = ({

const templateLink = getLink(linkToTemplate(organizationName, templateName));

const handleExport = async (format?: "zip") => {
try {
const blob = await API.downloadTemplateVersion(fileId, format);
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
const extension = format === "zip" ? "zip" : "tar";
link.download = `${templateName}-${templateVersion}.${extension}`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
} catch (error) {
console.error("Failed to export template:", error);
// TODO: Show user-friendly error message
}
};

return (
<>
<DropdownMenu>
Expand DownExpand Up@@ -102,6 +123,16 @@ const TemplateMenu: FC<TemplateMenuProps> = ({
<CopyIcon className="size-icon-sm" />
Duplicate&hellip;
</DropdownMenuItem>

<DropdownMenuItem onClick={() => handleExport()}>
<DownloadIcon className="size-icon-sm" />
Export as TAR
</DropdownMenuItem>

<DropdownMenuItem onClick={() => handleExport("zip")}>
<DownloadIcon className="size-icon-sm" />
Export as ZIP
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="text-content-destructive focus:text-content-destructive"
Expand DownExpand Up@@ -206,6 +237,7 @@ export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
templateId={template.id}
templateName={template.name}
templateVersion={activeVersion.name}
fileId={activeVersion.job.file_id}
onDelete={onDeleteTemplate}
/>
)}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp