web: re-format with prettier
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -5,10 +5,11 @@ import { MessageLevel } from "../messages/Message";
|
||||
|
||||
@customElement("ak-action-button")
|
||||
export class ActionButton extends SpinnerButton {
|
||||
|
||||
@property({attribute: false})
|
||||
@property({ attribute: false })
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
apiRequest: () => Promise<any> = () => { throw new Error(); };
|
||||
apiRequest: () => Promise<any> = () => {
|
||||
throw new Error();
|
||||
};
|
||||
|
||||
callAction = (): Promise<void> => {
|
||||
this.setLoading();
|
||||
@ -16,13 +17,13 @@ export class ActionButton extends SpinnerButton {
|
||||
if (e instanceof Error) {
|
||||
showMessage({
|
||||
level: MessageLevel.error,
|
||||
message: e.toString()
|
||||
message: e.toString(),
|
||||
});
|
||||
} else {
|
||||
e.text().then(t => {
|
||||
e.text().then((t) => {
|
||||
showMessage({
|
||||
level: MessageLevel.error,
|
||||
message: t
|
||||
message: t,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,4 +1,12 @@
|
||||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||
import PFModalBox from "@patternfly/patternfly/components/ModalBox/modal-box.css";
|
||||
@ -35,11 +43,25 @@ export class ModalButton extends LitElement {
|
||||
@property()
|
||||
size: PFSize = PFSize.Large;
|
||||
|
||||
@property({type: Boolean})
|
||||
@property({ type: Boolean })
|
||||
open = false;
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return [PFBase, PFButton, PFModalBox, PFForm, PFTitle, PFFormControl, PFBullseye, PFBackdrop, PFPage, PFCard, PFContent, AKGlobal, MODAL_BUTTON_STYLES];
|
||||
return [
|
||||
PFBase,
|
||||
PFButton,
|
||||
PFModalBox,
|
||||
PFForm,
|
||||
PFTitle,
|
||||
PFFormControl,
|
||||
PFBullseye,
|
||||
PFBackdrop,
|
||||
PFPage,
|
||||
PFCard,
|
||||
PFContent,
|
||||
AKGlobal,
|
||||
MODAL_BUTTON_STYLES,
|
||||
];
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@ -53,7 +75,7 @@ export class ModalButton extends LitElement {
|
||||
}
|
||||
|
||||
resetForms(): void {
|
||||
this.querySelectorAll<HTMLFormElement>("[slot=form]").forEach(form => {
|
||||
this.querySelectorAll<HTMLFormElement>("[slot=form]").forEach((form) => {
|
||||
if ("resetForm" in form) {
|
||||
form?.resetForm();
|
||||
}
|
||||
@ -62,7 +84,7 @@ export class ModalButton extends LitElement {
|
||||
|
||||
onClick(): void {
|
||||
this.open = true;
|
||||
this.querySelectorAll("*").forEach(child => {
|
||||
this.querySelectorAll("*").forEach((child) => {
|
||||
if ("requestUpdate" in child) {
|
||||
(child as LitElement).requestUpdate();
|
||||
}
|
||||
@ -70,17 +92,13 @@ export class ModalButton extends LitElement {
|
||||
}
|
||||
|
||||
renderModalInner(): TemplateResult {
|
||||
return html`<slot name='modal'></slot>`;
|
||||
return html`<slot name="modal"></slot>`;
|
||||
}
|
||||
|
||||
renderModal(): TemplateResult {
|
||||
return html`<div class="pf-c-backdrop">
|
||||
<div class="pf-l-bullseye">
|
||||
<div
|
||||
class="pf-c-modal-box ${this.size}"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
>
|
||||
<div class="pf-c-modal-box ${this.size}" role="dialog" aria-modal="true">
|
||||
<button
|
||||
@click=${() => (this.open = false)}
|
||||
class="pf-c-button pf-m-plain"
|
||||
@ -99,5 +117,4 @@ export class ModalButton extends LitElement {
|
||||
return html` <slot name="trigger" @click=${() => this.onClick()}></slot>
|
||||
${this.open ? this.renderModal() : ""}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,12 @@
|
||||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||
import PFSpinner from "@patternfly/patternfly/components/Spinner/spinner.css";
|
||||
@ -8,7 +16,7 @@ import { ERROR_CLASS, PRIMARY_CLASS, PROGRESS_CLASS, SUCCESS_CLASS } from "../..
|
||||
|
||||
@customElement("ak-spinner-button")
|
||||
export class SpinnerButton extends LitElement {
|
||||
@property({type: Boolean})
|
||||
@property({ type: Boolean })
|
||||
isRunning = false;
|
||||
|
||||
@property()
|
||||
@ -60,17 +68,20 @@ export class SpinnerButton extends LitElement {
|
||||
}
|
||||
this.setLoading();
|
||||
if (this.callAction) {
|
||||
this.callAction().then(() => {
|
||||
this.setDone(SUCCESS_CLASS);
|
||||
}).catch(() => {
|
||||
this.setDone(ERROR_CLASS);
|
||||
});
|
||||
this.callAction()
|
||||
.then(() => {
|
||||
this.setDone(SUCCESS_CLASS);
|
||||
})
|
||||
.catch(() => {
|
||||
this.setDone(ERROR_CLASS);
|
||||
});
|
||||
}
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
${this.isRunning
|
||||
? html` <span class="pf-c-button__progress">
|
||||
<ak-spinner size=${PFSize.Medium}></ak-spinner>
|
||||
</span>`
|
||||
<ak-spinner size=${PFSize.Medium}></ak-spinner>
|
||||
</span>`
|
||||
: ""}
|
||||
<slot></slot>
|
||||
</button>`;
|
||||
|
||||
@ -17,23 +17,25 @@ export class TokenCopyButton extends ActionButton {
|
||||
if (!this.identifier) {
|
||||
return Promise.reject();
|
||||
}
|
||||
return new CoreApi(DEFAULT_CONFIG).coreTokensViewKeyRetrieve({
|
||||
identifier: this.identifier
|
||||
}).then((token) => {
|
||||
if (!token.key) {
|
||||
return Promise.reject();
|
||||
}
|
||||
return navigator.clipboard.writeText(token.key).then(() => {
|
||||
this.buttonClass = SUCCESS_CLASS;
|
||||
setTimeout(() => {
|
||||
this.buttonClass = PRIMARY_CLASS;
|
||||
}, 1500);
|
||||
return new CoreApi(DEFAULT_CONFIG)
|
||||
.coreTokensViewKeyRetrieve({
|
||||
identifier: this.identifier,
|
||||
})
|
||||
.then((token) => {
|
||||
if (!token.key) {
|
||||
return Promise.reject();
|
||||
}
|
||||
return navigator.clipboard.writeText(token.key).then(() => {
|
||||
this.buttonClass = SUCCESS_CLASS;
|
||||
setTimeout(() => {
|
||||
this.buttonClass = PRIMARY_CLASS;
|
||||
}, 1500);
|
||||
});
|
||||
})
|
||||
.catch((err: Response | undefined) => {
|
||||
return err?.json().then((errResp) => {
|
||||
throw new Error(errResp["detail"]);
|
||||
});
|
||||
});
|
||||
}).catch((err: Response | undefined) => {
|
||||
return err?.json().then(errResp => {
|
||||
throw new Error(errResp["detail"]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user