Merge pull request 'feat(client): include version in exported scenario and snippet filenames' (#13) from feat/export-version-filename into master
Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
commit
3c8def3814
3 files changed
+16
-6
No files matched your search
@@ -123,8 +123,9 @@ export const snippets = {
|
|||||||
versions(id: string): Promise<SnippetVersion[]> {
|
versions(id: string): Promise<SnippetVersion[]> {
|
||||||
return request(`/snippets/${id}/versions`);
|
return request(`/snippets/${id}/versions`);
|
||||||
},
|
},
|
||||||
exportSnippet(id: string): Promise<unknown> {
|
exportSnippet(id: string, version?: number): Promise<unknown> {
|
||||||
return request(`/snippets/${id}/export`);
|
const query = version === undefined ? '' : `?version=${version}`;
|
||||||
|
return request(`/snippets/${id}/export${query}`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -247,7 +248,12 @@ export const scenarios = {
|
|||||||
},
|
},
|
||||||
exportScenario(
|
exportScenario(
|
||||||
id: string,
|
id: string,
|
||||||
options: { includeEnvironment: boolean; credentialIds: string[]; snippetIds: string[] } = {
|
options: {
|
||||||
|
includeEnvironment: boolean;
|
||||||
|
credentialIds: string[];
|
||||||
|
snippetIds: string[];
|
||||||
|
version?: number;
|
||||||
|
} = {
|
||||||
includeEnvironment: false,
|
includeEnvironment: false,
|
||||||
credentialIds: [],
|
credentialIds: [],
|
||||||
snippetIds: [],
|
snippetIds: [],
|
||||||
@@ -255,6 +261,9 @@ export const scenarios = {
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
params.set('includeEnvironment', String(options.includeEnvironment));
|
params.set('includeEnvironment', String(options.includeEnvironment));
|
||||||
|
if (options.version !== undefined) {
|
||||||
|
params.set('version', String(options.version));
|
||||||
|
}
|
||||||
for (const cid of options.credentialIds) {
|
for (const cid of options.credentialIds) {
|
||||||
params.append('credentialIds', cid);
|
params.append('credentialIds', cid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,12 +229,13 @@ export function ScenarioDetailPage() {
|
|||||||
includeEnvironment,
|
includeEnvironment,
|
||||||
credentialIds: credIds,
|
credentialIds: credIds,
|
||||||
snippetIds: Array.from(includedSnippetIds),
|
snippetIds: Array.from(includedSnippetIds),
|
||||||
|
version: scenario.version,
|
||||||
});
|
});
|
||||||
const blob = new Blob([yamlContent], { type: 'application/yaml' });
|
const blob = new Blob([yamlContent], { type: 'application/yaml' });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = `${scenario.name}.yaml`;
|
a.download = `${scenario.name}-v${scenario.version}.yaml`;
|
||||||
a.click();
|
a.click();
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
setExportModalOpen(false);
|
setExportModalOpen(false);
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ export function SnippetDetailPage() {
|
|||||||
|
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
if (!snippet) return;
|
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 blob = new Blob([yamlStringify(data)], { type: 'application/yaml' });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = `snippet-${snippet.alias}.yaml`;
|
a.download = `snippet-${snippet.alias}-v${snippet.version}.yaml`;
|
||||||
a.click();
|
a.click();
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user