web: fix needed because recent upgrade to task breaks spinner button (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>
This commit is contained in:
gcp-cherry-pick-bot[bot]
2024-06-18 17:39:13 +09:00
committed by GitHub
parent eef02f2892
commit 2f42144b33
3 changed files with 14 additions and 18 deletions

18
web/package-lock.json generated
View File

@ -18,10 +18,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",
@ -3333,15 +3333,6 @@
"integrity": "sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==",
"license": "BSD-3-Clause"
},
"node_modules/@lit-labs/task": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@lit-labs/task/-/task-3.1.0.tgz",
"integrity": "sha512-zMlcUtZeHDT83IiT2+CJBSoFvWDLnPEezhOCgqjxW4DmRHlbgd7jdft97T6dw4S4RvIETfI7OOyvubCV/EzTlg==",
"license": "BSD-3-Clause",
"dependencies": {
"@lit/task": "^1.0.0"
}
},
"node_modules/@lit/context": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@lit/context/-/context-1.1.2.tgz",
@ -3403,10 +3394,9 @@
}
},
"node_modules/@lit/task": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lit/task/-/task-1.0.0.tgz",
"integrity": "sha512-7jocGBh3yGlo3kKxQggZph2txK4X5GYNWp2FAsmV9u2spzUypwrzRzXe8I72icAb02B00+k2nlvxVcrQB6vyrw==",
"license": "BSD-3-Clause",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@lit/task/-/task-1.0.1.tgz",
"integrity": "sha512-fVLDtmwCau8NywnFIXaJxsCZjzaIxnVq+cFRKYC1Y4tA4/0rMTvF6DLZZ2JE51BwzOluaKtgJX8x1QDsQtAaIw==",
"dependencies": {
"@lit/reactive-element": "^1.0.0 || ^2.0.0"
}

View File

@ -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",

View File

@ -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,
@ -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);
}
@ -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`);