diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx index 0d9fcbc350..2d7f78ac54 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx @@ -55,6 +55,14 @@ export function DryRunResultsList() { {dryRun.results.map(result => { const failed = result.log.some(l => l.body.status === 'failed'); + let isLoading = false; + + async function downloadResult() { + isLoading = true; + await downloadDirectoryContents(result.directoryContents, `dry-run-result-${result.id}.zip`) + isLoading = false; + } + return ( downloadResult(result)} + disabled={isLoading} + onClick={() => downloadResult()} > @@ -94,12 +103,8 @@ export function DryRunResultsList() { } -async function downloadResult(result: DryRunResult) { - await createZipDownload(result.directoryContents, `dry-run-result-${result.id}.zip`) -} - -async function createZipDownload(directoryContents: { path: string; base64Content: string; executable: boolean; }[], name: string) { +async function downloadDirectoryContents(directoryContents: { path: string; base64Content: string; executable: boolean; }[], name: string) { const {default: JSZip} = await import('jszip'); const zip = new JSZip();