refactor: 💡 remove usage of ember/runloop & ember-pollster (#2705)

* refactor: 💡 remove usage of ember/runloop & ember-pollster

---------

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
Lisbet AlvarezandZhihe Li authored and GitHub committed 2025-03-06 12:20:48 -08:00
1 parent e29a83ec25
commit 29bde998ed
23 files changed
+225 -197

No files matched your search

@@ -6,7 +6,6 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { run } from '@ember/runloop';
export default class FormAuthenticateDetailsComponent extends Component {
// =properties
@@ -36,7 +35,7 @@ export default class FormAuthenticateDetailsComponent extends Component {
*/
@action
submit(fn, creds) {
run(() => this.resetPassword());
run(() => fn(creds));
this.resetPassword();
fn(creds);
}
}
@@ -6,7 +6,7 @@
<Hds::Button
@text={{t 'actions.refresh'}}
@color='secondary'
@icon={{if this.isLoading 'loading' 'reload'}}
@icon={{if this.toggleRefresh.isRunning 'loading' 'reload'}}
@disabled={{this.isLoading}}
{{on 'click' this.toggleRefresh}}
{{on 'click' this.toggleRefresh.perform}}
/>
@@ -4,22 +4,13 @@
*/
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { later } from '@ember/runloop';
import { dropTask, timeout } from 'ember-concurrency';
export default class LoadingButton extends Component {
// =actions
@tracked isLoading = false;
// =attributes
@action
async toggleRefresh() {
this.isLoading = true;
try {
await this.args.onClick();
} catch (e) {
console.error('Error while loading data', e);
}
later(() => (this.isLoading = false), 1000);
}
toggleRefresh = dropTask(async () => {
await this.args.onClick();
await timeout(1000);
});
}