Show config if options or schema (#8487)

This commit is contained in:
Joakim Sørensen 2021-03-01 12:55:14 +01:00 committed by GitHub
parent f7a3d2705c
commit f43af9c0a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -26,16 +26,15 @@ class HassioAddonConfigDashboard extends LitElement {
if (!this.addon) {
return html`<ha-circular-progress active></ha-circular-progress>`;
}
const hasOptions =
this.addon.options && Object.keys(this.addon.options).length;
const hasSchema =
hasOptions && this.addon.schema && Object.keys(this.addon.schema).length;
const hasConfiguration =
(this.addon.options && Object.keys(this.addon.options).length) ||
(this.addon.schema && Object.keys(this.addon.schema).length);
return html`
<div class="content">
${hasOptions || hasSchema || this.addon.network || this.addon.audio
${hasConfiguration || this.addon.network || this.addon.audio
? html`
${hasOptions || hasSchema
${hasConfiguration
? html`
<hassio-addon-config
.hass=${this.hass}

View File

@ -145,12 +145,10 @@ class HassioAddonConfig extends LitElement {
protected firstUpdated(changedProps) {
super.firstUpdated(changedProps);
this._canShowSchema =
Object.keys(this.addon.options).length !== 0 &&
!this.addon.schema!.find(
// @ts-ignore
(entry) => !SUPPORTED_UI_TYPES.includes(entry.type) || entry.multiple
);
this._canShowSchema = !this.addon.schema!.find(
// @ts-ignore
(entry) => !SUPPORTED_UI_TYPES.includes(entry.type) || entry.multiple
);
this._yamlMode = !this._canShowSchema;
}