(filename, newFilename)
| 146 | |
| 147 | // Copy YAML file |
| 148 | export async function postYamlCopy(filename, newFilename) { |
| 149 | try { |
| 150 | const yamlFilename = addYamlSuffix(filename) |
| 151 | const yamlNewFilename = addYamlSuffix(newFilename) |
| 152 | const response = await fetch(apiUrl(`/api/workflows/${encodeURIComponent(yamlFilename)}/copy`), { |
| 153 | method: 'POST', |
| 154 | headers: { |
| 155 | 'Content-Type': 'application/json', |
| 156 | }, |
| 157 | body: JSON.stringify({ |
| 158 | new_filename: yamlNewFilename |
| 159 | }) |
| 160 | }) |
| 161 | |
| 162 | const data = await response.json().catch(() => ({})) |
| 163 | |
| 164 | if (response.ok) { |
| 165 | return { |
| 166 | success: true, |
| 167 | filename: data?.filename || yamlNewFilename, |
| 168 | message: data?.message || 'Workflow copied successfully' |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | return { |
| 173 | success: false, |
| 174 | detail: data?.detail, |
| 175 | message: data?.message || 'Failed to copy workflow', |
| 176 | status: response.status |
| 177 | } |
| 178 | } catch (error) { |
| 179 | console.error('Error copying workflow YAML:', error) |
| 180 | return { |
| 181 | success: false, |
| 182 | message: 'API error' |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | // Load the YAML file list from the API with names and descriptions |
| 188 | export async function fetchWorkflowsWithDesc() { |
nothing calls this directly
no test coverage detected