Skip to content

Commit

Permalink
fix(upload): show loading spinner on drag & drop upload
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Nov 21, 2023
1 parent 32d2009 commit 7b76628
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions addon/components/document-view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{on "dragenter" this.onDragEnter}}
{{on "dragleave" this.onDragLeave}}
{{on "dragover" this.onDragOver}}
{{on "drop" this.onDrop}}
{{on "drop" (perform this.onDrop)}}
>
<div
class="uk-position-cover uk-padding-small uk-height-1-1 uk-overflow-auto"
Expand Down Expand Up @@ -74,11 +74,13 @@
class="uk-width-1 uk-padding-remove uk-position-bottom uk-button uk-button-primary"
type="button"
>
{{if
this.canDrop
(t "alexandria.document-grid.drop-to-upload")
(t "alexandria.document-grid.drop-not-allowed")
}}
{{#if this.onDrop.isRunning}}
<UkSpinner />
{{else if this.canDrop}}
{{t "alexandria.document-grid.drop-to-upload"}}
{{else}}
{{t "alexandria.document-grid.drop-not-allowed"}}
{{/if}}
</button>
{{/if}}
</div>
Expand Down
6 changes: 3 additions & 3 deletions addon/components/document-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { lastValue, task } from "ember-concurrency";
import { dropTask, lastValue, task } from "ember-concurrency";

import { ErrorHandler } from "ember-alexandria/helpers/error-handler";

Expand Down Expand Up @@ -96,7 +96,7 @@ export default class DocumentViewComponent extends Component {
event.stopPropagation();
}

@action async onDrop(event) {
onDrop = dropTask(async (event) => {
if (!this.args.filters.category) {
return;
}
Expand Down Expand Up @@ -126,7 +126,7 @@ export default class DocumentViewComponent extends Component {
}

this.isDragOver = false;
}
});

// * DOCUMENT SELECTION
handleKeyDown(event) {
Expand Down

0 comments on commit 7b76628

Please sign in to comment.