From 6e5da08719819e3825a3b7f3bcafb83658ceb7d0 Mon Sep 17 00:00:00 2001 From: Andrii Arsenin Date: Wed, 7 Oct 2026 17:34:21 +0300 Subject: [PATCH] feat(client): include version in exported scenario and snippet filenames - request the exact version being exported via ?version=N so file content always matches the filename - name downloads -v.yaml and snippet--v.yaml --- client/src/api/client.ts | 15 ++++++++++++--- client/src/pages/scenario/ScenarioDetailPage.tsx | 3 ++- client/src/pages/snippet/SnippetDetailPage.tsx | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/client/src/api/client.ts b/client/src/api/client.ts index 4c2a732..3dc7538 100644 --- a/client/src/api/client.ts +++ b/client/src/api/client.ts @@ -123,8 +123,9 @@ export const snippets = { versions(id: string): Promise { return request(`/snippets/${id}/versions`); }, - exportSnippet(id: string): Promise { - return request(`/snippets/${id}/export`); + exportSnippet(id: string, version?: number): Promise { + const query = version === undefined ? '' : `?version=${version}`; + return request(`/snippets/${id}/export${query}`); }, }; @@ -247,7 +248,12 @@ export const scenarios = { }, exportScenario( id: string, - options: { includeEnvironment: boolean; credentialIds: string[]; snippetIds: string[] } = { + options: { + includeEnvironment: boolean; + credentialIds: string[]; + snippetIds: string[]; + version?: number; + } = { includeEnvironment: false, credentialIds: [], snippetIds: [], @@ -255,6 +261,9 @@ export const scenarios = { ): Promise { const params = new URLSearchParams(); params.set('includeEnvironment', String(options.includeEnvironment)); + if (options.version !== undefined) { + params.set('version', String(options.version)); + } for (const cid of options.credentialIds) { params.append('credentialIds', cid); } diff --git a/client/src/pages/scenario/ScenarioDetailPage.tsx b/client/src/pages/scenario/ScenarioDetailPage.tsx index 2feb26b..a476ad6 100644 --- a/client/src/pages/scenario/ScenarioDetailPage.tsx +++ b/client/src/pages/scenario/ScenarioDetailPage.tsx @@ -229,12 +229,13 @@ export function ScenarioDetailPage() { includeEnvironment, credentialIds: credIds, snippetIds: Array.from(includedSnippetIds), + version: scenario.version, }); const blob = new Blob([yamlContent], { type: 'application/yaml' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; - a.download = `${scenario.name}.yaml`; + a.download = `${scenario.name}-v${scenario.version}.yaml`; a.click(); URL.revokeObjectURL(url); setExportModalOpen(false); diff --git a/client/src/pages/snippet/SnippetDetailPage.tsx b/client/src/pages/snippet/SnippetDetailPage.tsx index 24b025f..82dc700 100644 --- a/client/src/pages/snippet/SnippetDetailPage.tsx +++ b/client/src/pages/snippet/SnippetDetailPage.tsx @@ -51,12 +51,12 @@ export function SnippetDetailPage() { const handleExport = async () => { if (!snippet) return; - const data = await snippets.exportSnippet(snippet.id); + const data = await snippets.exportSnippet(snippet.id, snippet.version); const blob = new Blob([yamlStringify(data)], { type: 'application/yaml' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; - a.download = `snippet-${snippet.alias}.yaml`; + a.download = `snippet-${snippet.alias}-v${snippet.version}.yaml`; a.click(); URL.revokeObjectURL(url); }; -- 2.54.0