Skip to content

Commit f018fa8

Browse files
authored
Fixed the file upload issue (#2552)
- Ticket: ### [ENG-7588] - Feature flag: n/a ## Purpose There was the slightest chance of a race condition that I fixed using the "preUpload" called and a spinner. I first tried to use "enabled=false" and it literally destroys the entire widget. So then I moved to the spinner ## Summary of Changes Add a variable and preUpload method to the component. Added the variable to the spinner conditional statement to display the spinner once the file is uploaded. [ENG-7588]: https://openscience.atlassian.net/browse/ENG-7588
1 parent 584da77 commit f018fa8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/preprints/-components/submit/file/upload-file/component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import FileModel from 'ember-osf-web/models/file';
99
import { task } from 'ember-concurrency';
1010
import { waitFor } from '@ember/test-waiters';
1111
import { taskFor } from 'ember-concurrency-ts';
12+
import { tracked } from '@glimmer/tracking';
1213

1314
interface PreprintUploadArgs {
1415
manager: PreprintStateMachine;
@@ -28,6 +29,7 @@ export default class PreprintUpload extends Component<PreprintUploadArgs> {
2829
url?: URL;
2930
rootFolder?: FileModel;
3031
primaryFile: FileModel | undefined;
32+
@tracked isUploadFileDisplayed = false;
3133

3234
constructor(owner: unknown, args: any) {
3335
super(owner, args);
@@ -99,4 +101,11 @@ export default class PreprintUpload extends Component<PreprintUploadArgs> {
99101
}
100102
this.args.validate(file);
101103
}
104+
105+
@task
106+
@waitFor
107+
async preUpload(): Promise<void> {
108+
this.isUploadFileDisplayed = true;
109+
}
110+
102111
}

app/preprints/-components/submit/file/upload-file/template.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{#if (or this.preUrl.isRunning this.success.isRunning)}}
1+
{{#if (or this.preUrl.isRunning this.success.isRunning this.isUploadFileDisplayed)}}
22
<LoadingIndicator data-test-loading-indicator @dark={{true}} />
33
{{else}}
44
<div ...attributes>
@@ -15,7 +15,7 @@
1515
@enable={{@enable}}
1616
@id={{id}}
1717
@clickable={{this.clickableElementSelectors}}
18-
@preUpload={{this.preUpload}}
18+
@preUpload={{perform this.preUpload}}
1919
@success={{perform this.success}}
2020
>
2121
{{yield}}

0 commit comments

Comments
 (0)