Skip to content

Commit

Permalink
web: fix needed because recent upgrade to task breaks spinner button …
Browse files Browse the repository at this point in the history
…(cherry-pick #10142) (#10150)

web: fix needed because recent upgrade to task breaks spinner button (#10142)

web: fix broken Task plug-in

rebase and fix package json

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Co-authored-by: Ken Sternberg <133134217+kensternberg-authentik@users.noreply.github.com>
Co-authored-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
3 people authored Jun 18, 2024
1 parent eef02f2 commit 2f42144
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
18 changes: 4 additions & 14 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"@formatjs/intl-listformat": "^7.5.7",
"@fortawesome/fontawesome-free": "^6.5.2",
"@goauthentik/api": "^2024.4.2-1718378698",
"@lit-labs/task": "^3.1.0",
"@lit/context": "^1.1.2",
"@lit/localize": "^0.12.1",
"@lit/reactive-element": "^2.0.4",
"@lit/task": "^1.0.1",
"@open-wc/lit-helpers": "^0.7.0",
"@patternfly/elements": "^3.0.1",
"@patternfly/patternfly": "^4.224.2",
Expand Down
12 changes: 9 additions & 3 deletions web/src/elements/buttons/SpinnerButton/BaseTaskButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export abstract class BaseTaskButton extends CustomEmitterElement(AKElement) {
this.onSuccess = this.onSuccess.bind(this);
this.onError = this.onError.bind(this);
this.onClick = this.onClick.bind(this);
this.actionTask = new Task(this, {
this.actionTask = this.buildTask();
}

buildTask() {
return new Task(this, {
task: () => this.callAction(),
args: () => [],
autoRun: false,
Expand All @@ -77,8 +81,9 @@ export abstract class BaseTaskButton extends CustomEmitterElement(AKElement) {

onComplete() {
setTimeout(() => {
this.actionTask.status = TaskStatus.INITIAL;
this.dispatchCustomEvent(`${this.eventPrefix}-reset`);
// set-up for the next task...
this.actionTask = this.buildTask();
this.requestUpdate();
}, SPINNER_TIMEOUT);
}
Expand All @@ -98,7 +103,8 @@ export abstract class BaseTaskButton extends CustomEmitterElement(AKElement) {
}

onClick() {
if (this.actionTask.status !== TaskStatus.INITIAL) {
// Don't accept clicks when a task is in progress..
if (this.actionTask.status === TaskStatus.PENDING) {
return;
}
this.dispatchCustomEvent(`${this.eventPrefix}-click`);
Expand Down

0 comments on commit 2f42144

Please sign in to comment.