Skip to content

Commit 7def24a

Browse files
committed
Prevent uploading a file with an unsupported exception
Closes #100
1 parent bc90d8f commit 7def24a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/components/projects/WorkflowImport.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
cancel()
1818
1919
const workflowFile = data.get('workflowFile')
20-
console.log(workflowFile)
2120
2221
if (workflowFile.name == '') {
2322
throw new Error('No workflow file specified')
2423
}
2524
26-
const workflowMetadata = await workflowFile.text().then(data => JSON.parse(data))
27-
console.log(workflowMetadata)
25+
const workflowMetadata = await workflowFile.text()
26+
.then(data => JSON.parse(data))
27+
.catch(() => {
28+
throw new Error('The format of the selected file is not valid. Please select a valid workflow file.')
29+
})
2830
2931
// Request workflow import
3032
importing = true
@@ -58,7 +60,7 @@
5860

5961
<div class="mb-3">
6062
<label for="workflowFile" class="form-label">Select a workflow file</label>
61-
<input class="form-control" type="file" name="workflowFile" id="workflowFile">
63+
<input class="form-control" accept="application/json" type="file" name="workflowFile" id="workflowFile">
6264
</div>
6365

6466
<button class="btn btn-primary" disabled={importing}>

0 commit comments

Comments
 (0)