(artifact, options)
| 91 | } |
| 92 | }, |
| 93 | async downloadArtifact(artifact, options) { |
| 94 | set((state) => ({ |
| 95 | downloading: { ...state.downloading, [artifact.id]: true }, |
| 96 | })); |
| 97 | try { |
| 98 | const blob = options?.runId |
| 99 | ? await api.executions.downloadArtifact(options.runId, artifact.id) |
| 100 | : await api.artifacts.download(artifact.id); |
| 101 | const url = window.URL.createObjectURL(blob); |
| 102 | const link = document.createElement('a'); |
| 103 | link.href = url; |
| 104 | link.download = artifact.name || `artifact-${artifact.id}`; |
| 105 | document.body.appendChild(link); |
| 106 | link.click(); |
| 107 | document.body.removeChild(link); |
| 108 | window.URL.revokeObjectURL(url); |
| 109 | } catch (error) { |
| 110 | console.error('Failed to download artifact', error); |
| 111 | throw error; |
| 112 | } finally { |
| 113 | set((state) => { |
| 114 | const { [artifact.id]: _removed, ...next } = state.downloading; |
| 115 | return { downloading: next }; |
| 116 | }); |
| 117 | } |
| 118 | }, |
| 119 | async deleteArtifact(artifactId: string) { |
| 120 | set((state) => ({ |
| 121 | deleting: { ...state.deleting, [artifactId]: true }, |
no test coverage detected