diff --git a/src/panels/config/cloud/account/cloud-webhooks.ts b/src/panels/config/cloud/account/cloud-webhooks.ts index 8b35052539..9918fabcfd 100644 --- a/src/panels/config/cloud/account/cloud-webhooks.ts +++ b/src/panels/config/cloud/account/cloud-webhooks.ts @@ -1,14 +1,18 @@ import "@polymer/paper-item/paper-item"; import "@polymer/paper-item/paper-item-body"; -import "../../../../components/ha-circular-progress"; import { + css, + CSSResult, + customElement, html, + internalProperty, LitElement, property, - internalProperty, PropertyValues, } from "lit-element"; import "../../../../components/ha-card"; +import "../../../../components/ha-circular-progress"; +import "../../../../components/ha-settings-row"; import "../../../../components/ha-switch"; import { CloudStatusLoggedIn, @@ -17,13 +21,17 @@ import { deleteCloudhook, } from "../../../../data/cloud"; import { fetchWebhooks, Webhook } from "../../../../data/webhook"; +import { haStyle } from "../../../../resources/styles"; import { HomeAssistant, WebhookError } from "../../../../types"; import { showManageCloudhookDialog } from "../dialog-manage-cloudhook/show-dialog-manage-cloudhook"; +@customElement("cloud-webhooks") export class CloudWebhooks extends LitElement { @property({ attribute: false }) public hass?: HomeAssistant; - @property() public cloudStatus?: CloudStatusLoggedIn; + @property({ attribute: false }) public cloudStatus?: CloudStatusLoggedIn; + + @property({ type: Boolean }) public narrow!: boolean; @internalProperty() private _cloudHooks?: { [webhookId: string]: CloudWebhook; @@ -31,12 +39,7 @@ export class CloudWebhooks extends LitElement { @internalProperty() private _localHooks?: Webhook[]; - @internalProperty() private _progress: string[]; - - constructor() { - super(); - this._progress = []; - } + @internalProperty() private _progress: string[] = []; public connectedCallback() { super.connectedCallback(); @@ -45,7 +48,6 @@ export class CloudWebhooks extends LitElement { protected render() { return html` - ${this.renderStyle()}
${this.hass!.localize("ui.panel.config.cloud.account.webhooks.info")} - ${this._renderBody()} - + ${!this.cloudStatus || + !this._localHooks || + !this._cloudHooks || + !this.hass + ? html` +
+ ${this.hass!.localize( + "ui.panel.config.cloud.account.webhooks.loading" + )} +
+ ` + : this._localHooks.length === 0 + ? html` +
+ ${this.hass.localize( + "ui.panel.config.cloud.account.webhooks.no_hooks_yet" + )} + ${this.hass.localize( + "ui.panel.config.cloud.account.webhooks.no_hooks_yet_link_integration" + )} + + ${this.hass.localize( + "ui.panel.config.cloud.account.webhooks.no_hooks_yet2" + )} + ${this.hass.localize( + "ui.panel.config.cloud.account.webhooks.no_hooks_yet_link_automation" + )}. +
+ ` + : this._localHooks.map( + (entry) => html` + + + ${entry.name} + ${entry.domain !== entry.name.toLowerCase() + ? ` (${entry.domain})` + : ""} + + ${entry.webhook_id} + ${this._progress.includes(entry.webhook_id) + ? html` +
+ +
+ ` + : this._cloudHooks![entry.webhook_id] + ? html` + + ${this.hass!.localize( + "ui.panel.config.cloud.account.webhooks.manage" + )} + + ` + : html` + `} +
+ ` + )} - `; - } - - if (this._localHooks.length === 0) { - return html` - - `; - } - - return this._localHooks.map( - (entry) => html` -
- -
- ${entry.name} - ${entry.domain === entry.name.toLowerCase() - ? "" - : ` (${entry.domain})`} -
-
${entry.webhook_id}
-
- ${this._progress.includes(entry.webhook_id) - ? html` -
- -
- ` - : this._cloudHooks![entry.webhook_id] - ? html` - - ${this.hass!.localize( - "ui.panel.config.cloud.account.webhooks.manage" - )} - - ` - : html` `} -
- ` - ); - } - private _showDialog(webhookId: string) { const webhook = this._localHooks!.find( (ent) => ent.webhook_id === webhookId @@ -212,9 +207,10 @@ export class CloudWebhooks extends LitElement { : []; } - private renderStyle() { - return html` - - `; + ha-settings-row { + padding: 0; + } + `, + ]; } } @@ -245,5 +244,3 @@ declare global { "cloud-webhooks": CloudWebhooks; } } - -customElements.define("cloud-webhooks", CloudWebhooks);