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 <scenario>-v<N>.yaml and snippet-<alias>-v<N>.yaml
This commit is contained in:
3 files changed
+16
-6
No files matched your search
@@ -123,8 +123,9 @@ export const snippets = {
|
||||
versions(id: string): Promise<SnippetVersion[]> {
|
||||
return request(`/snippets/${id}/versions`);
|
||||
},
|
||||
exportSnippet(id: string): Promise<unknown> {
|
||||
return request(`/snippets/${id}/export`);
|
||||
exportSnippet(id: string, version?: number): Promise<unknown> {
|
||||
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<string> {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user