diff --git a/hassio/src/dialogs/system_checks/dialog-hassio-system-checks.ts b/hassio/src/dialogs/system_checks/dialog-hassio-system-checks.ts index 245d7aaea6..136dfc3728 100644 --- a/hassio/src/dialogs/system_checks/dialog-hassio-system-checks.ts +++ b/hassio/src/dialogs/system_checks/dialog-hassio-system-checks.ts @@ -2,7 +2,6 @@ import { CSSResult, customElement, html, - internalProperty, LitElement, property, TemplateResult, @@ -13,7 +12,7 @@ import { createCloseHeading } from "../../../../src/components/ha-dialog"; import "../../../../src/components/ha-settings-row"; import "../../../../src/components/ha-svg-icon"; import { extractApiErrorMessage } from "../../../../src/data/hassio/common"; -import { setCheckOption } from "../../../../src/data/hassio/resolution"; +import { setCheckOptions } from "../../../../src/data/hassio/resolution"; import { Supervisor } from "../../../../src/data/supervisor/supervisor"; import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box"; import { haStyle, haStyleDialog } from "../../../../src/resources/styles"; @@ -24,37 +23,39 @@ import { SystemChecksParams } from "./show-dialog-system-checks"; class HassioSystemChecksDialog extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ attribute: false }) public supervisor!: Supervisor; - - @internalProperty() private _opened = false; + @property({ attribute: false }) public supervisor?: Supervisor; protected render(): TemplateResult { + if (!this.supervisor) { + return html``; + } + return html`
${this.supervisor.resolution.checks.map( (check) => html` - ${this.supervisor.localize( - `dialog.system_check.check.${check.name}.title` - ) || check.name} + ${this.supervisor!.localize( + `dialog.system_check.check.${check.slug}.title` + ) || check.slug} - ${this.supervisor.localize( - `dialog.system_check.check.${check.name}.description` + ${this.supervisor!.localize( + `dialog.system_check.check.${check.slug}.description` )} { - this._opened = true; this.supervisor = dialogParams.supervisor; await this.updateComplete; } public closeDialog(): void { this.supervisor = undefined; - this._opened = false; fireEvent(this, "dialog-closed", { dialog: this.localName }); } @@ -91,13 +90,13 @@ class HassioSystemChecksDialog extends LitElement { const check = ev.currentTarget as any; try { - await setCheckOption(this.hass, check.check, { enabled: check.checked }); + await setCheckOptions(this.hass, check.slug, { enabled: check.checked }); fireEvent(this, "supervisor-collection-refresh", { collection: "resolution", }); } catch (err) { showAlertDialog(this, { - title: this.supervisor.localize( + title: this.supervisor!.localize( "dialog.system_check.failed_to_set_option" ), text: extractApiErrorMessage(err), diff --git a/src/data/hassio/resolution.ts b/src/data/hassio/resolution.ts index 586e5f0eb5..0a3df5380e 100644 --- a/src/data/hassio/resolution.ts +++ b/src/data/hassio/resolution.ts @@ -7,7 +7,7 @@ export interface HassioResolution { unhealthy: string[]; issues: string[]; suggestions: string[]; - checks: { name: string; enabled: boolean }[]; + checks: { slug: string; enabled: boolean }[]; } export const fetchHassioResolution = async ( @@ -29,7 +29,7 @@ export const fetchHassioResolution = async ( ); }; -export const setCheckOption = async ( +export const setCheckOptions = async ( hass: HomeAssistant, check: string, data: Record