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) { if (!this.addon) {
return html`<ha-circular-progress active></ha-circular-progress>`; return html`<ha-circular-progress active></ha-circular-progress>`;
} }
const hasOptions = const hasConfiguration =
this.addon.options && Object.keys(this.addon.options).length; (this.addon.options && Object.keys(this.addon.options).length) ||
const hasSchema = (this.addon.schema && Object.keys(this.addon.schema).length);
hasOptions && this.addon.schema && Object.keys(this.addon.schema).length;
return html` return html`
<div class="content"> <div class="content">
${hasOptions || hasSchema || this.addon.network || this.addon.audio ${hasConfiguration || this.addon.network || this.addon.audio
? html` ? html`
${hasOptions || hasSchema ${hasConfiguration
? html` ? html`
<hassio-addon-config <hassio-addon-config
.hass=${this.hass} .hass=${this.hass}

View File

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