mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 14:27:20 +00:00
Handle webhook component not loaded (#2255)
* Handle webhook component not loaded * Fix text
This commit is contained in:
parent
46a9b90ed0
commit
bc23dd37be
6
src/data/websocket_api.ts
Normal file
6
src/data/websocket_api.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export const ERR_ID_REUSE = "id_reuse";
|
||||||
|
export const ERR_INVALID_FORMAT = "invalid_format";
|
||||||
|
export const ERR_NOT_FOUND = "not_found";
|
||||||
|
export const ERR_UNKNOWN_COMMAND = "unknown_command";
|
||||||
|
export const ERR_UNKNOWN_ERROR = "unknown_error";
|
||||||
|
export const ERR_UNAUTHORIZED = "unauthorized";
|
@ -20,6 +20,7 @@ import {
|
|||||||
deleteCloudhook,
|
deleteCloudhook,
|
||||||
CloudWebhook,
|
CloudWebhook,
|
||||||
} from "../../../data/cloud";
|
} from "../../../data/cloud";
|
||||||
|
import { ERR_UNKNOWN_COMMAND } from "../../../data/websocket_api";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@ -86,7 +87,17 @@ export class CloudWebhooks extends LitElement {
|
|||||||
private _renderBody() {
|
private _renderBody() {
|
||||||
if (!this.cloudStatus || !this._localHooks || !this._cloudHooks) {
|
if (!this.cloudStatus || !this._localHooks || !this._cloudHooks) {
|
||||||
return html`
|
return html`
|
||||||
<div class="loading">Loading…</div>
|
<div class="body-text">Loading…</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._localHooks.length === 0) {
|
||||||
|
return html`
|
||||||
|
<div class="body-text">
|
||||||
|
Looks like you have no webhooks yet. Get started by configuring a
|
||||||
|
<a href="/config/integrations">webhook-based integration</a> or by
|
||||||
|
creating a <a href="/config/automation/new">webhook automation</a>.
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +199,15 @@ export class CloudWebhooks extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _fetchData() {
|
private async _fetchData() {
|
||||||
this._localHooks = await fetchWebhooks(this.hass!);
|
try {
|
||||||
|
this._localHooks = await fetchWebhooks(this.hass!);
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === ERR_UNKNOWN_COMMAND) {
|
||||||
|
this._localHooks = [];
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderStyle() {
|
private renderStyle() {
|
||||||
@ -197,7 +216,7 @@ export class CloudWebhooks extends LitElement {
|
|||||||
.body {
|
.body {
|
||||||
padding: 0 16px 8px;
|
padding: 0 16px 8px;
|
||||||
}
|
}
|
||||||
.loading {
|
.body-text {
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
}
|
}
|
||||||
.webhook {
|
.webhook {
|
||||||
@ -217,6 +236,7 @@ export class CloudWebhooks extends LitElement {
|
|||||||
.footer {
|
.footer {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
.body-text a,
|
||||||
.footer a {
|
.footer a {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user