From 0478aed28c3d76abd1e523d93ac3de5a6cb964e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Fri, 14 Apr 2023 14:35:25 +0200 Subject: [PATCH] Remove ha-call-api-button (#16182) --- hassio/src/resources/hassio-style.ts | 4 - src/components/buttons/ha-call-api-button.ts | 77 ------------------- .../config/cloud/account/cloud-account.ts | 1 - 3 files changed, 82 deletions(-) delete mode 100644 src/components/buttons/ha-call-api-button.ts diff --git a/hassio/src/resources/hassio-style.ts b/hassio/src/resources/hassio-style.ts index 5d52f618da..495d5d3e2e 100644 --- a/hassio/src/resources/hassio-style.ts +++ b/hassio/src/resources/hassio-style.ts @@ -44,10 +44,6 @@ export const hassioStyle = css` grid-template-columns: repeat(auto-fit, minmax(300px, 0.25fr)); } } - ha-call-api-button { - font-weight: 500; - color: var(--primary-color); - } .error { color: var(--error-color); margin-top: 16px; diff --git a/src/components/buttons/ha-call-api-button.ts b/src/components/buttons/ha-call-api-button.ts deleted file mode 100644 index 05fc1f878d..0000000000 --- a/src/components/buttons/ha-call-api-button.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { css, CSSResultGroup, html, LitElement } from "lit"; -import { customElement, property, query } from "lit/decorators"; -import { fireEvent } from "../../common/dom/fire_event"; -import { HomeAssistant } from "../../types"; -import "./ha-progress-button"; - -@customElement("ha-call-api-button") -class HaCallApiButton extends LitElement { - @property({ attribute: false }) public hass!: HomeAssistant; - - @property() public method: "POST" | "GET" | "PUT" | "DELETE" = "POST"; - - @property() public data = {}; - - @property({ type: Boolean, reflect: true }) public disabled = false; - - @property({ type: Boolean }) public progress = false; - - @property() public path?: string; - - @query("ha-progress-button", true) private _progressButton; - - render() { - return html` - - `; - } - - async _buttonTapped() { - this.progress = true; - const eventData: { - method: string; - path: string; - data: any; - success?: boolean; - response?: any; - } = { - method: this.method, - path: this.path!, - data: this.data, - }; - - try { - const resp = await this.hass.callApi(this.method, this.path!, this.data); - this.progress = false; - this._progressButton.actionSuccess(); - eventData.success = true; - eventData.response = resp; - } catch (err: any) { - this.progress = false; - this._progressButton.actionError(); - eventData.success = false; - eventData.response = err; - } - - fireEvent(this, "hass-api-called", eventData as any); - } - - static get styles(): CSSResultGroup { - return css` - :host([disabled]) { - pointer-events: none; - } - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "ha-call-api-button": HaCallApiButton; - } -} diff --git a/src/panels/config/cloud/account/cloud-account.ts b/src/panels/config/cloud/account/cloud-account.ts index d90056d731..2be0ccffbd 100644 --- a/src/panels/config/cloud/account/cloud-account.ts +++ b/src/panels/config/cloud/account/cloud-account.ts @@ -7,7 +7,6 @@ import { formatDateTime } from "../../../../common/datetime/format_date_time"; import { fireEvent } from "../../../../common/dom/fire_event"; import { computeRTLDirection } from "../../../../common/util/compute_rtl"; import { debounce } from "../../../../common/util/debounce"; -import "../../../../components/buttons/ha-call-api-button"; import "../../../../components/ha-alert"; import "../../../../components/ha-card"; import "../../../../components/ha-tip";