From f74175a544b81b9ee2dfed6d9c8e7aea805560bd Mon Sep 17 00:00:00 2001 From: Ludeeus Date: Mon, 11 Jan 2021 13:02:41 +0000 Subject: [PATCH 1/2] Hide configuration card if the addon does not expose options or schema --- .../config/hassio-addon-config-tab.ts | 20 +++++++++++++++---- src/data/hassio/addon.ts | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hassio/src/addon-view/config/hassio-addon-config-tab.ts b/hassio/src/addon-view/config/hassio-addon-config-tab.ts index 29e3f1778e46..0eb9a3be6381 100644 --- a/hassio/src/addon-view/config/hassio-addon-config-tab.ts +++ b/hassio/src/addon-view/config/hassio-addon-config-tab.ts @@ -26,12 +26,21 @@ class HassioAddonConfigDashboard extends LitElement { if (!this.addon) { return html``; } + const hasOptions = + this.addon.options && Object.keys(this.addon.options).length; + const hasSchema = + this.addon.schema && Object.keys(this.addon.schema).length; + return html`
- + ${hasOptions || hasSchema + ? html` + + ` + : ""} ${this.addon.network ? html` ` : ""} + ${!hasOptions && !hasSchema && !this.addon.network && !this.addon.audio + ? "This add-on does not expose configuration for you to mess with.... 👋" + : ""}
`; } diff --git a/src/data/hassio/addon.ts b/src/data/hassio/addon.ts index 902548f17421..5e05ae05bcdb 100644 --- a/src/data/hassio/addon.ts +++ b/src/data/hassio/addon.ts @@ -61,6 +61,7 @@ export interface HassioAddonDetails extends HassioAddonInfo { privileged: any; protected: boolean; rating: "1-6"; + schema: Record; services_role: string[]; slug: string; startup: "initialize" | "system" | "services" | "application" | "once"; From 5a0920616078d27c15871734c8a11fae7e50b892 Mon Sep 17 00:00:00 2001 From: Ludeeus Date: Mon, 11 Jan 2021 13:10:27 +0000 Subject: [PATCH 2/2] reorder --- .../config/hassio-addon-config-tab.ts | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/hassio/src/addon-view/config/hassio-addon-config-tab.ts b/hassio/src/addon-view/config/hassio-addon-config-tab.ts index 0eb9a3be6381..56b73f137d4d 100644 --- a/hassio/src/addon-view/config/hassio-addon-config-tab.ts +++ b/hassio/src/addon-view/config/hassio-addon-config-tab.ts @@ -33,33 +33,34 @@ class HassioAddonConfigDashboard extends LitElement { return html`
- ${hasOptions || hasSchema + ${hasOptions || hasSchema || this.addon.network || this.addon.audio ? html` - + ${hasOptions || hasSchema + ? html` + + ` + : ""} + ${this.addon.network + ? html` + + ` + : ""} + ${this.addon.audio + ? html` + + ` + : ""} ` - : ""} - ${this.addon.network - ? html` - - ` - : ""} - ${this.addon.audio - ? html` - - ` - : ""} - ${!hasOptions && !hasSchema && !this.addon.network && !this.addon.audio - ? "This add-on does not expose configuration for you to mess with.... 👋" - : ""} + : "This add-on does not expose configuration for you to mess with.... 👋"}
`; }